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

Make update_by_field only insert if it deleted a row. #1947

Open
bfops opened this issue Nov 5, 2024 · 0 comments
Open

Make update_by_field only insert if it deleted a row. #1947

bfops opened this issue Nov 5, 2024 · 0 comments

Comments

@bfops
Copy link
Collaborator

bfops commented Nov 5, 2024

Currently, bindings::query::update_by_field does a delete, ignores its result, then unconditionally calls insert, again ignoring its result. Consider what behavior we want and what is least surprising to users. My (pgoldman 2024-05-20) theory is that it should only call insert if a delete happened, and then should return the return value of insert.

Alter bindings::query::update_by_field to only call Table::insert if it actually deleted a row. It should also return the inserted row, as autoinc columns may still be updated within it.

Also consider making it an error to do update_by_{col} and supply a role which has a non-matching value in the col, like Foo::update_by_foo(&0, Foo { foo: 1, ..Default::default() }).

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

No branches or pull requests

1 participant