Skip to content

BANDWIDTH_SAVER no longer works with resolve_resource_projection #1338

@hlongmore

Description

@hlongmore

if config.BANDWIDTH_SAVER:

The sense of the conditional

    if config.BANDWIDTH_SAVER:
        return

makes the BANDWIDTH_SAVER have no effect, as all of the document fields get removed, unless one has all the fields in the projection.

Example:

POST http://localhost:5000/rules
Accept: application/json
Content-Type: application/json
Cache-Control: no-cache

[
  {
    "name": "Jaguar Jumps",
    "start": "2019-12-13T00:14:22.773Z",
    "duration": "weeks",
    "expires": true,
  },
  {
    "name": "Koala Kandy",
    "start": "2019-12-13T00:14:22.773Z",
    "duration": "weeks",
    "expires": true,
  }
]

results in only the auto processed fields. If I force-jump while debugging to skip to the return statement on the second one, I get the expected entire document. Below is what I get with that skip to the return:

{
  "_status": "OK",
  "_items": [
    {
      "_id": "5df420a8a9d79a0301ef5cad",
      "_created": "1970-01-01T00:00:00 ",
      "_updated": "1970-01-01T00:00:00 ",
      "_etag": "d000c9a42314a7fb8e8961911a5c66f78a18bfb7",
      "_links": {
        "self": {
          "title": "Rule",
          "href": "rules/5df420a8a9d79a0301ef5cad"
        }
      },
      "_status": "OK"
    },
    {
      "name": "Koala Kandy",
      "start": "2019-12-13T00:14:22 UTC",
      "duration": "weeks",
      "expires": true,
      "_updated": "2019-12-13T23:35:39 ",
      "_created": "2019-12-13T23:35:39 ",
      "_etag": "4a83a54e30cd0a097722d91cd8bf82a121d8198a",
      "_id": "5df420a8a9d79a0301ef5cae",
      "_links": {
        "self": {
          "title": "Rule",
          "href": "rules/5df420a8a9d79a0301ef5cae"
        },
      },
      "_status": "OK"
    }
  ]
}

Python version: 3.7.1
Eve version: 0.9.2
Schema:

rules = {
    'allow_unknown': True,
    'schema': {
        'name': {
            'type': 'string',
        },
        'start': {
            'type': 'datetime',
            'required': True,
            'coerce': to_datetime,
        },
        'duration': {
            'type': 'string',
            'allowed': ['days', 'weeks', 'months', 'years', 'one-time'],
            'required': True,
        },
        'expires': {
            'type': 'boolean',
            'default': False,
        },
    },
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions