-
-
Notifications
You must be signed in to change notification settings - Fork 550
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
Panic in insert_many
if ActiveModels
have different columns set
#1407
Comments
I also encountered this, I think it would be better to add an explanation that you need to change the number of columns. |
I think there are two cases. If the missing columns are nullable, SeaORM might be able to stuff in NULLs. Otherwise we should raise an error instead of panicking. The panicking comes from SeaQuery (I bet), would appreciate if @GeorgeHahn can provide the stack trace. |
panicking is raised from Lines 130 to 146 in e129785
My understanding from the code is underlying function If we can convert this into a compilation error that would be great, but I doubt it can be done. here's stack trace
|
I see. Then it is fixable to various degree; at least we should make it not panic. |
Will returning a |
Hi! Stumbled into this. Is there a workaround to be able to do insert_many without panics? |
Also bitten by this. I've got a simple loop which processes some data and inserts into a sqlite database. The iterator of A lack of panics would be appreciated. |
Yes, instead of panicking, we can build the query in a second pass. I think we can fix this in the next release. PR would be welcome meanwhile. The most straight-forward implementation is to fill in missing values with |
I've recently bumped into this problem. While it's not clear how sea-orm should properly solve this issue, I believe it might be useful to mention this behaviour in the docs. |
@belyakov-am do you know how to trace the issue? |
Encountered this when using loco-rs/loco and the seeding of data feature. I have a table with several nullable columns. Loco takes a yaml file as input and converts it to an Sample failing yaml: - id: 1
something: some value
nullable1: value
- id: 2
something: some value
nullable2: value Observe that the entry at ID 2 does not set a value for When this is converted to an There are two possible work-arounds:
- id: 1
something: some value
nullable1: value
nullable2:
- id: 2
something: some value
nullable1:
nullable2: value
- id: 1
something: some value
nullable1: value - id: 2
something: some value
nullable2: value |
Dear all who are interested in this issue, I've made a fix in the PR 2433. It is slightly tricky, so I'd appreciate if someone can help reading / testing it! |
issue still occurs sea-orm-1.1.2 |
we haven't released it yet, so to try out one has to point the dependency in cargo to something like:
|
It works as I expect using my sample data via loco-rs 0.9.0.
A work-around was added to loco-rs as loco-rs/loco#845 that is marked as part of milestone https://github.com/loco-rs/loco/milestone/21 Procedure
cargo.toml override
package.lock entries
|
Thank you @CandleCandle for helping! it's been released in 1.1.3 |
Description
insert_many
panics with the message "columns mismatch" if the entities to be stored have values in a mix of columns.Steps to Reproduce
See minimal reproduction below
Expected Behavior
This seems like it should be supported or explicitly disallowed.
Actual Behavior
Panic internal to the library
Reproduces How Often
100%
Versions
Tested with 0.10.7. Reproduces on Windows 10 and Ubuntu 20.04.
Additional Information
Minimal reproduction:
The text was updated successfully, but these errors were encountered: