Skip to content

Commit bc15b0e

Browse files
committed
Ensure string.Join is not translated with non array-mapped param (#3105)
string.Join translations are just valid if their parameter's TypeMapping is NpgsqlArrayTypeMapping.
1 parent c63416e commit bc15b0e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/EFCore.PG/Query/ExpressionTranslators/Internal/NpgsqlStringMethodTranslator.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Npgsql.EntityFrameworkCore.PostgreSQL.Query.Expressions.Internal;
22
using Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal;
3+
using Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.Mapping;
34
using static Npgsql.EntityFrameworkCore.PostgreSQL.Utilities.Statics;
45
using ExpressionExtensions = Microsoft.EntityFrameworkCore.Query.ExpressionExtensions;
56

@@ -339,7 +340,8 @@ public NpgsqlStringMethodTranslator(NpgsqlTypeMappingSource typeMappingSource, I
339340
|| method == String_Join4
340341
|| method == String_Join5
341342
|| method.IsClosedFormOf(String_Join_generic1)
342-
|| method.IsClosedFormOf(String_Join_generic2)))
343+
|| method.IsClosedFormOf(String_Join_generic2))
344+
&& arguments[1].TypeMapping is NpgsqlArrayTypeMapping)
343345
{
344346
// If the array of strings to be joined is a constant (NewArrayExpression), we translate to concat_ws.
345347
// Otherwise we translate to array_to_string, which also supports array columns and parameters.

0 commit comments

Comments
 (0)