From 240fc45973d71aa7e8efccfe1f720d4b6a694238 Mon Sep 17 00:00:00 2001 From: DarkWanderer Date: Tue, 25 Jul 2023 21:59:57 +0200 Subject: [PATCH] Explicitly hande DateOnly in HttpParameterFormatter #341 --- ClickHouse.Client/Formats/HttpParameterFormatter.cs | 12 ++++++------ ClickHouse.Client/Types/Date32Type.cs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ClickHouse.Client/Formats/HttpParameterFormatter.cs b/ClickHouse.Client/Formats/HttpParameterFormatter.cs index 5c19458a..8b3d6fc1 100644 --- a/ClickHouse.Client/Formats/HttpParameterFormatter.cs +++ b/ClickHouse.Client/Formats/HttpParameterFormatter.cs @@ -38,14 +38,14 @@ internal static string Format(ClickHouseType type, object value, bool quote) case DecimalType dt: return Convert.ToDecimal(value, CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture); - case DateType dt when value is DateTimeOffset @do: - return @do.Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture); + case DateType dt when value is DateTimeOffset @dto: + return @dto.Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture); +#if NET6_0_OR_GREATER + case DateType dt when value is DateOnly @do: + return @do.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture); +#endif case DateType dt: return Convert.ToDateTime(value, CultureInfo.InvariantCulture).ToString("yyyy-MM-dd", CultureInfo.InvariantCulture); - case Date32Type dt when value is DateTimeOffset @do: - return @do.Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture); - case Date32Type dt: - return Convert.ToDateTime(value, CultureInfo.InvariantCulture).ToString("yyyy-MM-dd", CultureInfo.InvariantCulture); case StringType st: case FixedStringType tt: diff --git a/ClickHouse.Client/Types/Date32Type.cs b/ClickHouse.Client/Types/Date32Type.cs index b7906e39..2d4f0df3 100644 --- a/ClickHouse.Client/Types/Date32Type.cs +++ b/ClickHouse.Client/Types/Date32Type.cs @@ -4,7 +4,7 @@ namespace ClickHouse.Client.Types; -internal class Date32Type : AbstractDateTimeType +internal class Date32Type : DateType { public override string Name { get; }