Skip to content

Datasource projection is not respected for POST requests #1189

Description

@Kobzol

Expected Behavior

When I specify a datasource with a projection on a domain, I expect that it would also be respected for inserting new items (POST requests).

I have an endpoint for users and I don't want to return one of their attributes (password) after a POST request that creates a new user. With bandwidth saver it wouldn't be returned, however I'm using BANDWIDTH_SAVER = False globally and thus Eve returns the attribute, even though it's not whitelisted in the datasource projection.

My scenario could be solved by allowing to set BANDWIDTH_SAVER per each endpoint individually, however I think that the datasource projection should be respected in POST requests.

BANDWIDTH_SAVER = False

'users': {
        'schema': user_schema,
        'resource_methods': ['GET', 'POST'],
        'authentication': AdminAuthenticator,
        'datasource': {
            'projection': {
                'username': 1
            }
        }
    }

POST /users returns { _id: ..., username: ..., password: ... }
GET /users doesn't return the password attribute (that is the correct behaviour)

Actual Behavior

The password field is returned after a POST request.

Environment

  • Python version: 3.6.5
  • Eve version: 0.8.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions