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

The trait is not implemented for #280

Closed
Marekuss opened this issue Mar 27, 2022 · 9 comments · Fixed by #292
Closed

The trait is not implemented for #280

Marekuss opened this issue Mar 27, 2022 · 9 comments · Fixed by #292

Comments

@Marekuss
Copy link

Description

Hello guys, im not able to compile minimal example (below) with rusqlite backend, where im getting follow error:

error[E0277]: the trait bound `ValueRef<'_>: From<&bool>` is not satisfied
   --> src/main.rs:4:1
    |
4   | sea_query::sea_query_driver_rusqlite!();
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<&bool>` is not implemented for `ValueRef<'_>`
    |
    = help: the following implementations were found:
              <ValueRef<'a> as From<&'a [u8]>>
              <ValueRef<'a> as From<&'a rusqlite::types::Value>>
              <ValueRef<'a> as From<&'a str>>
              <ValueRef<'a> as From<Option<T>>>
    = note: required because of the requirements on the impl of `Into<ValueRef<'_>>` for `&bool`
    = note: required because of the requirements on the impl of `From<&bool>` for `ToSqlOutput<'_>`
note: required by `from`
    = note: this error originates in the macro `opt_string_to_sql` (in Nightly builds, run with -Z macro-backtrace for more info)

Steps to Reproduce

  1. run cargo init --bin
  2. modify Cargo.toml
[package]
name = "sea_query_test"
version = "0.1.0"
edition = "2021"

[dependencies]
sea-query = { version = "^0", features = [
    "rusqlite"
]}

[dependencies.rusqlite]
version = "^0.27"
features = [
    "bundled"
]
  1. modify main.rs
use rusqlite::{Connection, Result};
use sea_query::*;

sea_query::sea_query_driver_rusqlite!();
use sea_query_driver_rusqlite::RusqliteValues;

fn main() -> Result<()> {
    println!("test");
    Ok(())
}
  1. run cargo update && cargo build

Versions

Linux: Linux user-server 5.4.0-99-generic #112-Ubuntu SMP Thu Feb 3 13:50:55 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
rustc: 1.57.0
cargo: 1.57.0

Additional Information

cargo tree | grep sea-

└── sea-query v0.23.0
    └── sea-query-derive v0.2.0 (proc-macro)

cargo tree

sea_query_test v0.1.0 (/home/user/Temp/sea_query_test)
├── rusqlite v0.27.0
│   ├── bitflags v1.3.2
│   ├── fallible-iterator v0.2.0
│   ├── fallible-streaming-iterator v0.1.9
│   ├── hashlink v0.7.0
│   │   └── hashbrown v0.11.2
│   │       └── ahash v0.7.6
│   │           ├── getrandom v0.2.5
│   │           │   ├── cfg-if v1.0.0
│   │           │   └── libc v0.2.121
│   │           └── once_cell v1.10.0
│   │           [build-dependencies]
│   │           └── version_check v0.9.4
│   ├── libsqlite3-sys v0.24.1
│   │   [build-dependencies]
│   │   ├── cc v1.0.73
│   │   ├── pkg-config v0.3.24
│   │   └── vcpkg v0.2.15
│   ├── memchr v2.4.1
│   └── smallvec v1.8.0
└── sea-query v0.23.0
    └── sea-query-derive v0.2.0 (proc-macro)
        ├── heck v0.3.3
        │   └── unicode-segmentation v1.9.0
        ├── proc-macro2 v1.0.36
        │   └── unicode-xid v0.2.2
        ├── quote v1.0.17
        │   └── proc-macro2 v1.0.36 (*)
        ├── syn v1.0.89
        │   ├── proc-macro2 v1.0.36 (*)
        │   ├── quote v1.0.17 (*)
        │   └── unicode-xid v0.2.2
        └── thiserror v1.0.30
            └── thiserror-impl v1.0.30 (proc-macro)
                ├── proc-macro2 v1.0.36 (*)
                ├── quote v1.0.17 (*)
                └── syn v1.0.89 (*)
@Marekuss Marekuss changed the title The trait is not implemented fo The trait is not implemented for Mar 27, 2022
@ikrivosheev
Copy link
Member

ikrivosheev commented Mar 30, 2022

@Marekuss thank you for the report, workaround enable features: ["with-json", "with-time", "with-uuid", "with-chrono"]

@ikrivosheev
Copy link
Member

Ooops... I understand. For my PR needed: rust-lang/rust#73663

@Marekuss
Copy link
Author

@ikrivosheev Thanks for hint, i tried it but another error happened:
cargo.toml

[package]
name = "sea_query_test"
version = "0.1.0"
edition = "2021"

[dependencies]
sea-query = { version = "^0", features = ["rusqlite", "with-json", "with-time", "with-uuid", "with-chrono"]}

[dependencies.rusqlite]
version = "^0.27"
features = [
    "bundled"
]

Error message

error[E0599]: the method `to_sql` exists for reference `&serde_json::value::Value`, but its trait bounds were not satisfied
   --> src/main.rs:4:1
    |
