Skip to content

It's not possible to use bstr feature #3702

Closed
@tumdum

Description

@tumdum

I have found these related issues/pull requests

This is most likely broken since #2039

Description

bstr is not a feature defined in the sqlx crate, but is documented in the readme file. Moreover bstr::BString is not supported out of the box either.

Reproduction steps

Cargo.toml:

[package]
name = "sqlx-repro"
version = "0.1.0"
edition = "2021"

[dependencies]
bstr = "1.11.3"
sqlx = { version = "0.8.3", features = ["sqlite", "runtime-tokio"] }
tokio = { version = "1.43.0", features = ["full"] }

src/main.rs:

use sqlx::{query_as, FromRow, Sqlite};

#[derive(Debug, FromRow)]
struct Foo {
    value: bstr::BString,
}

#[tokio::main]
async fn main() {
    let pool: sqlx::Pool<Sqlite> = todo!();
    let foo: Foo = query_as("select (value) from foos")
        .fetch_one(&pool)
        .await
        .unwrap();
}
$ cargo check
    Checking sqlx-repro v0.1.0 (/Users/t/dev/sqlx-repro)
warning: unreachable statement
  --> src/main.rs:11:5
   |
10 |       let pool: sqlx::Pool<Sqlite> = todo!();
   |                                      ------- any code following this expression is unreachable
11 | /     let foo: Foo = query_as("select (value) from foos")
12 | |         .fetch_one(&pool)
13 | |         .await
14 | |         .unwrap();
   | |__________________^ unreachable statement
   |
   = note: `#[warn(unreachable_code)]` on by default

error[E0277]: the trait bound `BString: sqlx::Decode<'_, Sqlite>` is not satisfied
   --> src/main.rs:12:10
    |
12  |         .fetch_one(&pool)
    |          ^^^^^^^^^ the trait `sqlx::Decode<'_, Sqlite>` is not implemented for `BString`
    |
    = help: the following other types implement trait `sqlx::Decode<'r, DB>`:
              `&'a str` implements `sqlx::Decode<'a, sqlx::Any>`
              `&'r JsonRawValue` implements `sqlx::Decode<'r, DB>`
              `&'r [u8]` implements `sqlx::Decode<'r, Sqlite>`
              `&'r [u8]` implements `sqlx::Decode<'r, sqlx::Any>`
              `&'r str` implements `sqlx::Decode<'r, Sqlite>`
              `Box<[u8]>` implements `sqlx::Decode<'_, Sqlite>`
              `Box<str>` implements `sqlx::Decode<'_, Sqlite>`
              `Cow<'r, str>` implements `sqlx::Decode<'r, Sqlite>`
            and 33 others
note: required for `Foo` to implement `for<'r> FromRow<'r, SqliteRow>`
   --> src/main.rs:3:17
    |
3   | #[derive(Debug, FromRow)]
    |                 ^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
