Skip to content
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

Insert many allow active models to have different column set #2433

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

tyt2y3
Copy link
Member

@tyt2y3 tyt2y3 commented Dec 1, 2024

Fixes #1407

This requires a new feature in sea-query, Value::as_null

@tyt2y3
Copy link
Member Author

tyt2y3 commented Dec 1, 2024

I believe this should have solved the problem once and for all. Since this is changing a core part of the library, we should test it more to prevent regression.

The safest way might be to have a new method insert_many_nopanic, but of course ideally we should replace the old method transparently.

Comment on lines 195 to 197
for col in columns.iter() {
self.columns.push(col.is_some());
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. self.columns is really for use with add(). so should we do self.columns.clear() first?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, reset (clear) it before altering it seems safer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or simply replace the columns vector, isn't this more readable?

self.columns = columns.iter().map(Option::is_some).collect();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic in insert_many if ActiveModels have different columns set
2 participants