Skip to content

<uuid::fmt::Hyphenated as sqlx::Type<MySql>::compatible() is wrong? #3409

Open
@AlphaKeks

Description

@AlphaKeks

Bug Description

I'm running MariaDB and have a table with a UUID column. When trying to fetch a row from this table and decoding the column into uuid::Uuid, it complains saying it expected 16 bytes, but got 36. This sort of makes sense, as I inserted the row using a string literal of a hyphenated UUID. When I try to use uuid::fmt::Hyphenated instead, it says the types aren't compatible. When using the query!() macro, it infers the type to be Vec<u8>, and decoding that as UTF-8 yields the expected string value I originally inserted. Maybe I'm just using these types incorrectly?

From what I can see in sqlx-mysql, uuid::Uuid expects 16 bytes, and uuid::fmt::Hyphenated just forwards to str? But str says it isn't compatible with anything that has a BINARY flag set, which the returned column does in my case...

Minimal Reproduction

https://github.com/AlphaKeks/sqlx-uuid-repro

What I would expect to happen is that either of the two queries succeed, but they both fail with the errors mentioned above.

Info

  • SQLx version: 0.8.0
  • SQLx features enabled: ["macros", "mysql", "runtime-tokio-rustls", "uuid"]
  • Database server and version: MariaDB 11.0
  • Operating system: Linux
  • rustc --version: rustc 1.80.0 (051478957 2024-07-21)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions