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

Throw error on mapper update/erase if the table has no primary key #285

Merged
merged 1 commit into from
Nov 24, 2019

Conversation

xfra35
Copy link
Member

@xfra35 xfra35 commented Sep 26, 2019

I just had a bad experience today with the DB\SQL\Mapper->save() executing an UPDATE on the whole table instead of a single row. I realized that the table had a unique key but no primary key... and the framework did nothing to prevent the massive undesired UPDATE.

Hence this proposal to throw an error on update/erase() if no PK can be found.

@KOTRET
Copy link
Contributor

KOTRET commented Sep 27, 2019

i welcome this pr, although i can imagine of config-tables with only one row in it, so that this breaks compatibility.

@ikkez
Copy link
Member

ikkez commented Nov 24, 2019

I'm actually for this change, as I also had a similar adventure once before. If there are edge-cases for 1-row tables, we'll find a solution for it. I could imagine to put this behaviour into a mass-update method, so that you can batch-update all or some records at once.

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

Successfully merging this pull request may close these issues.

3 participants