From 8ddf4245417034954417df88e1466098b8a0008f Mon Sep 17 00:00:00 2001 From: WhatzGames Date: Sun, 12 Nov 2023 00:48:18 +0100 Subject: [PATCH 01/12] Add translation for ToDate --- .../NpgsqlDbFunctionsExtensions.cs | 10 ++++++++++ .../Internal/NpgsqlStringMethodTranslator.cs | 2 ++ .../Query/NorthwindDbFunctionsQueryNpgsqlTest.cs | 14 ++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs b/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs index f1684865b..9223b5078 100644 --- a/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs +++ b/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs @@ -137,4 +137,14 @@ public static int Distance(this DbFunctions _, DateOnly a, DateOnly b) /// public static TimeSpan Distance(this DbFunctions _, DateTime a, DateTime b) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Distance))); + + /// + /// Returns the string as a Date + /// + /// The instance. + /// The string to be converted + /// The format of the input date + /// + public static DateOnly ToDate(this DbFunctions _, string value, string format) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(ToDate))); } diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs index c363bbcb5..0416443a4 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs @@ -45,6 +45,8 @@ public class NpgsqlStringMethodTranslator : IMethodCallTranslator private static readonly MethodInfo StringToArray = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod(nameof(NpgsqlDbFunctionsExtensions.StringToArray), new[] { typeof(DbFunctions), typeof(string), typeof(string) })!; private static readonly MethodInfo StringToArrayNullString = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod(nameof(NpgsqlDbFunctionsExtensions.StringToArray), new[] { typeof(DbFunctions), typeof(string), typeof(string), typeof(string) })!; + private static readonly MethodInfo ToDate = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod(nameof(NpgsqlDbFunctionsExtensions.ToDate), new[] { typeof(DbFunctions), typeof(string), typeof(string) })!; + private static readonly MethodInfo FirstOrDefaultMethodInfoWithoutArgs = typeof(Enumerable).GetRuntimeMethods().Single( m => m.Name == nameof(Enumerable.FirstOrDefault) diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs index e5c49de7a..d33f74461 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs @@ -207,6 +207,20 @@ WHERE string_to_array(c."ContactName", ' ', 'Maria') = ARRAY[NULL,'Anders']::tex """); } + [Fact] + public void ToDate_with_null_string() + { + using var context = CreateContext(); + var count = context.Orders.Count(c => EF.Functions.ToDate(c.OrderDate.ToString(), "YYYY-MM-DD") < new DateOnly(2000, 01, 01)); + Assert.Equal(830, count); + AssertSql( +""" +SELECT count(*)::int +FROM "Orders" AS o +WHERE to_date(o."OrderDate"::text, 'YYYY-MM-DD') < DATE '2000-01-01' +"""); + } + #endregion private void AssertSql(params string[] expected) From b3f76dd8861a738f134437c9b17418ce25c84330 Mon Sep 17 00:00:00 2001 From: WhatzGames Date: Sun, 12 Nov 2023 00:35:05 +0100 Subject: [PATCH 02/12] alignment --- .../Internal/NpgsqlStringMethodTranslator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs index 0416443a4..380adcf8a 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs @@ -45,7 +45,7 @@ public class NpgsqlStringMethodTranslator : IMethodCallTranslator private static readonly MethodInfo StringToArray = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod(nameof(NpgsqlDbFunctionsExtensions.StringToArray), new[] { typeof(DbFunctions), typeof(string), typeof(string) })!; private static readonly MethodInfo StringToArrayNullString = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod(nameof(NpgsqlDbFunctionsExtensions.StringToArray), new[] { typeof(DbFunctions), typeof(string), typeof(string), typeof(string) })!; - private static readonly MethodInfo ToDate = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod(nameof(NpgsqlDbFunctionsExtensions.ToDate), new[] { typeof(DbFunctions), typeof(string), typeof(string) })!; + private static readonly MethodInfo ToDate = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod(nameof(NpgsqlDbFunctionsExtensions.ToDate), new[] { typeof(DbFunctions), typeof(string), typeof(string) })!; private static readonly MethodInfo FirstOrDefaultMethodInfoWithoutArgs = typeof(Enumerable).GetRuntimeMethods().Single( From ccc065da5ae9b477cdc5aa5844b33c13ed69ace6 Mon Sep 17 00:00:00 2001 From: WhatzGames Date: Sun, 12 Nov 2023 01:27:04 +0100 Subject: [PATCH 03/12] test name correction for to_date --- .../Query/NorthwindDbFunctionsQueryNpgsqlTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs index d33f74461..95725fb77 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs @@ -208,7 +208,7 @@ WHERE string_to_array(c."ContactName", ' ', 'Maria') = ARRAY[NULL,'Anders']::tex } [Fact] - public void ToDate_with_null_string() + public void ToDate() { using var context = CreateContext(); var count = context.Orders.Count(c => EF.Functions.ToDate(c.OrderDate.ToString(), "YYYY-MM-DD") < new DateOnly(2000, 01, 01)); From df3751745bcb88e70d72f869fbb16299d6cab1db Mon Sep 17 00:00:00 2001 From: WhatzGames Date: Sun, 12 Nov 2023 01:57:15 +0100 Subject: [PATCH 04/12] Re-added translation that went missing for some reason annotated corrected nullability --- .../NpgsqlDbFunctionsExtensions.cs | 2 +- .../Internal/NpgsqlStringMethodTranslator.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs b/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs index 9223b5078..1924de928 100644 --- a/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs +++ b/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs @@ -145,6 +145,6 @@ public static TimeSpan Distance(this DbFunctions _, DateTime a, DateTime b) /// The string to be converted /// The format of the input date /// - public static DateOnly ToDate(this DbFunctions _, string value, string format) + public static DateOnly? ToDate(this DbFunctions _, string? value, string format) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(ToDate))); } diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs index 380adcf8a..0b81c562f 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs @@ -379,6 +379,18 @@ public NpgsqlStringMethodTranslator(NpgsqlTypeMappingSource typeMappingSource, I _typeMappingSource.FindMapping(typeof(string[]))); } + if (method == ToDate) + { + return _sqlExpressionFactory.Function( + "to_date", + new[] { arguments[1], arguments[2] }, + nullable: true, + argumentsPropagateNullability: new[] { true, false }, + typeof(DateOnly?), + _typeMappingSource.FindMapping(typeof(DateOnly?)) + ); + } + return null; } From 8078cb784f4ad9bf6758fede686428e78ac60f93 Mon Sep 17 00:00:00 2001 From: WhatzGames Date: Fri, 5 Jan 2024 20:20:09 +0100 Subject: [PATCH 05/12] Add translation for to_timestamp --- .../NpgsqlDbFunctionsExtensions.cs | 10 ++++++++++ .../Internal/NpgsqlStringMethodTranslator.cs | 14 ++++++++++++++ .../Query/NorthwindDbFunctionsQueryNpgsqlTest.cs | 14 ++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs b/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs index 1924de928..3cc4bae50 100644 --- a/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs +++ b/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs @@ -147,4 +147,14 @@ public static TimeSpan Distance(this DbFunctions _, DateTime a, DateTime b) /// public static DateOnly? ToDate(this DbFunctions _, string? value, string format) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(ToDate))); + + /// + /// Returns the string as a timestamp + /// + /// The instance. + /// The string to be converted + /// The format of the input date + /// + public static DateTime? ToTimestamp(this DbFunctions _, string? value, string format) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(ToTimestamp))); } diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs index 0b81c562f..55e8dd806 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs @@ -47,6 +47,8 @@ public class NpgsqlStringMethodTranslator : IMethodCallTranslator private static readonly MethodInfo ToDate = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod(nameof(NpgsqlDbFunctionsExtensions.ToDate), new[] { typeof(DbFunctions), typeof(string), typeof(string) })!; + private static readonly MethodInfo ToTimestamp = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod(nameof(NpgsqlDbFunctionsExtensions.ToTimestamp), new[] { typeof(DbFunctions), typeof(string), typeof(string) })!; + private static readonly MethodInfo FirstOrDefaultMethodInfoWithoutArgs = typeof(Enumerable).GetRuntimeMethods().Single( m => m.Name == nameof(Enumerable.FirstOrDefault) @@ -391,6 +393,18 @@ public NpgsqlStringMethodTranslator(NpgsqlTypeMappingSource typeMappingSource, I ); } + if (method == ToTimestamp) + { + return _sqlExpressionFactory.Function( + "to_timestamp", + new[] { arguments[1], arguments[2] }, + nullable: true, + argumentsPropagateNullability: new[] { true, false }, + typeof(DateTime?), + _typeMappingSource.FindMapping(typeof(DateTime?)) + ); + } + return null; } diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs index 95725fb77..abcf13ace 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs @@ -221,6 +221,20 @@ WHERE to_date(o."OrderDate"::text, 'YYYY-MM-DD') < DATE '2000-01-01' """); } + [Fact] + public void StringToTimestamp() + { + using var context = CreateContext(); + var count = context.Orders.Count(c => EF.Functions.ToTimestamp(c.OrderDate.ToString(), "YYYY-MM-DD") < new DateTime(2000, 01, 01, 0,0,0, DateTimeKind.Utc)); + Assert.Equal(830, count); + AssertSql( + """ +SELECT count(*)::int +FROM "Orders" AS o +WHERE to_timestamp(o."OrderDate"::text, 'YYYY-MM-DD') < TIMESTAMPTZ '2000-01-01 00:00:00Z' +"""); + } + #endregion private void AssertSql(params string[] expected) From c4b0951c4c67c0fad049d7f1b7f8c3e50e3ebe9d Mon Sep 17 00:00:00 2001 From: WhatzGames Date: Fri, 5 Jan 2024 20:45:13 +0100 Subject: [PATCH 06/12] rename test --- .../Query/NorthwindDbFunctionsQueryNpgsqlTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs index abcf13ace..9b56e4229 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs @@ -222,7 +222,7 @@ WHERE to_date(o."OrderDate"::text, 'YYYY-MM-DD') < DATE '2000-01-01' } [Fact] - public void StringToTimestamp() + public void ToTimestamp() { using var context = CreateContext(); var count = context.Orders.Count(c => EF.Functions.ToTimestamp(c.OrderDate.ToString(), "YYYY-MM-DD") < new DateTime(2000, 01, 01, 0,0,0, DateTimeKind.Utc)); From 135d26f383febb5c3ad857debe07c8b7c7fcdba7 Mon Sep 17 00:00:00 2001 From: WhatzGames Date: Mon, 18 Mar 2024 23:42:12 +0100 Subject: [PATCH 07/12] use collection expression --- .../Internal/NpgsqlStringMethodTranslator.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs index 62f6d1cf6..973affa83 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs @@ -78,9 +78,11 @@ public class NpgsqlStringMethodTranslator : IMethodCallTranslator private static readonly MethodInfo StringToArrayNullString = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod( nameof(NpgsqlDbFunctionsExtensions.StringToArray), [typeof(DbFunctions), typeof(string), typeof(string), typeof(string)])!; - private static readonly MethodInfo ToDate = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod(nameof(NpgsqlDbFunctionsExtensions.ToDate), new[] { typeof(DbFunctions), typeof(string), typeof(string) })!; + private static readonly MethodInfo ToDate = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod( + nameof(NpgsqlDbFunctionsExtensions.ToDate), [typeof(DbFunctions), typeof(string), typeof(string)])!; - private static readonly MethodInfo ToTimestamp = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod(nameof(NpgsqlDbFunctionsExtensions.ToTimestamp), new[] { typeof(DbFunctions), typeof(string), typeof(string) })!; + private static readonly MethodInfo ToTimestamp = typeof(NpgsqlDbFunctionsExtensions).GetRuntimeMethod( + nameof(NpgsqlDbFunctionsExtensions.ToTimestamp), [typeof(DbFunctions), typeof(string), typeof(string)])!; private static readonly MethodInfo FirstOrDefaultMethodInfoWithoutArgs = typeof(Enumerable).GetRuntimeMethods().Single( From 674cc05d8a32ba2e1c49a797cdd64eb1d280b523 Mon Sep 17 00:00:00 2001 From: WhatzGames Date: Tue, 19 Mar 2024 22:27:29 +0100 Subject: [PATCH 08/12] made format nullable --- .../DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs b/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs index f48e22e58..11d0a6199 100644 --- a/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs +++ b/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs @@ -149,7 +149,7 @@ public static TimeSpan Distance(this DbFunctions _, DateTime a, DateTime b) /// The string to be converted /// The format of the input date /// - public static DateOnly? ToDate(this DbFunctions _, string? value, string format) + public static DateOnly? ToDate(this DbFunctions _, string? value, string? format) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(ToDate))); /// @@ -159,6 +159,6 @@ public static TimeSpan Distance(this DbFunctions _, DateTime a, DateTime b) /// The string to be converted /// The format of the input date /// - public static DateTime? ToTimestamp(this DbFunctions _, string? value, string format) + public static DateTime? ToTimestamp(this DbFunctions _, string? value, string? format) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(ToTimestamp))); } From 61bce26a0a428b99c8d0e8b6a6335e25d575a59d Mon Sep 17 00:00:00 2001 From: WhatzGames Date: Tue, 19 Mar 2024 22:31:53 +0100 Subject: [PATCH 09/12] corrected nullability propagation flags --- .../Internal/NpgsqlStringMethodTranslator.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs index 973affa83..47d8479ec 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs @@ -437,7 +437,7 @@ public NpgsqlStringMethodTranslator(NpgsqlTypeMappingSource typeMappingSource, I "to_date", new[] { arguments[1], arguments[2] }, nullable: true, - argumentsPropagateNullability: new[] { true, false }, + argumentsPropagateNullability: new[] { true, true }, typeof(DateOnly?), _typeMappingSource.FindMapping(typeof(DateOnly?)) ); @@ -449,7 +449,7 @@ public NpgsqlStringMethodTranslator(NpgsqlTypeMappingSource typeMappingSource, I "to_timestamp", new[] { arguments[1], arguments[2] }, nullable: true, - argumentsPropagateNullability: new[] { true, false }, + argumentsPropagateNullability: new[] { true, true }, typeof(DateTime?), _typeMappingSource.FindMapping(typeof(DateTime?)) ); From 38d867f8333b96136f9767191c0ba1ad018513fc Mon Sep 17 00:00:00 2001 From: WhatzGames Date: Tue, 19 Mar 2024 22:32:40 +0100 Subject: [PATCH 10/12] removed nullable notation for mapping --- .../Internal/NpgsqlStringMethodTranslator.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs index 47d8479ec..4cf7a59de 100644 --- a/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs +++ b/src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs @@ -439,7 +439,7 @@ public NpgsqlStringMethodTranslator(NpgsqlTypeMappingSource typeMappingSource, I nullable: true, argumentsPropagateNullability: new[] { true, true }, typeof(DateOnly?), - _typeMappingSource.FindMapping(typeof(DateOnly?)) + _typeMappingSource.FindMapping(typeof(DateOnly)) ); } @@ -451,7 +451,7 @@ public NpgsqlStringMethodTranslator(NpgsqlTypeMappingSource typeMappingSource, I nullable: true, argumentsPropagateNullability: new[] { true, true }, typeof(DateTime?), - _typeMappingSource.FindMapping(typeof(DateTime?)) + _typeMappingSource.FindMapping(typeof(DateTime)) ); } From 632a89c2defa114ace4675d4a9b750f2d3aa50c4 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Wed, 20 Mar 2024 11:51:27 +0100 Subject: [PATCH 11/12] Doc fixup --- .../NpgsqlDbFunctionsExtensions.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs b/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs index 11d0a6199..15cf1ae2f 100644 --- a/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs +++ b/src/EFCore.PG/Extensions/DbFunctionsExtensions/NpgsqlDbFunctionsExtensions.cs @@ -143,22 +143,22 @@ public static TimeSpan Distance(this DbFunctions _, DateTime a, DateTime b) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Distance))); /// - /// Returns the string as a Date + /// Converts string to date according to the given format. /// /// The instance. - /// The string to be converted - /// The format of the input date - /// + /// The string to be converted. + /// The format of the input date. + /// public static DateOnly? ToDate(this DbFunctions _, string? value, string? format) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(ToDate))); /// - /// Returns the string as a timestamp + /// Converts string to time stamp according to the given format. /// /// The instance. /// The string to be converted /// The format of the input date - /// + /// public static DateTime? ToTimestamp(this DbFunctions _, string? value, string? format) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(ToTimestamp))); } From be42e4ef680d3a99001898758fe907d684744dd5 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Wed, 20 Mar 2024 12:12:55 +0100 Subject: [PATCH 12/12] Fix test baseline --- .../Query/NorthwindDbFunctionsQueryNpgsqlTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs b/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs index 8fe8d42c9..4b9f7a5da 100644 --- a/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs +++ b/test/EFCore.PG.FunctionalTests/Query/NorthwindDbFunctionsQueryNpgsqlTest.cs @@ -251,7 +251,7 @@ public void ToTimestamp() """ SELECT count(*)::int FROM "Orders" AS o -WHERE to_timestamp(o."OrderDate"::text, 'YYYY-MM-DD') < TIMESTAMPTZ '2000-01-01 00:00:00Z' +WHERE to_timestamp(o."OrderDate"::text, 'YYYY-MM-DD') < TIMESTAMPTZ '2000-01-01T00:00:00Z' """); }