Skip to content

Commit

Permalink
Explicitly hande DateOnly in HttpParameterFormatter #341 (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkWanderer authored Jul 25, 2023
1 parent fb5bb78 commit a1b0daa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions ClickHouse.Client/Formats/HttpParameterFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion ClickHouse.Client/Types/Date32Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace ClickHouse.Client.Types;

internal class Date32Type : AbstractDateTimeType
internal class Date32Type : DateType
{
public override string Name { get; }

Expand Down

0 comments on commit a1b0daa

Please sign in to comment.