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

It's not possible to use bstr feature #3702

Open
tumdum opened this issue Jan 25, 2025 · 0 comments · May be fixed by #3714
Open

It's not possible to use bstr feature #3702

tumdum opened this issue Jan 25, 2025 · 0 comments · May be fixed by #3714
Labels

Comments

@tumdum
Copy link

tumdum commented Jan 25, 2025

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)

@tumdum tumdum added the bug label Jan 25, 2025
@joeydewaal joeydewaal linked a pull request Jan 29, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant