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

PgHasArrayType is not implemented for Vec<i64> #2611

Closed
mrl5 opened this issue Jul 12, 2023 · 0 comments · Fixed by #2619
Closed

PgHasArrayType is not implemented for Vec<i64> #2611

mrl5 opened this issue Jul 12, 2023 · 0 comments · Fixed by #2619
Labels

Comments

@mrl5
Copy link
Contributor

mrl5 commented Jul 12, 2023

Bug Description

after upgrading to 0.7.0 I'm getting this error when using https://docs.rs/sqlx/latest/sqlx/trait.Type.html#transparent

error[E0277]: the trait bound `Vec<i64>: PgHasArrayType` is not satisfied
 --> src/lib.rs:1:10
  |
1 | #[derive(sqlx::Type)]
  |          ^^^^^^^^^^ the trait `PgHasArrayType` is not implemented for `Vec<i64>`
  |
  = help: the trait `PgHasArrayType` is implemented for `Vec<u8>`
  = help: see issue #48214
  = note: this error originates in the derive macro `sqlx::Type` (in Nightly builds, run with -Z macro-backtrace for more info)

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

Minimal Reproduction

cargo init --lib sqlx-test

src/lib.rs:

#[derive(sqlx::Type)]
#[sqlx(transparent)]
pub struct ScriptHashes(pub Vec<i64>);

Cargo.toml:

[package]
name = "sqlx-test2"
version = "0.1.0"
edition = "2021"

[dependencies]
sqlx = { version = "0.7.0", features = [
    "macros",
    "postgres",
] }

then

cargo build

Info

  • SQLx version: 0.7.0
  • SQLx features enabled: macros and postgres
  • Database server and version: Postgres 14 or 15
  • Operating system: linux
  • rustc --version: rustc 1.70.0 (90c541806 2023-05-31)

additional info

@mrl5 mrl5 added the bug label Jul 12, 2023
mrl5 added a commit to mrl5/sqlx that referenced this issue Jul 14, 2023
caused by launchbadge#2086
closes launchbadge#2611

seems like launchbadge#2086 fixed issue described by @Wopple by making that block
of code unreachable. Not as it was stated in
> Problem: PgHasArrayType was checking the application's postgres feature
> Solution: only check the library's postgres feature

after checking https://doc.rust-lang.org/std/macro.cfg.html
> `cfg!`, unlike `#[cfg]`, does not remove any code and only evaluates
> to true or false. For example, all blocks in an if/else expression
> need to be valid when `cfg!` is used for the condition, regardless of
> what `cfg!` is evaluating.

so to my understanding it would be `true` anyway in @woople scenario
abonander added a commit that referenced this issue Jul 14, 2023
rubenfiszel added a commit to windmill-labs/windmill that referenced this issue Jul 15, 2023
* DRAFT chore(backend): upgrade sqlx to ^0.7

related to:
* #1858
* launchbadge/sqlx#1163 (comment)

* (vol. 2) in 0.7, `Transaction` can no longer implement `Executor` directly

ref: https://github.com/launchbadge/sqlx/blob/afb6b1066e61f8e3875f530d96cfb5a299f13fda/examples/postgres/transaction/src/main.rs#L14-L17

notice that I'm temporarly using my custom patch
mrl5/sqlx@16e4c9a
it's related to launchbadge/sqlx#2611

* post git rebase chores

* use upstream fix from 0.7.1

* fix compile

---------

Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
Co-authored-by: Ruben Fiszel <ruben@rubenfiszel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant