From 310eeaed1cafcecffc3cf088aea40d6338a01a07 Mon Sep 17 00:00:00 2001 From: haudoing Date: Mon, 1 Apr 2024 22:36:00 +0800 Subject: [PATCH] These two regex won't match with the complex column type now. #783 --- CHANGELOG.md | 3 +++ pkg/converters/converters.go | 4 ++-- pkg/plugin/driver_test.go | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69894aa4..7187d068 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +### Fixes +- Fixed converter regex for `Nullable(IP)` and `Nullable(String)`. It won't match to `Array(Nullable(IP))` or `Array(Nullable(String))` any more. (#783) + ## 4.0.4 ### Fixes diff --git a/pkg/converters/converters.go b/pkg/converters/converters.go index a87d1b38..27f6d491 100644 --- a/pkg/converters/converters.go +++ b/pkg/converters/converters.go @@ -33,8 +33,8 @@ var matchRegexes = map[string]*regexp.Regexp{ "Nested()": regexp.MustCompile(`^Nested\(.*\)`), "Nullable(Date)": regexp.MustCompile(`^Nullable\(Date\(?`), "Nullable(Decimal)": regexp.MustCompile(`^Nullable\(Decimal`), - "Nullable(IP)": regexp.MustCompile(`Nullable\(IP`), - "Nullable(String)": regexp.MustCompile(`Nullable\(String`), + "Nullable(IP)": regexp.MustCompile(`^Nullable\(IP`), + "Nullable(String)": regexp.MustCompile(`^Nullable\(String`), "Point": regexp.MustCompile(`^Point`), "SimpleAggregateFunction()": regexp.MustCompile(`^SimpleAggregateFunction\(.*\)`), "Tuple()": regexp.MustCompile(`^Tuple\(.*\)`), diff --git a/pkg/plugin/driver_test.go b/pkg/plugin/driver_test.go index d3659298..20c0651f 100644 --- a/pkg/plugin/driver_test.go +++ b/pkg/plugin/driver_test.go @@ -868,6 +868,20 @@ func TestArrayNullableUInt256(t *testing.T) { } } +func TestArrayNullableString(t *testing.T) { + for name, protocol := range Protocols { + t.Run(fmt.Sprintf("using %s", name), func(t *testing.T) { + var val []*string + conn, close := setupTest(t, "col1 Array(Nullable(String))", protocol, nil) + defer close(t) + v := "48" + val = append(val, &v, nil) + insertData(t, conn, val) + checkRows(t, conn, 1, val) + }) + } +} + func TestMap(t *testing.T) { for name, protocol := range Protocols { t.Run(fmt.Sprintf("using %s", name), func(t *testing.T) {