-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add SqlStr #3723
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
Add SqlStr #3723
Conversation
I appreciate the effort on this, but in #3364 kind of got stuck on some design questions. I was thinking that I would:
It's extremely hard to resist scope creep with major refactors like this. At minimum I would still delete the (Also, I don't assume you intended to do this, but you erased my authorship in these commits.) |
This would be great, also dropping transactions would probably be easier.
Ah that's why the
This wasn't my first time trying to make this PR work, in my first attempt I tried working on top of your PR but there were too things changed in the |
CI is passing and this PR is using your commit, so this should be ready for the next step. What should the replacement for the Also while going through some of the lifetimes I noticed that the |
Yeah, deleting the lifetimes on |
CI should be fixed if you rebase. |
2d6caae
to
bbe8beb
Compare
@joeydewaal do you have time to address the merge conflicts? |
Yes, I'll work on this today |
Merge conflicts are resolved |
Co-authored-by: Austin Bonander <[email protected]>
Co-authored-by: Austin Bonander <[email protected]>
Another bikeshedding question: should we change the name of |
I don't really have a strong opinion on that, but since we trying to make it really safe we might as well. What name did you have in mind, I'm thinking of |
Yeah, let's deprecate |
On second thought, I'd rather just merge this. I think |
* refactor: introduce `SqlSafeStr` API * rebase main * Add SqlStr + remove Statement lifetime * Update the definition of Executor and AnyConnectionBackend + update Postgres driver * Update MySql driver * Update Sqlite driver * remove debug clone count * Reduce the amount of SqlStr clones * improve QueryBuilder error message * cargo fmt * fix clippy warnings * fix doc test * Avoid panic in `QueryBuilder::reset` * Use `QueryBuilder` when removing all test db's * Add comment to `SqlStr` Co-authored-by: Austin Bonander <[email protected]> * Update sqlx-core/src/query_builder.rs Co-authored-by: Austin Bonander <[email protected]> * Add `Clone` as supertrait to `Statement` * Move `Connection`, `AnyConnectionBackend` and `TransactionManager` to `SqlStr` * Replace `sql_cloned` with `sql` in `Statement` * Update `Executor` trait * Update unit tests + QueryBuilder changes * Remove code in comments * Update comment in `QueryBuilder` * Fix clippy warnings * Update `Migrate` comment * Small changes * Move `Migration` to `SqlStr` --------- Co-authored-by: Austin Bonander <[email protected]>
Not sure if it's appreciated to take over a PR but I thought I'd try and work #3364 out.
This PR changes the following things:
SqlStr
,AssertSqlStr
types andSqlSafeStr
trait.Statement
since the underlying sql string is now owned.Executor
trait to take aSqlStr
instead of a&'q str
.AnyStatement::try_from_statement
method to take aStatement
so theprepare_with
method onAnyConnectionBackend
doesn't have to clone theSqlStr
.There are still lifetimes that should be changed/relaxed, but this works.