Skip to content

Commit

Permalink
Merge pull request #557 from MarkMpn/direct-updates
Browse files Browse the repository at this point in the history
Direct updates
+semver: minor
  • Loading branch information
MarkMpn authored Oct 8, 2024
2 parents ddc9cf9 + 82b6178 commit 26994bc
Show file tree
Hide file tree
Showing 72 changed files with 4,928 additions and 1,323 deletions.
389 changes: 389 additions & 0 deletions MarkMpn.Sql4Cds.Engine.Tests/AdoProviderTests.cs

Large diffs are not rendered by default.

52 changes: 27 additions & 25 deletions MarkMpn.Sql4Cds.Engine.Tests/CteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class CteTests : FakeXrmEasyTestsBase, IQueryExecutionOptions

bool IQueryExecutionOptions.BypassCustomPlugins => false;

public event EventHandler PrimaryDataSourceChanged;

void IQueryExecutionOptions.ConfirmInsert(ConfirmDmlStatementEventArgs e)
{
}
Expand Down Expand Up @@ -78,7 +80,7 @@ void IQueryExecutionOptions.Progress(double? progress, string message)
[TestMethod]
public void SimpleSelect()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte AS (SELECT accountid, name FROM account)
Expand All @@ -102,7 +104,7 @@ WITH cte AS (SELECT accountid, name FROM account)
[TestMethod]
public void ColumnAliases()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte (id, n) AS (SELECT accountid, name FROM account)
Expand All @@ -126,7 +128,7 @@ WITH cte (id, n) AS (SELECT accountid, name FROM account)
[TestMethod]
public void MultipleAnchorQueries()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte (id, n) AS (SELECT accountid, name FROM account UNION ALL select contactid, fullname FROM contact)
Expand Down Expand Up @@ -159,7 +161,7 @@ WITH cte (id, n) AS (SELECT accountid, name FROM account UNION ALL select contac
[TestMethod]
public void MergeFilters()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte AS (SELECT contactid, firstname, lastname FROM contact WHERE firstname = 'Mark')
Expand Down Expand Up @@ -188,7 +190,7 @@ WITH cte AS (SELECT contactid, firstname, lastname FROM contact WHERE firstname
[TestMethod]
public void MultipleReferencesWithAliases()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte AS (SELECT contactid, firstname, lastname FROM contact WHERE firstname = 'Mark')
Expand Down Expand Up @@ -226,7 +228,7 @@ WITH cte AS (SELECT contactid, firstname, lastname FROM contact WHERE firstname
[TestMethod]
public void MultipleReferencesInUnionAll()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte AS (SELECT contactid, firstname, lastname FROM contact WHERE firstname = 'Mark')
Expand Down Expand Up @@ -262,7 +264,7 @@ WITH cte AS (SELECT contactid, firstname, lastname FROM contact WHERE firstname
[ExpectedException(typeof(NotSupportedQueryFragmentException))]
public void MultipleRecursiveReferences()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte AS (
Expand All @@ -279,7 +281,7 @@ UNION ALL
[ExpectedException(typeof(NotSupportedQueryFragmentException))]
public void HintsOnRecursiveReference()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte AS (
Expand All @@ -296,7 +298,7 @@ UNION ALL
[ExpectedException(typeof(NotSupportedQueryFragmentException))]
public void RecursionWithoutUnionAll()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte AS (
Expand All @@ -313,7 +315,7 @@ SELECT cte.* FROM cte
[ExpectedException(typeof(QueryParseException))]
public void OrderByWithoutTop()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte AS (
Expand All @@ -331,7 +333,7 @@ ORDER BY firstname
[ExpectedException(typeof(NotSupportedQueryFragmentException))]
public void GroupByOnRecursiveReference()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte AS (
Expand All @@ -348,7 +350,7 @@ UNION ALL
[ExpectedException(typeof(NotSupportedQueryFragmentException))]
public void AggregateOnRecursiveReference()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte AS (
Expand All @@ -365,7 +367,7 @@ SELECT MIN(contactid), MIN(firstname), MIN(lastname) FROM cte
[ExpectedException(typeof(NotSupportedQueryFragmentException))]
public void TopOnRecursiveReference()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte AS (
Expand All @@ -382,7 +384,7 @@ SELECT TOP 10 cte.* FROM cte
[ExpectedException(typeof(NotSupportedQueryFragmentException))]
public void OuterJoinOnRecursiveReference()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte AS (
Expand All @@ -399,7 +401,7 @@ UNION ALL
[ExpectedException(typeof(NotSupportedQueryFragmentException))]
public void SubqueryOnRecursiveReference()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte AS (
Expand All @@ -416,7 +418,7 @@ UNION ALL
[ExpectedException(typeof(NotSupportedQueryFragmentException))]
public void IncorrectColumnCount()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte (id, fname) AS (
Expand All @@ -431,7 +433,7 @@ WITH cte (id, fname) AS (
[ExpectedException(typeof(NotSupportedQueryFragmentException))]
public void AnonymousColumn()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte AS (
Expand All @@ -446,7 +448,7 @@ WITH cte AS (
[ExpectedException(typeof(NotSupportedQueryFragmentException))]
public void MissingAnchorQuery()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte (x, y) AS (
Expand All @@ -460,7 +462,7 @@ WITH cte (x, y) AS (
[TestMethod]
public void AliasedAnonymousColumn()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte (id, fname, lname) AS (
Expand Down Expand Up @@ -498,7 +500,7 @@ WITH cte (id, fname, lname) AS (
[TestMethod]
public void SelectStarFromValues()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH source_data_cte AS (
Expand Down Expand Up @@ -535,7 +537,7 @@ WITH source_data_cte AS (
[TestMethod]
public void SimpleRecursion()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH cte AS (
Expand Down Expand Up @@ -675,7 +677,7 @@ union all
[TestMethod]
public void Under()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH account_hierarchical(accountid) AS (
Expand Down Expand Up @@ -706,7 +708,7 @@ UNION ALL
[TestMethod]
public void EqOrUnder()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH account_hierarchical(accountid) AS (
Expand Down Expand Up @@ -737,7 +739,7 @@ UNION ALL
[TestMethod]
public void Above()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH account_hierarchical(accountid, parentaccountid) AS (
Expand Down Expand Up @@ -768,7 +770,7 @@ UNION ALL
[TestMethod]
public void EqOrAbove()
{
var planBuilder = new ExecutionPlanBuilder(_localDataSources.Values, this);
var planBuilder = new ExecutionPlanBuilder(new SessionContext(_localDataSources, this), this);

var query = @"
WITH account_hierarchical(accountid, parentaccountid) AS (
Expand Down
Loading

0 comments on commit 26994bc

Please sign in to comment.