Open DMaxter opened 11 months ago
Thank you for the investigation. I am confident that this is fixable, although can you illustrate the problem by showing the examples of:
I don't remember this issue very well, but I think this applies to one-to-many relationships
But what works is not using column_name
at all (so, the struct field should match what is defined in the database)
What doesn't work is using column_name
as described above
The workaround was to not use column_name
Description
I'm trying to use
load_many
to load the many side of multiple entities. However, if the many-side structure has the column name different from the struct name, and it is a primary key, it panics, as it tries to obtain the parameter through the column name and not through the struct parameter.As an example, this is a many side of a relation:
I receive a panic message like
With deeper debugging, I found out that this is triggered by this line: https://github.com/SeaQL/sea-orm/blob/0.12.3/src/query/loader.rs#L226
For this specific case, I found out that here the value is
cake_name
while the model given only hascake_id
, notcake_name
propertySteps to Reproduce
db.sql
Expected Behavior
Obtaining the many side
Actual Behavior
Panic
Reproduces How Often
Always
Workarounds
None, besides renaming the columns to match the model parameters (however this might not be possible, as is the case, because a migration from another platform is happening)
Reproducible Example
reproducer.zip
Versions
├── sea-orm v0.12.3 │ ├── sea-orm-macros v0.12.3 (proc-macro) │ │ ├── sea-bae v0.2.0 (proc-macro) │ ├── sea-query v0.30.1 │ ├── sea-query-binder v0.5.0 │ │ ├── sea-query v0.30.1 (*)