Skip to content

Commit df72b28

Browse files
committed
fix:修复pg函数【array_position】在高斯中不存在bug
1 parent 0358b16 commit df72b28

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<VersionPrefix>8.0.0</VersionPrefix>
3+
<VersionPrefix>8.0.1</VersionPrefix>
44
<LangVersion>preview</LangVersion>
55
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
66
<AnalysisLevel>latest</AnalysisLevel>
@@ -11,7 +11,7 @@
1111
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
1212
<ImplicitUsings>true</ImplicitUsings>
1313
<GenerateDocumentationFile>true</GenerateDocumentationFile>
14-
14+
<Description>修复数组函数【array_position】在高斯中已被剔除</Description>
1515
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1616
<PackageLicenseExpression>PostgreSQL</PackageLicenseExpression>
1717
<PackageProjectUrl>https://github.com/dotnetcore/EntityFrameworkCore.GaussDB</PackageProjectUrl>

src/EFCore.GaussDB/Query/ExpressionTranslators/Internal/GaussDBArrayMethodTranslator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static bool IsMappedToNonArray(SqlExpression arrayOrList)
126126
return _sqlExpressionFactory.Coalesce(
127127
_sqlExpressionFactory.Subtract(
128128
_sqlExpressionFactory.Function(
129-
"array_position",
129+
"array_next",
130130
new[] { array, item },
131131
nullable: true,
132132
TrueArrays[2],
@@ -146,7 +146,7 @@ static bool IsMappedToNonArray(SqlExpression arrayOrList)
146146
return _sqlExpressionFactory.Coalesce(
147147
_sqlExpressionFactory.Subtract(
148148
_sqlExpressionFactory.Function(
149-
"array_position",
149+
"array_next",
150150
new[] { array, item, startIndex },
151151
nullable: true,
152152
TrueArrays[3],

src/EFCore.GaussDB/Query/Internal/GaussDBQueryableMethodTranslatingExpressionVisitor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,15 +607,15 @@ protected override Expression ApplyInferredTypeMappings(
607607
case ColumnExpression:
608608
if (translatedItem is SqlConstantExpression { Value: null })
609609
{
610-
// We special-case null constant item and use array_position instead, since it does
610+
// We special-case null constant item and use array_next instead, since it does
611611
// nulls correctly (but doesn't use indexes)
612612
// TODO: once lambda-based caching is implemented, move this to GaussDBSqlNullabilityProcessor
613613
// (https://github.com/dotnet/efcore/issues/17598) and do for parameters as well.
614614
return BuildSimplifiedShapedQuery(
615615
source,
616616
_sqlExpressionFactory.IsNotNull(
617617
_sqlExpressionFactory.Function(
618-
"array_position",
618+
"array_next",
619619
new[] { array, translatedItem },
620620
nullable: true,
621621
argumentsPropagateNullability: FalseArrays[2],

src/EFCore.GaussDB/Query/Internal/GaussDBSqlNullabilityProcessor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ protected virtual SqlExpression VisitAny(PgAnyExpression anyExpression, bool all
234234

235235
// non_nullable = ANY(array) -> non_nullable = ANY(array) (optimized)
236236
// non_nullable = ANY(array) -> non_nullable = ANY(array) AND (non_nullable = ANY(array) IS NOT NULL) (full)
237-
// nullable = ANY(array) -> nullable = ANY(array) OR (nullable IS NULL AND array_position(array, NULL) IS NOT NULL) (optimized)
238-
// nullable = ANY(array) -> (nullable = ANY(array) AND (nullable = ANY(array) IS NOT NULL)) OR (nullable IS NULL AND array_position(array, NULL) IS NOT NULL) (full)
237+
// nullable = ANY(array) -> nullable = ANY(array) OR (nullable IS NULL AND array_next(array, NULL) IS NOT NULL) (optimized)
238+
// nullable = ANY(array) -> (nullable = ANY(array) AND (nullable = ANY(array) IS NOT NULL)) OR (nullable IS NULL AND array_next(array, NULL) IS NOT NULL) (full)
239239

240240
nullable = false;
241241

@@ -252,15 +252,15 @@ protected virtual SqlExpression VisitAny(PgAnyExpression anyExpression, bool all
252252
}
253253

254254
// If the item is nullable, add an OR to check for the item being null and the array containing null.
255-
// The latter check is done with array_position, which returns null when a value was not found, and
255+
// The latter check is done with array_next, which returns null when a value was not found, and
256256
// a position if the item (including null!) was found (IS NOT DISTINCT FROM semantics)
257257
return _sqlExpressionFactory.OrElse(
258258
updated,
259259
_sqlExpressionFactory.AndAlso(
260260
_sqlExpressionFactory.IsNull(item),
261261
_sqlExpressionFactory.IsNotNull(
262262
_sqlExpressionFactory.Function(
263-
"array_position",
263+
"array_next",
264264
new[] { array, _sqlExpressionFactory.Constant(null, item.TypeMapping) },
265265
nullable: true,
266266
argumentsPropagateNullability: FalseArrays[2],

0 commit comments

Comments
 (0)