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

Sqlx-core error in logger.rs FormatOptions reference #3544

Closed
tbar4 opened this issue Oct 4, 2024 · 12 comments · Fixed by #3545
Closed

Sqlx-core error in logger.rs FormatOptions reference #3544

tbar4 opened this issue Oct 4, 2024 · 12 comments · Fixed by #3545
Labels
bug:dependency A bug in a dependency, open until fixed by upgrade bug

Comments

@tbar4
Copy link
Contributor

tbar4 commented Oct 4, 2024

Bug Description

When using cargo install sea-orm-cli for versions 1.0.0 and 1.0.1 I get an error for the sqlx-core crate as follows:

       error[E0308]: mismatched types
       --> /home/server/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlx-core-0.7.4/src/logger.rs:112:29
       |
109 |                         sqlformat::format(
       |                         ----------------- arguments to this function are incorrect
...
112 |                             sqlformat::FormatOptions::default()
       |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&FormatOptions<'_>`, found `FormatOptions<'_>`
       |
       note: function defined here
           --> /home/server/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sqlformat-0.2.7/src/lib.rs:18:8
       |
18   | pub fn format(query: &str, params: &QueryParams, options: &FormatOptions) -> String {
       |        ^^^^^^
       help: consider borrowing here
       |
112 |                             &sqlformat::FormatOptions::default()
       |                             +

For more information about this error, try `rustc --explain E0308`.
error: could not compile `sqlx-core` (lib) due to 1 previous error

Minimal Reproduction

Run cargo install sea-orm-cli

Info

  • SQLx version: v0.7.4
  • SQLx features enabled: N/A
  • Database server and version: N/A
  • Operating system: Debian 12
  • rustc --version: rustc 1.81.0 (eeb90cda1 2024-09-04)
@tbar4 tbar4 added the bug label Oct 4, 2024
@abonander
Copy link
Collaborator

Looks like sqlformat accidentally introduced a breaking change:

Signature for format() in 0.2.6: https://docs.rs/sqlformat/0.2.6/sqlformat/fn.format.html
0.2.7: https://docs.rs/sqlformat/latest/sqlformat/fn.format.html

@danbiocchi
Copy link

danbiocchi commented Oct 4, 2024

Same here, came here to post this.
| 18 | pub fn format(query: &str, params: &QueryParams, options: &FormatOptions) -> String { | ^^^^^^ help: consider borrowing here | 118 | &sqlformat::FormatOptions::default() | +

@tbar4
Copy link
Contributor Author

tbar4 commented Oct 4, 2024

Thanks for the fast response, seems like others are having issues installing sea-orm-cli because of this issue SeaQL/sea-orm#2380

Prior to your response I forked the sqlx repo and made the change in the logger.rs file in sqlx-core and it gave me the opposite error, telling me to drop the reference to the &sqlformat::FormatOptions::default()

@danbiocchi
Copy link

Thanks for the fast response, seems like others are having issues installing sea-orm-cli because of this issue SeaQL/sea-orm#2380

Prior to your response I forked the sqlx repo and made the change in the logger.rs file in sqlx-core and it gave me the opposite error, telling me to drop the reference to the &sqlformat::FormatOptions::default()

Same here. I made the change myself it worked once and then told me to change back. Frustrating.

@oniony
Copy link

oniony commented Oct 4, 2024

Does anyone know if there an easy way for my project to override sqlx-core to use 0.2.6 specifically?

(I'm a Rust newbie and couldn't find a simple way to do this.)

@jdevries-hartvoorweb
Copy link

Came here to post this too. It also happens when using

  • cargo install sqlx-cli
  • cargo run when using sqlx

sqlx version 0.8.2
OS Kubuntu 24.04
rustc 1.81.0

@tbar4
Copy link
Contributor Author

tbar4 commented Oct 4, 2024

@oniony are you experiencing this issue with sea-orm-cli or the sqlx-cli? I am trying out fixes for sea-orm-cli, now

@abonander
Copy link
Collaborator

You should be able to do cargo install --locked sea-orm-cli or cargo install --locked sqlx-cli

@abonander
Copy link
Collaborator

I'd accept a PR to remove sqlformat at this point. We really shouldn't be formatting queries before logging them.

@oniony
Copy link

oniony commented Oct 4, 2024

I'm not using sea-orm-cli nor sqlx-cli. I was in the process of switching my project to use sqlx but the Cargo sync failed with this error.

I.e. I have a project with a dependency on sqlx 0.8.2 with runtime-tokio feature.

@danbiocchi
Copy link

danbiocchi commented Oct 4, 2024

Does anyone know if there an easy way for my project to override sqlx-core to use 0.2.6 specifically?

(I'm a Rust newbie and couldn't find a simple way to do this.)

[dependencies]
sqlformat = "=0.2.6"

Workaround I'm doing for now.

@kazizi-tenzr
Copy link

Downgrade worked

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:dependency A bug in a dependency, open until fixed by upgrade bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants