Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

put_internal doesn't skip validation on insert when skip_validation=True #1390

Open
absassi opened this issue May 8, 2020 · 6 comments
Open
Labels

Comments

@absassi
Copy link

absassi commented May 8, 2020

I would like to insert or update an item from internal server code, but the resource is complex and I don't want to replicate all the logic in Eve for timestamps, soft delete, media files, etc. in the application, so I'm trying to use eve.methods.put.put_internal for this. However, some of the fields changed from the server are marked read-only (as the client shouldn't be able to change them), so I want to skip validation (and also because I know the data is valid, so validation is redundant in this case).

Unfortunately, put_internal isn't skipping validation on insert when skip_validation=True, because it simply calls post_internal in eve/methods/put.py:153, but the skip_validation parameter is not forwarded to post_internal.

Of course, there are workarounds:

  • Check if the document exists first and then call post_internal directly passing skip_validation=True, but that means two queries in case of updates, because put_internal will make another one anyway.
  • Define an internal resource using the same collection as data source, with less strict validation rules and use that resource instead.
  • Replicate all the relevant logic from Eve in the application, calling app.data.insert and app.data.replace (or app.data.update) directly.

Expected Behavior

Calling put_internal with skip_validation=True should always skip validation.

Actual Behavior

Validation is skipped for updates, but not for inserts.

Environment

  • Python version: 3.6
  • Eve version: 1.1
@stale
Copy link

stale bot commented Nov 8, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Nov 8, 2020
@absassi
Copy link
Author

absassi commented Nov 10, 2020

Yes, this is still relevant.

@stale stale bot removed the stale label Nov 10, 2020
@stale
Copy link

stale bot commented Jun 11, 2021

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Jun 11, 2021
@absassi
Copy link
Author

absassi commented Jun 13, 2021

Yes, this is still relevant.

@stale stale bot removed the stale label Jun 13, 2021
@stale
Copy link

stale bot commented Apr 16, 2022

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Apr 16, 2022
@absassi
Copy link
Author

absassi commented May 5, 2022

Yes, this is still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant