From 8f1063c7fe03e2cd0701426cb8829ec31318e443 Mon Sep 17 00:00:00 2001 From: Maurycy Markowski Date: Fri, 21 Feb 2020 14:16:11 -0800 Subject: [PATCH] Fix to #19731 - Discuss default null propagation strategy for functions - obsoleteing SqlFunction methods and ctors that don't specify nullability propagation info explicitly, - correcting nullability for LongCount, - changing 'NullResultAllowed' to 'IsNullable' to be consistent with ColumnExpression, - other minor perf improvements & cleanup. Fixes #19731 --- .../Query/ISqlExpressionFactory.cs | 12 ++--- ...lityBasedSqlProcessingExpressionVisitor.cs | 46 +++++++--------- .../RelationalMethodCallTranslatorProvider.cs | 2 +- ...lationalSqlTranslatingExpressionVisitor.cs | 16 +++--- .../Query/SqlExpressionFactory.cs | 42 ++++++++------- .../SqlExpressions/SqlFunctionExpression.cs | 52 ++++++++++--------- ...erverGeometryCollectionMemberTranslator.cs | 2 +- ...erverGeometryCollectionMethodTranslator.cs | 2 +- .../SqlServerGeometryMemberTranslator.cs | 6 +-- .../SqlServerGeometryMethodTranslator.cs | 6 +-- .../SqlServerLineStringMemberTranslator.cs | 2 +- .../SqlServerLineStringMethodTranslator.cs | 2 +- ...qlServerMultiLineStringMemberTranslator.cs | 2 +- .../SqlServerPointMemberTranslator.cs | 2 +- .../SqlServerPolygonMemberTranslator.cs | 6 +-- .../SqlServerPolygonMethodTranslator.cs | 4 +- .../SqlServerByteArrayMethodTranslator.cs | 2 +- .../Internal/SqlServerConvertTranslator.cs | 2 +- .../SqlServerDateDiffFunctionsTranslator.cs | 2 +- .../SqlServerDateTimeMemberTranslator.cs | 12 ++--- .../SqlServerDateTimeMethodTranslator.cs | 2 +- .../SqlServerFromPartsFunctionTranslator.cs | 2 +- ...ServerFullTextSearchFunctionsTranslator.cs | 2 +- .../SqlServerIsDateFunctionTranslator.cs | 2 +- .../Query/Internal/SqlServerMathTranslator.cs | 6 +-- .../Internal/SqlServerNewGuidTranslator.cs | 2 +- .../SqlServerObjectToStringTranslator.cs | 2 +- .../Internal/SqlServerQuerySqlGenerator.cs | 2 +- ...qlServerSqlTranslatingExpressionVisitor.cs | 4 +- .../SqlServerStringMemberTranslator.cs | 2 +- .../SqlServerStringMethodTranslator.cs | 34 ++++++------ .../SqliteByteArrayMethodTranslator.cs | 4 +- .../Internal/SqliteDateTimeAddTranslator.cs | 4 +- .../SqliteDateTimeMemberTranslator.cs | 6 +-- .../Query/Internal/SqliteExpression.cs | 2 +- .../Query/Internal/SqliteMathTranslator.cs | 2 +- .../SqliteSqlTranslatingExpressionVisitor.cs | 2 +- .../Internal/SqliteStringLengthTranslator.cs | 2 +- .../Internal/SqliteStringMethodTranslator.cs | 22 ++++---- ...qliteGeometryCollectionMemberTranslator.cs | 2 +- ...qliteGeometryCollectionMethodTranslator.cs | 2 +- .../SqliteGeometryMemberTranslator.cs | 12 ++--- .../SqliteGeometryMethodTranslator.cs | 8 +-- .../SqliteLineStringMemberTranslator.cs | 4 +- .../SqliteLineStringMethodTranslator.cs | 2 +- .../SqliteMultiLineStringMemberTranslator.cs | 2 +- .../Internal/SqlitePointMemberTranslator.cs | 2 +- .../Internal/SqlitePolygonMemberTranslator.cs | 2 +- .../Internal/SqlitePolygonMethodTranslator.cs | 2 +- .../Query/UdfDbFunctionTestBase.cs | 8 +-- .../Query/SpatialQuerySqlServerFixture.cs | 2 +- .../Query/SpatialQuerySqliteFixture.cs | 2 +- 52 files changed, 189 insertions(+), 187 deletions(-) diff --git a/src/EFCore.Relational/Query/ISqlExpressionFactory.cs b/src/EFCore.Relational/Query/ISqlExpressionFactory.cs index a1d98adacd4..e8e068c439e 100644 --- a/src/EFCore.Relational/Query/ISqlExpressionFactory.cs +++ b/src/EFCore.Relational/Query/ISqlExpressionFactory.cs @@ -134,7 +134,7 @@ SqlFunctionExpression Function( SqlFunctionExpression Function( [NotNull] string name, [NotNull] IEnumerable arguments, - bool nullResultAllowed, + bool nullable, [NotNull] IEnumerable argumentsPropagateNullability, [NotNull] Type returnType, [CanBeNull] RelationalTypeMapping typeMapping = null); @@ -143,7 +143,7 @@ SqlFunctionExpression Function( [CanBeNull] string schema, [NotNull] string name, [NotNull] IEnumerable arguments, - bool nullResultAllowed, + bool nullable, [NotNull] IEnumerable argumentsPropagateNullability, [NotNull] Type returnType, [CanBeNull] RelationalTypeMapping typeMapping = null); @@ -152,7 +152,7 @@ SqlFunctionExpression Function( [CanBeNull] SqlExpression instance, [NotNull] string name, [NotNull] IEnumerable arguments, - bool nullResultAllowed, + bool nullable, bool instancePropagatesNullability, [NotNull] IEnumerable argumentsPropagateNullability, [NotNull] Type returnType, @@ -160,21 +160,21 @@ SqlFunctionExpression Function( SqlFunctionExpression Function( [NotNull] string name, - bool nullResultAllowed, + bool nullable, [NotNull] Type returnType, [CanBeNull] RelationalTypeMapping typeMapping = null); SqlFunctionExpression Function( [NotNull] string schema, [NotNull] string name, - bool nullResultAllowed, + bool nullable, [NotNull] Type returnType, [CanBeNull] RelationalTypeMapping typeMapping = null); SqlFunctionExpression Function( [CanBeNull] SqlExpression instance, [NotNull] string name, - bool nullResultAllowed, + bool nullable, bool instancePropagatesNullability, [NotNull] Type returnType, [CanBeNull] RelationalTypeMapping typeMapping = null); diff --git a/src/EFCore.Relational/Query/NullabilityBasedSqlProcessingExpressionVisitor.cs b/src/EFCore.Relational/Query/NullabilityBasedSqlProcessingExpressionVisitor.cs index 0d7f97229a0..c0b59d095a5 100644 --- a/src/EFCore.Relational/Query/NullabilityBasedSqlProcessingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/NullabilityBasedSqlProcessingExpressionVisitor.cs @@ -1287,7 +1287,7 @@ protected virtual SqlExpression ProcessNullNotNull( sqlUnaryExpression.TypeMapping)); } - if (!sqlFunctionExpression.NullResultAllowed) + if (!sqlFunctionExpression.IsNullable) { // when we know that function can't be nullable: // non_nullable_function() is null-> false @@ -1306,39 +1306,33 @@ protected virtual SqlExpression ProcessNullNotNull( nullabilityPropagationElements.Add(sqlFunctionExpression.Instance); } - for (var i = 0; i < sqlFunctionExpression.Arguments.Count; i++) + if (!sqlFunctionExpression.IsNiladic) { - if (sqlFunctionExpression.ArgumentsPropagateNullability[i]) + for (var i = 0; i < sqlFunctionExpression.Arguments.Count; i++) { - nullabilityPropagationElements.Add(sqlFunctionExpression.Arguments[i]); + if (sqlFunctionExpression.ArgumentsPropagateNullability[i]) + { + nullabilityPropagationElements.Add(sqlFunctionExpression.Arguments[i]); + } } } + // function(a, b) IS NULL -> a IS NULL || b IS NULL + // function(a, b) IS NOT NULL -> a IS NOT NULL && b IS NOT NULL if (nullabilityPropagationElements.Count > 0) { - var result = ProcessNullNotNull( - SqlExpressionFactory.MakeUnary( - sqlUnaryExpression.OperatorType, - nullabilityPropagationElements[0], - sqlUnaryExpression.Type, - sqlUnaryExpression.TypeMapping), - operandNullable: null); - - foreach (var element in nullabilityPropagationElements.Skip(1)) - { - result = SimplifyLogicalSqlBinaryExpression( + var result = nullabilityPropagationElements + .Select(e => ProcessNullNotNull( + SqlExpressionFactory.MakeUnary( + sqlUnaryExpression.OperatorType, + e, + sqlUnaryExpression.Type, + sqlUnaryExpression.TypeMapping), + operandNullable: null)) + .Aggregate((r, e) => SimplifyLogicalSqlBinaryExpression( sqlUnaryExpression.OperatorType == ExpressionType.Equal - ? SqlExpressionFactory.OrElse( - result, - ProcessNullNotNull( - SqlExpressionFactory.IsNull(element), - operandNullable: null)) - : SqlExpressionFactory.AndAlso( - result, - ProcessNullNotNull( - SqlExpressionFactory.IsNotNull(element), - operandNullable: null))); - } + ? SqlExpressionFactory.OrElse(r, e) + : SqlExpressionFactory.AndAlso(r, e))); return result; } diff --git a/src/EFCore.Relational/Query/RelationalMethodCallTranslatorProvider.cs b/src/EFCore.Relational/Query/RelationalMethodCallTranslatorProvider.cs index 9f1bda9d34f..cb32513fe5c 100644 --- a/src/EFCore.Relational/Query/RelationalMethodCallTranslatorProvider.cs +++ b/src/EFCore.Relational/Query/RelationalMethodCallTranslatorProvider.cs @@ -57,7 +57,7 @@ public virtual SqlExpression Translate( dbFunction.Schema, dbFunction.Name, arguments, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: arguments.Select(a => false).ToList(), method.ReturnType); } diff --git a/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs index d5ce8d01449..a6feb967b51 100644 --- a/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs @@ -101,7 +101,7 @@ public virtual SqlExpression TranslateAverage([NotNull] Expression expression) SqlExpressionFactory.Function( "AVG", new[] { sqlExpression }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { false }, typeof(double)), sqlExpression.Type, @@ -109,7 +109,7 @@ public virtual SqlExpression TranslateAverage([NotNull] Expression expression) : (SqlExpression)SqlExpressionFactory.Function( "AVG", new[] { sqlExpression }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { false }, sqlExpression.Type, sqlExpression.TypeMapping); @@ -127,7 +127,7 @@ public virtual SqlExpression TranslateCount([CanBeNull] Expression expression = SqlExpressionFactory.Function( "COUNT", new[] { SqlExpressionFactory.Fragment("*") }, - nullResultAllowed: false, + nullable: false, argumentsPropagateNullability: new[] { false }, typeof(int))); } @@ -144,7 +144,7 @@ public virtual SqlExpression TranslateLongCount([CanBeNull] Expression expressio SqlExpressionFactory.Function( "COUNT", new[] { SqlExpressionFactory.Fragment("*") }, - nullResultAllowed: false, + nullable: false, argumentsPropagateNullability: new[] { false }, typeof(long))); } @@ -162,7 +162,7 @@ public virtual SqlExpression TranslateMax([NotNull] Expression expression) ? SqlExpressionFactory.Function( "MAX", new[] { sqlExpression }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { false }, sqlExpression.Type, sqlExpression.TypeMapping) @@ -182,7 +182,7 @@ public virtual SqlExpression TranslateMin([NotNull] Expression expression) ? SqlExpressionFactory.Function( "MIN", new[] { sqlExpression }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { false }, sqlExpression.Type, sqlExpression.TypeMapping) @@ -210,7 +210,7 @@ public virtual SqlExpression TranslateSum([NotNull] Expression expression) SqlExpressionFactory.Function( "SUM", new[] { sqlExpression }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { false }, typeof(double)), inputType, @@ -218,7 +218,7 @@ public virtual SqlExpression TranslateSum([NotNull] Expression expression) : (SqlExpression)SqlExpressionFactory.Function( "SUM", new[] { sqlExpression }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { false }, inputType, sqlExpression.TypeMapping); diff --git a/src/EFCore.Relational/Query/SqlExpressionFactory.cs b/src/EFCore.Relational/Query/SqlExpressionFactory.cs index d8dad55a6fd..ffaa7712ae1 100644 --- a/src/EFCore.Relational/Query/SqlExpressionFactory.cs +++ b/src/EFCore.Relational/Query/SqlExpressionFactory.cs @@ -376,7 +376,7 @@ public virtual SqlFunctionExpression Coalesce(SqlExpression left, SqlExpression return SqlFunctionExpression.Create( "COALESCE", typeMappedArguments, - nullResultAllowed: true, + nullable: true, // COALESCE is handled separately since it's only nullable if *both* arguments are null argumentsPropagateNullability: new[] { false, false }, resultType, @@ -487,21 +487,24 @@ public virtual CaseExpression Case(IReadOnlyList whenClauses, Sq return new CaseExpression(typeMappedWhenClauses, elseResult); } + [Obsolete("Use overload that explicitly specifies value for 'argumentsPropagateNullability' argument.")] public virtual SqlFunctionExpression Function( string name, IEnumerable arguments, Type returnType, RelationalTypeMapping typeMapping = null) - => Function(name, arguments, nullResultAllowed: true, argumentsPropagateNullability: arguments.Select(a => false), returnType, typeMapping); + => Function(name, arguments, nullable: true, argumentsPropagateNullability: arguments.Select(a => false), returnType, typeMapping); + [Obsolete("Use overload that explicitly specifies value for 'argumentsPropagateNullability' argument.")] public virtual SqlFunctionExpression Function( string schema, string name, IEnumerable arguments, Type returnType, RelationalTypeMapping typeMapping = null) - => Function(schema, name, arguments, nullResultAllowed: true, argumentsPropagateNullability: arguments.Select(a => false), returnType, typeMapping); + => Function(schema, name, arguments, nullable: true, argumentsPropagateNullability: arguments.Select(a => false), returnType, typeMapping); + [Obsolete("Use overload that explicitly specifies values for 'instancePropagatesNullability' and 'argumentsPropagateNullability' arguments.")] public virtual SqlFunctionExpression Function( SqlExpression instance, string name, @@ -512,25 +515,26 @@ public virtual SqlFunctionExpression Function( instance, name, arguments, - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: false, argumentsPropagateNullability: arguments.Select(a => false), returnType, typeMapping); public virtual SqlFunctionExpression Function(string name, Type returnType, RelationalTypeMapping typeMapping = null) - => Function(name, nullResultAllowed: true, returnType, typeMapping); + => Function(name, nullable: true, returnType, typeMapping); public virtual SqlFunctionExpression Function(string schema, string name, Type returnType, RelationalTypeMapping typeMapping = null) - => Function(schema, name, nullResultAllowed: true, returnType, typeMapping); + => Function(schema, name, nullable: true, returnType, typeMapping); + [Obsolete("Use overload that explicitly specifies value for 'instancePropagatesNullability' argument.")] public virtual SqlFunctionExpression Function(SqlExpression instance, string name, Type returnType, RelationalTypeMapping typeMapping = null) - => Function(instance, name, nullResultAllowed: true, instancePropagatesNullability: false, returnType, typeMapping); + => Function(instance, name, nullable: true, instancePropagatesNullability: false, returnType, typeMapping); public virtual SqlFunctionExpression Function( string name, IEnumerable arguments, - bool nullResultAllowed, + bool nullable, IEnumerable argumentsPropagateNullability, Type returnType, RelationalTypeMapping typeMapping = null) @@ -549,7 +553,7 @@ public virtual SqlFunctionExpression Function( return SqlFunctionExpression.Create( name, typeMappedArguments, - nullResultAllowed, + nullable, argumentsPropagateNullability, returnType, typeMapping); @@ -559,7 +563,7 @@ public virtual SqlFunctionExpression Function( string schema, string name, IEnumerable arguments, - bool nullResultAllowed, + bool nullable, IEnumerable argumentsPropagateNullability, Type returnType, RelationalTypeMapping typeMapping = null) @@ -578,7 +582,7 @@ public virtual SqlFunctionExpression Function( schema, name, typeMappedArguments, - nullResultAllowed, + nullable, argumentsPropagateNullability, returnType, typeMapping); @@ -588,7 +592,7 @@ public virtual SqlFunctionExpression Function( SqlExpression instance, string name, IEnumerable arguments, - bool nullResultAllowed, + bool nullable, bool instancePropagatesNullability, IEnumerable argumentsPropagateNullability, Type returnType, @@ -609,34 +613,34 @@ public virtual SqlFunctionExpression Function( instance, name, typeMappedArguments, - nullResultAllowed, + nullable, instancePropagatesNullability, argumentsPropagateNullability, returnType, typeMapping); } - public virtual SqlFunctionExpression Function(string name, bool nullResultAllowed, Type returnType, RelationalTypeMapping typeMapping = null) + public virtual SqlFunctionExpression Function(string name, bool nullable, Type returnType, RelationalTypeMapping typeMapping = null) { Check.NotEmpty(name, nameof(name)); Check.NotNull(returnType, nameof(returnType)); - return SqlFunctionExpression.CreateNiladic(name, nullResultAllowed, returnType, typeMapping); + return SqlFunctionExpression.CreateNiladic(name, nullable, returnType, typeMapping); } - public virtual SqlFunctionExpression Function(string schema, string name, bool nullResultAllowed, Type returnType, RelationalTypeMapping typeMapping = null) + public virtual SqlFunctionExpression Function(string schema, string name, bool nullable, Type returnType, RelationalTypeMapping typeMapping = null) { Check.NotEmpty(schema, nameof(schema)); Check.NotEmpty(name, nameof(name)); Check.NotNull(returnType, nameof(returnType)); - return SqlFunctionExpression.CreateNiladic(schema, name, nullResultAllowed, returnType, typeMapping); + return SqlFunctionExpression.CreateNiladic(schema, name, nullable, returnType, typeMapping); } public virtual SqlFunctionExpression Function( SqlExpression instance, string name, - bool nullResultAllowed, + bool nullable, bool instancePropagatesNullability, Type returnType, RelationalTypeMapping typeMapping = null) @@ -647,7 +651,7 @@ public virtual SqlFunctionExpression Function( return SqlFunctionExpression.CreateNiladic( ApplyDefaultTypeMapping(instance), name, - nullResultAllowed, + nullable, instancePropagatesNullability, returnType, typeMapping); diff --git a/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs index 44825ce18a6..fde6ddcabd5 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/SqlFunctionExpression.cs @@ -17,22 +17,24 @@ public static SqlFunctionExpression CreateNiladic( [NotNull] string name, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) - => CreateNiladic(name, nullResultAllowed: true, type, typeMapping); + => CreateNiladic(name, nullable: true, type, typeMapping); public static SqlFunctionExpression CreateNiladic( [NotNull] string schema, [NotNull] string name, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) - => CreateNiladic(schema, name, nullResultAllowed: true, type, typeMapping); + => CreateNiladic(schema, name, nullable: true, type, typeMapping); + [Obsolete("Use constructor that explicitly specifies value for 'instancePropagatesNullability' argument.")] public static SqlFunctionExpression CreateNiladic( [NotNull] SqlExpression instance, [NotNull] string name, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) - => CreateNiladic(instance, name, nullResultAllowed: true, instancePropagatesNullability: false, type, typeMapping); + => CreateNiladic(instance, name, nullable: true, instancePropagatesNullability: false, type, typeMapping); + [Obsolete("Use constructor that explicitly specifies value for 'instancePropagatesNullability' and 'argumentsPropagateNullability' arguments.")] public static SqlFunctionExpression Create( [NotNull] SqlExpression instance, [NotNull] string name, @@ -43,30 +45,32 @@ public static SqlFunctionExpression Create( instance, name, arguments, - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: false, argumentsPropagateNullability: arguments.Select(a => false), type, typeMapping); + [Obsolete("Use constructor that explicitly specifies value for 'argumentsPropagateNullability' argument.")] public static SqlFunctionExpression Create( [NotNull] string name, [NotNull] IEnumerable arguments, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) - => Create(name, arguments, nullResultAllowed: true, argumentsPropagateNullability: arguments.Select(a => false), type, typeMapping); + => Create(name, arguments, nullable: true, argumentsPropagateNullability: arguments.Select(a => false), type, typeMapping); + [Obsolete("Use constructor that explicitly specifies value for 'argumentsPropagateNullability' argument.")] public static SqlFunctionExpression Create( [CanBeNull] string schema, [NotNull] string name, [NotNull] IEnumerable arguments, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) - => Create(schema, name, arguments, nullResultAllowed: true, argumentsPropagateNullability: arguments.Select(a => false), type, typeMapping); + => Create(schema, name, arguments, nullable: true, argumentsPropagateNullability: arguments.Select(a => false), type, typeMapping); public static SqlFunctionExpression CreateNiladic( [NotNull] string name, - bool nullResultAllowed, + bool nullable, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) { @@ -79,7 +83,7 @@ public static SqlFunctionExpression CreateNiladic( name, niladic: true, arguments: null, - nullResultAllowed, + nullable, instancePropagatesNullability: null, argumentsPropagateNullability: null, builtIn: true, @@ -90,7 +94,7 @@ public static SqlFunctionExpression CreateNiladic( public static SqlFunctionExpression CreateNiladic( [NotNull] string schema, [NotNull] string name, - bool nullResultAllowed, + bool nullable, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) { @@ -104,7 +108,7 @@ public static SqlFunctionExpression CreateNiladic( name, niladic: true, arguments: null, - nullResultAllowed, + nullable, instancePropagatesNullability: null, argumentsPropagateNullability: null, builtIn: true, @@ -115,7 +119,7 @@ public static SqlFunctionExpression CreateNiladic( public static SqlFunctionExpression CreateNiladic( [NotNull] SqlExpression instance, [NotNull] string name, - bool nullResultAllowed, + bool nullable, bool instancePropagatesNullability, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) @@ -130,7 +134,7 @@ public static SqlFunctionExpression CreateNiladic( name, niladic: true, arguments: null, - nullResultAllowed, + nullable, instancePropagatesNullability, argumentsPropagateNullability: null, builtIn: true, @@ -142,7 +146,7 @@ public static SqlFunctionExpression Create( [NotNull] SqlExpression instance, [NotNull] string name, [NotNull] IEnumerable arguments, - bool nullResultAllowed, + bool nullable, bool instancePropagatesNullability, [NotNull] IEnumerable argumentsPropagateNullability, [NotNull] Type type, @@ -160,7 +164,7 @@ public static SqlFunctionExpression Create( name, niladic: false, arguments, - nullResultAllowed, + nullable, instancePropagatesNullability, argumentsPropagateNullability, builtIn: true, @@ -171,7 +175,7 @@ public static SqlFunctionExpression Create( public static SqlFunctionExpression Create( [NotNull] string name, [NotNull] IEnumerable arguments, - bool nullResultAllowed, + bool nullable, [NotNull] IEnumerable argumentsPropagateNullability, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) @@ -186,7 +190,7 @@ public static SqlFunctionExpression Create( name, niladic: false, arguments, - nullResultAllowed, + nullable, instancePropagatesNullability: null, argumentsPropagateNullability, builtIn: true, @@ -198,7 +202,7 @@ public static SqlFunctionExpression Create( [CanBeNull] string schema, [NotNull] string name, [NotNull] IEnumerable arguments, - bool nullResultAllowed, + bool nullable, [NotNull] IEnumerable argumentsPropagateNullability, [NotNull] Type type, [CanBeNull] RelationalTypeMapping typeMapping) @@ -213,7 +217,7 @@ public static SqlFunctionExpression Create( name, niladic: false, arguments, - nullResultAllowed, + nullable, instancePropagatesNullability: null, argumentsPropagateNullability, builtIn: false, @@ -227,7 +231,7 @@ public SqlFunctionExpression( [NotNull] string name, bool niladic, [CanBeNull] IEnumerable arguments, - bool nullResultAllowed, + bool nullable, bool? instancePropagatesNullability, [CanBeNull] IEnumerable argumentsPropagateNullability, bool builtIn, @@ -244,7 +248,7 @@ public SqlFunctionExpression( IsNiladic = niladic; IsBuiltIn = builtIn; Arguments = (arguments ?? Array.Empty()).ToList(); - NullResultAllowed = nullResultAllowed; + IsNullable = nullable; InstancePropagatesNullability = instancePropagatesNullability; ArgumentsPropagateNullability = (argumentsPropagateNullability ?? Array.Empty()).ToList(); } @@ -262,7 +266,7 @@ public SqlFunctionExpression( /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public virtual bool NullResultAllowed { get; private set; } + public virtual bool IsNullable { get; private set; } /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -301,7 +305,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) Name, IsNiladic, arguments, - NullResultAllowed, + IsNullable, InstancePropagatesNullability, ArgumentsPropagateNullability, IsBuiltIn, @@ -317,7 +321,7 @@ public virtual SqlFunctionExpression ApplyTypeMapping([CanBeNull] RelationalType Name, IsNiladic, Arguments, - NullResultAllowed, + IsNullable, InstancePropagatesNullability, ArgumentsPropagateNullability, IsBuiltIn, @@ -333,7 +337,7 @@ public virtual SqlFunctionExpression Update([CanBeNull] SqlExpression instance, Name, IsNiladic, arguments, - NullResultAllowed, + IsNullable, InstancePropagatesNullability, ArgumentsPropagateNullability, IsBuiltIn, diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMemberTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMemberTranslator.cs index 158079a0aa4..ad7ff9f6630 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMemberTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMemberTranslator.cs @@ -32,7 +32,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member instance, "STNumGeometries", Array.Empty(), - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability: Array.Empty(), returnType); diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMethodTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMethodTranslator.cs index 5b118c63f73..92effc83d5d 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMethodTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMethodTranslator.cs @@ -42,7 +42,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method arguments[0], _sqlExpressionFactory.Constant(1)) }, - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability: new[] { false }, method.ReturnType, diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs index d6662692bce..aa97b308e4e 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs @@ -73,7 +73,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member instance, functionName, Array.Empty(), - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability: Array.Empty(), returnType, @@ -124,7 +124,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member instance, "STGeometryType", Array.Empty(), - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability: Array.Empty(), typeof(string)), @@ -136,7 +136,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member return _sqlExpressionFactory.Function( instance, "STSrid", - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, returnType); } diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMethodTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMethodTranslator.cs index 6a41b8b34a9..0534d7b9eb3 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMethodTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMethodTranslator.cs @@ -109,7 +109,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method instance, functionName, finalArguments, - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability, method.ReturnType, @@ -127,7 +127,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method arguments[0], _sqlExpressionFactory.Constant(1)) }, - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability: new[] { false }, method.ReturnType, @@ -157,7 +157,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method instance, "STDistance", finalArguments, - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability: finalArguments.Select(a => true), typeof(double)), diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMemberTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMemberTranslator.cs index abb93b3c660..9baae114288 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMemberTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMemberTranslator.cs @@ -60,7 +60,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member instance, functionName, Enumerable.Empty(), - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability: Enumerable.Empty(), returnType, diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMethodTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMethodTranslator.cs index b9c9fe2b217..5df3e4dc453 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMethodTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMethodTranslator.cs @@ -44,7 +44,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method arguments[0], _sqlExpressionFactory.Constant(1)) }, - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability: new[] { true }, method.ReturnType, diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerMultiLineStringMemberTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerMultiLineStringMemberTranslator.cs index 97e7c20afa9..c98f6323116 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerMultiLineStringMemberTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerMultiLineStringMemberTranslator.cs @@ -32,7 +32,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member instance, "STIsClosed", Array.Empty(), - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability: Array.Empty(), returnType); diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPointMemberTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPointMemberTranslator.cs index b73d8fc2090..b15b05db65b 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPointMemberTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPointMemberTranslator.cs @@ -51,7 +51,7 @@ public SqlExpression Translate(SqlExpression instance, MemberInfo member, Type r return _sqlExpressionFactory.Function( instance, propertyName, - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, returnType); } diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMemberTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMemberTranslator.cs index 8c27bc524ac..2d2c8aec4ae 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMemberTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMemberTranslator.cs @@ -53,7 +53,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member instance, "RingN", new[] { _sqlExpressionFactory.Constant(1) }, - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability: new[] { false }, returnType, @@ -67,7 +67,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member instance, "NumRings", Array.Empty(), - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability: Array.Empty(), returnType), @@ -85,7 +85,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member instance, functionName, Array.Empty(), - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability: Array.Empty(), returnType, diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMethodTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMethodTranslator.cs index 9671022e62b..0b5599056ff 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMethodTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMethodTranslator.cs @@ -50,7 +50,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method arguments[0], _sqlExpressionFactory.Constant(2)) }, - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability: new[] { true }, method.ReturnType, @@ -66,7 +66,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method arguments[0], _sqlExpressionFactory.Constant(1)) }, - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability: new[] { true }, method.ReturnType, diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerByteArrayMethodTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerByteArrayMethodTranslator.cs index 9dcad381237..438a696c58d 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerByteArrayMethodTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerByteArrayMethodTranslator.cs @@ -39,7 +39,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method _sqlExpressionFactory.Function( "CHARINDEX", new[] { value, source }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true }, typeof(int)), _sqlExpressionFactory.Constant(0)); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs index 12401dd0810..714caba79b2 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs @@ -62,7 +62,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method ? _sqlExpressionFactory.Function( "CONVERT", new[] { _sqlExpressionFactory.Fragment(_typeMapping[method.Name]), arguments[0] }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { false, true }, method.ReturnType) : null; diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs index 8058b63ec11..961619a7dd0 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs @@ -355,7 +355,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method return _sqlExpressionFactory.Function( "DATEDIFF", new[] { _sqlExpressionFactory.Fragment(datePart), startDate, endDate }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { false, true, true }, typeof(int)); } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs index 7b29371c9db..aae79c66f76 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs @@ -50,7 +50,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member return _sqlExpressionFactory.Function( "DATEPART", new[] { _sqlExpressionFactory.Fragment(datePart), instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { false, true }, returnType); } @@ -61,7 +61,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member return _sqlExpressionFactory.Function( "CONVERT", new[] { _sqlExpressionFactory.Fragment("date"), instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { false, true }, returnType, declaringType == typeof(DateTime) @@ -75,7 +75,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member return _sqlExpressionFactory.Function( declaringType == typeof(DateTime) ? "GETDATE" : "SYSDATETIMEOFFSET", Array.Empty(), - nullResultAllowed: false, + nullable: false, argumentsPropagateNullability: Array.Empty(), returnType); @@ -83,7 +83,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member var serverTranslation = _sqlExpressionFactory.Function( declaringType == typeof(DateTime) ? "GETUTCDATE" : "SYSUTCDATETIME", Array.Empty(), - nullResultAllowed: false, + nullable: false, argumentsPropagateNullability: Array.Empty(), returnType); @@ -100,11 +100,11 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member _sqlExpressionFactory.Function( "GETDATE", Array.Empty(), - nullResultAllowed: false, + nullable: false, argumentsPropagateNullability: Array.Empty(), typeof(DateTime)) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { false, true }, returnType); } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs index 1a4ecfca54c..5f4d695efc7 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs @@ -61,7 +61,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method _sqlExpressionFactory.Convert(arguments[0], typeof(int)), instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { false, true, true }, instance.Type, instance.TypeMapping); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs index b6fd080e5cc..0c251c99d02 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs @@ -70,7 +70,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method return _sqlExpressionFactory.Function( value.FunctionName, arguments.Skip(1), - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: arguments.Skip(1).Select(a => true), _dateFromPartsMethodInfo.ReturnType, _typeMappingSource.FindMapping(_dateFromPartsMethodInfo.ReturnType, value.ReturnType)); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs index fdf16dff182..78971f993b9 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs @@ -81,7 +81,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method return _sqlExpressionFactory.Function( functionName, functionArguments, - nullResultAllowed: true, + nullable: true, // TODO: don't propagate for now argumentsPropagateNullability: functionArguments.Select(a => false).ToList(), typeof(bool)); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerIsDateFunctionTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerIsDateFunctionTranslator.cs index 1187aaaabe1..030c149592a 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerIsDateFunctionTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerIsDateFunctionTranslator.cs @@ -30,7 +30,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method _sqlExpressionFactory.Function( "ISDATE", new[] { arguments[1] }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, _methodInfo.ReturnType), _methodInfo.ReturnType) diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs index cf3f4a20a33..607edc57cef 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs @@ -92,7 +92,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method return _sqlExpressionFactory.Function( sqlFunctionName, newArguments, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: newArguments.Select(a => true).ToArray(), method.ReturnType, sqlFunctionName == "SIGN" ? null : typeMapping); @@ -105,7 +105,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method return _sqlExpressionFactory.Function( "ROUND", new[] { argument, _sqlExpressionFactory.Constant(0), _sqlExpressionFactory.Constant(1) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, false, false }, method.ReturnType, argument.TypeMapping); @@ -119,7 +119,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method return _sqlExpressionFactory.Function( "ROUND", new[] { argument, digits }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true }, method.ReturnType, argument.TypeMapping); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerNewGuidTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerNewGuidTranslator.cs index 19c772bd348..314fbe88a50 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerNewGuidTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerNewGuidTranslator.cs @@ -30,7 +30,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method ? _sqlExpressionFactory.Function( "NEWID", Array.Empty(), - nullResultAllowed: false, + nullable: false, argumentsPropagateNullability: Array.Empty(), method.ReturnType) : null; diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs index 2750d4e9bee..5b060d01906 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs @@ -58,7 +58,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method ? _sqlExpressionFactory.Function( "CONVERT", new[] { _sqlExpressionFactory.Fragment(storeType), instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new bool[] { false, true }, typeof(string)) : null; diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs index 5b0e62d8cc0..ddcaddfc028 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs @@ -67,7 +67,7 @@ protected override Expression VisitSqlFunction(SqlFunctionExpression sqlFunction schema: "dbo", sqlFunctionExpression.Name, sqlFunctionExpression.Arguments, - sqlFunctionExpression.NullResultAllowed, + sqlFunctionExpression.IsNullable, sqlFunctionExpression.ArgumentsPropagateNullability, sqlFunctionExpression.Type, sqlFunctionExpression.TypeMapping); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs index 3ff5754462a..73abfee5e3a 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs @@ -76,7 +76,7 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression) var dataLengthSqlFunction = SqlExpressionFactory.Function( "DATALENGTH", new[] { sqlExpression }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new bool[] { true }, isBinaryMaxDataType ? typeof(long) : typeof(int)); @@ -100,7 +100,7 @@ public override SqlExpression TranslateLongCount(Expression expression = null) SqlExpressionFactory.Function( "COUNT_BIG", new[] { SqlExpressionFactory.Fragment("*") }, - nullResultAllowed: true, + nullable: false, argumentsPropagateNullability: new[] { false }, typeof(long))); } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerStringMemberTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerStringMemberTranslator.cs index 338fa565bd8..05b55e1a4ec 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerStringMemberTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerStringMemberTranslator.cs @@ -31,7 +31,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member _sqlExpressionFactory.Function( "LEN", new[] { instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, typeof(long)), returnType); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerStringMethodTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerStringMethodTranslator.cs index 33c4da6d355..291b0f446df 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerStringMethodTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerStringMethodTranslator.cs @@ -90,7 +90,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method charIndexExpression = _sqlExpressionFactory.Function( "CHARINDEX", new[] { argument, _sqlExpressionFactory.ApplyTypeMapping(instance, stringTypeMapping) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new [] { true, true }, typeof(long)); @@ -101,7 +101,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method charIndexExpression = _sqlExpressionFactory.Function( "CHARINDEX", new[] { argument, _sqlExpressionFactory.ApplyTypeMapping(instance, stringTypeMapping) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true }, method.ReturnType); } @@ -133,7 +133,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method return _sqlExpressionFactory.Function( "REPLACE", new[] { instance, firstArgument, secondArgument }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true, true }, method.ReturnType, stringTypeMapping); @@ -145,7 +145,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method return _sqlExpressionFactory.Function( _toLowerMethodInfo.Equals(method) ? "LOWER" : "UPPER", new[] { instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, method.ReturnType, instance.TypeMapping); @@ -163,7 +163,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method _sqlExpressionFactory.Constant(1)), arguments[1] }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true, true }, method.ReturnType, instance.TypeMapping); @@ -183,12 +183,12 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method _sqlExpressionFactory.Function( "RTRIM", new[] { argument }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, argument.Type, argument.TypeMapping) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, argument.Type, argument.TypeMapping), @@ -203,7 +203,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method return _sqlExpressionFactory.Function( "LTRIM", new[] { instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, instance.Type, instance.TypeMapping); @@ -217,7 +217,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method return _sqlExpressionFactory.Function( "RTRIM", new[] { instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, instance.Type, instance.TypeMapping); @@ -235,12 +235,12 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method _sqlExpressionFactory.Function( "RTRIM", new[] { instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, instance.Type, instance.TypeMapping) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, instance.Type, instance.TypeMapping); @@ -267,7 +267,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method _sqlExpressionFactory.Function( "CHARINDEX", new[] { pattern, instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true }, typeof(int)), _sqlExpressionFactory.Constant(0)); @@ -281,7 +281,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method _sqlExpressionFactory.Function( "CHARINDEX", new[] { pattern, instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true }, typeof(int)), _sqlExpressionFactory.Constant(0))); @@ -344,11 +344,11 @@ private SqlExpression TranslateStartsEndsWith(SqlExpression instance, SqlExpress _sqlExpressionFactory.Function( "LEN", new[] { pattern }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, typeof(int)) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true }, typeof(string), stringTypeMapping), @@ -364,11 +364,11 @@ private SqlExpression TranslateStartsEndsWith(SqlExpression instance, SqlExpress _sqlExpressionFactory.Function( "LEN", new[] { pattern }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, typeof(int)) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true }, typeof(string), stringTypeMapping), diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteByteArrayMethodTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteByteArrayMethodTranslator.cs index d5965da3161..aa160ee6032 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteByteArrayMethodTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteByteArrayMethodTranslator.cs @@ -31,7 +31,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method : _sqlExpressionFactory.Function( "char", new[] { arguments[1] }, - nullResultAllowed: false, + nullable: false, argumentsPropagateNullability: new[] { false }, typeof(string)); @@ -39,7 +39,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method _sqlExpressionFactory.Function( "instr", new[] { source, value }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true }, typeof(int)), _sqlExpressionFactory.Constant(0)); diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs index 6051cf62e39..ebf2dacf9f6 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs @@ -87,12 +87,12 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method new[] { modifier }), _sqlExpressionFactory.Constant("0") }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, false }, method.ReturnType), _sqlExpressionFactory.Constant(".") }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, false }, method.ReturnType); } diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs index 42a8b6dca15..59b3d205768 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs @@ -61,7 +61,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member _sqlExpressionFactory.Function( "julianday", new[] { instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, typeof(double)), _sqlExpressionFactory.Constant(1721425.5)), // NB: Result of julianday('0001-01-01 00:00:00') @@ -137,12 +137,12 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member modifiers), _sqlExpressionFactory.Constant("0") }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, false }, returnType), _sqlExpressionFactory.Constant(".") }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, false }, returnType); } diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteExpression.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteExpression.cs index d4c9735e101..71eb318e9d5 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteExpression.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteExpression.cs @@ -58,7 +58,7 @@ public static SqlFunctionExpression Strftime( return sqlExpressionFactory.Function( "strftime", finalArguments, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: finalArguments.Select(a => true), returnType, typeMapping); diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs index a7162651881..bedd1e060be 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs @@ -81,7 +81,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method return _sqlExpressionFactory.Function( sqlFunctionName, finalArguments, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: finalArguments.Select(a => true).ToList(), method.ReturnType, typeMapping); diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteSqlTranslatingExpressionVisitor.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteSqlTranslatingExpressionVisitor.cs index 6397d74ec29..9b5a393bb54 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteSqlTranslatingExpressionVisitor.cs @@ -94,7 +94,7 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression) ? SqlExpressionFactory.Function( "length", new[] { sqlExpression }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, typeof(int)) : null; diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringLengthTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringLengthTranslator.cs index cdb83178bcb..4203a34adf1 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringLengthTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringLengthTranslator.cs @@ -29,7 +29,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member ? _sqlExpressionFactory.Function( "length", new[] { instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, returnType) : null; diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringMethodTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringMethodTranslator.cs index da69e7357ff..47fb1fd9156 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringMethodTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringMethodTranslator.cs @@ -97,7 +97,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method _sqlExpressionFactory.ApplyTypeMapping(instance, stringTypeMapping), _sqlExpressionFactory.ApplyTypeMapping(argument, stringTypeMapping) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true }, method.ReturnType), _sqlExpressionFactory.Constant(1)); @@ -117,7 +117,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method _sqlExpressionFactory.ApplyTypeMapping(firstArgument, stringTypeMapping), _sqlExpressionFactory.ApplyTypeMapping(secondArgument, stringTypeMapping) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true, true }, method.ReturnType, stringTypeMapping); @@ -129,7 +129,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method return _sqlExpressionFactory.Function( _toLowerMethodInfo.Equals(method) ? "lower" : "upper", new[] { instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, method.ReturnType, instance.TypeMapping); @@ -140,7 +140,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method return _sqlExpressionFactory.Function( "substr", new[] { instance, _sqlExpressionFactory.Add(arguments[0], _sqlExpressionFactory.Constant(1)), arguments[1] }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true, true }, method.ReturnType, instance.TypeMapping); @@ -156,7 +156,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method _sqlExpressionFactory.Function( "trim", new[] { argument }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, argument.Type, argument.TypeMapping), @@ -200,7 +200,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method _sqlExpressionFactory.Function( "instr", new[] { instance, pattern }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true }, typeof(int)), _sqlExpressionFactory.Constant(0))); @@ -276,11 +276,11 @@ private SqlExpression TranslateStartsEndsWith(SqlExpression instance, SqlExpress _sqlExpressionFactory.Function( "length", new[] { pattern }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, typeof(int)) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, false, true }, typeof(string), stringTypeMapping), @@ -301,11 +301,11 @@ private SqlExpression TranslateStartsEndsWith(SqlExpression instance, SqlExpress _sqlExpressionFactory.Function( "length", new[] { pattern }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, typeof(int))) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true }, typeof(string), stringTypeMapping), @@ -373,7 +373,7 @@ private SqlExpression ProcessTrimMethod(SqlExpression instance, IReadOnlyList true).ToList(), typeof(string), typeMapping); diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMemberTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMemberTranslator.cs index 2a127c34a08..2baa5017fe8 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMemberTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMemberTranslator.cs @@ -30,7 +30,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member ? _sqlExpressionFactory.Function( "NumGeometries", new[] { instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, returnType) : null; diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMethodTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMethodTranslator.cs index 9e861f73ade..3994c6893fa 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMethodTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMethodTranslator.cs @@ -37,7 +37,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method arguments[0], _sqlExpressionFactory.Constant(1)) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true }, method.ReturnType); } diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMemberTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMemberTranslator.cs index d12049e0626..ed541aa97ee 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMemberTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMemberTranslator.cs @@ -57,7 +57,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member _sqlExpressionFactory.Function( functionName, new[] { instance }, - nullResultAllowed: false, + nullable: false, argumentsPropagateNullability: new[] { false }, returnType)) }, @@ -65,7 +65,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member : (SqlExpression)_sqlExpressionFactory.Function( functionName, new[] { instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, returnType); } @@ -80,12 +80,12 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member _sqlExpressionFactory.Function( "GeometryType", new[] { instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, returnType), _sqlExpressionFactory.Constant(" ZM") }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, returnType), new CaseWhenClause(_sqlExpressionFactory.Constant("POINT"), _sqlExpressionFactory.Constant("Point")), @@ -109,12 +109,12 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member _sqlExpressionFactory.Function( "GeometryType", new[] { instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, typeof(string)), _sqlExpressionFactory.Constant(" ZM") }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, typeof(string)), new CaseWhenClause(_sqlExpressionFactory.Constant("POINT"), _sqlExpressionFactory.Constant(OgcGeometryType.Point)), diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMethodTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMethodTranslator.cs index 58e70520a99..de9341b1dd0 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMethodTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMethodTranslator.cs @@ -84,7 +84,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method _sqlExpressionFactory.Function( functionName, finalArguments, - nullResultAllowed: false, + nullable: false, finalArguments.Select(a => false), method.ReturnType)) }, @@ -94,7 +94,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method return _sqlExpressionFactory.Function( functionName, finalArguments, - nullResultAllowed: true, + nullable: true, finalArguments.Select(a => true), method.ReturnType); } @@ -110,7 +110,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method arguments[0], _sqlExpressionFactory.Constant(1)) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true }, method.ReturnType); } @@ -121,7 +121,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method _sqlExpressionFactory.Function( "Distance", new[] { instance, arguments[0] }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true }, typeof(double)), arguments[1]); diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMemberTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMemberTranslator.cs index f6fde8a67d8..7d0167eb222 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMemberTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMemberTranslator.cs @@ -47,7 +47,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member _sqlExpressionFactory.Function( functionName, new[] { instance }, - nullResultAllowed: false, + nullable: false, argumentsPropagateNullability: new[] { false }, returnType)) }, @@ -55,7 +55,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member : (SqlExpression)_sqlExpressionFactory.Function( functionName, new[] { instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, returnType); } diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMethodTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMethodTranslator.cs index 311139c4ee0..c12b586c977 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMethodTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMethodTranslator.cs @@ -39,7 +39,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method arguments[0], _sqlExpressionFactory.Constant(1)) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true, true }, method.ReturnType); } diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteMultiLineStringMemberTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteMultiLineStringMemberTranslator.cs index 69abd08c7f6..2581a787e77 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteMultiLineStringMemberTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteMultiLineStringMemberTranslator.cs @@ -36,7 +36,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member _sqlExpressionFactory.Function( "IsClosed", new[] { instance }, - nullResultAllowed: false, + nullable: false, argumentsPropagateNullability: new[] { false }, returnType)) }, diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePointMemberTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePointMemberTranslator.cs index 60db74be625..3bfc553061d 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePointMemberTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePointMemberTranslator.cs @@ -38,7 +38,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member ? _sqlExpressionFactory.Function( functionName, new[] { instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, returnType) : null; diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMemberTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMemberTranslator.cs index 4e8d976fc89..e53d1116365 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMemberTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMemberTranslator.cs @@ -37,7 +37,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member ? _sqlExpressionFactory.Function( functionName, new[] { instance }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new[] { true }, returnType) : null; diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMethodTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMethodTranslator.cs index 78d14928f92..6937d311d5b 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMethodTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMethodTranslator.cs @@ -33,7 +33,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method return _sqlExpressionFactory.Function( "InteriorRingN", new[] { instance, _sqlExpressionFactory.Add(arguments[0], _sqlExpressionFactory.Constant(1)) }, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: new [] { true, true }, method.ReturnType); } diff --git a/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs index 4b31c84c510..a1b220d3816 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/UdfDbFunctionTestBase.cs @@ -129,7 +129,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasTranslation(args => SqlFunctionExpression.Create( "IsDate", args, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: args.Select(a => true).ToList(), isDateMethodInfo.ReturnType, null)); @@ -140,7 +140,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasTranslation(args => SqlFunctionExpression.Create( "len", args, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: args.Select(a => true).ToList(), methodInfo.ReturnType, null)); @@ -161,7 +161,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasTranslation(args => SqlFunctionExpression.Create( "IsDate", args, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: args.Select(a => true).ToList(), isDateMethodInfo2.ReturnType, null)); @@ -174,7 +174,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasTranslation(args => SqlFunctionExpression.Create( "len", args, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: args.Select(a => true).ToList(), methodInfo2.ReturnType, null)); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerFixture.cs index a547dcb1c07..76108c92395 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerFixture.cs @@ -40,7 +40,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con instance: e.First(), "STDistance", arguments: e.Skip(1), - nullResultAllowed: true, + nullable: true, instancePropagatesNullability: true, argumentsPropagateNullability: e.Skip(1).Select(a => true), typeof(double), diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteFixture.cs index cedb9ae4699..e460b0cf713 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteFixture.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteFixture.cs @@ -41,7 +41,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con e => SqlFunctionExpression.Create( "Distance", arguments: e, - nullResultAllowed: true, + nullable: true, argumentsPropagateNullability: e.Select(a => true).ToList(), typeof(double), null)));