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 prepare fails against remote DB, works against local DB #2698

Open
alextes opened this issue Aug 18, 2023 · 2 comments
Open

sqlx prepare fails against remote DB, works against local DB #2698

alextes opened this issue Aug 18, 2023 · 2 comments
Labels

Comments

@alextes
Copy link

alextes commented Aug 18, 2023

Bug Description

I'm quite lost as to what is going wrong, or how to even debug it.

I have a project using sqlx 0.7.1, sqlx-cli is at 0.7.1, I'm using offline mode. When running against a local 14.9 postgres, all is fine, when running against any of our remote (test, stag, prod) 14.8 postgres DBs, I get errors for dozens (I'm guessing all) queries in our codebase:

error: error occurred while decoding column 0: expected value at line 28 column 5
  --> src/beacon_chain/balances/backfill.rs:19:23
   |
19 |       let slots_count = sqlx::query!(
   |  _______________________^
20 | |         "
21 | |         SELECT
22 | |             COUNT(beacon_states.slot) as \"count!\"
...  |
32 | |         from.0,
33 | |     )
   | |_____^
   |
   = note: this error originates in the macro `$crate::sqlx_macros::expand_query` which comes from the expansion of the macro `sqlx::query` (in Nightly builds, run with -Z macro-backtrace for more info)

error: error occurred while decoding column 0: expected value at line 27 column 5
  --> src/beacon_chain/balances/backfill.rs:57:16
   |
57 |       let rows = sqlx::query!(
   |  ________________^
58 | |         "
59 | |         SELECT
60 | |             beacon_states.state_root,
...  |
72 | |         from.0,
73 | |     )
   | |_____^
   |
   = note: this error originates in the macro `$crate::sqlx_macros::expand_query` which comes from the expansion of the macro `sqlx::query` (in Nightly builds, run with -Z macro-backtrace for more info)

I've tried to run a nightly build with the -Z macro-backtrace flag but whichever way I pass it yields only further errors, no backtrace.

Any ideas for what I can try to debug this? At the moment it's really hard to see what is going on, and why this runs fine against my local DB but fails against the remotes.

Minimal Reproduction

Have not tried. Can set up a repro with both postgres versions, queries, sqlx prepare, but before I do I thought I'd ask if there was a way to debug this myself.

Info

  • SQLx version: 0.7.1
  • SQLx features enabled: [ "chrono", "json", "postgres", "runtime-tokio-native-tls" ]
  • Database server and version: Postgresql 14.8 + Postgresql 14.9
  • Operating system: linux + macos
  • rustc --version: 1.71
@alextes alextes added the bug label Aug 18, 2023
@ryanmcgrath
Copy link

This might be the bug that was solved in #2670 - which is unfortunately not released yet.

I would love for this to get a point release as I've been bitten by this several times this week alone.

@garma83
Copy link

garma83 commented Sep 19, 2023

I also am running into this; for what its worth also with a COUNT(*) query

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

No branches or pull requests

3 participants