From 958bcc86fef51bb9e35c8508954e099666b817a0 Mon Sep 17 00:00:00 2001 From: tdakkota Date: Tue, 22 Oct 2024 12:41:12 +0300 Subject: [PATCH] fix(proto): properly handle `Enum8` and `Enum8(...)` in conflicts checker --- proto/column.go | 6 ++++++ proto/column_test.go | 2 ++ 2 files changed, 8 insertions(+) diff --git a/proto/column.go b/proto/column.go index d9a46f3..40ab7cb 100644 --- a/proto/column.go +++ b/proto/column.go @@ -127,9 +127,15 @@ func (c ColumnType) Conflicts(b ColumnType) bool { if cBase == ColumnTypeDecimal || bBase == ColumnTypeDecimal { return c.decimalDowncast() != b.decimalDowncast() } + if cBase != bBase { return true } + switch cBase { + case ColumnTypeEnum8, ColumnTypeEnum16: + return false + } + if c.normalizeCommas() == b.normalizeCommas() { return false } diff --git a/proto/column_test.go b/proto/column_test.go index cd14035..227b0ea 100644 --- a/proto/column_test.go +++ b/proto/column_test.go @@ -60,6 +60,8 @@ func TestColumnType_Elem(t *testing.T) { {A: "Map(String,String)", B: "Map(String, String)"}, {A: "Enum8('increment' = 1, 'gauge' = 2)", B: "Int8"}, {A: "Int8", B: "Enum8('increment' = 1, 'gauge' = 2)"}, + {A: "Enum8('increment' = 1, 'gauge' = 2)", B: "Enum8"}, + {A: "Enum8", B: "Enum8('increment' = 1, 'gauge' = 2)"}, {A: "Decimal256", B: "Decimal(76, 38)"}, {A: "Nullable(Decimal256)", B: "Nullable(Decimal(76, 38))"}, } {