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

Implement for sqlx #329

Merged
merged 5 commits into from
Dec 11, 2023
Merged

Implement for sqlx #329

merged 5 commits into from
Dec 11, 2023

Conversation

Kijewski
Copy link
Contributor

No description provided.

@Kijewski
Copy link
Contributor Author

Mysql and Postgres are untested.

compact_str/src/features/sqlx/mysql.rs Outdated Show resolved Hide resolved
compact_str/src/features/sqlx/postgres.rs Outdated Show resolved Hide resolved
compact_str/src/features/sqlx/sqlite.rs Outdated Show resolved Hide resolved
@Kijewski Kijewski marked this pull request as draft October 24, 2023 08:29
@Kijewski Kijewski marked this pull request as ready for review October 24, 2023 08:46
@Kijewski
Copy link
Contributor Author

I am using namespaced features in this PR now, which would mean that this MSRV is stuck to 1.60. Do you think that's okay?

@ParkMyCar
Copy link
Owner

I am using namespaced features in this PR now, which would mean that this MSRV is stuck to 1.60. Do you think that's okay?

Yeah I think bumping the MSRV to 1.60 is a good idea! It will also help with #328

Copy link
Owner

@ParkMyCar ParkMyCar 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 putting up this PR @Kijewski, I really appreciate it!

The implementation looks good, just one comment on the macro. Otherwise it looks like we'll need to update the x-plat CI workflow and exclude at least the sqlx/sqlite feature since we're failing to build sqlite via cross.

compact_str/src/features/sqlx.rs Outdated Show resolved Hide resolved
@Kijewski
Copy link
Contributor Author

Yeah, I used a bit too many macros in here. :)

Could you have a look how to update the CI workflow? I don't know exactly how to exclude the test when cross compiling.

Comment on lines +38 to +49
#[cfg_attr(docsrs, doc(cfg(feature = "sqlx")))]
impl<'r, DB> Decode<'r, DB> for CompactString
where
DB: Database,
for<'x> &'x str: Decode<'x, DB> + Type<DB>,
{
fn decode(value: <DB as HasValueRef<'r>>::ValueRef) -> Result<Self, BoxDynError> {
let value = value.to_owned();
let value: &str = value.try_decode()?;
Ok(value.try_to_compact_string()?)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to not specifically implement Decode for each of the Database variants? They each look like they have faster code paths for decoding &str that can be used to create a CompactStr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those functions are only available in their respective crates, and let value: &str = value.try_decode()?; boils down to the same code.

@ParkMyCar
Copy link
Owner

Thanks for the PR @Kijewski!

The CI issue looks to be sqlx-sqlite trying to build libsqlite3-sys, which not surprisingly fails in cross, I ignored the sqlx-* features for x-plat builds with cross. The MSRV check fails because it looks like proptest updates their MSRV again, I'll fix this in a separate PR though!

@ParkMyCar ParkMyCar merged commit 08d03c5 into ParkMyCar:main Dec 11, 2023
27 of 28 checks passed
@Kijewski Kijewski deleted the pr-sqlx branch December 12, 2023 12:51
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.

4 participants