-
Notifications
You must be signed in to change notification settings - Fork 1.4k
optional sqlx feature json
required for type JSONB of column/param X
#3316
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
Comments
Why not open a PR? |
The patch was taken from an old PR by another author that was merged that solved an unrelated issue. This PR was created before a commit (not to my knowledge) that led to the referenced error (thus this breaking commit was not in the PR branch) but merged after this commit was pushed. |
Okay.. so that seems somewhat
Footnotes
|
(very much partially) debugging this:
Here it goes into my code as above does not have a reproducible example attached ^^ My code is this. I have included just the relevant parts, and it is not fully minimal. If this turns out to be a problem, I will contribute a minimal example
CREATE TABLE en
(
key TEXT UNIQUE PRIMARY KEY NOT NULL,
data TEXT NOT NULL,
);
alter table en alter column data type jsonb using data::jsonb; let key = "1";
let result = sqlx::query_scalar!("SELECT data FROM en WHERE key = $1", key)
.fetch_optional(&pool)
.await; The macro expands to:
I am somewhat lost what happens in that macros' sqlx/sqlx-postgres/src/types/json.rs Lines 17 to 25 in 3bec3f0
So to me it seems like |
expanding the #[cfg(feature = "json")]
_ if <sqlx::types::JsonValue as sqlx_core::types::Type<Postgres>>::type_info() == *info => Some(::sqlx_core::select_input_type!( sqlx::types::JsonValue )), #[cfg(feature = "json")]
_ if <sqlx::types::JsonValue as sqlx_core::types::Type<Postgres>>::compatible(info) => Some(select_input_type!( sqlx::types::JsonValue )), |
@CommanderStorm is it fixed if you add |
Uh oh!
There was an error while loading. Please reload this page.
Bug Description
Compiling my project on using sqlx from latest GitHub commit gives me an error akin to:
My Cargo.toml:
(as seen, i have the
json
feature enabled)This occurs is all places where JSONB is used
Minimal Reproduction
Use the latest commit of
sqlx
, enabling thejson
feature, then write a query using thesqlx::query!
macro that uses JSONBInfo
["postgres", "macros", "runtime-tokio-rustls", "chrono", "json", "uuid"]
rustc --version
: rustc 1.81.0-nightly (b5b13568f 2024-06-10)Notes
Using the following patch fixes this error:
The text was updated successfully, but these errors were encountered: