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

Implementing ToSql for [u8;N] #3714

Merged
merged 5 commits into from
Jul 26, 2023
Merged

Implementing ToSql for [u8;N] #3714

merged 5 commits into from
Jul 26, 2023

Conversation

snf
Copy link
Contributor

@snf snf commented Jul 25, 2023

Hi thanks for developing and supporting diesel.

This PR would allow to bind slices of arbitrary size to queries (my specific usecase is raw queries). It's mostly for convenience to prevent having to reshape types prior to sending them to diesel.

An alternative would be to implement it for all the T: AsRef<[u8]>.

@weiznich weiznich requested a review from a team July 25, 2023 18:02
@weiznich
Copy link
Member

Thanks for opening this PR. Could you add at least some minor text for the motivation of that PR.

@snf
Copy link
Contributor Author

snf commented Jul 25, 2023

Hi sorry about that, I was editing the description and got distracted by other stuff. Just added it now

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 the update. The change itself looks good.

I would like to see a test for that in diesel_tests/tests/types.rs just to have something for the future to assert that this impl is there.

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

@weiznich weiznich enabled auto-merge July 26, 2023 12:38
@snf
Copy link
Contributor Author

snf commented Jul 26, 2023

Thank you! Waiting for the tests though

@weiznich
Copy link
Member

Waiting for the tests though

It's configured in such a way that it only merges the PR if the test passes. I just allows me to not coming back for merging in a day or two if everything is fine.

@snf
Copy link
Contributor Author

snf commented Jul 26, 2023

I'll come back to it this afternoon (failed test)

@weiznich
Copy link
Member

Oh, right. It needs a similar impl like that one:

#[derive(AsExpression)]
#[diesel(foreign_derive, not_sized)]
#[diesel(sql_type = Binary)]
struct BinarySliceProxy([u8]);

(Although I'm not sure if the derive correctly handles const generics…)

auto-merge was automatically disabled July 26, 2023 16:03

Head branch was pushed to by a user without write access

@snf
Copy link
Contributor Author

snf commented Jul 26, 2023

I'm not sure all of this is actually needed. I can also squash the commits into a single one to reduce noise.

@weiznich weiznich self-requested a review July 26, 2023 18:24
@weiznich weiznich added this pull request to the merge queue Jul 26, 2023
Merged via the queue into diesel-rs:master with commit f4d5f93 Jul 26, 2023
31 checks passed
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