From 6793fa5a6d154db74e9d6767ceafa4af11c50bac Mon Sep 17 00:00:00 2001 From: twowind Date: Sun, 10 Mar 2024 12:50:48 +0800 Subject: [PATCH] Fix map[string]number parse --- clickhouse_test.go | 9 +++++---- conn_go18_test.go | 2 +- conn_test.go | 1 + dataparser.go | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/clickhouse_test.go b/clickhouse_test.go index bfd1be3..fa64ca7 100644 --- a/clickhouse_test.go +++ b/clickhouse_test.go @@ -37,12 +37,13 @@ var ddls = []string{ ipv6 IPv6, fs FixedString(8), lc LowCardinality(String), - m Map(String, Array(Int64)) + m Map(String, Array(Int64)), + mi64 Map(String, Int64) ) ENGINE = Memory`, `INSERT INTO data VALUES - (-1, 1, 1.0, true, '1', '1', [1], [10], '2011-03-06', '2011-03-06 06:20:00', 'one', '10.1111', '100.1111', '1000.1111', '1.1111', '127.0.0.1', '2001:db8:3333:4444:5555:6666:7777:8888', '12345678', 'one', {'key1':[1]}), - (-2, 2, 2.0, false, '2', '2', [2], [20], '2012-05-31', '2012-05-31 11:20:00', 'two', '30.1111', '300.1111', '2000.1111', '2.1111', '8.8.8.8', '2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF', '88888888', 'two', {'key2':[2]}), - (-3, 3, 3.0, true, '3', '2', [3], [30], '2016-04-04', '2016-04-04 11:30:00', 'three', '40.1111', '400.1111', '3000.1111', '3.1111', '255.255.255.255', '::1234:5678', '87654321', 'three', {'key3':[3]}) + (-1, 1, 1.0, true, '1', '1', [1], [10], '2011-03-06', '2011-03-06 06:20:00', 'one', '10.1111', '100.1111', '1000.1111', '1.1111', '127.0.0.1', '2001:db8:3333:4444:5555:6666:7777:8888', '12345678', 'one', {'key1':[1]}, {'key1':1}), + (-2, 2, 2.0, false, '2', '2', [2], [20], '2012-05-31', '2012-05-31 11:20:00', 'two', '30.1111', '300.1111', '2000.1111', '2.1111', '8.8.8.8', '2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF', '88888888', 'two', {'key2':[2]}, {'key2':2}), + (-3, 3, 3.0, true, '3', '2', [3], [30], '2016-04-04', '2016-04-04 11:30:00', 'three', '40.1111', '400.1111', '3000.1111', '3.1111', '255.255.255.255', '::1234:5678', '87654321', 'three', {'key3':[3]}, {'key3':3}) `, } diff --git a/conn_go18_test.go b/conn_go18_test.go index 45955a9..403e0e1 100644 --- a/conn_go18_test.go +++ b/conn_go18_test.go @@ -60,7 +60,7 @@ func (s *connSuite) TestColumnTypes() { "Int64", "UInt64", "Float64", "Bool", "String", "String", "Array(Int16)", "Array(UInt8)", "Date", "DateTime", "Enum8('one' = 1, 'two' = 2, 'three' = 3)", "Decimal(9, 4)", "Decimal(18, 4)", "Decimal(38, 4)", "Decimal(10, 4)", "IPv4", "IPv6", "FixedString(8)", "LowCardinality(String)", - "Map(String, Array(Int64))", + "Map(String, Array(Int64))", "Map(String, Int64)", } s.Require().Equal(len(expected), len(types)) for i, e := range expected { diff --git a/conn_test.go b/conn_test.go index 223c277..0bdf1ee 100644 --- a/conn_test.go +++ b/conn_test.go @@ -49,6 +49,7 @@ func (s *connSuite) TestQuery() { "10.1111", "100.1111", "1000.1111", "1.1111", "127.0.0.1", "2001:db8:3333:4444:5555:6666:7777:8888", "12345678", "one", map[string][]int64{"key1": {1}}, + map[string]int64{"key1": 1}, }, }, }, diff --git a/dataparser.go b/dataparser.go index 49e4439..0c59ac8 100644 --- a/dataparser.go +++ b/dataparser.go @@ -38,7 +38,7 @@ loop: switch r { case eof: break loop - case ',', ']', ')': + case ',', ']', ')', '}': _ = s.UnreadRune() break loop }