-
Notifications
You must be signed in to change notification settings - Fork 189
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
Refactor(torii-core): Optimize and clean sql statements #927
Conversation
Thanks! there are some sizable changes coming down the pipe (#916), I think we could wait for this one to land first. Also we're gonna be moving to |
Reopening for @gianalarcon now that nested model is implemented |
Ready for review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor suggestion otherwise lgtm!
)); | ||
); | ||
// execute first to get created_at | ||
let query_result: SqliteRow = sqlx::query(&insert_entities).fetch_one(&self.pool).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use query_as
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging. Feel free to follow up with the change
Refactor fn register_model(), and fn set_entity() to get rid of extra SQL query statements.
Solution
Use RETURNING clause to avoid unnecessary SQL statements