Skip to content

Cannot retrieve inserted row when using UUID as primary key #340

Answered by stephenafamo
korECM asked this question in Q&A
Discussion options

You must be logged in to vote

So............................. this is a limitation of MySQL.

MySQL does not support the RETURNING clause, so it is tricky to retrieve a row that was just inserted.

IF a table has an auto increment field, we can use LastInsertID() to retrieve this.

If not, Bob tries to see if you have set any unique rows while inserting. For example, if email is a unique field and you insert a row with the email [email protected], then Bob can try to retrieve the row with that email and guarantee that it was the row that was just inserted.

However, in this case, you are not manually setting any unique rows (the UUID is set by default), so there is no way for Bob to retrieve what row was inserted.

If us…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@korECM
Comment options

@stephenafamo
Comment options

Answer selected by stephenafamo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn't working question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #338 on January 09, 2025 22:25.