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

inserting null on an autoincrement primary key prevents cleanup #58

Open
jtopenpetition opened this issue Jun 14, 2023 · 0 comments · May be fixed by #57
Open

inserting null on an autoincrement primary key prevents cleanup #58

jtopenpetition opened this issue Jun 14, 2023 · 0 comments · May be fixed by #57

Comments

@jtopenpetition
Copy link

When I have a table with a primary key column that's also increment, it's valid to set it to null on the insert statement. the last insert it will then return the auto increment value, which is the primary key in that case.

As already noticed in #44, the auto increment column doesn't have to be part of the primary key, so the return value of last insert id ironically doesn't necessarily belong to the primary key. However, #44 also broke the case, which one might perceive as more common, that the last insert id may also be the primary key.

So, haveInDatabase(table, ['id' => null, ...]) with id as autoincrement and pk will lead to the id being set to null for cleanup, which results in the row not being removed at teardown.

I have prepared a fix for this case, which hopefully is specific enough to not interfere with other use cases.

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 a pull request may close this issue.

1 participant