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

Moveable binds and rows #3977

Merged
merged 3 commits into from
Apr 12, 2024
Merged

Conversation

momobel
Copy link
Contributor

@momobel momobel commented Apr 5, 2024

In the context of diesel_async, an async connection would also like to be used with sqlite. To enable creating an async connection wrapping a syn connection some types needs to be moveable and/or owned.

This PR adds support for moveable binds and owned row in core Diesel types as well as the sqlite connection and backend.

Support for postgres was tested at compile time but crashed due to invalid Rc constraints. That would need some deeper look to properly implement but doesn't seem to be blocking.

@momobel momobel changed the title Moveable binds and row Moveable binds and rows Apr 5, 2024
@weiznich weiznich requested a review from a team April 5, 2024 06:35
Copy link
Member

@weiznich weiznich left a comment

Choose a reason for hiding this comment

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

Thanks for opening this PR and thanks for working on this. Overall, as already discussed the implementation looks good.

I left a round of feedback consisting of minor mostly stylistic things, otherwise this should be fine to merge.

diesel/src/query_builder/bind_collector.rs Outdated Show resolved Hide resolved
diesel/src/query_builder/bind_collector.rs Outdated Show resolved Hide resolved
diesel/src/query_builder/bind_collector.rs Show resolved Hide resolved
diesel/src/query_builder/collected_query.rs Show resolved Hide resolved
diesel/src/query_builder/collected_query.rs Outdated Show resolved Hide resolved
diesel/src/row.rs Outdated Show resolved Hide resolved
diesel/src/sqlite/connection/row.rs Show resolved Hide resolved
diesel/src/sqlite/connection/row.rs Outdated Show resolved Hide resolved
diesel/src/sqlite/connection/row.rs Outdated Show resolved Hide resolved
@momobel momobel force-pushed the moveable_binds_and_row branch 4 times, most recently from cccd84a to 5da1637 Compare April 11, 2024 07:03
Copy link
Member

@weiznich weiznich left a comment

Choose a reason for hiding this comment

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

Looks good, beside the minor stylistic changes requested.

diesel/src/sqlite/connection/mod.rs Outdated Show resolved Hide resolved
diesel/src/query_builder/bind_collector.rs Outdated Show resolved Hide resolved
diesel/src/sqlite/connection/row.rs Outdated Show resolved Hide resolved
diesel/src/sqlite/connection/sqlite_value.rs Outdated Show resolved Hide resolved
@momobel momobel force-pushed the moveable_binds_and_row branch 2 times, most recently from 3e20b51 to db0eb9b Compare April 12, 2024 06:30
It will be a hard error in 2024 edition so implement it "properly"

warning: creating a mutable reference to mutable static is discouraged
   --> diesel/src/sqlite/connection/mod.rs:229:18
    |
229 |         unsafe { &mut SQLITE_METADATA_LOOKUP }
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference to mutable static
    |
    = note: for more information, see issue #114447 <rust-lang/rust#114447>
    = note: this will be a hard error in the 2024 edition
    = note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
    = note: `#[warn(static_mut_refs)]` on by default
@weiznich weiznich enabled auto-merge April 12, 2024 07:05
@weiznich weiznich added this pull request to the merge queue Apr 12, 2024
Merged via the queue into diesel-rs:master with commit 793de72 Apr 12, 2024
48 checks passed
@momobel momobel deleted the moveable_binds_and_row branch April 22, 2024 11:18
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.

2 participants