Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add to_sql for bytes Cow as well#1051

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sfackler merged 2 commits intorust-postgres:masterfromandrewbaxter:patch-1
Jul 20, 2023
Merged

Add to_sql for bytes Cow as well#1051

sfackler merged 2 commits intorust-postgres:masterfromandrewbaxter:patch-1
Jul 20, 2023

Conversation

andrewbaxter
Copy link
Contributor

No description provided.

@andrewbaxterandrewbaxter marked this pull request as draftJuly 20, 2023 13:54
@andrewbaxterandrewbaxter changed the titleDraft: Add to_sql for bytes Cow as wellAdd to_sql for bytes Cow as wellJul 20, 2023

impl<'a>ToSqlforCow<'a,[u8]>{
fnto_sql(&self,ty:&Type,w:&mutBytesMut) ->Result<IsNull,Box<dynError +Sync +Send>>{
<&strasToSql>::to_sql(&self.as_ref(), ty, w)
Copy link
Collaborator

Choose a reason for hiding this comment

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

str -> [u8], and you shouldn't need the.as_ref().

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ah yeah, sorry, was just testing it locally. I'll fix that now!

Copy link
ContributorAuthor

@andrewbaxterandrewbaxterJul 20, 2023
edited
Loading

Choose a reason for hiding this comment

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

Withoutas_ref I get

error[E0308]: mismatched types    --> postgres-types/src/lib.rs:1040:34     |1040 |         <&[u8] as ToSql>::to_sql(&self, ty, w)     |         ------------------------ ^^^^^ expected `&&[u8]`, found `&&Cow<'_, [u8]>`     |         |     |         arguments to this function are incorrect     |     = note: expected reference `&&[u8]`                found reference `&&Cow<'a, [u8]>`note: method defined here    --> postgres-types/src/lib.rs:851:8     |851  |     fn to_sql(&self, ty: &Type, out: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>>     |        ^^^^^^

Copy link
ContributorAuthor

@andrewbaxterandrewbaxterJul 20, 2023
edited
Loading

Choose a reason for hiding this comment

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

Thestr thing was fixed, I think this is ready to go. And thanks for the fast review!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh yeah, you'd need to do the same&&**self dance you can see above. This works as well though.

@andrewbaxterandrewbaxter marked this pull request as ready for reviewJuly 20, 2023 14:30
@sfacklersfackler merged commitd16a9cd intorust-postgres:masterJul 20, 2023
@sfackler
Copy link
Collaborator

Thanks!

andrewbaxter reacted with heart emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@sfacklersfacklersfackler left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@andrewbaxter@sfackler

[8]ページ先頭

©2009-2025 Movatter.jp