Skip to content

MySql type VARCHAR with *_bin collation incorrectly interpreted as VARBINARY Column #3387

Open
@DrewMcArthur

Description

@DrewMcArthur

Is your feature request related to a problem? Please describe.
I have a column in my MySql DB: Column: FileName, Collation: utf8mb4_0900_bin, Definition: varchar(255), which when I try to convert to a struct:

#[derive(sqlx::FromRow)]
#[sqlx(rename_all = "PascalCase")]
struct Row {
  file_name: String
}

throws an error:

error occurred while decoding column "FileName": mismatched types; Rust type
  | `alloc::string::String` (as SQL type `VARCHAR`) is not compatible with SQL
  | type `VARBINARY`

Describe the solution you'd like
This conversion should work, since the actual type is a VARCHAR, not VARBINARY

Describe alternatives you've considered
I could store these variables as Vec<u8>, or manually impl FromRow, but that's obviously not ideal.

Additional context
I assume the collation is what's causing sqlx to interpret the type as VARBINARY?

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