From b6844d7c3b55e41c6478808600ce937b0ce650f2 Mon Sep 17 00:00:00 2001 From: DarkWanderer Date: Mon, 18 Mar 2024 11:15:21 +0100 Subject: [PATCH] Remove Json type as unsupported --- ClickHouse.Client.Tests/BulkCopyTests.cs | 2 +- ClickHouse.Client.Tests/TestUtilities.cs | 5 ---- ClickHouse.Client/ADO/Feature.cs | 8 ------ .../Formats/HttpParameterFormatter.cs | 1 - ClickHouse.Client/Types/JsonType.cs | 28 ------------------- ClickHouse.Client/Types/TypeConverter.cs | 1 - 6 files changed, 1 insertion(+), 44 deletions(-) delete mode 100644 ClickHouse.Client/Types/JsonType.cs diff --git a/ClickHouse.Client.Tests/BulkCopyTests.cs b/ClickHouse.Client.Tests/BulkCopyTests.cs index 39df59c6..250cb1d9 100644 --- a/ClickHouse.Client.Tests/BulkCopyTests.cs +++ b/ClickHouse.Client.Tests/BulkCopyTests.cs @@ -85,6 +85,7 @@ public async Task ShouldExecuteMultipleBulkInsertions() BatchSize = 100 }; + await bulkCopy.InitAsync(); await bulkCopy.WriteToServerAsync(Enumerable.Repeat(new[] { (object)0 }, 1)); i++; } @@ -187,7 +188,6 @@ public async Task ShouldExecuteBulkInsertWithComplexColumnName(string columnName } [Test] - [RequiredFeature(Feature.InlineQuery)] public async Task ShouldInsertIntoTableWithLotsOfColumns() { var tableName = "test.bulk_long_columns"; diff --git a/ClickHouse.Client.Tests/TestUtilities.cs b/ClickHouse.Client.Tests/TestUtilities.cs index 29bfcac4..c37b4348 100644 --- a/ClickHouse.Client.Tests/TestUtilities.cs +++ b/ClickHouse.Client.Tests/TestUtilities.cs @@ -214,11 +214,6 @@ public static IEnumerable GetDataTypeSamples() Tuple.Create(.3, .4) }); - if (SupportedFeatures.HasFlag(Feature.Json)) - { - //yield return new DataTypeSample("Json", typeof(string), "'{\"a\": \"b\", \"c\": 3}'", "{\"a\": \"b\", \"c\": 3}"); - } - if (SupportedFeatures.HasFlag(Feature.Variant)) { yield return new DataTypeSample("Variant(UInt64, String, Array(UInt64))", typeof(string), "'Hello, World!'::Variant(UInt64, String, Array(UInt64))", "Hello, World!"); diff --git a/ClickHouse.Client/ADO/Feature.cs b/ClickHouse.Client/ADO/Feature.cs index c4a8a912..93a7714a 100644 --- a/ClickHouse.Client/ADO/Feature.cs +++ b/ClickHouse.Client/ADO/Feature.cs @@ -8,10 +8,6 @@ public enum Feature { None = 0, // Special value - [Obsolete] - [SinceVersion("20.5")] - InlineQuery = 2, - [Obsolete] [SinceVersion("20.1")] DateTime64 = 4, @@ -46,10 +42,6 @@ public enum Feature [SinceVersion("22.6")] Stats = 2048, - [Obsolete] - [SinceVersion("22.6")] - Json = 4096, - [SinceVersion("22.8")] AsyncInsert = 8192, diff --git a/ClickHouse.Client/Formats/HttpParameterFormatter.cs b/ClickHouse.Client/Formats/HttpParameterFormatter.cs index 3290f137..327bca4d 100644 --- a/ClickHouse.Client/Formats/HttpParameterFormatter.cs +++ b/ClickHouse.Client/Formats/HttpParameterFormatter.cs @@ -54,7 +54,6 @@ internal static string Format(ClickHouseType type, object value, bool quote) case IPv4Type ip4: case IPv6Type ip6: case UuidType uuidType: - case JsonType jsonType: return quote ? value.ToString().Escape().QuoteSingle() : value.ToString().Escape(); case LowCardinalityType lt: diff --git a/ClickHouse.Client/Types/JsonType.cs b/ClickHouse.Client/Types/JsonType.cs deleted file mode 100644 index 28634989..00000000 --- a/ClickHouse.Client/Types/JsonType.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Text.Json; -using ClickHouse.Client.Formats; - -namespace ClickHouse.Client.Types; - -internal class JsonType : ClickHouseType -{ - public override Type FrameworkType => typeof(string); - - public override object Read(ExtendedBinaryReader reader) => reader.ReadString(); - - public override string ToString() => "Json"; - - public override void Write(ExtendedBinaryWriter writer, object value) - { - if (value is null) throw new ArgumentNullException(nameof(value)); - switch (value) - { - case string s: - writer.Write(s); break; - case JsonElement e: - writer.Write(e.ToString()); break; - default: - throw new NotImplementedException($"Cannot convert {value.GetType()} to Json"); - } - } -} diff --git a/ClickHouse.Client/Types/TypeConverter.cs b/ClickHouse.Client/Types/TypeConverter.cs index 95d2ce61..e6a7ac9f 100644 --- a/ClickHouse.Client/Types/TypeConverter.cs +++ b/ClickHouse.Client/Types/TypeConverter.cs @@ -167,7 +167,6 @@ static TypeConverter() RegisterPlainType(); // JSON/Object - RegisterPlainType(); RegisterParameterizedType(); // Mapping fixups