The Wayback Machine - http://web.archive.org/web/20220402194119/https://github.com/diesel-rs/diesel/pull/3035
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 jsonb concat operator #3035

Merged
merged 4 commits into from Feb 3, 2022

Conversation

czotomo
Copy link
Contributor

@czotomo czotomo commented Feb 1, 2022

No description provided.

@czotomo
Copy link
Contributor Author

@czotomo czotomo commented Feb 1, 2022

@weiznich am I supposed to push all the changes generated by compiletests locally even if Cargo.lock now contains bumped version of mysqlclient-sys? 🤔

Copy link
Member

@weiznich weiznich left a comment

Looks good from my side with those small suggestions fixed 👍

About the compile tests: Yes those need an update too, as some error messages change due to the fact that there are now additional trait impls that rustc could suggest. You can do that by running TRYBUILD=overwrite cargo test in the compile tests directory and commit the changes afterwards. I will add that to the general instructions, as this may happen for other operators as well.

/// let santas_address: serde_json::Value = serde_json::from_str(r#"{
/// "street": "Article Circle Expressway 1",
/// "city": "North Pole",
/// "postcode": "99705",
/// "state": "Alaska"
/// }"#).unwrap();
Copy link
Member

@weiznich weiznich Feb 2, 2022

Choose a reason for hiding this comment

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

Could we use the serde_json::json! macro here? That should make it much easier to read the code + remove the .unwrap()

(Same for the other json strings)

T::SqlType: JsonB,
{
}
#[doc(hidden)]
/// Marker trait used to implement `PgJsonbExpressionMethods` on the appropriate types.
pub trait JsonB {}

impl JsonB for Jsonb {}
Copy link
Member

@weiznich weiznich Feb 2, 2022

Choose a reason for hiding this comment

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

We should allow nullable jsonb values here too. That's possible by the following change:

Suggested change
T::SqlType: JsonB,
{
}
#[doc(hidden)]
/// Marker trait used to implement `PgJsonbExpressionMethods` on the appropriate types.
pub trait JsonB {}
impl JsonB for Jsonb {}
T::SqlType: JsonbOrNullableJsonb,
{
}
#[doc(hidden)]
/// Marker trait used to implement `PgJsonbExpressionMethods` on the appropriate types.
pub trait JsonbOrNullableJsonb {}
impl JsonbOrNullableJsonb for Jsonb {}
impl JsonbOrNullableJsonb for Nullable<Jsonb> {}

@czotomo czotomo requested a review from weiznich Feb 2, 2022
@weiznich weiznich merged commit f25881d into diesel-rs:master Feb 3, 2022
31 checks passed
@weiznich
Copy link
Member

@weiznich weiznich commented Feb 3, 2022

Thanks for your contribution ❤️

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.

None yet

2 participants