Skip to content

optional sqlx feature json required for type JSONB of column/param X #3316

Closed
@jay3332

Description

@jay3332

Bug Description

Compiling my project on using sqlx from latest GitHub commit gives me an error akin to:

$ cargo check --all-features
error: optional sqlx feature `json` required for type JSONB of column #6 ("embeds")
   --> src/db/channel.rs:340:27
    |
340 |           let mut message = sqlx::query!(
    |  ___________________________^
341 | |             r#"SELECT
342 | |                 messages.*,
343 | |                 embeds AS "embeds_ser: sqlx::types::Json<Vec<Embed>>"
...   |
351 | |             channel_id as i64,
352 | |         )
    | |_________^
    |
    = note: this error originates in the macro `$crate::sqlx_macros::expand_query` which comes from the expansion of the macro `sqlx::query` (in Nightly builds, run with -Z macro-backtrace for more info)

My Cargo.toml:

[dependencies.sqlx]
git = "https://github.com/launchbadge/sqlx.git"
version = "0.8.0-alpha.0"
features = ["postgres", "macros", "runtime-tokio-rustls", "chrono", "json", "uuid"]
optional = true

(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 the json feature, then write a query using the sqlx::query! macro that uses JSONB

Info

  • SQLx version: 0.8.0-alpha0 (commit 0eb2ee9)
  • SQLx features enabled: ["postgres", "macros", "runtime-tokio-rustls", "chrono", "json", "uuid"]
  • Database server and version: Postgres 14.12
  • Operating system: macOS Sonoma 14.0
  • rustc --version: rustc 1.81.0-nightly (b5b13568f 2024-06-10)

Notes

Using the following patch fixes this error:

git = "https://github.com/benluelo/sqlx.git"
branch = "fix-encode-decode-derives"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions