-
-
Notifications
You must be signed in to change notification settings - Fork 519
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
Let last_insert_id
optional and flexible.
#2393
Open
langyo
wants to merge
11
commits into
SeaQL:master
Choose a base branch
from
langyo:upgrade_exec_result
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
langyo
force-pushed
the
upgrade_exec_result
branch
3 times, most recently
from
October 14, 2024 02:33
8e19e10
to
8ed9b89
Compare
langyo
force-pushed
the
upgrade_exec_result
branch
from
October 14, 2024 02:35
8ed9b89
to
2495b40
Compare
cc @billy1624 @tyt2y3 |
langyo
changed the title
Let
Let Oct 17, 2024
last_insert_id
optional.last_insert_id
optional and flexible.
This reverts commit 3356023.
langyo
force-pushed
the
upgrade_exec_result
branch
from
October 17, 2024 16:30
e5a7246
to
fb8ea9d
Compare
langyo
force-pushed
the
upgrade_exec_result
branch
from
October 20, 2024 09:20
b1d27f2
to
60d0964
Compare
Some attempts were rolled back because gluesql/gluesql#1579
Temporarily circumvent the problem of not being able to correctly query the newly inserted elements caused by the upstream warehouse. gluesql/gluesql#1579
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Info
I'm sorry for submitting such a PR so presumptuously. I found that the type of
last_insert_id
is flawed.last_insert_id
will not be returned anyway, because Postgres may directly use a non-integer primary key.last_insert_id
is entirely up to the user. If the user cannot get a valid ID from the actual database transferred (for example, for databases such assurrealdb
, their IDs are UUIDs rather than integers), it is unreasonable to return a 0 directly.This change is likely to affect a considerable number of downstream libraries, so it is a breaking change. Whether to make such a change requires discussion and decision.
Breaking Changes
last_insert_id
optional.last_insert_id
follows the primary key's type.I am not in a hurry to merge now. I am trying to make more radical changes to synchronize
last_insert_id
directly with the type corresponding to PrimaryKey instead of hard-coded u64 type. It may adapt to more complex table structures.In addition to the fact that this field should be optional, I also consider the default generation of PrimaryKey. As mentioned in another discussion I cited, what we actually need is not necessarily a query logic that "may not return
last_insert_id
", but that we can generate the primary key by SeaORM instead of the database engine if necessary.Combining these two requirements, we get a
last_insert_id
that can be generated in advance and returned normally without hard-coding it asu64
. Not only meet the needs of primary keys that may not necessarily return u64 type, but also specify the "default value" of this primary key which is generated by us in advance rather than provided by the database engine itself.Finally, let's review the scenarios where this is applicable. One type is to use such as UUID, ULID, GUID as the primary key of the database table. The other type is to use the creation time as the index of the database table. Both of these types belong to the categories that the database engine cannot guarantee to have their corresponding implementations. We should indirectly provide auxiliary implementations through ORM.