Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Handle batch inserts #3

Closed
telezhnaya opened this issue Feb 23, 2022 · 3 comments
Closed

Handle batch inserts #3

telezhnaya opened this issue Feb 23, 2022 · 3 comments

Comments

@telezhnaya
Copy link
Collaborator

With sqlx, it's not possible to say

sqlx::query("INSERT INTO table VALUES ?", my_vector_of_objects);

It's not even possible to say

sqlx::query("INSERT INTO table VALUES ?", my_object);

You have to put each field of your object into the placeholder

sqlx::query("INSERT INTO table VALUES (?, ..., ?)", my_object.a, ..., my_object.z);

It becomes a nightmare when we are talking about batch inserts.
I've created the solution which builds the correct SQL from pieces, but it leads to the SQL injections.
I also abused fmt::Display for this, which is also not good.
We need to think about a better solution.

@telezhnaya telezhnaya mentioned this issue Feb 23, 2022
2 tasks
@telezhnaya
Copy link
Collaborator Author

launchbadge/sqlx#1766

@telezhnaya
Copy link
Collaborator Author

We came up with MySqlOptions, it's the best we can do right now

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

No branches or pull requests

1 participant