From e40747a43fc4283ce013d05209a112e16f88115b Mon Sep 17 00:00:00 2001 From: baishen Date: Tue, 30 Dec 2025 17:39:57 +0800 Subject: [PATCH 1/2] fix display nested geo values --- cli/tests/00-base.result | 1 + cli/tests/00-base.sql | 3 +++ sql/src/value/string_decoder.rs | 30 ++++++++++++++++-------------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/cli/tests/00-base.result b/cli/tests/00-base.result index 6c2f66051..19bbbbd02 100644 --- a/cli/tests/00-base.result +++ b/cli/tests/00-base.result @@ -37,4 +37,5 @@ NULL "{""k1"":""v1"",""k2"":""v2""}" (2,NULL) 1 NULL 1 ab NULL v1 2 NULL "{""k1"":""v1"",""k2"":""v2""}" [6162,78797A] "([1,2],""2024-04-10"")" +"[{""type"": ""Point"", ""coordinates"": [-122.35,37.55]}]" "[{""type"": ""LineString"", ""coordinates"": [[0.75,0.75],[-10,20]]}]" bye diff --git a/cli/tests/00-base.sql b/cli/tests/00-base.sql index cc7594c2b..f618dfa4a 100644 --- a/cli/tests/00-base.sql +++ b/cli/tests/00-base.sql @@ -64,6 +64,9 @@ select a[1], b['k1'], c:x, c:y from test_nested; select {'k1':'v1','k2':'v2'}, [to_binary('ab'), to_binary('xyz')], (parse_json('[1,2]'), to_date('2024-04-10')); +set geometry_output_format='GEOJSON'; +select [to_geometry('POINT(-122.35 37.55)')], [st_geographyfromewkt('LINESTRING(0.75 0.75, -10 20)')]; + select 'bye'; drop table test; drop table test_decimal; diff --git a/sql/src/value/string_decoder.rs b/sql/src/value/string_decoder.rs index 9d3c01512..bfd310daf 100644 --- a/sql/src/value/string_decoder.rs +++ b/sql/src/value/string_decoder.rs @@ -354,26 +354,28 @@ impl ValueDecoder { fn read_geometry>(&self, reader: &mut Cursor) -> Result { let mut buf = Vec::new(); - if reader.read_quoted_text(&mut buf, b'"').is_err() { - if let Ok(val) = self.read_json(reader) { - return Ok(Value::Variant(val)); - } - reader.read_quoted_text(&mut buf, b'\'')?; + if reader.read_quoted_text(&mut buf, b'"').is_ok() + || reader.read_quoted_text(&mut buf, b'\'').is_ok() + { + Ok(Value::Geometry(unsafe { String::from_utf8_unchecked(buf) })) + } else { + let val = self.read_json(reader)?; + Ok(Value::Geometry(val)) } - Ok(Value::Geometry(unsafe { String::from_utf8_unchecked(buf) })) } fn read_geography>(&self, reader: &mut Cursor) -> Result { let mut buf = Vec::new(); - if reader.read_quoted_text(&mut buf, b'"').is_err() { - if let Ok(val) = self.read_json(reader) { - return Ok(Value::Variant(val)); - } - reader.read_quoted_text(&mut buf, b'\'')?; + if reader.read_quoted_text(&mut buf, b'"').is_ok() + || reader.read_quoted_text(&mut buf, b'\'').is_ok() + { + Ok(Value::Geography(unsafe { + String::from_utf8_unchecked(buf) + })) + } else { + let val = self.read_json(reader)?; + Ok(Value::Geography(val)) } - Ok(Value::Geography(unsafe { - String::from_utf8_unchecked(buf) - })) } fn read_nullable>( From 74f91072d23b835f821d73568a214eaddfafde1f Mon Sep 17 00:00:00 2001 From: baishen Date: Tue, 30 Dec 2025 17:51:17 +0800 Subject: [PATCH 2/2] fix --- cli/tests/00-base.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/tests/00-base.result b/cli/tests/00-base.result index 19bbbbd02..219cfe541 100644 --- a/cli/tests/00-base.result +++ b/cli/tests/00-base.result @@ -37,5 +37,5 @@ NULL "{""k1"":""v1"",""k2"":""v2""}" (2,NULL) 1 NULL 1 ab NULL v1 2 NULL "{""k1"":""v1"",""k2"":""v2""}" [6162,78797A] "([1,2],""2024-04-10"")" -"[{""type"": ""Point"", ""coordinates"": [-122.35,37.55]}]" "[{""type"": ""LineString"", ""coordinates"": [[0.75,0.75],[-10,20]]}]" +"[{""type"": ""Point"", ""coordinates"": [-122.35,37.55]}]" "[{""type"": ""LineString"", ""coordinates"": [[0.75,0.75],[-10,20]]}]" bye