From 2eede4b09ad189c985fb900410c2602c99678b0d Mon Sep 17 00:00:00 2001 From: Jinyang Li <410670140@qq.com> Date: Thu, 5 Feb 2026 03:05:12 -0500 Subject: [PATCH] fix(mysql): use lenient flag comparison for ENUM types TiDB (and potentially other MySQL-compatible databases) may return ENUM columns with additional flags like NOT_NULL or NO_DEFAULT_VALUE. The previous exact flag comparison caused type mismatches even though both sides were valid ENUM types. This change makes ENUM comparison check only that both types have the ENUM flag set, ignoring other flags that don't affect type compatibility. Fixes #3750 Refs #1241 --- sqlx-mysql/src/type_info.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sqlx-mysql/src/type_info.rs b/sqlx-mysql/src/type_info.rs index d37997b665..418d6cdd10 100644 --- a/sqlx-mysql/src/type_info.rs +++ b/sqlx-mysql/src/type_info.rs @@ -110,6 +110,11 @@ impl PartialEq for MySqlTypeInfo { | ColumnType::String | ColumnType::VarString | ColumnType::Enum => { + // For ENUM types, only require both have ENUM flag set (TiDB compatibility) + // TiDB may return additional flags like NOT_NULL that don't affect type compatibility + if self.flags.contains(ColumnFlags::ENUM) && other.flags.contains(ColumnFlags::ENUM) { + return true; + } return self.flags == other.flags; } _ => {}