4   | struct Foo {
    |        ^^^
note: required by a bound in `QueryAs::<'q, DB, O, A>::fetch_one`
   --> /Users/t/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-core-0.8.3/src/query_as.rs:86:23
    |
86  |     O: Send + Unpin + for<'r> FromRow<'r, DB::Row>,
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `QueryAs::<'q, DB, O, A>::fetch_one`
...
160 |     pub async fn fetch_one<'e, 'c: 'e, E>(self, executor: E) -> Result<O, Error>
    |                  --------- required by a bound in this associated function
    = note: this error originates in the derive macro `FromRow` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `BString: Type<Sqlite>` is not satisfied
   --> src/main.rs:12:10
    |
12  |         .fetch_one(&pool)
    |          ^^^^^^^^^ the trait `Type<Sqlite>` is not implemented for `BString`
    |
    = help: the following other types implement trait `Type<DB>`:
              `&T` implements `Type<DB>`
              `Box<[u8]>` implements `Type<Sqlite>`
              `Box<str>` implements `Type<Sqlite>`
              `Cow<'_, str>` implements `Type<Sqlite>`
              `Json<T>` implements `Type<Sqlite>`
              `JsonRawValue` implements `Type<DB>`
              `JsonValue` implements `Type<DB>`
              `NonZero<i16>` implements `Type<DB>`
            and 34 others
note: required for `Foo` to implement `for<'r> FromRow<'r, SqliteRow>`
   --> src/main.rs:3:17
    |
3   | #[derive(Debug, FromRow)]
    |                 ^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
4   | struct Foo {
    |        ^^^
note: required by a bound in `QueryAs::<'q, DB, O, A>::fetch_one`
   --> /Users/t/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-core-0.8.3/src/query_as.rs:86:23
    |
86  |     O: Send + Unpin + for<'r> FromRow<'r, DB::Row>,
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `QueryAs::<'q, DB, O, A>::fetch_one`
...
160 |     pub async fn fetch_one<'e, 'c: 'e, E>(self, executor: E) -> Result<O, Error>
    |                  --------- required by a bound in this associated function
    = note: this error originates in the derive macro `FromRow` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `BString: sqlx::Decode<'_, Sqlite>` is not satisfied
  --> src/main.rs:12:10
   |
12 |         .fetch_one(&pool)
   |          ^^^^^^^^^ the trait `sqlx::Decode<'_, Sqlite>` is not implemented for `BString`
   |
   = help: the following other types implement trait `sqlx::Decode<'r, DB>`:
             `&'a str` implements `sqlx::Decode<'a, sqlx::Any>`
             `&'r JsonRawValue` implements `sqlx::Decode<'r, DB>`
             `&'r [u8]` implements `sqlx::Decode<'r, Sqlite>`
             `&'r [u8]` implements `sqlx::Decode<'r, sqlx::Any>`
             `&'r str` implements `sqlx::Decode<'r, Sqlite>`
             `Box<[u8]>` implements `sqlx::Decode<'_, Sqlite>`
             `Box<str>` implements `sqlx::Decode<'_, Sqlite>`
             `Cow<'r, str>` implements `sqlx::Decode<'r, Sqlite>`
           and 33 others
note: required for `Foo` to implement `for<'r> FromRow<'r, SqliteRow>`
  --> src/main.rs:3:17
   |
3  | #[derive(Debug, FromRow)]
   |                 ^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
4  | struct Foo {
   |        ^^^
note: required by a bound in `QueryAs<'q, DB, O, A>`
  --> /Users/t/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-core-0.8.3/src/query_as.rs:86:23
   |
86 |     O: Send + Unpin + for<'r> FromRow<'r, DB::Row>,
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `QueryAs<'q, DB, O, A>`
   = note: this error originates in the derive macro `FromRow` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `BString: sqlx::Decode<'_, Sqlite>` is not satisfied
  --> src/main.rs:11:20
   |
11 |       let foo: Foo = query_as("select (value) from foos")
   |  ____________________^
12 | |         .fetch_one(&pool)
   | |_________________________^ the trait `sqlx::Decode<'_, Sqlite>` is not implemented for `BString`
   |
   = help: the following other types implement trait `sqlx::Decode<'r, DB>`:
             `&'a str` implements `sqlx::Decode<'a, sqlx::Any>`
             `&'r JsonRawValue` implements `sqlx::Decode<'r, DB>`
             `&'r [u8]` implements `sqlx::Decode<'r, Sqlite>`
             `&'r [u8]` implements `sqlx::Decode<'r, sqlx::Any>`
             `&'r str` implements `sqlx::Decode<'r, Sqlite>`
             `Box<[u8]>` implements `sqlx::Decode<'_, Sqlite>`
             `Box<str>` implements `sqlx::Decode<'_, Sqlite>`
             `Cow<'r, str>` implements `sqlx::Decode<'r, Sqlite>`
           and 33 others
note: required for `Foo` to implement `for<'r> FromRow<'r, SqliteRow>`
  --> src/main.rs:3:17
   |
3  | #[derive(Debug, FromRow)]
   |                 ^^^^^^^ unsatisfied trait bound introduced in this `derive` macro
4  | struct Foo {
   |        ^^^
note: required by a bound in `QueryAs<'q, DB, O, A>`
  --> /Users/t/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-core-0.8.3/src/query_as.rs:86:23
   |
86 |     O: Send + Unpin + for<'r> FromRow<'r, DB::Row>,
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `QueryAs<'q, DB, O, A>`
   = note: this error originates in the derive macro `FromRow` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.
warning: `sqlx-repro` (bin "sqlx-repro") generated 1 warning
error: could not compile `sqlx-repro` (bin "sqlx-repro") due to 4 previous errors; 1 warning emitted

SQLx version

0.8.3

Enabled SQLx features

sqlite runtime-tokio

Database server and version

bundled sqlite

Operating system

macOS 15.1.1 (24B2091)

Rust version

rustc 1.84.0 (9fc6b4312 2025-01-07)

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