Skip to content

Commit

Permalink
Use flags to detect MySQL enums
Browse files Browse the repository at this point in the history
In some cases the returned value is of `ColumnType::String`, but it has
the `ENUM` flag set.
  • Loading branch information
Julius de Bruijn authored and mehcode committed Oct 13, 2020
1 parent 277d041 commit 7a70717
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sqlx-core/src/mysql/protocol/text/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ impl ColumnType {
) -> &'static str {
let is_binary = char_set == 63;
let is_unsigned = flags.contains(ColumnFlags::UNSIGNED);
let is_enum = flags.contains(ColumnFlags::ENUM);

match self {
ColumnType::Tiny if max_size == Some(1) => "BOOLEAN",
Expand Down Expand Up @@ -196,6 +197,7 @@ impl ColumnType {
ColumnType::Json => "JSON",

ColumnType::String if is_binary => "BINARY",
ColumnType::String if is_enum => "ENUM",
ColumnType::VarChar | ColumnType::VarString if is_binary => "VARBINARY",

ColumnType::String => "CHAR",
Expand Down

0 comments on commit 7a70717

Please sign in to comment.