Skip to content

Commit

Permalink
Updated tests with new not-null filters
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMpn committed Jun 21, 2024
1 parent 868edb7 commit 539083d
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions MarkMpn.Sql4Cds.Engine.Tests/ExecutionPlanTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ public void NonUniqueJoinExpression()
</filter>
</entity>
</fetch>");
var contactComputeScalar = AssertNode<ComputeScalarNode>(join.RightSource);
var contactFilter = AssertNode<FilterNode>(join.RightSource);
Assert.AreEqual("Expr1 IS NOT NULL", contactFilter.Filter.ToSql());
var contactComputeScalar = AssertNode<ComputeScalarNode>(contactFilter.Source);
var contactFetch = AssertNode<FetchXmlScan>(contactComputeScalar.Source);
AssertFetchXml(contactFetch, @"
<fetch>
Expand Down Expand Up @@ -3099,7 +3101,9 @@ public void FoldFilterWithNonFoldedJoin()

var select = AssertNode<SelectNode>(plans[0]);
var join = AssertNode<HashJoinNode>(select.Source);
var leftCompute = AssertNode<ComputeScalarNode>(join.LeftSource);
var leftFilter = AssertNode<FilterNode>(join.LeftSource);
Assert.AreEqual("Expr1 IS NOT NULL", leftFilter.Filter.ToSql());
var leftCompute = AssertNode<ComputeScalarNode>(leftFilter.Source);
var leftFetch = AssertNode<FetchXmlScan>(leftCompute.Source);
AssertFetchXml(leftFetch, @"
<fetch>
Expand All @@ -3110,7 +3114,9 @@ public void FoldFilterWithNonFoldedJoin()
</filter>
</entity>
</fetch>");
var rightCompute = AssertNode<ComputeScalarNode>(join.RightSource);
var rightFilter = AssertNode<FilterNode>(join.RightSource);
Assert.AreEqual("Expr2 IS NOT NULL", rightFilter.Filter.ToSql());
var rightCompute = AssertNode<ComputeScalarNode>(rightFilter.Source);
var rightFetch = AssertNode<FetchXmlScan>(rightCompute.Source);
AssertFetchXml(rightFetch, @"
<fetch>
Expand Down Expand Up @@ -5832,9 +5838,27 @@ public void ExplicitCollation()
Assert.AreEqual("p.name", join.LeftAttribute.ToSql());
Assert.AreEqual("Expr1", join.RightAttribute.ToSql());
var fetch1 = AssertNode<FetchXmlScan>(join.LeftSource);
var computeScalar = AssertNode<ComputeScalarNode>(join.RightSource);

AssertFetchXml(fetch1, @"
<fetch xmlns:generator='MarkMpn.SQL4CDS'>
<entity name='account'>
<all-attributes />
<filter>
<condition attribute='name' operator='not-null' />
</filter>
</entity>
</fetch>");
var filter = AssertNode<FilterNode>(join.RightSource);
Assert.AreEqual("Expr1 IS NOT NULL", filter.Filter.ToSql());
var computeScalar = AssertNode<ComputeScalarNode>(filter.Source);
Assert.AreEqual("ExplicitCollation(f.name COLLATE French_CI_AS)", computeScalar.Columns["Expr1"].ToSql());
var fetch2 = AssertNode<FetchXmlScan>(computeScalar.Source);
AssertFetchXml(fetch2, @"
<fetch xmlns:generator='MarkMpn.SQL4CDS'>
<entity name='account'>
<all-attributes />
</entity>
</fetch>");
}

[TestMethod]
Expand Down

0 comments on commit 539083d

Please sign in to comment.