Skip to content

Commit c9415fa

Browse files
committed
Add test for conditional experssion in partial indexes
index filter builder uses Expression processor, just in case we should have such test case
1 parent 347cbc1 commit c9415fa

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

Orm/Xtensive.Orm.Tests/Storage/PartialIndexTest.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2011-2021 Xtensive LLC.
1+
// Copyright (C) 2011-2024 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Denis Krjuchkov
@@ -164,6 +164,16 @@ public class ContainsOperatorSupport : TestBase
164164
public string TestField { get; set; }
165165
}
166166

167+
[HierarchyRoot, Index(nameof(TestField), Filter = nameof(Index))]
168+
public class ConditionalExpressionSuport : TestBase
169+
{
170+
public static Expression<Func<ConditionalExpressionSuport, bool>> Index =>
171+
test => test.Id == ((test.TestField == null) ? 100 : 200) ? test.TestField.Contains("hello") : false;
172+
173+
[Field]
174+
public string TestField { get; set; }
175+
}
176+
167177
[HierarchyRoot,
168178
Index(nameof(TestField), Filter = nameof(More), Name = "MoreIndex"),
169179
Index(nameof(TestField), Filter = nameof(Less), Name = "LessIndex")]
@@ -543,6 +553,9 @@ private void AssertBuildFailure(params Type[] entities)
543553
[Test]
544554
public void ContainsOperatorSupportTest() => AssertBuildSuccess(typeof(ContainsOperatorSupport));
545555

556+
[Test]
557+
public void ConditionalOperationSupportTest() => AssertBuildSuccess(typeof(ConditionalExpressionSuport));
558+
546559
[Test]
547560
public void DoubleIndexWithNameTest() => AssertBuildSuccess(typeof(DoubleIndexWithName));
548561

0 commit comments

Comments
 (0)