4   | sea_query::sea_query_driver_rusqlite!();
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `&serde_json::value::Value` due to unsatisfied trait bounds
    |
   ::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.79/src/value/mod.rs:115:1
    |
115 | pub enum Value {
    | -------------- doesn't satisfy `serde_json::value::Value: ToSql`
    |
    = note: the following trait bounds were not satisfied:
            `serde_json::value::Value: ToSql`
            which is required by `&serde_json::value::Value: ToSql`
    = note: this error originates in the macro `ty_to_sql` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: the method `to_sql` exists for reference `&chrono::naive::date::NaiveDate`, but its trait bounds were not satisfied
  --> src/main.rs:4:1
   |
4  | sea_query::sea_query_driver_rusqlite!();
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `&chrono::naive::date::NaiveDate` due to unsatisfied trait bounds
   |
  ::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.19/src/naive/date.rs:99:1
   |
99 | pub struct NaiveDate {
   | -------------------- doesn't satisfy `chrono::naive::date::NaiveDate: ToSql`
   |
   = note: the following trait bounds were not satisfied:
           `chrono::naive::date::NaiveDate: ToSql`
           which is required by `&chrono::naive::date::NaiveDate: ToSql`
   = note: this error originates in the macro `ty_to_sql` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: the method `to_sql` exists for reference `&chrono::naive::time::NaiveTime`, but its trait bounds were not satisfied
   --> src/main.rs:4:1
    |
4   | sea_query::sea_query_driver_rusqlite!();
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `&chrono::naive::time::NaiveTime` due to unsatisfied trait bounds
    |
   ::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.19/src/naive/time.rs:182:1
    |
182 | pub struct NaiveTime {
    | -------------------- doesn't satisfy `chrono::naive::time::NaiveTime: ToSql`
    |
    = note: the following trait bounds were not satisfied:
            `chrono::naive::time::NaiveTime: ToSql`
            which is required by `&chrono::naive::time::NaiveTime: ToSql`
    = note: this error originates in the macro `ty_to_sql` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: the method `to_sql` exists for reference `&chrono::naive::datetime::NaiveDateTime`, but its trait bounds were not satisfied
  --> src/main.rs:4:1
   |
4  | sea_query::sea_query_driver_rusqlite!();
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `&chrono::naive::datetime::NaiveDateTime` due to unsatisfied trait bounds
   |
  ::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.19/src/naive/datetime.rs:62:1
   |
62 | pub struct NaiveDateTime {
   | ------------------------ doesn't satisfy `chrono::naive::datetime::NaiveDateTime: ToSql`
   |
   = note: the following trait bounds were not satisfied:
           `chrono::naive::datetime::NaiveDateTime: ToSql`
           which is required by `&chrono::naive::datetime::NaiveDateTime: ToSql`
   = note: this error originates in the macro `ty_to_sql` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: the method `to_sql` exists for reference `&chrono::datetime::DateTime<chrono::offset::utc::Utc>`, but its trait bounds were not satisfied
  --> src/main.rs:4:1
   |
4  | sea_query::sea_query_driver_rusqlite!();
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `&chrono::datetime::DateTime<chrono::offset::utc::Utc>` due to unsatisfied trait bounds
   |
  ::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.19/src/datetime.rs:70:1
   |
70 | pub struct DateTime<Tz: TimeZone> {
   | --------------------------------- doesn't satisfy `_: ToSql`
   |
   = note: the following trait bounds were not satisfied:
           `chrono::datetime::DateTime<chrono::offset::utc::Utc>: ToSql`
           which is required by `&chrono::datetime::DateTime<chrono::offset::utc::Utc>: ToSql`
   = note: this error originates in the macro `ty_to_sql` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: the method `to_sql` exists for reference `&chrono::datetime::DateTime<chrono::offset::local::Local>`, but its trait bounds were not satisfied
  --> src/main.rs:4:1
   |
4  | sea_query::sea_query_driver_rusqlite!();
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `&chrono::datetime::DateTime<chrono::offset::local::Local>` due to unsatisfied trait bounds
   |
  ::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.19/src/datetime.rs:70:1
   |
70 | pub struct DateTime<Tz: TimeZone> {
   | --------------------------------- doesn't satisfy `_: ToSql`
   |
   = note: the following trait bounds were not satisfied:
           `chrono::datetime::DateTime<chrono::offset::local::Local>: ToSql`
           which is required by `&chrono::datetime::DateTime<chrono::offset::local::Local>: ToSql`
   = note: this error originates in the macro `ty_to_sql` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: the method `to_sql` exists for reference `&chrono::datetime::DateTime<chrono::offset::fixed::FixedOffset>`, but its trait bounds were not satisfied
  --> src/main.rs:4:1
   |
4  | sea_query::sea_query_driver_rusqlite!();
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `&chrono::datetime::DateTime<chrono::offset::fixed::FixedOffset>` due to unsatisfied trait bounds
   |
  ::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/chrono-0.4.19/src/datetime.rs:70:1
   |
70 | pub struct DateTime<Tz: TimeZone> {
   | --------------------------------- doesn't satisfy `_: ToSql`
   |
   = note: the following trait bounds were not satisfied:
           `chrono::datetime::DateTime<chrono::offset::fixed::FixedOffset>: ToSql`
           which is required by `&chrono::datetime::DateTime<chrono::offset::fixed::FixedOffset>: ToSql`
   = note: this error originates in the macro `ty_to_sql` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: the method `to_sql` exists for reference `&time::offset_date_time::OffsetDateTime`, but its trait bounds were not satisfied
  --> src/main.rs:4:1
   |
4  | sea_query::sea_query_driver_rusqlite!();
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `&time::offset_date_time::OffsetDateTime` due to unsatisfied trait bounds
   |
  ::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.2.27/src/offset_date_time.rs:36:1
   |
36 | pub struct OffsetDateTime {
   | ------------------------- doesn't satisfy `time::offset_date_time::OffsetDateTime: ToSql`
   |
   = note: the following trait bounds were not satisfied:
           `time::offset_date_time::OffsetDateTime: ToSql`
           which is required by `&time::offset_date_time::OffsetDateTime: ToSql`
   = note: this error originates in the macro `ty_to_sql` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: the method `to_sql` exists for reference `&uuid::Uuid`, but its trait bounds were not satisfied
   --> src/main.rs:4:1
    |
4   | sea_query::sea_query_driver_rusqlite!();
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `&uuid::Uuid` due to unsatisfied trait bounds
    |
   ::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/uuid-0.8.2/src/lib.rs:261:1
    |
261 | pub struct Uuid(Bytes);
    | ----------------------- doesn't satisfy `uuid::Uuid: ToSql`
    |
    = note: the following trait bounds were not satisfied:
            `uuid::Uuid: ToSql`
            which is required by `&uuid::Uuid: ToSql`
    = note: this error originates in the macro `ty_to_sql` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0599`.
warning: `sea_query_test` (bin "sea_query_test") generated 3 warnings
error: could not compile `sea_query_test` due to 9 previous errors; 3 warnings emitted

@ikrivosheev
Copy link
Member

@Marekuss and add features for rusqlite which enable support for: serde, uuid, time and chrono.

@ikrivosheev
Copy link
Member

@ikrivosheev
Copy link
Member

@Marekuss, I create PR which fix the issue)

@Marekuss
Copy link
Author

Marekuss commented Apr 4, 2022

@ikrivosheev Thanks a lot for your effort.

regardind to

@Marekuss you can see example: https://github.com/SeaQL/sea-query/tree/master/examples/rusqlite

Example with sea_query 0.22 work well:

[package]
name = "sea-query-rusqlite-example"
version = "0.1.0"
edition = "2021"

[dependencies]
chrono = { version = "^0" }
time = { version = "^0.2" }
serde_json = { version = "^1" }
uuid = { version = "^0", features = ["serde", "v4"] }
sea-query = { version = "^0.22", features = [
    "rusqlite",
    "with-chrono",
    "with-json",
    "with-uuid"
] }

[dependencies.rusqlite]
version = "^0.27"
features = [
    "bundled",
    "chrono",
    "serde_json",
    "uuid",
    "time",
]

For sea_query version 0.23 where is added "time"

[package]
name = "sea-query-rusqlite-example"
version = "0.1.0"
edition = "2021"

[dependencies]
chrono = { version = "^0" }
time = { version = "^0.2" }
serde_json = { version = "^1" }
uuid = { version = "^0", features = ["serde", "v4"] }
sea-query = { version = "^0.23", features = [
    "rusqlite",
    "with-chrono",
    "with-json",
    "with-uuid",
    "with-time",
] }

[dependencies.rusqlite]
version = "^0.27"
features = [
    "bundled",
    "chrono",
    "serde_json",
    "uuid",
    "time",
]

with error message:

error[E0599]: the method `to_sql` exists for reference `&time::offset_date_time::OffsetDateTime`, but its trait bounds were not satisfied
  --> src/main.rs:5:1
   |
5  | sea_query::sea_query_driver_rusqlite!();
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `&time::offset_date_time::OffsetDateTime` due to unsatisfied trait bounds
   |
  ::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/time-0.2.27/src/offset_date_time.rs:36:1
   |
36 | pub struct OffsetDateTime {
   | ------------------------- doesn't satisfy `time::offset_date_time::OffsetDateTime: ToSql`
   |
   = note: the following trait bounds were not satisfied:
           `time::offset_date_time::OffsetDateTime: ToSql`
           which is required by `&time::offset_date_time::OffsetDateTime: ToSql`
   = note: this error originates in the macro `ty_to_sql` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
 --> src/main.rs:5:1
  |
5 | sea_query::sea_query_driver_rusqlite!();
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `Result`, found `()`
  |
  = note:   expected enum `Result<ToSqlOutput<'_>, rusqlite::Error>`
          found unit type `()`
  = note: this error originates in the macro `sea_query::sea_query_driver_rusqlite` (in Nightly builds, run with -Z macro-backtrace for more info)

@ikrivosheev Please, do you think i missed something ?
Thanks M.

@ikrivosheev
Copy link
Member

@Marekuss maybe you can wait until my PR is merged?)

@ikrivosheev
Copy link
Member

@Marekuss try new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants