Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Replace vs Merge Update on PATCH #1496

@ghost

Description

Feature Request

Providing a header that will allow a PATCH request to replace a key value instead of using PUT, PUT replaces fields I want to
preserve and leave unchangeable.

Unless this can be achieved in another way

Expected Behavior

# Create a record
POST /api/profiles
{
  'name': 'Test',
  'fields': {
    'one': 1,
    'two': 2
  }
}
# => { _created: 'blah', _id: '123456' }

# then update fields with a PATCH request
PATCH /api/profiles/123456
{
  'fields': {
    'three': 3,
    'four': 4
  }
}

# then get the updated record
GET /api/profiles/123456
# RESPONSE
{
  '_id': '123456',
  'name': 'Test',
  'fields': {
    'three': 3,
    'four': 4
  }
}

Actual Behavior

Tell us what happens instead.

# Create a record
POST /api/profiles
{
  'name': 'Test',
  'fields': {
    'one': 1,
    'two': 2
  }
}
# => { _created: 'blah', _id: '123456' }

# then update fields with a PATCH request
PATCH /api/profiles/123456
{
  'fields': {
    'three': 3,
    'four': 4
  }
}

# then get the updated record
GET /api/profiles/123456
# RESPONSE
{
  '_id': '123456',
  'name': 'Test',
  'fields': {
    'one': 1,
    'two': 2,
    'three': 3,
    'four': 4
  }
}

Environment

  • Python version: 3.10
  • Eve version: 2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions