-
-
Notifications
You must be signed in to change notification settings - Fork 539
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
InsertResult
to return the primary key's type
#103
Comments
InsertResult
return the column's type, not i64InsertResult
to return the column's type, not i64
How we handle composite primary keys? |
Composite primary keys can't be auto generated, and so it's less important. But I think the type could be a tuple, if we really try to support it. Let's leave it and return 0 for now. |
I think this issue can be related to #101 if we have an attribute |
And btw... returning statement in Postgres can return multiple columns at once. |
I think for the average case where there is only one column as primary key, adding one container layer is counter intuitive. impl PrimaryKeyTrait for PrimaryKey {
type ValueType = i32;
} |
Adding type def is a good suggestion |
I've had a dive into the code for this.. it seems like adding pub struct InsertResult<T> {
pub last_insert_id: T,
} And impl Future<
Output = Result<InsertResult<<A::Entity as EntityTrait>::PrimaryKey::ValueType>, DbErr>
> This what I'm thinking would be the best way.. |
Agreed. |
InsertResult
to return the column's type, not i64InsertResult
to return the primary key's type, not i64
InsertResult
to return the primary key's type, not i64InsertResult
to return the primary key's type
Currently, the
last_insert_id
from InsertResult simply uses the ExecResult's last_insert_id.However, at least for Postgres with
returning
, we should be able to retrieve the primary key column for the Entity and return the value in its native type. For example, auuid
instead of ani64
.The text was updated successfully, but these errors were encountered: