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

MariaDB "RETURNING" clause used with query_as returns MySqlRow instead of struct #2457

Closed
jgirardet opened this issue Apr 15, 2023 · 3 comments
Labels

Comments

@jgirardet
Copy link

Bug Description

MariaDB "RETURNING" with query_as return MySqlRow instead of struct. The same code works perfectly in sqlite and postgres.

Minimal Reproduction

    let maison = sqlx::query_as!(Maison, r#"INSERT INTO maison (id
        ,adresse
        ,taille
        ,piscine) VALUES (?, ?, ?, ?) RETURNING id as "id!:_",adresse as "adresse!:_",taille as "taille!:_",piscine"#, 5, "lieu5",23, true)
        .fetch_one(&p.pool).await.unwrap();
    assert_eq!(maison, Maison{id:5, adresse:"lieu5".to_string(), taille: 23, piscine:Some(true)});

error:

error[E0369]: binary operation `==` cannot be applied to type `sqlx::mysql::MySqlRow`
  --> tests/commons/tests/insert.rs:41:5
   |
41 |     assert_eq!(maison, Maison{id:5, adresse:"lieu5".to_string(), taille: 23, piscine:Some(true)});
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |     |
   |     sqlx::mysql::MySqlRow
   |     commons::entities::my::Maison
   |
   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

Info

  • SQLx version: 0.6.3
  • SQLx features enabled: "runtime-async-std-native-tls", "uuid", "chrono", "bigdecimal",
  • Database server and version: MariaDB 10..1
  • Operating system: arch linux (garuda)
  • rustc --version: 1.68.2
@jgirardet jgirardet added the bug label Apr 15, 2023
@GCastilho
Copy link

The macro query! also don't understand the RETURNING clause, showing nothing on the record even when fetch_one is used

I'm using the same version and DB

@tgross35
Copy link

tgross35 commented Feb 7, 2024

I think this is related to #1530, which has an upstream issue open

@abonander
Copy link
Collaborator

Closing as duplicate

@abonander abonander closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2024
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

4 participants