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

sea-query-postgres support for bind params compile error #679

Closed
sartak opened this issue Aug 20, 2023 · 3 comments
Closed

sea-query-postgres support for bind params compile error #679

sartak opened this issue Aug 20, 2023 · 3 comments

Comments

@sartak
Copy link

sartak commented Aug 20, 2023

Description

I'm adopting sea-query in a tokio-postgres project, but I hit some trouble where the sea_query_postgres::PostgresBinder trait has no effect, and so it's difficult to convert bind values to the types needed to pass to postgres.

Steps to Reproduce

  1. Clone sea-query repo and cd examples/postgres/
  2. Run the following two commands to switch the sea-query dependencies to the latest releases (with the features used by the example):
    cargo add [email protected] -F with-uuid,with-chrono,with-json,with-time,postgres-array,with-rust_decimal
    cargo add [email protected] -F with-uuid,with-chrono,with-json,with-time,postgres-array,with-rust_decimal
  3. Run cargo build

Expected Behavior

The example compiles cleanly.

Actual Behavior

λ cargo build
   Compiling sea-query-postgres-example v0.1.0 ([…]/sea-query/examples/postgres)
error[E0599]: no method named `build_postgres` found for mutable reference `&mut sea_query::InsertStatement` in the current scope
   --> src/main.rs:118:10
    |
88  |       let (sql, values) = Query::insert()
    |  _________________________-
89  | |         .into_table(Document::Table)
90  | |         .columns([
91  | |             Document::Uuid,
...   |
117 | |         ])
118 | |         .build_postgres(PostgresQueryBuilder);
    | |         -^^^^^^^^^^^^^^ method not found in `&mut InsertStatement`
    | |_________|
    | 

error[E0599]: no method named `build_postgres` found for mutable reference `&mut sea_query::SelectStatement` in the current scope
   --> src/main.rs:138:10
    |
125 |       let (sql, values) = Query::select()
    |  _________________________-
126 | |         .columns([
127 | |             Document::Id,
128 | |             Document::Uuid,
...   |
137 | |         .limit(1)
138 | |         .build_postgres(PostgresQueryBuilder);
    | |         -^^^^^^^^^^^^^^ method not found in `&mut SelectStatement`
    | |_________|
    | 

warning: unused import: `sea_query_postgres::PostgresBinder`
 --> src/main.rs:6:5
  |
6 | use sea_query_postgres::PostgresBinder;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

For more information about this error, try `rustc --explain E0599`.
warning: `sea-query-postgres-example` (bin "sea-query-postgres-example") generated 1 warning
error: could not compile `sea-query-postgres-example` (bin "sea-query-postgres-example") due to 2 previous errors; 1 warning emitted

Reproduces How Often

Happens every time as of a784868

Versions

λ cargo tree | g sea-
sea-query-postgres-example v0.1.0 ([…]/sea-query/examples/postgres)
├── sea-query v0.30.0
│   ├── sea-query-derive v0.4.0 (proc-macro)
├── sea-query-postgres v0.3.0
│   └── sea-query v0.29.1

λ rustc --version
rustc 1.70.0 (90c541806 2023-05-31)

λ uname -a
Linux […] 5.4.0-144-generic #161-Ubuntu SMP Fri Feb 3 14:49:04 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Additional Information

Downgrading the example to sea-query 0.29.1 via cargo add [email protected] -F with-uuid,with-chrono,with-json,with-time,postgres-array,with-rust_decimal appears to fix the problem, presumably because now the two sea-query versions (the one used by example and the one used by sea-query-postgres) are consistent.

Also, this probably goes without saying, but the example also compiles cleanly when using the git master versions. I reckon the fix here is to ship a sea-query-postgres 0.3.1 that bumps its sea-query dependency to 0.30.0?

@sartak sartak changed the title Postgres example no longer compiles with released versions Postgres support for bind params broken Aug 20, 2023
@sartak sartak changed the title Postgres support for bind params broken sea-query-postgres support for bind params compile error Aug 20, 2023
@tyt2y3
Copy link
Member

tyt2y3 commented Aug 21, 2023

sea-query-postgres 0.3 is meant to be paired with sea-query 0.29
Due to a dependency upgrade sea-query 0.30 would require a new version (0.4) for sea-query-postgres.
But 0.30 and 0.29 is otherwise identical.
I might make a new release this week.

@sartak
Copy link
Author

sartak commented Sep 2, 2023

This works now with sea-query 0.30.1 and sea-query-postgres 0.4.0, thanks

@sartak sartak closed this as completed Sep 2, 2023
@tyt2y3
Copy link
Member

tyt2y3 commented Sep 2, 2023

Oh right! Thanks for the nudge!

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

No branches or pull requests

2 participants