diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index b497c44da..e734fcc67 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -1,9 +1,15 @@ name: SingleStore EntityFramework Core -on: [push] +on: + pull_request: + types: [opened, synchronize, reopened] + push: + branches: [main] + workflow_call: + workflow_dispatch: env: - DOTNET_VERSION: 8.0.405 + DOTNET_VERSION: 9.0.101 LICENSE_KEY: ${{ secrets.LICENSE_KEY }} SQL_USER_PASSWORD: ${{ secrets.SQL_USER_PASSWORD }} S2MS_API_KEY: ${{ secrets.S2MS_API_KEY }} @@ -115,13 +121,13 @@ jobs: run: dotnet build SingleStore.EFCore.sln -c Release - name: Run Unit Tests - run: dotnet test test/EFCore.SingleStore.Tests -f net8.0 -c Release --no-build + run: dotnet test test/EFCore.SingleStore.Tests -f net9.0 -c Release --no-build - name: Rebuild migrations run: pwsh ./test/EFCore.SingleStore.IntegrationTests/scripts/rebuild.ps1 - name: Run Integration Tests - run: dotnet test test/EFCore.SingleStore.IntegrationTests -f net8.0 -c Release --no-build + run: dotnet test test/EFCore.SingleStore.IntegrationTests -f net9.0 -c Release --no-build - name: Run Functional Tests ${{ matrix.singlestore_version }} - ${{ matrix.func_test_script }} run: ${{ matrix.func_test_script }} @@ -161,13 +167,13 @@ jobs: run: dotnet build SingleStore.EFCore.sln -c Release - name: Run EFCore.SingleStore.Tests - run: .\.github\workflows\test_setup\run-test-windows.ps1 -test_block EFCore.SingleStore.Tests -target_framework net8.0 + run: .\.github\workflows\test_setup\run-test-windows.ps1 -test_block EFCore.SingleStore.Tests -target_framework net9.0 - name: Rebuild migrations run: .\test\EFCore.SingleStore.IntegrationTests\scripts\rebuild.ps1 - name: Run EFCore.SingleStore.IntegrationTests - run: .\.github\workflows\test_setup\run-test-windows.ps1 -test_block EFCore.SingleStore.IntegrationTests -target_framework net8.0 + run: .\.github\workflows\test_setup\run-test-windows.ps1 -test_block EFCore.SingleStore.IntegrationTests -target_framework net9.0 - name: Run Functional Test Block run: ${{ matrix.func_test_block_path }} diff --git a/.github/workflows/test_setup/run-functional-tests1.ps1 b/.github/workflows/test_setup/run-functional-tests1.ps1 index 712939ef1..ddec77530 100644 --- a/.github/workflows/test_setup/run-functional-tests1.ps1 +++ b/.github/workflows/test_setup/run-functional-tests1.ps1 @@ -1,124 +1,124 @@ cd test\EFCore.SingleStore.FunctionalTests\ -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsQuerySingleStoreTest.' $TOTAL_FAILURES = ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.Ef6GroupBySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.Ef6GroupBySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.CompositeKeysQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.CompositeKeysQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.CompositeKeysSplitQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.CompositeKeysSplitQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.DateOnlyQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.DateOnlyQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.EscapesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.EscapesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.EntitySplittingQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.EntitySplittingQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FromSqlQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FromSqlQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FieldsOnlyLoadSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FieldsOnlyLoadSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FiltersInheritanceQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FiltersInheritanceQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FromSqlSprocQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FromSqlSprocQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FunkyDataQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FunkyDataQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.GearsOfWarFromSqlQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.GearsOfWarFromSqlQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.GearsOfWarQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.GearsOfWarQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.IncludeOneToOneSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.IncludeOneToOneSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.InheritanceQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.InheritanceQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftPocoChangeTrackingTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftPocoChangeTrackingTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.BoolIndexingOptimizationDisabledSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.BoolIndexingOptimizationDisabledSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftDomChangeTrackingTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftDomChangeTrackingTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftDomQueryTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftDomQueryTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.InheritanceRelationshipsQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.InheritanceRelationshipsQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsSharedTypeQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsSharedTypeQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsSplitQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsSplitQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTFiltersInheritanceQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTFiltersInheritanceQuerySingleStoreTest.' $TOTAL_FAILURES = ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTGearsOfWarQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTGearsOfWarQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTInheritanceQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTInheritanceQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTRelationshipsQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTRelationshipsQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.WarningsSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.WarningsSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ConcurrencyDetectorDisabledSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ConcurrencyDetectorDisabledSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.CompositeKeyEndToEndSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.CompositeKeyEndToEndSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.CommandInterceptionSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.CommandInterceptionSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.BuiltInDataTypesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.BuiltInDataTypesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ConnectionSettingsSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ConnectionSettingsSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~ConnectionInterceptionSingleStoreTest' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~ConnectionInterceptionSingleStoreTest' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ConferencePlannerSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ConferencePlannerSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ConcurrencyDetectorEnabledSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ConcurrencyDetectorEnabledSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.DataAnnotationSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.DataAnnotationSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.CustomConvertersSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.CustomConvertersSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ConvertToProviderTypesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ConvertToProviderTypesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ConnectionSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ConnectionSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.EntitySplittingSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.EntitySplittingSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NonSharedModelUpdatesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NonSharedModelUpdatesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.DesignTimeSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.DesignTimeSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.DefaultValuesTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.DefaultValuesTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.DatabindingSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.DatabindingSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~FindSingleStoreTest' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~FindSingleStoreTest' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FieldMappingSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FieldMappingSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ExistingConnectionSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ExistingConnectionSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.GraphUpdatesSingleStoreTestBase.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.GraphUpdatesSingleStoreTestBase.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.GraphUpdatesSingleStoreClientNoActionTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.GraphUpdatesSingleStoreClientNoActionTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.GraphUpdatesSingleStoreClientCascadeTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.GraphUpdatesSingleStoreClientCascadeTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FullInfrastructureMigrationsTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FullInfrastructureMigrationsTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.LoggingSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.LoggingSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.LoadSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.LoadSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.LazyLoadProxySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.LazyLoadProxySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.KeysWithConvertersSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.KeysWithConvertersSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ManyToManyLoadSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ManyToManyLoadSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ManyToManyTrackingSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ManyToManyTrackingSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.MaterializationInterceptionSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.MaterializationInterceptionSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) diff --git a/.github/workflows/test_setup/run-functional-tests2.ps1 b/.github/workflows/test_setup/run-functional-tests2.ps1 index 1ccdb887a..56bc5c28c 100644 --- a/.github/workflows/test_setup/run-functional-tests2.ps1 +++ b/.github/workflows/test_setup/run-functional-tests2.ps1 @@ -1,147 +1,156 @@ cd test\EFCore.SingleStore.FunctionalTests\ -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsSplitSharedTypeQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsSplitSharedTypeQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsSharedTypeQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsSharedTypeQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftPocoQueryTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftPocoQueryTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftStringChangeTrackingTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftStringChangeTrackingTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftStringQueryTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftStringQueryTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftDomChangeTrackingTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftDomChangeTrackingTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftDomQueryTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftDomQueryTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftPocoChangeTrackingTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftPocoChangeTrackingTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftPocoQueryTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftPocoQueryTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftStringChangeTrackingTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftStringChangeTrackingTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftStringQueryTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftStringQueryTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ManyToManyHeterogeneousQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.MappingQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.MappingQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.MatchQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.MatchQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAsTrackingQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAsTrackingQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAsNoTrackingQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAsNoTrackingQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAggregateQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAggregateQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAggregateOperatorsQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAggregateOperatorsQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindDbFunctionsQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindDbFunctionsQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindCompiledQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindCompiledQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindChangeTrackingQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindChangeTrackingQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindGroupByQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindGroupByQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindFunctionsQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindFunctionsQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindEFPropertyIncludeQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindEFPropertyIncludeQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindKeylessEntitiesQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindKeylessEntitiesQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindJoinQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindJoinQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindIncludeQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindIncludeQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindIncludeNoTrackingQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindIncludeNoTrackingQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindQueryFiltersQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindQueryFiltersQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindMiscellaneousQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindMiscellaneousQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSelectQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSelectQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSetOperationsQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSetOperationsQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSplitIncludeNoTrackingQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSplitIncludeNoTrackingQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSplitIncludeQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSplitIncludeQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSqlQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSqlQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindStringIncludeQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindStringIncludeQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindWhereQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindWhereQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NullKeysSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NullKeysSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NullSemanticsQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NullSemanticsQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.OwnedEntityQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.OwnedEntityQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.OwnedQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.OwnedQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.QueryFilterFuncletizationSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.QueryFilterFuncletizationSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindNavigationsQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindNavigationsQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SharedTypeQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SharedTypeQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.QueryNoClientEvalSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.QueryNoClientEvalSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SqlExecutorSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SimpleQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ToSqlQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SqlExecutorSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCGearsOfWarQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ToSqlQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCFiltersInheritanceQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCGearsOfWarQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCInheritanceQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCFiltersInheritanceQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCManyToManyNoTrackingQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCInheritanceQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCManyToManyQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCManyToManyNoTrackingQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCRelationshipsQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCManyToManyQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindBulkUpdatesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCRelationshipsQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCFiltersInheritanceBulkUpdatesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindBulkUpdatesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCInheritanceBulkUpdatesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCFiltersInheritanceBulkUpdatesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTFiltersInheritanceBulkUpdatesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCInheritanceBulkUpdatesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTInheritanceBulkUpdatesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTFiltersInheritanceBulkUpdatesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexTypeBulkUpdatesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTInheritanceBulkUpdatesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexTypesTrackingSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexTypeBulkUpdatesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexTypeQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexTypesTrackingSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.BadDataJsonDeserializationSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexTypeQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocComplexTypeQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.BadDataJsonDeserializationSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocAdvancedMappingsQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocComplexTypeQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.OperatorsProceduralSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocAdvancedMappingsQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.OperatorsQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.OperatorsProceduralSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.OptionalDependentQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.OperatorsQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SqlQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.OptionalDependentQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPHInheritanceQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SqlQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreConnectionStringOptionsValidatorTests.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPHInheritanceQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocComplexTypeQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreConnectionStringOptionsValidatorTests.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocJsonQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocManyToManyQuerySingleStoreTest.' +$TOTAL_FAILURES += ($LASTEXITCODE -ne 0) +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocQueryFiltersQuerySingleStoreTest.' +$TOTAL_FAILURES += ($LASTEXITCODE -ne 0) +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocQuerySplittingQuerySingleStoreTest.' +$TOTAL_FAILURES += ($LASTEXITCODE -ne 0) +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocMiscellaneousQuerySingleStoreTest.' +$TOTAL_FAILURES += ($LASTEXITCODE -ne 0) + cd ..\..\ diff --git a/.github/workflows/test_setup/run-functional-tests3.ps1 b/.github/workflows/test_setup/run-functional-tests3.ps1 index e46f3c35c..55a294e40 100644 --- a/.github/workflows/test_setup/run-functional-tests3.ps1 +++ b/.github/workflows/test_setup/run-functional-tests3.ps1 @@ -1,78 +1,78 @@ cd test\EFCore.SingleStore.FunctionalTests\ -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.MigrationsSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.MigrationsSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.MigrationsInfrastructureSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.MigrationsInfrastructureSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.OptimisticConcurrencySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.OptimisticConcurrencySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NotificationEntitiesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NotificationEntitiesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindQueryTaggingQuerySingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindQueryTaggingQuerySingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.MusicStoreSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.MusicStoreSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.PropertyValuesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.PropertyValuesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.OverzealousInitializationSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.OverzealousInitializationSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreDatabaseModelFactoryTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreDatabaseModelFactoryTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.StoreValueGenerationSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.StoreValueGenerationSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreTypeMappingTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreTypeMappingTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.StoredProcedureUpdateSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.StoredProcedureUpdateSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreJsonMicrosoftTypeMappingTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreJsonMicrosoftTypeMappingTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreJsonNewtonsoftTypeMappingTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreJsonNewtonsoftTypeMappingTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreUpdateSqlGeneratorTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreUpdateSqlGeneratorTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~SaveChangesInterceptionSingleStoreTest' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~SaveChangesInterceptionSingleStoreTest' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SeedingSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SeedingSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SerializationSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SerializationSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreMigrationsSqlGeneratorTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreMigrationsSqlGeneratorTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreComplianceTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreComplianceTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreApiConsistencyTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreApiConsistencyTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.StoreGeneratedSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.StoreGeneratedSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.StoreGeneratedFixupSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.StoreGeneratedFixupSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SpatialSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SpatialSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreServiceCollectionExtensionsTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreServiceCollectionExtensionsTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreNetTopologySuiteApiConsistencyTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreNetTopologySuiteApiConsistencyTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TableSplittingSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TableSplittingSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTTableSplittingSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTTableSplittingSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TransactionInterceptionSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TransactionInterceptionSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TransactionSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TransactionSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TwoDatabasesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TwoDatabasesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.UpdatesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.UpdatesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ValueConvertersEndToEndSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ValueConvertersEndToEndSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.WithConstructorsSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.WithConstructorsSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FiltersInheritanceBulkUpdatesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FiltersInheritanceBulkUpdatesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.InheritanceBulkUpdatesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.InheritanceBulkUpdatesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) -dotnet.exe test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NonSharedModelBulkUpdatesSingleStoreTest.' +dotnet.exe test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NonSharedModelBulkUpdatesSingleStoreTest.' $TOTAL_FAILURES += ($LASTEXITCODE -ne 0) cd ..\..\ diff --git a/.github/workflows/test_setup/run_functional_tests1.sh b/.github/workflows/test_setup/run_functional_tests1.sh index f4e5b9c34..5b817f0b8 100755 --- a/.github/workflows/test_setup/run_functional_tests1.sh +++ b/.github/workflows/test_setup/run_functional_tests1.sh @@ -1,170 +1,171 @@ cd test/EFCore.SingleStore.FunctionalTests/ -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TwoDatabasesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TwoDatabasesSingleStoreTest.' ((TOTAL_FAILURES = $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.CompositeKeysQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.CompositeKeysQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.Ef6GroupBySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.Ef6GroupBySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.CompositeKeysSplitQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.CompositeKeysSplitQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.DateOnlyQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.DateOnlyQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.EscapesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.EscapesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.EntitySplittingQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.EntitySplittingQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FromSqlQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FromSqlQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FieldsOnlyLoadSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FieldsOnlyLoadSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FiltersInheritanceQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FiltersInheritanceQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FromSqlSprocQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FromSqlSprocQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FunkyDataQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FunkyDataQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.GearsOfWarFromSqlQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.GearsOfWarFromSqlQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.GearsOfWarQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.GearsOfWarQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.IncludeOneToOneSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.IncludeOneToOneSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.InheritanceQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.InheritanceQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftPocoChangeTrackingTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftPocoChangeTrackingTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.BoolIndexingOptimizationDisabledSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.BoolIndexingOptimizationDisabledSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftDomChangeTrackingTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftDomChangeTrackingTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftDomQueryTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftDomQueryTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.InheritanceRelationshipsQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.InheritanceRelationshipsQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsSharedTypeQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsSharedTypeQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsSplitQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsSplitQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsSplitSharedTypeQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsCollectionsSplitSharedTypeQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsSharedTypeQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexNavigationsSharedTypeQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftPocoQueryTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftPocoQueryTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftStringChangeTrackingTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftStringChangeTrackingTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftStringQueryTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonMicrosoftStringQueryTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftDomChangeTrackingTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftDomChangeTrackingTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftDomQueryTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftDomQueryTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftPocoChangeTrackingTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftPocoChangeTrackingTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftPocoQueryTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftPocoQueryTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftStringChangeTrackingTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftStringChangeTrackingTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftStringQueryTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.JsonNewtonsoftStringQueryTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ManyToManyHeterogeneousQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.MappingQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.MappingQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.MatchQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.MatchQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAsTrackingQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAsTrackingQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAsNoTrackingQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAsNoTrackingQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAggregateQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAggregateQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAggregateOperatorsQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindAggregateOperatorsQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindDbFunctionsQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindDbFunctionsQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindCompiledQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindCompiledQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindChangeTrackingQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindChangeTrackingQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindGroupByQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindGroupByQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindFunctionsQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindFunctionsQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindEFPropertyIncludeQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindEFPropertyIncludeQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindKeylessEntitiesQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindKeylessEntitiesQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindJoinQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindJoinQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindIncludeQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindIncludeQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindIncludeNoTrackingQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindIncludeNoTrackingQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindQueryFiltersQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindQueryFiltersQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindMiscellaneousQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindMiscellaneousQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSelectQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSelectQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSetOperationsQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSetOperationsQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSplitIncludeNoTrackingQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSplitIncludeNoTrackingQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSplitIncludeQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSplitIncludeQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSqlQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindSqlQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindStringIncludeQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindStringIncludeQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindWhereQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindWhereQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NullKeysSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NullKeysSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NullSemanticsQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NullSemanticsQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.OwnedEntityQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.OwnedEntityQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.OwnedQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.OwnedQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.QueryFilterFuncletizationSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.QueryFilterFuncletizationSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindNavigationsQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindNavigationsQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SharedTypeQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SharedTypeQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.QueryNoClientEvalSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.QueryNoClientEvalSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SqlExecutorSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SimpleQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ToSqlQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SqlExecutorSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.WithConstructorsSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ToSqlQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FiltersInheritanceBulkUpdatesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.WithConstructorsSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.InheritanceBulkUpdatesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FiltersInheritanceBulkUpdatesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NonSharedModelBulkUpdatesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.InheritanceBulkUpdatesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindBulkUpdatesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NonSharedModelBulkUpdatesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCFiltersInheritanceBulkUpdatesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindBulkUpdatesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCInheritanceBulkUpdatesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCFiltersInheritanceBulkUpdatesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTFiltersInheritanceBulkUpdatesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCInheritanceBulkUpdatesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTInheritanceBulkUpdatesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTFiltersInheritanceBulkUpdatesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreModelBuilderGenericTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTInheritanceBulkUpdatesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindStringComparisonFunctionsQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) + cd ../../ if [[ $TOTAL_FAILURES -ne 0 ]]; then diff --git a/.github/workflows/test_setup/run_functional_tests2.sh b/.github/workflows/test_setup/run_functional_tests2.sh index 40e49cd6f..12bf7cc4a 100755 --- a/.github/workflows/test_setup/run_functional_tests2.sh +++ b/.github/workflows/test_setup/run_functional_tests2.sh @@ -1,178 +1,189 @@ cd test/EFCore.SingleStore.FunctionalTests/ -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FullInfrastructureMigrationsTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FullInfrastructureMigrationsTest.' ((TOTAL_FAILURES = $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCGearsOfWarQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCGearsOfWarQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCFiltersInheritanceQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCFiltersInheritanceQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCInheritanceQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCInheritanceQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCManyToManyNoTrackingQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCManyToManyNoTrackingQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCManyToManyQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCManyToManyQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCRelationshipsQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPCRelationshipsQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTFiltersInheritanceQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTFiltersInheritanceQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTGearsOfWarQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTGearsOfWarQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTInheritanceQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTInheritanceQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTRelationshipsQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTRelationshipsQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.WarningsSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.WarningsSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ConcurrencyDetectorDisabledSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ConcurrencyDetectorDisabledSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.CompositeKeyEndToEndSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.CompositeKeyEndToEndSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.CommandInterceptionSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.CommandInterceptionSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.BuiltInDataTypesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.BuiltInDataTypesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ConnectionSettingsSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ConnectionSettingsSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~ConnectionInterceptionSingleStoreTest' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~ConnectionInterceptionSingleStoreTest' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ConferencePlannerSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ConferencePlannerSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ConcurrencyDetectorEnabledSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ConcurrencyDetectorEnabledSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.DataAnnotationSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.DataAnnotationSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.CustomConvertersSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.CustomConvertersSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ConvertToProviderTypesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ConvertToProviderTypesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ConnectionSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ConnectionSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.EntitySplittingSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.EntitySplittingSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NonSharedModelUpdatesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NonSharedModelUpdatesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.DesignTimeSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.DesignTimeSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.DefaultValuesTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.DefaultValuesTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.DatabindingSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.DatabindingSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~FindSingleStoreTest' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~FindSingleStoreTest' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.FieldMappingSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.FieldMappingSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ExistingConnectionSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ExistingConnectionSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.GraphUpdatesSingleStoreTestBase.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.GraphUpdatesSingleStoreTestBase.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.GraphUpdatesSingleStoreClientNoActionTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.GraphUpdatesSingleStoreClientNoActionTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.GraphUpdatesSingleStoreClientCascadeTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.GraphUpdatesSingleStoreClientCascadeTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.LoggingSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.LoggingSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.LoadSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.LoadSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.LazyLoadProxySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.LazyLoadProxySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.KeysWithConvertersSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.KeysWithConvertersSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ManyToManyLoadSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ManyToManyLoadSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ManyToManyTrackingSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ManyToManyTrackingSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.MaterializationInterceptionSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.MaterializationInterceptionSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.MigrationsSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.MigrationsSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.MigrationsInfrastructureSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.MigrationsInfrastructureSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.OptimisticConcurrencySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.OptimisticConcurrencySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NotificationEntitiesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NotificationEntitiesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindQueryTaggingQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.NorthwindQueryTaggingQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.MusicStoreSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.MusicStoreSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.PropertyValuesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.PropertyValuesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.OverzealousInitializationSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.OverzealousInitializationSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreDatabaseModelFactoryTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreDatabaseModelFactoryTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.StoreValueGenerationSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.StoreValueGenerationSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreTypeMappingTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreTypeMappingTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.StoredProcedureUpdateSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.StoredProcedureUpdateSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreJsonMicrosoftTypeMappingTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreJsonMicrosoftTypeMappingTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreJsonNewtonsoftTypeMappingTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreJsonNewtonsoftTypeMappingTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreUpdateSqlGeneratorTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreUpdateSqlGeneratorTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~SaveChangesInterceptionSingleStoreTest' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~SaveChangesInterceptionSingleStoreTest' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SeedingSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SeedingSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SerializationSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SerializationSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreMigrationsSqlGeneratorTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreMigrationsSqlGeneratorTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreComplianceTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreComplianceTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreApiConsistencyTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreApiConsistencyTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.StoreGeneratedSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.StoreGeneratedSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.StoreGeneratedFixupSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.StoreGeneratedFixupSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SpatialSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SpatialSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreServiceCollectionExtensionsTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreServiceCollectionExtensionsTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreNetTopologySuiteApiConsistencyTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreNetTopologySuiteApiConsistencyTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TableSplittingSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TableSplittingSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTTableSplittingSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPTTableSplittingSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TransactionInterceptionSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TransactionInterceptionSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TransactionSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TransactionSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ValueConvertersEndToEndSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ValueConvertersEndToEndSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.UpdatesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.UpdatesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexTypeBulkUpdatesSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexTypeBulkUpdatesSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexTypesTrackingSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexTypesTrackingSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexTypeQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.ComplexTypeQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.BadDataJsonDeserializationSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.BadDataJsonDeserializationSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocComplexTypeQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocComplexTypeQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocAdvancedMappingsQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocAdvancedMappingsQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.OperatorsProceduralSingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.OperatorsProceduralSingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.OperatorsQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.OperatorsQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.OptionalDependentQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.OptionalDependentQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SqlQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SqlQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.TPHInheritanceQuerySingleStoreTest.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.TPHInheritanceQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) -dotnet test -f net8.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreConnectionStringOptionsValidatorTests.' +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.SingleStoreConnectionStringOptionsValidatorTests.' +((TOTAL_FAILURES += $? != 0)) +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocComplexTypeQuerySingleStoreTest.' +((TOTAL_FAILURES += $? != 0)) +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocJsonQuerySingleStoreTest.' +((TOTAL_FAILURES += $? != 0)) +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocManyToManyQuerySingleStoreTest.' +((TOTAL_FAILURES += $? != 0)) +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocQueryFiltersQuerySingleStoreTest.' +((TOTAL_FAILURES += $? != 0)) +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocQuerySplittingQuerySingleStoreTest.' +((TOTAL_FAILURES += $? != 0)) +dotnet test -f net9.0 -c Release --no-build --filter 'FullyQualifiedName~.AdHocMiscellaneousQuerySingleStoreTest.' ((TOTAL_FAILURES += $? != 0)) - cd ../../ diff --git a/Dependencies.targets b/Dependencies.targets deleted file mode 100644 index 2238f6241..000000000 --- a/Dependencies.targets +++ /dev/null @@ -1,51 +0,0 @@ - - - [8.0.13,8.0.999] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index b68a0b34d..c69eb8316 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -18,6 +18,7 @@ Copyright 2017-2022 © Pomelo Foundation. Copyright $([System.DateTime]::Now.Year) © SingleStore Inc. singlestore_logo.png true + true latest true MIT @@ -32,9 +33,9 @@ net8.0 - net8.0 + net9.0 net8.0 - net8.0 + net9.0 net8.0 diff --git a/Directory.Build.targets b/Directory.Build.targets deleted file mode 100644 index 46b45a2ad..000000000 --- a/Directory.Build.targets +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 000000000..4424c1ae8 --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,59 @@ + + + + [9.0.0,9.0.999] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pomelo.EFCore.SingleStore.sln b/Pomelo.EFCore.SingleStore.sln deleted file mode 100644 index cf2435fd0..000000000 --- a/Pomelo.EFCore.SingleStore.sln +++ /dev/null @@ -1,102 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29209.152 -MinimumVisualStudioVersion = 15.0.26730.03 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7E8380DB-F015-407B-99C2-26404E551673}" - ProjectSection(SolutionItems) = preProject - src\Directory.Build.props = src\Directory.Build.props - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6EC4A4AA-D865-4EF9-BD52-C2D0AA075CDF}" - ProjectSection(SolutionItems) = preProject - test\Directory.Build.props = test\Directory.Build.props - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F0BD39F9-2120-45AD-9FA0-9B080E38DAE5}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - Development.props.sample = Development.props.sample - Directory.Build.props = Directory.Build.props - Directory.Build.targets = Directory.Build.targets - global.json = global.json - Version.props = Version.props - README.md = README.md - dotnet-tools.json = dotnet-tools.json - Dependencies.targets = Dependencies.targets - NuGet.config = NuGet.config - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFCore.SingleStore", "src\EFCore.SingleStore\EFCore.SingleStore.csproj", "{FC2779F0-2A2A-4BE2-B5A8-FDA31A4A404A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFCore.SingleStore.Tests", "test\EFCore.SingleStore.Tests\EFCore.SingleStore.Tests.csproj", "{DE5212AE-4C17-4702-851D-0F1FC0D32E3C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFCore.SingleStore.FunctionalTests", "test\EFCore.SingleStore.FunctionalTests\EFCore.SingleStore.FunctionalTests.csproj", "{E7D9C7D9-1CDD-4745-975D-9752AE095418}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFCore.SingleStore.IntegrationTests", "test\EFCore.SingleStore.IntegrationTests\EFCore.SingleStore.IntegrationTests.csproj", "{FF3B4140-42B3-4127-96D8-681858A5387B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EFCore.SingleStore.NTS", "src\EFCore.SingleStore.NTS\EFCore.SingleStore.NTS.csproj", "{7A727AB9-38F0-40E5-B134-7AC830B8D1EC}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EFCore.SingleStore.Json.Microsoft", "src\EFCore.SingleStore.Json.Microsoft\EFCore.SingleStore.Json.Microsoft.csproj", "{C27A301A-F47E-4584-88DB-0474AE446405}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EFCore.SingleStore.Json.Newtonsoft", "src\EFCore.SingleStore.Json.Newtonsoft\EFCore.SingleStore.Json.Newtonsoft.csproj", "{BBA0BB73-3D75-4F08-992F-A2CF9F52E7AD}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QueryBaselineUpdater", "tools\QueryBaselineUpdater\QueryBaselineUpdater.csproj", "{57293669-2ADF-448F-AE22-B49BAC4A335E}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{DD543966-92C7-4FE6-B953-3270E3E11D46}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {FC2779F0-2A2A-4BE2-B5A8-FDA31A4A404A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FC2779F0-2A2A-4BE2-B5A8-FDA31A4A404A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FC2779F0-2A2A-4BE2-B5A8-FDA31A4A404A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FC2779F0-2A2A-4BE2-B5A8-FDA31A4A404A}.Release|Any CPU.Build.0 = Release|Any CPU - {DE5212AE-4C17-4702-851D-0F1FC0D32E3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DE5212AE-4C17-4702-851D-0F1FC0D32E3C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DE5212AE-4C17-4702-851D-0F1FC0D32E3C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DE5212AE-4C17-4702-851D-0F1FC0D32E3C}.Release|Any CPU.Build.0 = Release|Any CPU - {E7D9C7D9-1CDD-4745-975D-9752AE095418}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E7D9C7D9-1CDD-4745-975D-9752AE095418}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E7D9C7D9-1CDD-4745-975D-9752AE095418}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E7D9C7D9-1CDD-4745-975D-9752AE095418}.Release|Any CPU.Build.0 = Release|Any CPU - {FF3B4140-42B3-4127-96D8-681858A5387B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FF3B4140-42B3-4127-96D8-681858A5387B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FF3B4140-42B3-4127-96D8-681858A5387B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FF3B4140-42B3-4127-96D8-681858A5387B}.Release|Any CPU.Build.0 = Release|Any CPU - {7A727AB9-38F0-40E5-B134-7AC830B8D1EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7A727AB9-38F0-40E5-B134-7AC830B8D1EC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7A727AB9-38F0-40E5-B134-7AC830B8D1EC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7A727AB9-38F0-40E5-B134-7AC830B8D1EC}.Release|Any CPU.Build.0 = Release|Any CPU - {C27A301A-F47E-4584-88DB-0474AE446405}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C27A301A-F47E-4584-88DB-0474AE446405}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C27A301A-F47E-4584-88DB-0474AE446405}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C27A301A-F47E-4584-88DB-0474AE446405}.Release|Any CPU.Build.0 = Release|Any CPU - {BBA0BB73-3D75-4F08-992F-A2CF9F52E7AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BBA0BB73-3D75-4F08-992F-A2CF9F52E7AD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BBA0BB73-3D75-4F08-992F-A2CF9F52E7AD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BBA0BB73-3D75-4F08-992F-A2CF9F52E7AD}.Release|Any CPU.Build.0 = Release|Any CPU - {57293669-2ADF-448F-AE22-B49BAC4A335E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {57293669-2ADF-448F-AE22-B49BAC4A335E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {57293669-2ADF-448F-AE22-B49BAC4A335E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {57293669-2ADF-448F-AE22-B49BAC4A335E}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {FC2779F0-2A2A-4BE2-B5A8-FDA31A4A404A} = {7E8380DB-F015-407B-99C2-26404E551673} - {DE5212AE-4C17-4702-851D-0F1FC0D32E3C} = {6EC4A4AA-D865-4EF9-BD52-C2D0AA075CDF} - {E7D9C7D9-1CDD-4745-975D-9752AE095418} = {6EC4A4AA-D865-4EF9-BD52-C2D0AA075CDF} - {FF3B4140-42B3-4127-96D8-681858A5387B} = {6EC4A4AA-D865-4EF9-BD52-C2D0AA075CDF} - {7A727AB9-38F0-40E5-B134-7AC830B8D1EC} = {7E8380DB-F015-407B-99C2-26404E551673} - {C27A301A-F47E-4584-88DB-0474AE446405} = {7E8380DB-F015-407B-99C2-26404E551673} - {BBA0BB73-3D75-4F08-992F-A2CF9F52E7AD} = {7E8380DB-F015-407B-99C2-26404E551673} - {57293669-2ADF-448F-AE22-B49BAC4A335E} = {DD543966-92C7-4FE6-B953-3270E3E11D46} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {48E34212-4B35-4A81-92F9-3C25D4E76D6C} - EndGlobalSection -EndGlobal diff --git a/Pomelo.snk b/Pomelo.snk deleted file mode 100644 index 2d064c242..000000000 Binary files a/Pomelo.snk and /dev/null differ diff --git a/SingleStore.EFCore.sln b/SingleStore.EFCore.sln index c85d3382c..4c91165e8 100644 --- a/SingleStore.EFCore.sln +++ b/SingleStore.EFCore.sln @@ -17,12 +17,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution .editorconfig = .editorconfig Development.props.sample = Development.props.sample Directory.Build.props = Directory.Build.props - Directory.Build.targets = Directory.Build.targets global.json = global.json Version.props = Version.props README.md = README.md dotnet-tools.json = dotnet-tools.json - Dependencies.targets = Dependencies.targets + Directory.Packages.props = Directory.Packages.props EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFCore.SingleStore", "src\EFCore.SingleStore\EFCore.SingleStore.csproj", "{FC2779F0-2A2A-4BE2-B5A8-FDA31A4A404A}" diff --git a/Version.props b/Version.props index acf5578e2..1ca9b52d5 100644 --- a/Version.props +++ b/Version.props @@ -7,8 +7,8 @@ - "-rtm" - Code quality production ready, major release - "-servicing" - Code quality production ready, mainly bugfixes --> - 8.0.3 - servicing + 9.0.0 + rtm - true true diff --git a/dotnet-tools.json b/dotnet-tools.json index a6a3adb61..305bdb11d 100644 --- a/dotnet-tools.json +++ b/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "dotnet-ef": { - "version": "8.0.13", + "version": "9.0.0", "commands": [ "dotnet-ef" ] diff --git a/global.json b/global.json index b7e335716..db8627a23 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100", + "version": "9.0.100", "allowPrerelease": false, "rollForward": "latestFeature" } diff --git a/src/EFCore.SingleStore.Json.Microsoft/EFCore.SingleStore.Json.Microsoft.csproj b/src/EFCore.SingleStore.Json.Microsoft/EFCore.SingleStore.Json.Microsoft.csproj index a843cbfb9..2f83894c1 100644 --- a/src/EFCore.SingleStore.Json.Microsoft/EFCore.SingleStore.Json.Microsoft.csproj +++ b/src/EFCore.SingleStore.Json.Microsoft/EFCore.SingleStore.Json.Microsoft.csproj @@ -60,7 +60,6 @@ - @@ -69,7 +68,7 @@ - + diff --git a/src/EFCore.SingleStore.Json.Newtonsoft/EFCore.SingleStore.Json.Newtonsoft.csproj b/src/EFCore.SingleStore.Json.Newtonsoft/EFCore.SingleStore.Json.Newtonsoft.csproj index 06f673a8e..6980b622c 100644 --- a/src/EFCore.SingleStore.Json.Newtonsoft/EFCore.SingleStore.Json.Newtonsoft.csproj +++ b/src/EFCore.SingleStore.Json.Newtonsoft/EFCore.SingleStore.Json.Newtonsoft.csproj @@ -33,7 +33,7 @@ - + @@ -67,7 +67,6 @@ - diff --git a/src/EFCore.SingleStore.NTS/EFCore.SingleStore.NTS.csproj b/src/EFCore.SingleStore.NTS/EFCore.SingleStore.NTS.csproj index c9465c7a0..b4802f018 100644 --- a/src/EFCore.SingleStore.NTS/EFCore.SingleStore.NTS.csproj +++ b/src/EFCore.SingleStore.NTS/EFCore.SingleStore.NTS.csproj @@ -33,7 +33,7 @@ - + @@ -67,7 +67,6 @@ - diff --git a/src/EFCore.SingleStore.NTS/Query/Internal/SingleStoreGeometryMemberTranslator.cs b/src/EFCore.SingleStore.NTS/Query/Internal/SingleStoreGeometryMemberTranslator.cs index fd5eb8ec5..828d0ae85 100644 --- a/src/EFCore.SingleStore.NTS/Query/Internal/SingleStoreGeometryMemberTranslator.cs +++ b/src/EFCore.SingleStore.NTS/Query/Internal/SingleStoreGeometryMemberTranslator.cs @@ -87,7 +87,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member { new CaseWhenClause( _sqlExpressionFactory.IsNull(instance), - _sqlExpressionFactory.Constant(null, RelationalTypeMapping.NullMapping)) + _sqlExpressionFactory.Constant(null, returnType, resultTypeMapping)) }, sqlExpression); } diff --git a/src/EFCore.SingleStore.NTS/Query/Internal/SingleStoreLineStringMemberTranslator.cs b/src/EFCore.SingleStore.NTS/Query/Internal/SingleStoreLineStringMemberTranslator.cs index 7d1dd9447..510e3a26e 100644 --- a/src/EFCore.SingleStore.NTS/Query/Internal/SingleStoreLineStringMemberTranslator.cs +++ b/src/EFCore.SingleStore.NTS/Query/Internal/SingleStoreLineStringMemberTranslator.cs @@ -88,7 +88,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member { new CaseWhenClause( _sqlExpressionFactory.IsNull(instance), - _sqlExpressionFactory.Constant(null, RelationalTypeMapping.NullMapping)) + _sqlExpressionFactory.Constant(null, returnType, resultTypeMapping)) }, sqlExpression); } diff --git a/src/EFCore.SingleStore.NTS/Query/Internal/SingleStoreMultiLineStringMemberTranslator.cs b/src/EFCore.SingleStore.NTS/Query/Internal/SingleStoreMultiLineStringMemberTranslator.cs index e81900187..a2cfe6353 100644 --- a/src/EFCore.SingleStore.NTS/Query/Internal/SingleStoreMultiLineStringMemberTranslator.cs +++ b/src/EFCore.SingleStore.NTS/Query/Internal/SingleStoreMultiLineStringMemberTranslator.cs @@ -46,7 +46,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member { new CaseWhenClause( _sqlExpressionFactory.IsNull(instance), - _sqlExpressionFactory.Constant(null, RelationalTypeMapping.NullMapping)) + _sqlExpressionFactory.Constant(null, returnType)) }, sqlExpression); } diff --git a/src/EFCore.SingleStore/Design/Internal/SingleStoreAnnotationCodeGenerator.cs b/src/EFCore.SingleStore/Design/Internal/SingleStoreAnnotationCodeGenerator.cs index 9ed684096..86e9975f4 100644 --- a/src/EFCore.SingleStore/Design/Internal/SingleStoreAnnotationCodeGenerator.cs +++ b/src/EFCore.SingleStore/Design/Internal/SingleStoreAnnotationCodeGenerator.cs @@ -13,6 +13,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Utilities; using EntityFrameworkCore.SingleStore.Metadata.Internal; @@ -82,6 +83,12 @@ private static readonly MethodInfo _propertyHasCharSetMethodInfo typeof(PropertyBuilder), typeof(string)); + private static readonly MethodInfo _complexTypePropertyHasCharSetMethodInfo + = typeof(SingleStoreComplexTypePropertyBuilderExtensions).GetRequiredRuntimeMethod( + nameof(SingleStoreComplexTypePropertyBuilderExtensions.HasCharSet), + typeof(ComplexTypePropertyBuilder), + typeof(string)); + public SingleStoreAnnotationCodeGenerator([JetBrains.Annotations.NotNull] AnnotationCodeGeneratorDependencies dependencies) : base(dependencies) { @@ -264,6 +271,13 @@ protected override MethodCallCodeFragment GenerateFluentApi(IProperty property, switch (annotation.Name) { case SingleStoreAnnotationNames.CharSet when annotation.Value is string { Length: > 0 } charSet: + if (property.DeclaringType is IComplexType) + { + return new MethodCallCodeFragment( + _complexTypePropertyHasCharSetMethodInfo, + charSet); + } + return new MethodCallCodeFragment( _propertyHasCharSetMethodInfo, charSet); diff --git a/src/EFCore.SingleStore/EFCore.SingleStore.csproj b/src/EFCore.SingleStore/EFCore.SingleStore.csproj index 3a61616fe..1bed12492 100644 --- a/src/EFCore.SingleStore/EFCore.SingleStore.csproj +++ b/src/EFCore.SingleStore/EFCore.SingleStore.csproj @@ -6,6 +6,8 @@ EntityFrameworkCore.SingleStore EntityFrameworkCore.SingleStore README.md + $(NoWarn);EF9100 + $(NoWarn);CS1591 @@ -50,7 +52,7 @@ - + diff --git a/src/EFCore.SingleStore/Extensions/SingleStoreComplexTypePropertyBuilderExtensions.cs b/src/EFCore.SingleStore/Extensions/SingleStoreComplexTypePropertyBuilderExtensions.cs new file mode 100644 index 000000000..15f4bc40d --- /dev/null +++ b/src/EFCore.SingleStore/Extensions/SingleStoreComplexTypePropertyBuilderExtensions.cs @@ -0,0 +1,46 @@ +// Copyright (c) Pomelo Foundation. All rights reserved. +// Copyright (c) SingleStore Inc. All rights reserved. +// Licensed under the MIT. See LICENSE in the project root for license information. + +using JetBrains.Annotations; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore.Utilities; + +// ReSharper disable once CheckNamespace +namespace Microsoft.EntityFrameworkCore +{ + /// + /// MySQL specific extension methods for . + /// + public static class SingleStoreComplexTypePropertyBuilderExtensions + { + /// + /// Configures the charset for the property's column. + /// + /// The builder for the property being configured. + /// The name of the charset to configure for the property's column. + /// The same builder instance so that multiple calls can be chained. + public static ComplexTypePropertyBuilder HasCharSet( + [NotNull] this ComplexTypePropertyBuilder propertyBuilder, + string charSet) + { + Check.NotNull(propertyBuilder, nameof(propertyBuilder)); + + var property = propertyBuilder.Metadata; + property.SetCharSet(charSet); + + return propertyBuilder; + } + + /// + /// Configures the charset for the property's column. + /// + /// The builder for the property being configured. + /// The name of the charset to configure for the property's column. + /// The same builder instance so that multiple calls can be chained. + public static ComplexTypePropertyBuilder HasCharSet( + [NotNull] this ComplexTypePropertyBuilder propertyBuilder, + string charSet) + => (ComplexTypePropertyBuilder)HasCharSet((ComplexTypePropertyBuilder)propertyBuilder, charSet); + } +} diff --git a/src/EFCore.SingleStore/Extensions/SingleStoreDbContextOptionsBuilderExtensions.cs b/src/EFCore.SingleStore/Extensions/SingleStoreDbContextOptionsBuilderExtensions.cs index 654ec91dd..730057930 100644 --- a/src/EFCore.SingleStore/Extensions/SingleStoreDbContextOptionsBuilderExtensions.cs +++ b/src/EFCore.SingleStore/Extensions/SingleStoreDbContextOptionsBuilderExtensions.cs @@ -55,7 +55,11 @@ public static DbContextOptionsBuilder UseSingleStore( ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension); ConfigureWarnings(optionsBuilder); - mySqlOptionsAction?.Invoke(new SingleStoreDbContextOptionsBuilder(optionsBuilder)); + + var mySqlDbContextOptionsBuilder = new SingleStoreDbContextOptionsBuilder(optionsBuilder) + .TranslateParameterizedCollectionsToConstants(); + + mySqlOptionsAction?.Invoke(mySqlDbContextOptionsBuilder); return optionsBuilder; } @@ -98,7 +102,11 @@ public static DbContextOptionsBuilder UseSingleStore( ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension); ConfigureWarnings(optionsBuilder); - mySqlOptionsAction?.Invoke(new SingleStoreDbContextOptionsBuilder(optionsBuilder)); + + var mySqlDbContextOptionsBuilder = new SingleStoreDbContextOptionsBuilder(optionsBuilder) + .TranslateParameterizedCollectionsToConstants(); + + mySqlOptionsAction?.Invoke(mySqlDbContextOptionsBuilder); return optionsBuilder; } @@ -144,7 +152,11 @@ public static DbContextOptionsBuilder UseSingleStore( ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension); ConfigureWarnings(optionsBuilder); - mySqlOptionsAction?.Invoke(new SingleStoreDbContextOptionsBuilder(optionsBuilder)); + + var mySqlDbContextOptionsBuilder = new SingleStoreDbContextOptionsBuilder(optionsBuilder) + .TranslateParameterizedCollectionsToConstants(); + + mySqlOptionsAction?.Invoke(mySqlDbContextOptionsBuilder); return optionsBuilder; } @@ -189,7 +201,11 @@ public static DbContextOptionsBuilder UseSingleStore( ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension); ConfigureWarnings(optionsBuilder); - mySqlOptionsAction?.Invoke(new SingleStoreDbContextOptionsBuilder(optionsBuilder)); + + var mySqlDbContextOptionsBuilder = new SingleStoreDbContextOptionsBuilder(optionsBuilder) + .TranslateParameterizedCollectionsToConstants(); + + mySqlOptionsAction?.Invoke(mySqlDbContextOptionsBuilder); return optionsBuilder; } diff --git a/src/EFCore.SingleStore/Extensions/SingleStoreDbFunctionsExtensions.cs b/src/EFCore.SingleStore/Extensions/SingleStoreDbFunctionsExtensions.cs index 091071be0..a25b982d5 100644 --- a/src/EFCore.SingleStore/Extensions/SingleStoreDbFunctionsExtensions.cs +++ b/src/EFCore.SingleStore/Extensions/SingleStoreDbFunctionsExtensions.cs @@ -9,6 +9,8 @@ // ReSharper disable once CheckNamespace namespace Microsoft.EntityFrameworkCore { + // TODO: Change method return types for units of `SECOND` and smaller from `int` to `long`. + /// /// Provides CLR methods that get translated to database functions when used in LINQ to Entities queries. /// The methods on this class are accessed via . @@ -167,9 +169,11 @@ public static class SingleStoreDbFunctionsExtensions #endregion ConvertTimeZone + #region DateDiffYear + /// /// Counts the number of year boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(YEAR,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(YEAR,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -183,7 +187,7 @@ public static int DateDiffYear( /// /// Counts the number of year boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(YEAR,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(YEAR,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -197,7 +201,7 @@ public static int DateDiffYear( /// /// Counts the number of year boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(YEAR,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(YEAR,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -211,7 +215,7 @@ public static int DateDiffYear( /// /// Counts the number of year boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(YEAR,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(YEAR,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -225,7 +229,7 @@ public static int DateDiffYear( /// /// Counts the number of year boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(YEAR,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(YEAR,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -239,7 +243,7 @@ public static int DateDiffYear( /// /// Counts the number of year boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(YEAR,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(YEAR,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -251,9 +255,101 @@ public static int DateDiffYear( DateOnly? endDate) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffYear))); + #endregion DateDiffYear + + #region DateDiffQuarter + + /// + /// Counts the number of quarter boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(QUARTER,startDate,endDate)`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of quarter boundaries crossed between the dates. + public static int DateDiffQuarter( + [CanBeNull] this DbFunctions _, + DateTime startDate, + DateTime endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffQuarter))); + + /// + /// Counts the number of quarter boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(QUARTER,startDate,endDate)`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of quarter boundaries crossed between the dates. + public static int? DateDiffQuarter( + [CanBeNull] this DbFunctions _, + DateTime? startDate, + DateTime? endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffQuarter))); + + /// + /// Counts the number of quarter boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(QUARTER,startDate,endDate)`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of quarter boundaries crossed between the dates. + public static int DateDiffQuarter( + [CanBeNull] this DbFunctions _, + DateTimeOffset startDate, + DateTimeOffset endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffQuarter))); + + /// + /// Counts the number of quarter boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(QUARTER,startDate,endDate)`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of quarter boundaries crossed between the dates. + public static int? DateDiffQuarter( + [CanBeNull] this DbFunctions _, + DateTimeOffset? startDate, + DateTimeOffset? endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffQuarter))); + + /// + /// Counts the number of quarter boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(QUARTER,startDate,endDate)`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of quarter boundaries crossed between the dates. + public static int DateDiffQuarter( + [CanBeNull] this DbFunctions _, + DateOnly startDate, + DateOnly endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffQuarter))); + + /// + /// Counts the number of quarter boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(QUARTER,startDate,endDate)`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of quarter boundaries crossed between the dates. + public static int? DateDiffQuarter( + [CanBeNull] this DbFunctions _, + DateOnly? startDate, + DateOnly? endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffQuarter))); + + #endregion DateDiffQuarter + + #region DateDiffMonth + /// /// Counts the number of month boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MONTH,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MONTH,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -267,7 +363,7 @@ public static int DateDiffMonth( /// /// Counts the number of month boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MONTH,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MONTH,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -281,7 +377,7 @@ public static int DateDiffMonth( /// /// Counts the number of month boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MONTH,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MONTH,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -295,7 +391,7 @@ public static int DateDiffMonth( /// /// Counts the number of month boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MONTH,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MONTH,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -309,7 +405,7 @@ public static int DateDiffMonth( /// /// Counts the number of month boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MONTH,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MONTH,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -323,7 +419,7 @@ public static int DateDiffMonth( /// /// Counts the number of month boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MONTH,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MONTH,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -335,9 +431,101 @@ public static int DateDiffMonth( DateOnly? endDate) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffMonth))); + #endregion DateDiffMonth + + #region DateDiffWeek + + /// + /// Counts the number of week boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(WEEK,startDate,endDate)`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of week boundaries crossed between the dates. + public static int DateDiffWeek( + [CanBeNull] this DbFunctions _, + DateTime startDate, + DateTime endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffWeek))); + + /// + /// Counts the number of week boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(WEEK,startDate,endDate)`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of week boundaries crossed between the dates. + public static int? DateDiffWeek( + [CanBeNull] this DbFunctions _, + DateTime? startDate, + DateTime? endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffWeek))); + + /// + /// Counts the number of week boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(WEEK,startDate,endDate)`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of week boundaries crossed between the dates. + public static int DateDiffWeek( + [CanBeNull] this DbFunctions _, + DateTimeOffset startDate, + DateTimeOffset endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffWeek))); + + /// + /// Counts the number of week boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(WEEK,startDate,endDate)`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of week boundaries crossed between the dates. + public static int? DateDiffWeek( + [CanBeNull] this DbFunctions _, + DateTimeOffset? startDate, + DateTimeOffset? endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffWeek))); + + /// + /// Counts the number of week boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(WEEK,startDate,endDate)`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of week boundaries crossed between the dates. + public static int DateDiffWeek( + [CanBeNull] this DbFunctions _, + DateOnly startDate, + DateOnly endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffWeek))); + + /// + /// Counts the number of week boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(WEEK,startDate,endDate)`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of week boundaries crossed between the dates. + public static int? DateDiffWeek( + [CanBeNull] this DbFunctions _, + DateOnly? startDate, + DateOnly? endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffWeek))); + + #endregion DateDiffWeek + + #region DateDiffDay + /// /// Counts the number of day boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(DAY,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(DAY,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -351,7 +539,7 @@ public static int DateDiffDay( /// /// Counts the number of day boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(DAY,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(DAY,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -365,7 +553,7 @@ public static int DateDiffDay( /// /// Counts the number of day boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(DAY,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(DAY,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -379,7 +567,7 @@ public static int DateDiffDay( /// /// Counts the number of day boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(DAY,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(DAY,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -393,7 +581,7 @@ public static int DateDiffDay( /// /// Counts the number of day boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(DAY,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(DAY,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -407,7 +595,7 @@ public static int DateDiffDay( /// /// Counts the number of day boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(DAY,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(DAY,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -419,9 +607,13 @@ public static int DateDiffDay( DateOnly? endDate) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffDay))); + #endregion DateDiffDay + + #region DateDiffHour + /// /// Counts the number of hour boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(HOUR,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(HOUR,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -435,7 +627,7 @@ public static int DateDiffHour( /// /// Counts the number of hour boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(HOUR,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(HOUR,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -449,7 +641,7 @@ public static int DateDiffHour( /// /// Counts the number of hour boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(HOUR,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(HOUR,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -463,7 +655,7 @@ public static int DateDiffHour( /// /// Counts the number of hour boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(HOUR,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(HOUR,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -477,7 +669,7 @@ public static int DateDiffHour( /// /// Counts the number of hour boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(HOUR,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(HOUR,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -491,7 +683,7 @@ public static int DateDiffHour( /// /// Counts the number of hour boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(HOUR,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(HOUR,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -503,9 +695,13 @@ public static int DateDiffHour( DateOnly? endDate) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffHour))); + #endregion DateDiffHour + + #region DateDiffMinute + /// /// Counts the number of minute boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MINUTE,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MINUTE,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -519,7 +715,7 @@ public static int DateDiffMinute( /// /// Counts the number of minute boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MINUTE,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MINUTE,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -533,7 +729,7 @@ public static int DateDiffMinute( /// /// Counts the number of minute boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MINUTE,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MINUTE,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -547,7 +743,7 @@ public static int DateDiffMinute( /// /// Counts the number of minute boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MINUTE,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MINUTE,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -561,7 +757,7 @@ public static int DateDiffMinute( /// /// Counts the number of minute boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MINUTE,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MINUTE,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -575,7 +771,7 @@ public static int DateDiffMinute( /// /// Counts the number of minute boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MINUTE,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MINUTE,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -587,9 +783,13 @@ public static int DateDiffMinute( DateOnly? endDate) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffMinute))); + #endregion DateDiffMinute + + #region DateDiffSecond + /// /// Counts the number of second boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(SECOND,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(SECOND,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -603,7 +803,7 @@ public static int DateDiffSecond( /// /// Counts the number of second boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(SECOND,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(SECOND,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -617,7 +817,7 @@ public static int DateDiffSecond( /// /// Counts the number of second boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(SECOND,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(SECOND,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -631,7 +831,7 @@ public static int DateDiffSecond( /// /// Counts the number of second boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(SECOND,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(SECOND,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -645,7 +845,7 @@ public static int DateDiffSecond( /// /// Counts the number of second boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(SECOND,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(SECOND,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -659,7 +859,7 @@ public static int DateDiffSecond( /// /// Counts the number of second boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(SECOND,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(SECOND,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -671,9 +871,101 @@ public static int DateDiffSecond( DateOnly? endDate) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffSecond))); + #endregion DateDiffSecond + + #region DateDiffMillisecond + + /// + /// Counts the number of millisecond boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) DIV 1000`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of millisecond boundaries crossed between the dates. + public static int DateDiffMillisecond( + [CanBeNull] this DbFunctions _, + DateTime startDate, + DateTime endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffMillisecond))); + + /// + /// Counts the number of millisecond boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) DIV 1000`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of millisecond boundaries crossed between the dates. + public static int? DateDiffMillisecond( + [CanBeNull] this DbFunctions _, + DateTime? startDate, + DateTime? endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffMillisecond))); + + /// + /// Counts the number of millisecond boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) DIV 1000`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of millisecond boundaries crossed between the dates. + public static int DateDiffMillisecond( + [CanBeNull] this DbFunctions _, + DateTimeOffset startDate, + DateTimeOffset endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffMillisecond))); + + /// + /// Counts the number of millisecond boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) DIV 1000`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of millisecond boundaries crossed between the dates. + public static int? DateDiffMillisecond( + [CanBeNull] this DbFunctions _, + DateTimeOffset? startDate, + DateTimeOffset? endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffMillisecond))); + + /// + /// Counts the number of millisecond boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) DIV 1000`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of millisecond boundaries crossed between the dates. + public static int DateDiffMillisecond( + [CanBeNull] this DbFunctions _, + DateOnly startDate, + DateOnly endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffMillisecond))); + + /// + /// Counts the number of millisecond boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) DIV 1000`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of millisecond boundaries crossed between the dates. + public static int? DateDiffMillisecond( + [CanBeNull] this DbFunctions _, + DateOnly? startDate, + DateOnly? endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffMillisecond))); + + #endregion DateDiffMillisecond + + #region DateDiffMicrosecond + /// /// Counts the number of microsecond boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MICROSECOND,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -687,7 +979,7 @@ public static int DateDiffMicrosecond( /// /// Counts the number of microsecond boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MICROSECOND,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -701,7 +993,7 @@ public static int DateDiffMicrosecond( /// /// Counts the number of microsecond boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MICROSECOND,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -715,7 +1007,7 @@ public static int DateDiffMicrosecond( /// /// Counts the number of microsecond boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MICROSECOND,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -729,7 +1021,7 @@ public static int DateDiffMicrosecond( /// /// Counts the number of microsecond boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MICROSECOND,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -743,7 +1035,7 @@ public static int DateDiffMicrosecond( /// /// Counts the number of microsecond boundaries crossed between the startDate and endDate. - /// Corresponds to TIMESTAMPDIFF(MICROSECOND,startDate,endDate). + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate)`. /// /// The DbFunctions instance. /// Starting date for the calculation. @@ -755,6 +1047,186 @@ public static int DateDiffMicrosecond( DateOnly? endDate) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffMicrosecond))); + #endregion DateDiffMicrosecond + + #region DateDiffTick + + /// + /// Counts the number of tick boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) * 10`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of tick boundaries crossed between the dates. + public static int DateDiffTick( + [CanBeNull] this DbFunctions _, + DateTime startDate, + DateTime endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffTick))); + + /// + /// Counts the number of tick boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) * 10`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of tick boundaries crossed between the dates. + public static int? DateDiffTick( + [CanBeNull] this DbFunctions _, + DateTime? startDate, + DateTime? endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffTick))); + + /// + /// Counts the number of tick boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) * 10`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of tick boundaries crossed between the dates. + public static int DateDiffTick( + [CanBeNull] this DbFunctions _, + DateTimeOffset startDate, + DateTimeOffset endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffTick))); + + /// + /// Counts the number of tick boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) * 10`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of tick boundaries crossed between the dates. + public static int? DateDiffTick( + [CanBeNull] this DbFunctions _, + DateTimeOffset? startDate, + DateTimeOffset? endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffTick))); + + /// + /// Counts the number of tick boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) * 10`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of tick boundaries crossed between the dates. + public static int DateDiffTick( + [CanBeNull] this DbFunctions _, + DateOnly startDate, + DateOnly endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffTick))); + + /// + /// Counts the number of tick boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) * 10`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of tick boundaries crossed between the dates. + public static int? DateDiffTick( + [CanBeNull] this DbFunctions _, + DateOnly? startDate, + DateOnly? endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffTick))); + + #endregion DateDiffTick + + #region DateDiffNanosecond + + /// + /// Counts the number of nanosecond boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) * 1000`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of nanosecond boundaries crossed between the dates. + public static int DateDiffNanosecond( + [CanBeNull] this DbFunctions _, + DateTime startDate, + DateTime endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffNanosecond))); + + /// + /// Counts the number of nanosecond boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) * 1000`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of nanosecond boundaries crossed between the dates. + public static int? DateDiffNanosecond( + [CanBeNull] this DbFunctions _, + DateTime? startDate, + DateTime? endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffNanosecond))); + + /// + /// Counts the number of nanosecond boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) * 1000`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of nanosecond boundaries crossed between the dates. + public static int DateDiffNanosecond( + [CanBeNull] this DbFunctions _, + DateTimeOffset startDate, + DateTimeOffset endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffNanosecond))); + + /// + /// Counts the number of nanosecond boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) * 1000`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of nanosecond boundaries crossed between the dates. + public static int? DateDiffNanosecond( + [CanBeNull] this DbFunctions _, + DateTimeOffset? startDate, + DateTimeOffset? endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffNanosecond))); + + /// + /// Counts the number of nanosecond boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) * 1000`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of nanosecond boundaries crossed between the dates. + public static int DateDiffNanosecond( + [CanBeNull] this DbFunctions _, + DateOnly startDate, + DateOnly endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffNanosecond))); + + /// + /// Counts the number of nanosecond boundaries crossed between the startDate and endDate. + /// Corresponds to `TIMESTAMPDIFF(MICROSECOND,startDate,endDate) * 1000`. + /// + /// The DbFunctions instance. + /// Starting date for the calculation. + /// Ending date for the calculation. + /// Number of nanosecond boundaries crossed between the dates. + public static int? DateDiffNanosecond( + [CanBeNull] this DbFunctions _, + DateOnly? startDate, + DateOnly? endDate) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateDiffNanosecond))); + + #endregion DateDiffNanosecond + + #region Like + /// /// /// An implementation of the SQL LIKE operation. On relational databases this is usually directly @@ -769,7 +1241,9 @@ public static int DateDiffMicrosecond( /// /// The DbFunctions instance. /// The property of entity that is to be matched. - /// The pattern which may involve wildcards %,_,[,],^. + /// + /// The pattern which may involve the wildcards `%` and `_`. The character `\` is used to escape wildcards and itself. + /// /// true if there is a match. public static bool Like( [CanBeNull] this DbFunctions _, @@ -790,10 +1264,10 @@ public static bool Like( /// /// The DbFunctions instance. /// The property of entity that is to be matched. - /// The pattern which may involve wildcards %,_,[,],^. + /// The pattern which may involve the wildcards `%` and `_`. /// - /// The escape character (as a single character string) to use in front of %,_,[,],^ - /// if they are not used as wildcards. + /// The escape character (as a single character string) to use in front of `%` and `_` (if they are not used as wildcards), and + /// itself. /// /// true if there is a match. public static bool Like( @@ -803,6 +1277,10 @@ public static bool Like( [CanBeNull] string escapeCharacter) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Like))); + #endregion Like + + #region Match + /// /// /// An implementation of the SQL MATCH operation for Full Text search. @@ -883,6 +1361,10 @@ public static double Match( [CanBeNull] string pattern) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Match))); + #endregion Match + + #region Misc + /// /// /// For a string argument `value`, Hex() returns a hexadecimal string representation of `value` where @@ -959,5 +1441,7 @@ public static float Radians( this DbFunctions _, float degrees) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Radians))); + + #endregion Misc } } diff --git a/src/EFCore.SingleStore/Extensions/SingleStoreJsonDbFunctionsExtensions.cs b/src/EFCore.SingleStore/Extensions/SingleStoreJsonDbFunctionsExtensions.cs index 5113f3a0e..c74e329b8 100644 --- a/src/EFCore.SingleStore/Extensions/SingleStoreJsonDbFunctionsExtensions.cs +++ b/src/EFCore.SingleStore/Extensions/SingleStoreJsonDbFunctionsExtensions.cs @@ -85,6 +85,20 @@ public static T JsonExtract( [NotNull] params string[] paths) => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(JsonExtract))); + /// + /// Checks if overlaps . + /// + /// DbFunctions instance + /// + /// A JSON column or value. Can be a JSON DOM object, a string property mapped to JSON, or a user POCO mapped to JSON. + /// + /// + /// A JSON column or value. Can be a JSON DOM object, a string, or a user POCO mapped to JSON. + /// + public static bool JsonOverlaps( + [CanBeNull] this DbFunctions _, [NotNull] object json1, [NotNull] object json2) + => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(JsonOverlaps))); + /// /// Checks if contains . /// diff --git a/src/EFCore.SingleStore/Infrastructure/MariaDbServerVersion.cs b/src/EFCore.SingleStore/Infrastructure/MariaDbServerVersion.cs index 1d57fb753..f4ce5a6c9 100644 --- a/src/EFCore.SingleStore/Infrastructure/MariaDbServerVersion.cs +++ b/src/EFCore.SingleStore/Infrastructure/MariaDbServerVersion.cs @@ -18,6 +18,9 @@ public class MariaDbServerVersion : ServerVersion public static readonly string MariaDbTypeIdentifier = nameof(ServerType.MariaDb).ToLowerInvariant(); public static readonly ServerVersion LatestSupportedServerVersion = new MariaDbServerVersion(new Version(10, 9, 4)); + public override string DefaultUtf8CsCollation => Supports.DefaultCharSetUtf8Mb4 ? "utf8mb4_bin" : "utf8_bin"; + public override string DefaultUtf8CiCollation => Supports.DefaultCharSetUtf8Mb4 ? "utf8mb4_general_ci" : "utf8_general_ci"; + public override ServerVersionSupport Supports { get; } public MariaDbServerVersion(Version version) diff --git a/src/EFCore.SingleStore/Infrastructure/ServerVersion.cs b/src/EFCore.SingleStore/Infrastructure/ServerVersion.cs index 546d2fdea..da34bb51c 100644 --- a/src/EFCore.SingleStore/Infrastructure/ServerVersion.cs +++ b/src/EFCore.SingleStore/Infrastructure/ServerVersion.cs @@ -5,6 +5,8 @@ using System; using System.Data; using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Utilities; using SingleStoreConnector; using EntityFrameworkCore.SingleStore.Infrastructure; @@ -37,8 +39,8 @@ protected ServerVersion(Version version, ServerType type, string typeIdentifier public virtual int MaxKeyLength => Supports.LargerKeyLength ? 3072 : 767; public virtual CharSet DefaultCharSet => Supports.DefaultCharSetUtf8Mb4 ? CharSet.Utf8Mb4 : CharSet.Utf8; - public virtual string DefaultUtf8CsCollation => Supports.DefaultCharSetUtf8Mb4 ? "utf8mb4_bin" : "utf8_bin"; - public virtual string DefaultUtf8CiCollation => Supports.DefaultCharSetUtf8Mb4 ? "utf8mb4_general_ci" : "utf8_general_ci"; + public abstract string DefaultUtf8CsCollation { get; } + public abstract string DefaultUtf8CiCollation { get; } public override bool Equals(object obj) => obj is ServerVersion version && @@ -82,6 +84,36 @@ public static ServerVersion AutoDetect(string connectionString) return Parse(connection.S2ServerVersion); } + /// + /// Retrieves the (version number and server type) from a database server. + /// + /// The connection string. + /// A to observe while waiting for the task to complete. + /// + /// A task that represents the asynchronous auto detect operation. The task result contains the of the database. + /// + /// + /// Uses a connection string to open a connection to the database server and then executes a command. + /// The connection will ignore the database specified in the connection string. It therefore makes not difference, whether the + /// database already exists or not. + /// + public static async Task AutoDetectAsync(string connectionString, CancellationToken cancellationToken = default) + { + var connection = new SingleStoreConnection( + new SingleStoreConnectionStringBuilder(connectionString) + { + Database = string.Empty, + AutoEnlist = false, + Pooling = false, + }.ConnectionString); + + await using (connection.ConfigureAwait(false)) + { + await connection.OpenAsync(cancellationToken).ConfigureAwait(false); + return Parse(connection.S2ServerVersion); + } + } + /// /// Retrieves the (version number and server type) from a database server. /// @@ -118,6 +150,102 @@ public static ServerVersion AutoDetect(SingleStoreConnection connection) return Parse(serverVersion); } + /// + /// Retrieves the (version number and server type) from a database server. + /// + /// The connection. + /// A to observe while waiting for the task to complete. + /// + /// A task that represents the asynchronous auto detect operation. The task result contains the of the database. + /// + /// + /// Uses a connection to the database server to execute a command. + /// If the connection has already been opened, the connection is is being used as is. Otherwise, the connection is being cloned and + /// ignores any database specified in the connection string of the connection. It therefore makes not difference, whether the + /// database already exists or not, and the of the parameter after the + /// return of the call is the same as before the call. + /// + public static async Task AutoDetectAsync(SingleStoreConnection connection, CancellationToken cancellationToken = default) + { + string serverVersion; + + if (connection.State != ConnectionState.Open) + { + var clonedConnection = connection.CloneWith( + new SingleStoreConnectionStringBuilder(connection.ConnectionString) + { + Database = string.Empty, + AutoEnlist = false, + Pooling = false, + }.ConnectionString); + + await using (clonedConnection.ConfigureAwait(false)) + { + await clonedConnection.OpenAsync(cancellationToken).ConfigureAwait(false); + serverVersion = clonedConnection.S2ServerVersion; + } + } + else + { + serverVersion = connection.S2ServerVersion; + } + + return Parse(serverVersion); + } + + /// + /// Retrieves the (version number and server type) from a database server. + /// + /// The data source. + /// The . + /// + /// Uses a that represents a database to execute a command. + /// The data source is used to create a connection to the database server and ignores any database specified in the underlying + /// connection string. It therefore makes not difference, whether a specified database already exists or not. + /// + public static ServerVersion AutoDetect(SingleStoreDataSource dataSource) + { + using var connection = dataSource.CreateConnection(); + connection.ConnectionString = new SingleStoreConnectionStringBuilder(connection.ConnectionString) + { + Database = string.Empty, + AutoEnlist = false, + Pooling = false, + }.ConnectionString; + connection.Open(); + return Parse(connection.S2ServerVersion); + } + + /// + /// Retrieves the (version number and server type) from a database server. + /// + /// The data source. + /// A to observe while waiting for the task to complete. + /// + /// A task that represents the asynchronous auto detect operation. The task result contains the of the database. + /// + /// + /// Uses a that represents a database to execute a command. + /// The data source is used to create a connection to the database server and ignores any database specified in the underlying + /// connection string. It therefore makes not difference, whether a specified database already exists or not. + /// + public static async Task AutoDetectAsync(SingleStoreDataSource dataSource, CancellationToken cancellationToken = default) + { + var connection = dataSource.CreateConnection(); + await using (connection.ConfigureAwait(false)) + { + connection.ConnectionString = new SingleStoreConnectionStringBuilder(connection.ConnectionString) + { + Database = string.Empty, + AutoEnlist = false, + Pooling = false, + }.ConnectionString; + + await connection.OpenAsync(cancellationToken).ConfigureAwait(false); + return Parse(connection.S2ServerVersion); + } + } + /// /// Converts a string, containing the server version and type, into a . /// diff --git a/src/EFCore.SingleStore/Infrastructure/ServerVersionSupport.cs b/src/EFCore.SingleStore/Infrastructure/ServerVersionSupport.cs index 52761f85e..f6e187dca 100644 --- a/src/EFCore.SingleStore/Infrastructure/ServerVersionSupport.cs +++ b/src/EFCore.SingleStore/Infrastructure/ServerVersionSupport.cs @@ -60,6 +60,7 @@ public virtual bool PropertyOrVersion(string propertyNameOrServerVersion) public virtual bool CrossApply => false; public virtual bool OuterReferenceInMultiLevelSubquery => false; public virtual bool Json => false; + public virtual bool JsonOverlaps => false; public virtual bool GeneratedColumns => false; public virtual bool NullableGeneratedColumns => false; public virtual bool ParenthesisEnclosedGeneratedColumnExpressions => false; @@ -97,6 +98,8 @@ public virtual bool PropertyOrVersion(string propertyNameOrServerVersion) public virtual bool Values => false; public virtual bool ValuesWithRows => false; public virtual bool WhereSubqueryReferencesOuterQuery => false; + public virtual bool FieldReferenceInTableValueConstructor => false; + public virtual bool CollationCharacterSetApplicabilityWithFullCollationNameColumn => false; public virtual bool JsonTableImplementationStable => JsonTable; public virtual bool JsonTableImplementationWithoutMySqlBugs => JsonTable; diff --git a/src/EFCore.SingleStore/Infrastructure/SingleStoreServerVersion.cs b/src/EFCore.SingleStore/Infrastructure/SingleStoreServerVersion.cs index 53b08c537..c1bd94151 100644 --- a/src/EFCore.SingleStore/Infrastructure/SingleStoreServerVersion.cs +++ b/src/EFCore.SingleStore/Infrastructure/SingleStoreServerVersion.cs @@ -19,6 +19,9 @@ public class SingleStoreServerVersion : ServerVersion public override ServerVersionSupport Supports { get; } + public override string DefaultUtf8CsCollation => Supports.DefaultCharSetUtf8Mb4 ? "utf8mb4_bin" : "utf8_bin"; + public override string DefaultUtf8CiCollation => Supports.DefaultCharSetUtf8Mb4 ? "utf8mb4_general_ci" : "utf8_general_ci"; + public SingleStoreServerVersion(Version version) : base(version, ServerType.SingleStore) { @@ -93,9 +96,12 @@ internal SingleStoreServerVersionSupport([NotNull] ServerVersion serverVersion) public override bool LimitWithNonConstantValue => false; public override bool JsonTable => false; public override bool JsonValue => false; + public override bool JsonOverlaps => false; public override bool Values => false; public override bool ValuesWithRows => false; public override bool WhereSubqueryReferencesOuterQuery => false; + public override bool FieldReferenceInTableValueConstructor => true; + public override bool CollationCharacterSetApplicabilityWithFullCollationNameColumn => false; public override bool JsonTableImplementationStable => false; public override bool JsonTableImplementationWithoutMySqlBugs => false; // Other non-fatal bugs regarding JSON_TABLE. diff --git a/src/EFCore.SingleStore/Internal/SingleStoreOptions.cs b/src/EFCore.SingleStore/Internal/SingleStoreOptions.cs index 04b72bb94..acb0c65ec 100644 --- a/src/EFCore.SingleStore/Internal/SingleStoreOptions.cs +++ b/src/EFCore.SingleStore/Internal/SingleStoreOptions.cs @@ -11,6 +11,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using EntityFrameworkCore.SingleStore.Infrastructure; using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.EntityFrameworkCore.Storage.Internal; using Microsoft.Extensions.DependencyInjection; using SingleStoreConnector; @@ -55,7 +56,7 @@ public virtual void Initialize(IDbContextOptions options) var mySqlOptions = options.FindExtension() ?? new SingleStoreOptionsExtension(); var mySqlJsonOptions = (SingleStoreJsonOptionsExtension)options.Extensions.LastOrDefault(e => e is SingleStoreJsonOptionsExtension); - ConnectionSettings = GetConnectionSettings(mySqlOptions); + ConnectionSettings = GetConnectionSettings(mySqlOptions, options); DataSource = mySqlOptions.DataSource; ServerVersion = mySqlOptions.ServerVersion ?? throw new InvalidOperationException($"The {nameof(ServerVersion)} has not been set."); NoBackslashEscapes = mySqlOptions.NoBackslashEscapes; @@ -75,7 +76,7 @@ public virtual void Validate(IDbContextOptions options) { var mySqlOptions = options.FindExtension() ?? new SingleStoreOptionsExtension(); var mySqlJsonOptions = (SingleStoreJsonOptionsExtension)options.Extensions.LastOrDefault(e => e is SingleStoreJsonOptionsExtension); - var connectionSettings = GetConnectionSettings(mySqlOptions); + var connectionSettings = GetConnectionSettings(mySqlOptions, options); // // CHECK: To we have to ensure that the ApplicationServiceProvider itself is not replaced, because we rely on it in our @@ -245,10 +246,12 @@ protected virtual SingleStoreDefaultDataTypeMappings ApplyDefaultDataTypeMapping return defaultDataTypeMappings; } - private static SingleStoreConnectionSettings GetConnectionSettings(SingleStoreOptionsExtension relationalOptions) + private static SingleStoreConnectionSettings GetConnectionSettings(SingleStoreOptionsExtension relationalOptions, IDbContextOptions options) => relationalOptions.Connection != null ? new SingleStoreConnectionSettings(relationalOptions.Connection) - : new SingleStoreConnectionSettings(relationalOptions.ConnectionString); + : new SingleStoreConnectionSettings( + new NamedConnectionStringResolver(options) + .ResolveConnectionString(relationalOptions.ConnectionString ?? string.Empty)); protected virtual bool Equals(SingleStoreOptions other) { diff --git a/src/EFCore.SingleStore/Migrations/Internal/SingleStoreHistoryRepository.cs b/src/EFCore.SingleStore/Migrations/Internal/SingleStoreHistoryRepository.cs index 71a9fe026..469cb5893 100644 --- a/src/EFCore.SingleStore/Migrations/Internal/SingleStoreHistoryRepository.cs +++ b/src/EFCore.SingleStore/Migrations/Internal/SingleStoreHistoryRepository.cs @@ -3,17 +3,22 @@ // Licensed under the MIT. See LICENSE in the project root for license information. using System; +using System.Data.Common; using System.Linq; using System.Text; +using System.Threading; +using System.Threading.Tasks; +using EntityFrameworkCore.SingleStore.Infrastructure; +using EntityFrameworkCore.SingleStore.Storage.Internal; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage; -using EntityFrameworkCore.SingleStore.Infrastructure; -using EntityFrameworkCore.SingleStore.Storage.Internal; +using SingleStoreConnector; namespace EntityFrameworkCore.SingleStore.Migrations.Internal { @@ -21,12 +26,157 @@ public class SingleStoreHistoryRepository : HistoryRepository { private const string MigrationsScript = nameof(MigrationsScript); + // Similar to the old GET_LOCK timeout (72h), but now used as command timeout while waiting on row lock. + private const int LockTimeoutSeconds = 60 * 60 * 24 * 3; + private readonly SingleStoreSqlGenerationHelper _sqlGenerationHelper; + private readonly string _lockConnectionString; + public SingleStoreHistoryRepository([NotNull] HistoryRepositoryDependencies dependencies) : base(dependencies) { _sqlGenerationHelper = (SingleStoreSqlGenerationHelper)dependencies.SqlGenerationHelper; + + // Capture early to avoid password being stripped after Open() (PersistSecurityInfo default is false). + _lockConnectionString = dependencies.Connection.ConnectionString + ?? dependencies.Connection.DbConnection.ConnectionString; + } + + // We now use a dedicated connection + transaction to hold a row lock, + // therefore the lock must be released explicitly by disposing the lock object. + public override LockReleaseBehavior LockReleaseBehavior + => LockReleaseBehavior.Explicit; + + public override IMigrationsDatabaseLock AcquireDatabaseLock() + { + Dependencies.MigrationsLogger.AcquiringMigrationLock(); + + var lockConnection = CreateLockConnection(); + try + { + EnsureLockTable(lockConnection); + + var transaction = lockConnection.BeginTransaction(); + + AcquireRowLock(lockConnection, transaction); + + return new SingleStoreMigrationDatabaseLock(this, lockConnection, transaction); + } + catch + { + lockConnection.Dispose(); + throw; + } + } + + public override async Task AcquireDatabaseLockAsync(CancellationToken cancellationToken = default) + { + Dependencies.MigrationsLogger.AcquiringMigrationLock(); + + var lockConnection = CreateLockConnection(); + try + { + await EnsureLockTableAsync(lockConnection, cancellationToken).ConfigureAwait(false); + + var transaction = await lockConnection.BeginTransactionAsync(cancellationToken).ConfigureAwait(false); + + await AcquireRowLockAsync(lockConnection, transaction, cancellationToken).ConfigureAwait(false); + + return new SingleStoreMigrationDatabaseLock(this, lockConnection, transaction, cancellationToken); + } + catch + { + await lockConnection.DisposeAsync().ConfigureAwait(false); + throw; + } + } + + /// + /// Returns the name of the database-wide lock for migrations. + /// + protected virtual string GetDatabaseLockName(string databaseName) + => $"__{databaseName}_EFMigrationsLock"; + + private string GetLockTableName() + => GetDatabaseLockName(Dependencies.Connection.DbConnection.Database); + + private SingleStoreConnection CreateLockConnection() + { + var connection = new SingleStoreConnection(_lockConnectionString); + connection.Open(); + + // Make sure the lock connection is using the same database as the main connection. + var db = Dependencies.Connection.DbConnection.Database; + if (!string.IsNullOrEmpty(db) && + !string.Equals(connection.Database, db, StringComparison.OrdinalIgnoreCase)) + { + connection.ChangeDatabase(db); + } + + return connection; + } + + private void EnsureLockTable(SingleStoreConnection connection) + { + var table = SqlGenerationHelper.DelimitIdentifier(GetLockTableName()); + + using var command = connection.CreateCommand(); + command.CommandTimeout = LockTimeoutSeconds; + + // ROWSTORE ensures fast, predictable locking behavior. + command.CommandText = $""" +CREATE ROWSTORE TABLE IF NOT EXISTS {table} ( + `Id` INT NOT NULL PRIMARY KEY +); +"""; + command.ExecuteNonQuery(); + + command.CommandText = $"""INSERT IGNORE INTO {table} (`Id`) VALUES (1);"""; + command.ExecuteNonQuery(); + } + + private async Task EnsureLockTableAsync(SingleStoreConnection connection, CancellationToken cancellationToken) + { + var table = SqlGenerationHelper.DelimitIdentifier(GetLockTableName()); + + using var command = connection.CreateCommand(); + command.CommandTimeout = LockTimeoutSeconds; + + command.CommandText = $""" +CREATE ROWSTORE TABLE IF NOT EXISTS {table} ( + `Id` INT NOT NULL PRIMARY KEY +); +"""; + await command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false); + + command.CommandText = $"""INSERT IGNORE INTO {table} (`Id`) VALUES (1);"""; + await command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false); + } + + private void AcquireRowLock(SingleStoreConnection connection, DbTransaction transaction) + { + var table = SqlGenerationHelper.DelimitIdentifier(GetLockTableName()); + + using var command = connection.CreateCommand(); + command.Transaction = (SingleStoreTransaction)transaction; + command.CommandTimeout = LockTimeoutSeconds; + + // A write statement acquires a row lock that is held until the transaction ends. + command.CommandText = $"""UPDATE {table} SET `Id` = `Id` WHERE `Id` = 1;"""; + command.ExecuteNonQuery(); + } + + private async Task AcquireRowLockAsync(SingleStoreConnection connection, DbTransaction transaction, CancellationToken cancellationToken) + { + var table = SqlGenerationHelper.DelimitIdentifier(GetLockTableName()); + + using var command = connection.CreateCommand(); + command.Transaction = (SingleStoreTransaction)transaction; + command.CommandTimeout = LockTimeoutSeconds; + + command.CommandText = $"""UPDATE {table} SET `Id` = `Id` WHERE `Id` = 1;"""; + await command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false); } protected override void ConfigureTable([NotNull] EntityTypeBuilder history) @@ -70,26 +220,10 @@ public override string GetCreateIfNotExistsScript() return script.Insert(script.IndexOf("CREATE TABLE", StringComparison.Ordinal) + 12, " IF NOT EXISTS"); } - /// - /// Overridden by database providers to generate a SQL Script that will `BEGIN` a block - /// of SQL if and only if the migration with the given identifier does not already exist in the history table. - /// - /// The migration identifier. - /// The generated SQL. public override string GetBeginIfNotExistsScript(string migrationId) => GetBeginIfScript(migrationId, true); - /// - /// Overridden by database providers to generate a SQL Script that will `BEGIN` a block - /// of SQL if and only if the migration with the given identifier already exists in the history table. - /// - /// The migration identifier. - /// The generated SQL. public override string GetBeginIfExistsScript(string migrationId) => GetBeginIfScript(migrationId, false); - /// - /// Overridden by database providers to generate a SQL script to `END` the SQL block. - /// - /// The generated SQL. public virtual string GetBeginIfScript(string migrationId, bool notExists) => $@"DROP PROCEDURE IF EXISTS {MigrationsScript}; DELIMITER // CREATE PROCEDURE {MigrationsScript}() @@ -97,10 +231,6 @@ public override string GetCreateIfNotExistsScript() IF{(notExists ? " NOT" : null)} EXISTS(SELECT 1 FROM {SqlGenerationHelper.DelimitIdentifier(TableName, TableSchema)} WHERE {SqlGenerationHelper.DelimitIdentifier(MigrationIdColumnName)} = '{migrationId}') THEN "; - /// - /// Overridden by database providers to generate a SQL script to `END` the SQL block. - /// - /// The generated SQL. public override string GetEndIfScript() => $@" END IF; END // @@ -118,25 +248,19 @@ public virtual void ConfigureModel(ModelBuilder modelBuilder) private string _migrationIdColumnName; private string _productVersionColumnName; - // Customized implementation. protected virtual IModel EnsureModel() { if (_model == null) { var conventionSet = Dependencies.ConventionSetBuilder.CreateConventionSet(); - // Use public API to remove the convention, issue #214 ConventionSet.Remove(conventionSet.ModelInitializedConventions, typeof(DbSetFindingConvention)); ConventionSet.Remove(conventionSet.ModelInitializedConventions, typeof(RelationalDbFunctionAttributeConvention)); var modelBuilder = new ModelBuilder(conventionSet); - #region Custom implementation - ConfigureModel(modelBuilder); - #endregion - modelBuilder.Entity( x => { @@ -150,7 +274,6 @@ protected virtual IModel EnsureModel() return _model; } - // Original implementation. public override string GetCreateScript() { var model = EnsureModel(); @@ -161,14 +284,12 @@ public override string GetCreateScript() return string.Concat(commandList.Select(c => c.CommandText)); } - // Original implementation. protected override string MigrationIdColumnName => _migrationIdColumnName ??= EnsureModel() .FindEntityType(typeof(HistoryRow))! .FindProperty(nameof(HistoryRow.MigrationId))! .GetColumnName(); - // Original implementation. protected override string ProductVersionColumnName => _productVersionColumnName ??= EnsureModel() .FindEntityType(typeof(HistoryRow))! @@ -176,5 +297,29 @@ protected override string ProductVersionColumnName .GetColumnName(); #endregion Necessary implementation because we cannot directly override EnsureModel + + private sealed class SingleStoreMigrationDatabaseLock( + SingleStoreHistoryRepository historyRepository, + SingleStoreConnection lockConnection, + DbTransaction lockTransaction, + CancellationToken cancellationToken = default) + : IMigrationsDatabaseLock + { + public IHistoryRepository HistoryRepository => historyRepository; + + public void Dispose() + { + try { lockTransaction.Rollback(); } catch { /* ignore */ } + lockTransaction.Dispose(); + lockConnection.Dispose(); + } + + public async ValueTask DisposeAsync() + { + try { await lockTransaction.RollbackAsync(cancellationToken).ConfigureAwait(false); } catch { /* ignore */ } + await lockTransaction.DisposeAsync().ConfigureAwait(false); + await lockConnection.DisposeAsync().ConfigureAwait(false); + } + } } } diff --git a/src/EFCore.SingleStore/Migrations/Internal/SingleStoreMigrationsModelDiffer.cs b/src/EFCore.SingleStore/Migrations/Internal/SingleStoreMigrationsModelDiffer.cs index e3f15c99d..eb8b465a5 100644 --- a/src/EFCore.SingleStore/Migrations/Internal/SingleStoreMigrationsModelDiffer.cs +++ b/src/EFCore.SingleStore/Migrations/Internal/SingleStoreMigrationsModelDiffer.cs @@ -33,11 +33,13 @@ protected static class InternalLocalAnnotationNames public SingleStoreMigrationsModelDiffer( IRelationalTypeMappingSource typeMappingSource, IMigrationsAnnotationProvider migrationsAnnotationProvider, + IRelationalAnnotationProvider relationalAnnotationProvider, IRowIdentityMapFactory rowIdentityMapFactory, CommandBatchPreparerDependencies commandBatchPreparerDependencies) : base( typeMappingSource, migrationsAnnotationProvider, + relationalAnnotationProvider, rowIdentityMapFactory, commandBatchPreparerDependencies) { diff --git a/src/EFCore.SingleStore/Migrations/Internal/SingleStoreMigrator.cs b/src/EFCore.SingleStore/Migrations/Internal/SingleStoreMigrator.cs index e47f28303..148c404a9 100644 --- a/src/EFCore.SingleStore/Migrations/Internal/SingleStoreMigrator.cs +++ b/src/EFCore.SingleStore/Migrations/Internal/SingleStoreMigrator.cs @@ -7,10 +7,10 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; -using JetBrains.Annotations; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations.Internal; using Microsoft.EntityFrameworkCore.Migrations.Operations; @@ -39,19 +39,23 @@ public class SingleStoreMigrator : Migrator private readonly IRelationalCommandDiagnosticsLogger _commandLogger; public SingleStoreMigrator( - [NotNull] IMigrationsAssembly migrationsAssembly, - [NotNull] IHistoryRepository historyRepository, - [NotNull] IDatabaseCreator databaseCreator, - [NotNull] IMigrationsSqlGenerator migrationsSqlGenerator, - [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder, - [NotNull] IMigrationCommandExecutor migrationCommandExecutor, - [NotNull] IRelationalConnection connection, - [NotNull] ISqlGenerationHelper sqlGenerationHelper, - [NotNull] ICurrentDbContext currentContext, - [NotNull] IModelRuntimeInitializer modelRuntimeInitializer, - [NotNull] IDiagnosticsLogger logger, - [NotNull] IRelationalCommandDiagnosticsLogger commandLogger, - [NotNull] IDatabaseProvider databaseProvider) + IMigrationsAssembly migrationsAssembly, + IHistoryRepository historyRepository, + IDatabaseCreator databaseCreator, + IMigrationsSqlGenerator migrationsSqlGenerator, + IRawSqlCommandBuilder rawSqlCommandBuilder, + IMigrationCommandExecutor migrationCommandExecutor, + IRelationalConnection connection, + ISqlGenerationHelper sqlGenerationHelper, + ICurrentDbContext currentContext, + IModelRuntimeInitializer modelRuntimeInitializer, + IDiagnosticsLogger logger, + IRelationalCommandDiagnosticsLogger commandLogger, + IDatabaseProvider databaseProvider, + IMigrationsModelDiffer migrationsModelDiffer, + IDesignTimeModel designTimeModel, + IDbContextOptions contextOptions, + IExecutionStrategy executionStrategy) : base( migrationsAssembly, historyRepository, @@ -65,7 +69,11 @@ public SingleStoreMigrator( modelRuntimeInitializer, logger, commandLogger, - databaseProvider) + databaseProvider, + migrationsModelDiffer, + designTimeModel, + contextOptions, + executionStrategy) { _migrationsAssembly = migrationsAssembly; _rawSqlCommandBuilder = rawSqlCommandBuilder; @@ -146,13 +154,11 @@ protected virtual List GetAllMigrationOperations(string from PopulateMigrations( appliedMigrations, toMigration, - out var migrationsToApply, - out var migrationsToRevert, - out var actualTargetMigration); + out var migratorData); - return migrationsToApply + return migratorData.AppliedMigrations .SelectMany(x => x.UpOperations) - .Concat(migrationsToRevert.SelectMany(x => x.DownOperations)) + .Concat(migratorData.RevertedMigrations.SelectMany(x => x.DownOperations)) .ToList(); } @@ -293,7 +299,7 @@ INTO HAS_AUTO_INCREMENT_ID WHERE `TABLE_SCHEMA` = (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())) AND `TABLE_NAME` = TABLE_NAME_ARGUMENT AND `COLUMN_NAME` = COLUMN_NAME_ARGUMENT - AND `COLUMN_TYPE` LIKE '%int%' + AND `COLUMN_TYPE` LIKE '%bigint%' AND `COLUMN_KEY` = 'PRI'; IF HAS_AUTO_INCREMENT_ID THEN SELECT `COLUMN_TYPE` @@ -302,7 +308,7 @@ INTO PRIMARY_KEY_TYPE WHERE `TABLE_SCHEMA` = (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())) AND `TABLE_NAME` = TABLE_NAME_ARGUMENT AND `COLUMN_NAME` = COLUMN_NAME_ARGUMENT - AND `COLUMN_TYPE` LIKE '%int%' + AND `COLUMN_TYPE` LIKE '%bigint%' AND `COLUMN_KEY` = 'PRI'; SELECT `COLUMN_NAME` INTO PRIMARY_KEY_COLUMN_NAME @@ -310,7 +316,7 @@ INTO PRIMARY_KEY_COLUMN_NAME WHERE `TABLE_SCHEMA` = (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())) AND `TABLE_NAME` = TABLE_NAME_ARGUMENT AND `COLUMN_NAME` = COLUMN_NAME_ARGUMENT - AND `COLUMN_TYPE` LIKE '%int%' + AND `COLUMN_TYPE` LIKE '%bigint%' AND `COLUMN_KEY` = 'PRI'; SET SQL_EXP = CONCAT('ALTER TABLE `', (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())), '`.`', TABLE_NAME_ARGUMENT, '` MODIFY COLUMN `', PRIMARY_KEY_COLUMN_NAME, '` ', PRIMARY_KEY_TYPE, ' NOT NULL AUTO_INCREMENT;'); SET @SQL_EXP = SQL_EXP; diff --git a/src/EFCore.SingleStore/Migrations/SingleStoreMigrationsSqlGenerator.cs b/src/EFCore.SingleStore/Migrations/SingleStoreMigrationsSqlGenerator.cs index 35aef468c..5c91267b4 100644 --- a/src/EFCore.SingleStore/Migrations/SingleStoreMigrationsSqlGenerator.cs +++ b/src/EFCore.SingleStore/Migrations/SingleStoreMigrationsSqlGenerator.cs @@ -322,8 +322,63 @@ protected override void CreateTableConstraints( CreateTableCheckConstraints(operation, model, builder); CreateTableForeignKeys(operation, model, builder);*/ } + protected override void Generate(AlterTableOperation operation, IModel model, MigrationCommandListBuilder builder) { + var oldCharSet = operation.OldTable[SingleStoreAnnotationNames.CharSet] as string; + var newCharSet = operation[SingleStoreAnnotationNames.CharSet] as string; + + var oldCollation = operation.OldTable[RelationalAnnotationNames.Collation] as string; + var newCollation = operation[RelationalAnnotationNames.Collation] as string; + + if (newCollation != oldCollation && newCollation != null) + { + // A new collation has been set. It takes precedence over any defined charset. + // if charset also changed, emit it in the same ALTER TABLE. + builder.Append("ALTER TABLE ").Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name, operation.Schema)); + + if (newCharSet != oldCharSet && newCharSet != null) + { + builder.Append(" CHARACTER SET ").Append(newCharSet).Append(", "); + } + else + { + builder.Append(" "); + } + + builder + .Append("COLLATE ") + .Append(newCollation) + .AppendLine(Dependencies.SqlGenerationHelper.StatementTerminator); + + EndStatement(builder); + } + else if (newCharSet != oldCharSet || + newCollation != oldCollation && newCollation == null) + { + // The charset has been changed or the collation has been reset to the default. + if (newCharSet != null) + { + // A new charset has been set without an explicit collation. + builder + .Append("ALTER TABLE ") + .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name, operation.Schema)) + .Append(" CHARACTER SET ") + .Append(newCharSet) + .AppendLine(Dependencies.SqlGenerationHelper.StatementTerminator); + + EndStatement(builder); + } + else + { + // Do not emit a table-level "reset to database defaults" statement here. + // In practice this path shows up for delegation-only charset/collation changes, + // where explicit column ALTERs already represent the real schema change. + // The previous dynamic-SQL implementation using PREPARE/EXECUTE caused + // invalid SQL execution on SingleStore. + } + } + if (operation.Comment != operation.OldTable.Comment) { builder.Append("ALTER TABLE ") @@ -375,6 +430,83 @@ protected override void Generate( Check.NotNull(operation, nameof(operation)); Check.NotNull(builder, nameof(builder)); + // SingleStore does not support MODIFY COLUMN for computed columns. + // Computed columns must be dropped and re-added. + // (ALTER TABLE ... MODIFY COLUMN AS (...) PERSISTED is invalid syntax in SingleStore.) + if (operation.ComputedColumnSql != null || operation.OldColumn?.ComputedColumnSql != null) + { + // If the target is no longer computed, we can’t "modify away" the computed definition either. + if (operation.ComputedColumnSql == null) + { + throw new InvalidOperationException( + $"Altering computed column '{operation.Table}.{operation.Name}' to a non-computed column isn't supported by SingleStore. " + + "Drop and re-add the column explicitly."); + } + + var dependentIndexes = model? + .GetRelationalModel() + .FindTable(operation.Table, operation.Schema)? + .Indexes + .Where(i => i.Name != null && + i.Columns.Any(c => string.Equals(c.Name, operation.Name, StringComparison.Ordinal))) + .ToList(); + + if (dependentIndexes != null) + { + foreach (var index in dependentIndexes) + { + Generate( + new DropIndexOperation + { + Name = index.Name, + Schema = operation.Schema, + Table = operation.Table, + }, + model, + builder); + } + } + + // DROP COLUMN + builder + .Append("ALTER TABLE ") + .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Table, operation.Schema)) + .Append(" DROP COLUMN ") + .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name)) + .AppendLine(Dependencies.SqlGenerationHelper.StatementTerminator); + + builder.EndCommand(); + + // ADD COLUMN (recreate with the new definition) + builder + .Append("ALTER TABLE ") + .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Table, operation.Schema)) + .Append(" ADD "); + + ColumnDefinition( + operation.Schema, + operation.Table, + operation.Name, + operation, + model, + builder); + + builder.AppendLine(Dependencies.SqlGenerationHelper.StatementTerminator); + builder.EndCommand(); + + if (dependentIndexes != null) + { + foreach (var index in dependentIndexes) + { + var createIndexOperation = CreateIndexOperationRuntimeSafe(index); + Generate(createIndexOperation, model, builder); + } + } + + return; + } + + // Default path (normal columns) builder .Append("ALTER TABLE ") .Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Table, operation.Schema)) @@ -392,6 +524,64 @@ protected override void Generate( builder.EndCommand(); } + private static T TryGetRuntimeSafe(Func getter, T fallback = default) + { + try + { + return getter(); + } + catch (InvalidOperationException) + { + return fallback; + } + } + + private static CreateIndexOperation CreateIndexOperationRuntimeSafe(ITableIndex index) + { + var operation = new CreateIndexOperation + { + Name = index.Name, + Table = index.Table.Name, + Schema = index.Table.Schema, + Columns = index.Columns.Select(c => c.Name).ToArray(), + IsUnique = index.IsUnique, + }; + + var isDescending = TryGetRuntimeSafe(() => index.IsDescending); + if (isDescending != null) + { + operation.IsDescending = isDescending.ToArray(); + } + + var filter = TryGetRuntimeSafe(() => index.Filter); + if (filter != null) + { + operation.Filter = filter; + } + + if (index.FindAnnotation(SingleStoreAnnotationNames.IndexPrefixLength)?.Value is int[] prefixLengths) + { + operation[SingleStoreAnnotationNames.IndexPrefixLength] = prefixLengths; + } + + if (index.FindAnnotation(SingleStoreAnnotationNames.SpatialIndex)?.Value is bool spatial) + { + operation[SingleStoreAnnotationNames.SpatialIndex] = spatial; + } + + if (index.FindAnnotation(SingleStoreAnnotationNames.FullTextIndex)?.Value is bool fullText) + { + operation[SingleStoreAnnotationNames.FullTextIndex] = fullText; + } + + if (index.FindAnnotation(SingleStoreAnnotationNames.FullTextParser)?.Value is string parser) + { + operation[SingleStoreAnnotationNames.FullTextParser] = parser; + } + + return operation; + } + /// /// Builds commands for the given /// by making calls on the given . @@ -941,7 +1131,8 @@ protected override void ColumnDefinition( if (operation.ComputedColumnSql == null) { - ColumnDefinitionWithCharSet(schema, table, name, operation, model, builder); + // AUTO_INCREMENT columns don't support DEFAULT values. + ColumnDefinitionWithCharSet(schema, table, name, operation, model, builder, withDefaultValue: !autoIncrement); GenerateComment(operation.Comment, builder); @@ -1033,7 +1224,14 @@ private void GenerateComment(string comment, MigrationCommandListBuilder builder .Append(SingleStoreStringTypeMapping.EscapeSqlLiteralWithLineBreaks(comment, !_options.NoBackslashEscapes, false)); } - private void ColumnDefinitionWithCharSet(string schema, string table, string name, ColumnOperation operation, IModel model, MigrationCommandListBuilder builder) + private void ColumnDefinitionWithCharSet( + string schema, + string table, + string name, + ColumnOperation operation, + IModel model, + MigrationCommandListBuilder builder, + bool withDefaultValue) { if (operation.ComputedColumnSql != null) { @@ -1050,7 +1248,10 @@ private void ColumnDefinitionWithCharSet(string schema, string table, string nam builder.Append(operation.IsNullable ? " NULL" : " NOT NULL"); - DefaultValue(operation.DefaultValue, operation.DefaultValueSql, columnType, builder); + if (withDefaultValue) + { + DefaultValue(operation.DefaultValue, operation.DefaultValueSql, columnType, builder); + } var srid = operation[SingleStoreAnnotationNames.SpatialReferenceSystemId]; if (srid is int && @@ -1109,10 +1310,10 @@ private static string GetColumnTypeWithCharSetAndCollation(ColumnOperation opera } protected override void DefaultValue( - object defaultValue, - string defaultValueSql, - string columnType, - MigrationCommandListBuilder builder) + object defaultValue, + string defaultValueSql, + string columnType, + MigrationCommandListBuilder builder) { Check.NotNull(builder, nameof(builder)); @@ -1126,14 +1327,18 @@ protected override void DefaultValue( } else { - Dependencies.MigrationsLogger.DefaultValueNotSupportedWarning(defaultValueSql, _options.ServerVersion, columnType); + Dependencies.MigrationsLogger.DefaultValueNotSupportedWarning( + defaultValueSql, + _options.ServerVersion, + columnType); } } else if (defaultValue is not null) { - var isDefaultValueSupported = IsDefaultValueSupported(columnType); - var supportsDefaultExpressionSyntax = _options.ServerVersion.Supports.DefaultExpression || - _options.ServerVersion.Supports.AlternativeDefaultExpression; + var isLiteralDefaultValueSupported = IsLiteralDefaultValueSupported(columnType); + var supportsDefaultExpressionSyntax = + _options.ServerVersion.Supports.DefaultExpression || + _options.ServerVersion.Supports.AlternativeDefaultExpression; var typeMapping = Dependencies.TypeMappingSource.GetMappingForValue(defaultValue); @@ -1144,10 +1349,9 @@ protected override void DefaultValue( var sqlLiteralDefaultValue = typeMapping.GenerateSqlLiteral(defaultValue); - if (isDefaultValueSupported || - supportsDefaultExpressionSyntax) + if (isLiteralDefaultValueSupported || supportsDefaultExpressionSyntax) { - var useDefaultExpressionSyntax = !isDefaultValueSupported; + var useDefaultExpressionSyntax = !isLiteralDefaultValueSupported; builder.Append(" DEFAULT "); @@ -1173,9 +1377,27 @@ protected override void DefaultValue( } } + private bool IsLiteralDefaultValueSupported(string columnType) + { + if (IsSpatialStoreType(columnType)) + { + return false; + } + + if (columnType.Contains("blob", StringComparison.OrdinalIgnoreCase) || + columnType.Contains("text", StringComparison.OrdinalIgnoreCase) || + columnType.Contains("json", StringComparison.OrdinalIgnoreCase)) + { + // SingleStore supports defaults for BLOB/TEXT/JSON starting with 8.1.12. + return _options.ServerVersion.Version >= new Version(8, 1, 12); + } + + return true; + } + private bool IsDefaultValueSqlSupported(string defaultValueSql, string columnType) { - if (IsDefaultValueSupported(columnType)) + if (IsLiteralDefaultValueSupported(columnType)) { return true; } @@ -1212,47 +1434,16 @@ protected override void CreateTablePrimaryKeyConstraint( [CanBeNull] IModel model, [NotNull] MigrationCommandListBuilder builder) { - Check.NotNull(operation, nameof(operation)); - Check.NotNull(builder, nameof(builder)); - - var primaryKey = operation.PrimaryKey; - if (primaryKey != null) - { - builder.AppendLine(","); - - // MySQL InnoDB has the requirement, that an AUTO_INCREMENT column has to be the first - // column participating in an index. - - var sortedColumnNames = primaryKey.Columns.Length > 1 - ? primaryKey.Columns - .Select(columnName => operation.Columns.First(co => co.Name == columnName)) - .OrderBy(co => co[SingleStoreAnnotationNames.ValueGenerationStrategy] is SingleStoreValueGenerationStrategy generationStrategy - && generationStrategy == SingleStoreValueGenerationStrategy.IdentityColumn - ? 0 - : 1) - .Select(co => co.Name) - .ToArray() - : primaryKey.Columns; - - var sortedPrimaryKey = new AddPrimaryKeyOperation() - { - Schema = primaryKey.Schema, - Table = primaryKey.Table, - Name = primaryKey.Name, - Columns = sortedColumnNames, - IsDestructiveChange = primaryKey.IsDestructiveChange, - }; - - foreach (var annotation in primaryKey.GetAnnotations()) - { - sortedPrimaryKey[annotation.Name] = annotation.Value; - } - - PrimaryKeyConstraint( - sortedPrimaryKey, - model, - builder); - } + // We used to move an AUTO_INCREMENT column to the first position in a primary key, if the PK was a compound key and the column + // was not in the first position. We did this to satisfy InnoDB. + // However, this is technically an inaccuracy, and leads to incompatible FK -> PK mappings in MySQL 8.4. + // We will therefore reverse that behavior to leaving the key order unchanged again. + // This will lead to two issues: + // - Migrations that upgrade vom Pomelo < 9.0 to Pomelo 9.0 will not include this change automatically, because the model + // never changed (we only made the change (before and now) here in MySqlMigrationsSqlGenerator). + // - There now needs to be an index for those cases, that contains the AUTO_INCREMENT column as its first column. + + base.CreateTablePrimaryKeyConstraint(operation, model, builder); } protected override void Generate( @@ -1415,7 +1606,7 @@ protected override void IndexTraits(MigrationOperation operation, IModel model, } } - protected override void IndexOptions(CreateIndexOperation operation, IModel model, MigrationCommandListBuilder builder) + protected override void IndexOptions(MigrationOperation operation, IModel model, MigrationCommandListBuilder builder) { // The base implementation supports index filters in form of a WHERE clause. // This is not supported by MySQL, so we don't call it here. diff --git a/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/BitwiseOperationReturnTypeCorrectingExpressionVisitor.cs b/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/BitwiseOperationReturnTypeCorrectingExpressionVisitor.cs new file mode 100644 index 000000000..47a442309 --- /dev/null +++ b/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/BitwiseOperationReturnTypeCorrectingExpressionVisitor.cs @@ -0,0 +1,88 @@ +// Copyright (c) Pomelo Foundation. All rights reserved. +// Copyright (c) SingleStore Inc. All rights reserved. +// Licensed under the MIT. See LICENSE in the project root for license information. + +using System.Linq.Expressions; +using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.Query.SqlExpressions; +using EntityFrameworkCore.SingleStore.Query.Internal; + +namespace EntityFrameworkCore.SingleStore.Query.ExpressionVisitors.Internal; + +/// +/// MySQL implicitly casts numbers used in all bitwise operations to BIGINT UNSIGNED. +/// Bitwise operations are: +/// +/// +/// Operator +/// Description +/// +/// +/// & +/// Bitwise AND +/// +/// +/// >> +/// Right shift +/// +/// +/// << +/// Left shift +/// +/// +/// ^ +/// Bitwise OR +/// +/// +/// ~ +/// Bitwise inversion +/// +/// +/// We need to cast them back to their expected type. +/// +public class BitwiseOperationReturnTypeCorrectingExpressionVisitor : ExpressionVisitor +{ + private readonly SingleStoreSqlExpressionFactory _sqlExpressionFactory; + + public BitwiseOperationReturnTypeCorrectingExpressionVisitor(SingleStoreSqlExpressionFactory sqlExpressionFactory) + { + _sqlExpressionFactory = sqlExpressionFactory; + } + + protected override Expression VisitExtension(Expression extensionExpression) + => extensionExpression switch + { + SqlUnaryExpression unaryExpression => VisitUnary(unaryExpression), + SqlBinaryExpression binaryExpression => VisitBinary(binaryExpression), + ShapedQueryExpression shapedQueryExpression => shapedQueryExpression.UpdateQueryExpression(Visit(shapedQueryExpression.QueryExpression)), + _ => base.VisitExtension(extensionExpression) + }; + + protected virtual Expression VisitUnary(SqlUnaryExpression sqlUnaryExpression) + => base.VisitExtension(sqlUnaryExpression) is var visitedExpression && + visitedExpression is SqlUnaryExpression { OperatorType: ExpressionType.Not } visitedSqlUnaryExpression && + visitedSqlUnaryExpression.Type != typeof(bool) + ? _sqlExpressionFactory.Convert( + visitedSqlUnaryExpression, + visitedSqlUnaryExpression.Type, + visitedSqlUnaryExpression.TypeMapping) + : visitedExpression; + + protected virtual Expression VisitBinary(SqlBinaryExpression sqlBinaryExpression) + => base.VisitExtension(sqlBinaryExpression) is var visitedExpression && + visitedExpression is SqlBinaryExpression + { + OperatorType: ExpressionType.And + or ExpressionType.RightShift + or ExpressionType.LeftShift + or ExpressionType.ExclusiveOr + or ExpressionType.Or + or ExpressionType.Not + } visitedSqlBinaryExpression && + visitedSqlBinaryExpression.Type != typeof(bool) + ? _sqlExpressionFactory.Convert( + visitedSqlBinaryExpression, + visitedSqlBinaryExpression.Type, + visitedSqlBinaryExpression.TypeMapping) + : visitedExpression; +} diff --git a/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreDbFunctionsExtensionsMethodTranslator.cs b/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreDbFunctionsExtensionsMethodTranslator.cs index f8d1842d7..b8a08888d 100644 --- a/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreDbFunctionsExtensionsMethodTranslator.cs +++ b/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreDbFunctionsExtensionsMethodTranslator.cs @@ -233,7 +233,7 @@ SqlExpression RewriteSessionTz(SqlExpression expr) arguments[2], match.TypeMapping); - var excapeChar = arguments.Count == 4 + var escapeChar = arguments.Count == 4 ? InferStringTypeMappingOrApplyDefault( arguments[3], match.TypeMapping) @@ -242,7 +242,7 @@ SqlExpression RewriteSessionTz(SqlExpression expr) return _sqlExpressionFactory.Like( match, pattern, - excapeChar); + escapeChar); } if (Equals(method, _isMatchMethodInfo) || diff --git a/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreJsonDbFunctionsTranslator.cs b/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreJsonDbFunctionsTranslator.cs index 9621bd7d7..267778b45 100644 --- a/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreJsonDbFunctionsTranslator.cs +++ b/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreJsonDbFunctionsTranslator.cs @@ -91,6 +91,11 @@ public virtual SqlExpression Translate( method.ReturnType, _sqlExpressionFactory.FindMapping(method.ReturnType, "json"), false), + nameof(SingleStoreJsonDbFunctionsExtensions.JsonOverlaps) + => _sqlExpressionFactory.NullableFunction( + "JSON_OVERLAPS", + new[] { Json(args[0]), args[1] }, + typeof(bool)), nameof(SingleStoreJsonDbFunctionsExtensions.JsonContains) => _sqlExpressionFactory.NullableFunction( "JSON_CONTAINS", @@ -128,9 +133,10 @@ public virtual SqlExpression Translate( .Append(_sqlExpressionFactory.Constant("one")) .Append(args[1]) .AppendIfTrue( - args.Length >= 3, () => args.Length >= 4 + args.Length >= 3, + () => args.Length >= 4 ? args[3] - : _sqlExpressionFactory.Constant(null, RelationalTypeMapping.NullMapping)) + : _sqlExpressionFactory.Constant(null, typeof(string))) .AppendIfTrue(args.Length >= 3, () => args[2]), typeof(bool), null, diff --git a/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreJsonTableExpression.cs b/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreJsonTableExpression.cs index 2a143a00e..7e83b50b5 100644 --- a/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreJsonTableExpression.cs +++ b/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreJsonTableExpression.cs @@ -15,7 +15,7 @@ namespace EntityFrameworkCore.SingleStore.Query.ExpressionTranslators.Internal; /// /// An expression that represents a MySQL JSON_TABLE() function call in a SQL tree. /// -public class SingleStoreJsonTableExpression : TableValuedFunctionExpression, IClonableTableExpressionBase +public class SingleStoreJsonTableExpression : TableValuedFunctionExpression { /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -135,26 +135,6 @@ public virtual SingleStoreJsonTableExpression Update( ? this : new SingleStoreJsonTableExpression(Alias, jsonExpression, path, columnInfos); - - /// - /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to - /// the same compatibility standards as public APIs. It may be changed or removed without notice in - /// 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. - /// - // TODO: Deep clone, see #30982 - public virtual TableExpressionBase Clone() - { - var clone = new SingleStoreJsonTableExpression(Alias, JsonExpression, Path, ColumnInfos); - - foreach (var annotation in GetAnnotations()) - { - clone.AddAnnotation(annotation.Name, annotation.Value); - } - - return clone; - } - /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in diff --git a/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreStringComparisonMethodTranslator.cs b/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreStringComparisonMethodTranslator.cs index 262fd28bb..b738630e6 100644 --- a/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreStringComparisonMethodTranslator.cs +++ b/src/EFCore.SingleStore/Query/ExpressionTranslators/Internal/SingleStoreStringComparisonMethodTranslator.cs @@ -410,13 +410,13 @@ private SqlExpression MakeStartsWithEndsWithExpressionImpl( // in C# and send a simple LIKE. return constantPrefixSuffixExpression.Value switch { - null => _sqlExpressionFactory.Like(targetTransform(target), _sqlExpressionFactory.Constant(null, stringTypeMapping)), + null => _sqlExpressionFactory.Like(targetTransform(target), _sqlExpressionFactory.Constant(null, typeof(string), stringTypeMapping)), "" => _sqlExpressionFactory.Like(targetTransform(target), _sqlExpressionFactory.Constant("%")), string s => _sqlExpressionFactory.Like( targetTransform(target), prefixSuffixTransform( _sqlExpressionFactory.Constant( - $"{(startsWith ? string.Empty : "%")}{(s.Any(IsLikeWildChar) ? EscapeLikePattern(s) : s)}{(startsWith ? "%" : string.Empty)}"))), + $"{(startsWith ? string.Empty : "%")}{(s.Any(IsLikeWildOrEscapeChar) ? EscapeLikePattern(s) : s)}{(startsWith ? "%" : string.Empty)}"))), _ => throw new UnreachableException(), }; } @@ -467,17 +467,15 @@ private SqlExpression MakeContainsExpressionImpl( if (pattern is SqlConstantExpression constantPatternExpression) { - // The prefix is constant. Aside from null or empty, we escape all special characters (%, _, \) - // in C# and send a simple LIKE. // The prefix is constant. Aside from null or empty, we escape all special characters (%, _, \) // in C# and send a simple LIKE. return constantPatternExpression.Value switch { - null => _sqlExpressionFactory.Like(targetTransform(target), _sqlExpressionFactory.Constant(null, stringTypeMapping)), + null => _sqlExpressionFactory.Like(targetTransform(target), _sqlExpressionFactory.Constant(null, typeof(string), stringTypeMapping)), "" => _sqlExpressionFactory.Like(targetTransform(target), _sqlExpressionFactory.Constant("%")), string s => _sqlExpressionFactory.Like( targetTransform(target), - patternTransform(_sqlExpressionFactory.Constant($"%{(s.Any(IsLikeWildChar) ? EscapeLikePattern(s) : s)}%"))), + patternTransform(_sqlExpressionFactory.Constant($"%{(s.Any(IsLikeWildOrEscapeChar) ? EscapeLikePattern(s) : s)}%"))), _ => throw new UnreachableException(), }; } @@ -519,7 +517,8 @@ private SqlExpression MakeContainsExpressionImpl( _sqlExpressionFactory.Constant(string.Empty, stringTypeMapping))))); } - protected virtual SqlExpression GetLikeExpressionUsingParameter(QueryCompilationContext queryCompilationContext, + protected virtual SqlExpression GetLikeExpressionUsingParameter( + QueryCompilationContext queryCompilationContext, SqlExpression target, Func targetTransform, SqlExpression pattern, @@ -696,15 +695,15 @@ private SqlExpression Locate(SqlExpression sub, SqlExpression str, SqlExpression private const char LikeEscapeChar = '\\'; - private static bool IsLikeWildChar(char c) => c == '%' || c == '_'; + private static bool IsLikeWildOrEscapeChar(char c) => IsLikeWildChar(c) || LikeEscapeChar == c; + private static bool IsLikeWildChar(char c) => c is '%' or '_'; private static string EscapeLikePattern(string pattern) { var builder = new StringBuilder(); foreach (var c in pattern) { - if (IsLikeWildChar(c) || - c == LikeEscapeChar) + if (IsLikeWildOrEscapeChar(c)) { builder.Append(LikeEscapeChar); } diff --git a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreBoolOptimizingExpressionVisitor.cs b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreBoolOptimizingExpressionVisitor.cs index 6dd7ad7bb..98997b084 100644 --- a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreBoolOptimizingExpressionVisitor.cs +++ b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreBoolOptimizingExpressionVisitor.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; @@ -99,7 +100,7 @@ protected override Expression VisitColumn(ColumnExpression columnExpression) } protected override Expression VisitDelete(DeleteExpression deleteExpression) - => deleteExpression.Update((SelectExpression)Visit(deleteExpression.SelectExpression)); + => deleteExpression.Update(deleteExpression.Table, (SelectExpression)Visit(deleteExpression.SelectExpression)); protected override Expression VisitDistinct(DistinctExpression distinctExpression) { @@ -245,7 +246,7 @@ protected override Expression VisitSelect(SelectExpression selectExpression) return changed ? selectExpression.Update( - projections, tables, predicate, groupBy, havingExpression, orderings, limit, offset) + tables, predicate, groupBy, havingExpression, projections, orderings, offset, limit) : selectExpression; } @@ -672,14 +673,25 @@ protected override Expression VisitValues(ValuesExpression valuesExpression) var parentOptimize = _optimize; _optimize = false; - var rowValues = new RowValueExpression[valuesExpression.RowValues.Count]; - for (var i = 0; i < rowValues.Length; i++) + switch (valuesExpression) { - rowValues[i] = (RowValueExpression)Visit(valuesExpression.RowValues[i]); - } + case { RowValues: not null }: + var rowValues = new RowValueExpression[valuesExpression.RowValues!.Count]; + for (var i = 0; i < rowValues.Length; i++) + { + rowValues[i] = (RowValueExpression)Visit(valuesExpression.RowValues[i]); + } + _optimize = parentOptimize; + return valuesExpression.Update(rowValues); - _optimize = parentOptimize; - return valuesExpression.Update(rowValues); + case { ValuesParameter: not null }: + var valuesParameter = (SqlParameterExpression)Visit(valuesExpression.ValuesParameter); + _optimize = parentOptimize; + return valuesExpression.Update(valuesParameter); + + default: + throw new UnreachableException(); + } } } } diff --git a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreHavingExpressionVisitor.cs b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreHavingExpressionVisitor.cs index df237865d..96188add9 100644 --- a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreHavingExpressionVisitor.cs +++ b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreHavingExpressionVisitor.cs @@ -9,81 +9,127 @@ using EntityFrameworkCore.SingleStore.Query.Expressions.Internal; using EntityFrameworkCore.SingleStore.Query.Internal; -namespace EntityFrameworkCore.SingleStore.Query.ExpressionVisitors.Internal +namespace EntityFrameworkCore.SingleStore.Query.ExpressionVisitors.Internal; + +/// +/// MySQL & MariaDB currently do not support complex expressions in HAVING clauses (e.g. function calls). +/// Instead, they want you to reference SELECT aliases for those expressions in the HAVING clause. +/// See https://bugs.mysql.com/bug.php?id=103961 +/// This is only an issue for HAVING expressions that do not contain any aggregate functions. +/// +public class SingleStoreHavingExpressionVisitor : ExpressionVisitor { - public class SingleStoreHavingExpressionVisitor : ExpressionVisitor + private readonly SingleStoreSqlExpressionFactory _sqlExpressionFactory; + private readonly SingleStoreContainsAggregateFunctionExpressionVisitor _containsAggregateFunctionExpressionVisitor; + private bool _usePrePostprocessorMode; + + public SingleStoreHavingExpressionVisitor(SingleStoreSqlExpressionFactory sqlExpressionFactory) + { + _sqlExpressionFactory = sqlExpressionFactory; + _containsAggregateFunctionExpressionVisitor = new SingleStoreContainsAggregateFunctionExpressionVisitor(); + } + + public virtual Expression Process(Expression expression, bool usePrePostprocessorMode) { - private readonly SingleStoreSqlExpressionFactory _sqlExpressionFactory; - private SingleStoreContainsAggregateFunctionExpressionVisitor _containsAggregateFunctionExpressionVisitor; + _usePrePostprocessorMode = usePrePostprocessorMode; + return Visit(expression); + } - public SingleStoreHavingExpressionVisitor(SingleStoreSqlExpressionFactory sqlExpressionFactory) + protected override Expression VisitExtension(Expression extensionExpression) + => extensionExpression switch { - _sqlExpressionFactory = sqlExpressionFactory; + SelectExpression selectExpression => VisitSelect(selectExpression), + ShapedQueryExpression shapedQueryExpression => VisitShapedQuery(shapedQueryExpression), + RelationalGroupByShaperExpression relationalGroupByShaperExpression => VisitRelationalGroupByShaper( + relationalGroupByShaperExpression), + _ => base.VisitExtension(extensionExpression) + }; + + private Expression VisitRelationalGroupByShaper(RelationalGroupByShaperExpression relationalGroupByShaperExpression) + { + if (_usePrePostprocessorMode) + { + Visit(relationalGroupByShaperExpression.KeySelector); + Visit(relationalGroupByShaperExpression.ElementSelector); + Visit(relationalGroupByShaperExpression.GroupingEnumerable); + + return relationalGroupByShaperExpression; } - protected override Expression VisitExtension(Expression extensionExpression) - => extensionExpression switch - { - SelectExpression selectExpression => VisitSelect(selectExpression), - ShapedQueryExpression shapedQueryExpression => shapedQueryExpression.Update( - Visit(shapedQueryExpression.QueryExpression), Visit(shapedQueryExpression.ShaperExpression)), - _ => base.VisitExtension(extensionExpression) - }; + return base.VisitExtension(relationalGroupByShaperExpression); + } + + private ShapedQueryExpression VisitShapedQuery(ShapedQueryExpression shapedQueryExpression) + { + if (_usePrePostprocessorMode) + { + Visit(shapedQueryExpression.QueryExpression); + Visit(shapedQueryExpression.ShaperExpression); - protected virtual Expression VisitSelect(SelectExpression selectExpression) + return shapedQueryExpression; + } + + return shapedQueryExpression.Update( + Visit(shapedQueryExpression.QueryExpression), + Visit(shapedQueryExpression.ShaperExpression)); + } + + protected virtual Expression VisitSelect(SelectExpression selectExpression) + { + selectExpression = (SelectExpression)base.VisitExtension(selectExpression); + + var havingExpression = selectExpression.Having; + + if (HasHavingExpressionWithoutAggregateFunction(havingExpression)) { - // MySQL & MariaDB currently do not support complex expressions in HAVING clauses (e.g. function calls). - // Instead, they want you to reference SELECT aliases for those expressions in the HAVING clause. - // See https://bugs.mysql.com/bug.php?id=103961 - // This is only an issue for HAVING expressions that do not contain any aggregate functions. - var havingExpression = selectExpression.Having; - if (havingExpression is not null && - havingExpression is not SqlConstantExpression && - havingExpression is not SingleStoreColumnAliasReferenceExpression) + if (_usePrePostprocessorMode) { - _containsAggregateFunctionExpressionVisitor ??= new SingleStoreContainsAggregateFunctionExpressionVisitor(); - if (!_containsAggregateFunctionExpressionVisitor.ProcessUntilSelect(havingExpression)) - { - selectExpression.PushdownIntoSubquery(); - var subQuery = (SelectExpression) selectExpression.Tables.Single(); - - var projectionIndex = subQuery.AddToProjection(havingExpression); - var alias = subQuery.Projection[projectionIndex].Alias; - - var columnAliasReferenceExpression = _sqlExpressionFactory.ColumnAliasReference( - alias, - havingExpression, - havingExpression.Type, - havingExpression.TypeMapping); - - // Having expressions, not containing an aggregate function, need to be part of the GROUP BY clause, because they now also - // appear as part of the SELECT clause. - var groupBy = subQuery.GroupBy.ToList(); - groupBy.Add(columnAliasReferenceExpression); - - subQuery = subQuery.Update( - subQuery.Projection, - subQuery.Tables, - subQuery.Predicate, - groupBy, - columnAliasReferenceExpression, - subQuery.Orderings, - subQuery.Limit, - subQuery.Offset); - - selectExpression = selectExpression.Update( - selectExpression.Projection, - new[] {subQuery}, - selectExpression.Predicate, - selectExpression.GroupBy, - selectExpression.Having, - selectExpression.Orderings, - selectExpression.Limit, - selectExpression.Offset); - } + // This part needs to run before `RelationalQueryTranslationPostprocessor.Process()` is called, so that the + // `SelectExpression` is still mutable, and we can call `SelectExpression.PushdownIntoSubquery()`. + + selectExpression.PushdownIntoSubquery(); + + // Paradoxically, it seems quite complicated to change the subquery, as long as the outer query is still mutable. + // We postpone that work for later, when the outer query is immutable, and we simply use the normal expression visitor + // update process. } + else + { + // This part needs to run after `RelationalQueryTranslationPostprocessor.Process()` is called, so that the + // `SelectExpression` is already immutable, and we can simply update the select subquery. + + var projectionIndex = selectExpression.AddToProjection(havingExpression!); + var alias = selectExpression.Projection[projectionIndex].Alias; + + var columnAliasReferenceExpression = _sqlExpressionFactory.ColumnAliasReference( + alias, + havingExpression, + havingExpression.Type, + havingExpression.TypeMapping); - return base.VisitExtension(selectExpression); + // Having expressions, not containing an aggregate function, need to be part of the GROUP BY clause, because they now + // also appear as part of the SELECT clause. + selectExpression = selectExpression.Update( + selectExpression.Tables, + selectExpression.Predicate, + selectExpression.GroupBy.Append(columnAliasReferenceExpression).ToList(), + having: columnAliasReferenceExpression, + selectExpression.Projection, + selectExpression.Orderings, + selectExpression.Offset, + selectExpression.Limit); + } } + + return selectExpression; } + + /// + /// Backed by `EFCore.SingleStore.Tests/Behaviors/HavingBehavior.cs`. + /// + private bool HasHavingExpressionWithoutAggregateFunction(SqlExpression havingExpression) + => havingExpression is not null + and not SqlConstantExpression + and not SingleStoreColumnAliasReferenceExpression && + !_containsAggregateFunctionExpressionVisitor.ProcessUntilSelect(havingExpression); } diff --git a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreNonWorkingHavingExpressionVisitor.cs b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreNonWorkingHavingExpressionVisitor.cs new file mode 100644 index 000000000..f835de7ea --- /dev/null +++ b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreNonWorkingHavingExpressionVisitor.cs @@ -0,0 +1,234 @@ +// Copyright (c) Pomelo Foundation. All rights reserved. +// Copyright (c) SingleStore Inc. All rights reserved. +// Licensed under the MIT. See LICENSE in the project root for license information. + +using System.Linq; +using System.Linq.Expressions; +using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.Query.SqlExpressions; +using EntityFrameworkCore.SingleStore.Query.Expressions.Internal; +using EntityFrameworkCore.SingleStore.Query.Internal; + +namespace EntityFrameworkCore.SingleStore.Query.ExpressionVisitors.Internal +{ + // TODO: 9.0 + // Remove from codebase. + public class SingleStoreNonWorkingHavingExpressionVisitor : ExpressionVisitor + { + private readonly SingleStoreSqlExpressionFactory _sqlExpressionFactory; + private readonly SqlAliasManager _sqlAliasManager; + private SingleStoreContainsAggregateFunctionExpressionVisitor _containsAggregateFunctionExpressionVisitor; + + public SingleStoreNonWorkingHavingExpressionVisitor(SingleStoreSqlExpressionFactory sqlExpressionFactory, SqlAliasManager sqlAliasManager) + { + _sqlExpressionFactory = sqlExpressionFactory; + _sqlAliasManager = sqlAliasManager; + } + + protected override Expression VisitExtension(Expression extensionExpression) + => extensionExpression switch + { + SelectExpression selectExpression => VisitSelectMutable(selectExpression), + // SelectExpression selectExpression => VisitSelectImmutable(selectExpression), + ShapedQueryExpression shapedQueryExpression => VisitShapedQuery(shapedQueryExpression), + _ => base.VisitExtension(extensionExpression) + }; + + private ShapedQueryExpression VisitShapedQuery(ShapedQueryExpression shapedQueryExpression) + => shapedQueryExpression.Update( + (SelectExpression)Visit(shapedQueryExpression.QueryExpression), + Visit(shapedQueryExpression.ShaperExpression)); + + /// + /// This might work, if we would know if the outer query is supposed to be mutable or not (which we cannot directly find out + /// because `SelectExpression.IsMutable` is internal) and if we could copy or recreate the projection mappings of the outer query. + /// + protected virtual Expression VisitSelectMutable(SelectExpression selectExpression) + { + // MySQL & MariaDB currently do not support complex expressions in HAVING clauses (e.g. function calls). + // Instead, they want you to reference SELECT aliases for those expressions in the HAVING clause. + // See https://bugs.mysql.com/bug.php?id=103961 + // This is only an issue for HAVING expressions that do not contain any aggregate functions. + var havingExpression = selectExpression.Having; + if (havingExpression is not null && + havingExpression is not SqlConstantExpression && + havingExpression is not SingleStoreColumnAliasReferenceExpression) + { + _containsAggregateFunctionExpressionVisitor ??= new SingleStoreContainsAggregateFunctionExpressionVisitor(); + if (!_containsAggregateFunctionExpressionVisitor.ProcessUntilSelect(havingExpression)) + { + var newSelectExpression = selectExpression.Clone(); + + newSelectExpression.PushdownIntoSubquery(); + + var subQuery = (SelectExpression)newSelectExpression.Tables.Single(); + var projectionIndex = subQuery.AddToProjection(havingExpression); + var alias = subQuery.Projection[projectionIndex].Alias; + + var columnAliasReferenceExpression = _sqlExpressionFactory.ColumnAliasReference( + alias, + havingExpression, + havingExpression.Type, + havingExpression.TypeMapping); + + // Having expressions, not containing an aggregate function, need to be part of the GROUP BY clause, because they now also + // appear as part of the SELECT clause. + var groupBy = subQuery.GroupBy.ToList(); + groupBy.Add(columnAliasReferenceExpression); + + subQuery = new SelectExpression( + subQuery.Alias, + subQuery.Tables.ToList(), + subQuery.Predicate, + groupBy, + columnAliasReferenceExpression, + subQuery.Projection.ToList(), + subQuery.IsDistinct, + subQuery.Orderings.ToList(), + subQuery.Offset, + subQuery.Limit, + subQuery.Tags, + subQuery.GetAnnotations().ToDictionary(a => a.Name, a => a), + _sqlAliasManager, + isMutable: false + ); + + newSelectExpression = new SelectExpression( + newSelectExpression.Alias, + [subQuery], + newSelectExpression.Predicate, + newSelectExpression.GroupBy.ToList(), + newSelectExpression.Having, + projections: [], + newSelectExpression.IsDistinct, + newSelectExpression.Orderings.ToList(), + newSelectExpression.Offset, + newSelectExpression.Limit, + newSelectExpression.Tags, + newSelectExpression.GetAnnotations().ToDictionary(a => a.Name, a => a), + _sqlAliasManager, + isMutable: true + ); + + // + // UNSOLVED: Somehow recreate projection mappings here. + // + + selectExpression = newSelectExpression; + } + } + + return base.VisitExtension(selectExpression); + } + + /// + /// This basically needs to reimplement `SelectExpression.PushdownIntoSubquery()`, which we are definitely not going to do. + /// + protected virtual Expression VisitSelectImmutable(SelectExpression selectExpression) + { + // MySQL & MariaDB currently do not support complex expressions in HAVING clauses (e.g. function calls). + // Instead, they want you to reference SELECT aliases for those expressions in the HAVING clause. + // See https://bugs.mysql.com/bug.php?id=103961 + // This is only an issue for HAVING expressions that do not contain any aggregate functions. + var havingExpression = selectExpression.Having; + if (havingExpression is not null && + havingExpression is not SqlConstantExpression && + havingExpression is not SingleStoreColumnAliasReferenceExpression) + { + _containsAggregateFunctionExpressionVisitor ??= new SingleStoreContainsAggregateFunctionExpressionVisitor(); + if (!_containsAggregateFunctionExpressionVisitor.ProcessUntilSelect(havingExpression)) + { + var subquery = selectExpression.Clone(); + subquery.ReplaceProjection([]); + + var alias = "having"; + var havingProjectionExpression = new ProjectionExpression(havingExpression, alias); + var columnAliasReferenceExpression = _sqlExpressionFactory.ColumnAliasReference( + alias, + havingExpression, + havingExpression.Type, + havingExpression.TypeMapping); + + // Having expressions, not containing an aggregate function, need to be part of the GROUP BY clause, because they now also + // appear as part of the SELECT clause. + subquery = subquery.Update( + subquery.Tables, + subquery.Predicate, + subquery.GroupBy.Append(columnAliasReferenceExpression).ToList(), + columnAliasReferenceExpression, + subquery.Projection.Append(havingProjectionExpression).ToList(), + subquery.Limit is not null || subquery.Offset is not null + ? subquery.Orderings + : [], + subquery.Offset, // Offset/limit parameters got switched around between EF Core 8 and 9 for no good reason. + subquery.Limit); + + + var outerSelectOrderings = selectExpression.Orderings; + + // foreach (var ordering in subquery.Orderings) + // { + // var orderingExpression = ordering.Expression; + // if (liftOrderings && projectionMap.TryGetValue(orderingExpression, out var outerColumn)) + // { + // _orderings.Add(ordering.Update(outerColumn)); + // } + // else if (liftOrderings + // && (!IsDistinct + // && GroupBy.Count == 0 + // || GroupBy.Contains(orderingExpression))) + // { + // _orderings.Add( + // ordering.Update( + // subquery.GenerateOuterColumn(subqueryAlias, orderingExpression))); + // } + // else + // { + // _orderings.Clear(); + // break; + // } + // } + + + selectExpression = selectExpression.Update( + [subquery], + selectExpression.Predicate, + groupBy: [], + having: null, + subquery.Projection/*.Select(p => new ProjectionExpression(new ColumnExpression(p.Alias, subquery.Alias, p.Type, null)))*/, + outerSelectOrderings, + null, + null); + } + } + + return base.VisitExtension(selectExpression); + } + + // private ColumnExpression GenerateOuterColumn( + // SelectExpression subquery, + // string tableAlias, + // SqlExpression projection/*, + // string columnAlias = null*/) + // { + // // TODO: Add check if we can add projection in subquery to generate out column + // // Subquery having Distinct or GroupBy can block it. + // var index = subquery.AddToProjection(projection); + // var projectionExpression = subquery.Projection[index]; + // return CreateColumnExpression(projectionExpression, tableAlias); + // } + // + // private static ColumnExpression CreateColumnExpression(ProjectionExpression subqueryProjection, string tableAlias) + // => new( + // subqueryProjection.Alias, + // tableAlias, + // subqueryProjection.Type, + // subqueryProjection.Expression.TypeMapping!, + // subqueryProjection.Expression switch + // { + // ColumnExpression columnExpression => columnExpression.IsNullable, + // SqlConstantExpression sqlConstantExpression => sqlConstantExpression.Value == null, + // _ => true + // }); + } +} diff --git a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreParameterInliningExpressionVisitor.cs b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreParameterInliningExpressionVisitor.cs index c62f85c51..5a5b1a465 100644 --- a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreParameterInliningExpressionVisitor.cs +++ b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreParameterInliningExpressionVisitor.cs @@ -108,7 +108,7 @@ protected virtual Expression VisitSqlParameter(SqlParameterExpression sqlParamet return new SingleStoreInlinedParameterExpression( sqlParameterExpression, - _sqlExpressionFactory.Constant( + (SqlConstantExpression)_sqlExpressionFactory.Constant( _parametersValues[sqlParameterExpression.Name], sqlParameterExpression.TypeMapping)); } diff --git a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQuerySqlGenerator.cs b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQuerySqlGenerator.cs index dff9a70e4..a5b109f35 100644 --- a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQuerySqlGenerator.cs +++ b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQuerySqlGenerator.cs @@ -412,7 +412,7 @@ protected override Expression VisitDelete(DeleteExpression deleteExpression) } throw new InvalidOperationException( - RelationalStrings.ExecuteOperationWithUnsupportedOperatorInSqlGeneration(nameof(RelationalQueryableExtensions.ExecuteDelete))); + RelationalStrings.ExecuteOperationWithUnsupportedOperatorInSqlGeneration(nameof(EntityFrameworkQueryableExtensions.ExecuteDelete))); } protected override Expression VisitUpdate(UpdateExpression updateExpression) @@ -480,7 +480,7 @@ protected override Expression VisitUpdate(UpdateExpression updateExpression) } throw new InvalidOperationException( - RelationalStrings.ExecuteOperationWithUnsupportedOperatorInSqlGeneration(nameof(RelationalQueryableExtensions.ExecuteUpdate))); + RelationalStrings.ExecuteOperationWithUnsupportedOperatorInSqlGeneration(nameof(EntityFrameworkQueryableExtensions.ExecuteUpdate))); } protected override Expression VisitJsonScalar(JsonScalarExpression jsonScalarExpression) @@ -548,6 +548,11 @@ protected override Expression VisitJsonScalar(JsonScalarExpression jsonScalarExp protected override void GenerateValues(ValuesExpression valuesExpression) { + if (valuesExpression.RowValues is null) + { + throw new UnreachableException(); + } + if (_options.ServerVersion.Supports.Values || _options.ServerVersion.Supports.ValuesWithRows) { @@ -718,33 +723,24 @@ private SqlUnaryExpression VisitConvert(SqlUnaryExpression sqlUnaryExpression) !castMapping.Equals(sqlUnaryExpression.Operand.TypeMapping.StoreType, StringComparison.OrdinalIgnoreCase) && !sameInnerCastStoreType) { - var useDecimalToDoubleWorkaround = false; - - if (castMapping.StartsWith("double") && - !_options.ServerVersion.Supports.DoubleCast) - { - useDecimalToDoubleWorkaround = true; - castMapping = "decimal(65,30)"; - } - - if (useDecimalToDoubleWorkaround) + // SingleStore does not support CAST(.. AS double) (CAST/CONVERT target types are limited), + // but it does support the cast operator ":>" for DOUBLE/FLOAT. + if (castMapping.StartsWith("double", StringComparison.OrdinalIgnoreCase) && + !_options.ServerVersion.Supports.DoubleCast) { Sql.Append("("); + Visit(sqlUnaryExpression.Operand); + Sql.Append(" :> "); + Sql.Append("double"); + Sql.Append(")"); } - - Sql.Append("CAST("); - Visit(sqlUnaryExpression.Operand); - Sql.Append(" AS "); - Sql.Append(castMapping); - Sql.Append(")"); - - // FLOAT and DOUBLE are supported by CAST() as of MySQL 8.0.17. - // For server versions before that, a workaround is applied, that casts to a DECIMAL, - // that is then added to 0e0, which results in a DOUBLE. - // REF: https://dev.mysql.com/doc/refman/8.0/en/number-literals.html - if (useDecimalToDoubleWorkaround) + else { - Sql.Append(" + 0e0)"); + Sql.Append("CAST("); + Visit(sqlUnaryExpression.Operand); + Sql.Append(" AS "); + Sql.Append(castMapping); + Sql.Append(")"); } } else @@ -824,11 +820,32 @@ public virtual Expression VisitSingleStoreCollateExpression(SingleStoreCollateEx { Check.NotNull(mySqlCollateExpression, nameof(mySqlCollateExpression)); - Sql.Append("CONVERT("); + // SingleStore doesn't support CONVERT(... USING charset) syntax + // Instead, use the cast operator `:>` with collation + // e.g., 'value' :> VARCHAR(255) COLLATE utf8mb4_bin + Sql.Append("("); Visit(mySqlCollateExpression.ValueExpression); + Sql.Append(" :> "); + + // Determine the appropriate varchar size based on type mapping + var typeMapping = mySqlCollateExpression.ValueExpression.TypeMapping ?? mySqlCollateExpression.TypeMapping; + var storeType = typeMapping?.StoreType?.ToLower(); + var varcharType = "VARCHAR(255)"; // Default + + // Extract size from store type if available (e.g., "varchar(50)" -> "VARCHAR(50)") + if (!string.IsNullOrEmpty(storeType) && + (storeType.StartsWith("varchar") || storeType.StartsWith("char"))) + { + var sizeStart = storeType.IndexOf('('); + if (sizeStart >= 0) + { + varcharType = $"VARCHAR{storeType.Substring(sizeStart)}"; + } + } - Sql.Append($" USING {mySqlCollateExpression.Charset}) COLLATE {mySqlCollateExpression.Collation}"); + Sql.Append(varcharType); + Sql.Append($" COLLATE {mySqlCollateExpression.Collation})"); return mySqlCollateExpression; } diff --git a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQueryTranslationPostprocessor.cs b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQueryTranslationPostprocessor.cs index e8edf17bb..4a148e99f 100644 --- a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQueryTranslationPostprocessor.cs +++ b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQueryTranslationPostprocessor.cs @@ -17,7 +17,7 @@ public class SingleStoreQueryTranslationPostprocessor : RelationalQueryTranslati public SingleStoreQueryTranslationPostprocessor( QueryTranslationPostprocessorDependencies dependencies, RelationalQueryTranslationPostprocessorDependencies relationalDependencies, - QueryCompilationContext queryCompilationContext, + SingleStoreQueryCompilationContext queryCompilationContext, ISingleStoreOptions options, SingleStoreSqlExpressionFactory sqlExpressionFactory) : base(dependencies, relationalDependencies, queryCompilationContext) @@ -28,8 +28,15 @@ public SingleStoreQueryTranslationPostprocessor( public override Expression Process(Expression query) { + var mySqlHavingExpressionVisitor = new SingleStoreHavingExpressionVisitor(_sqlExpressionFactory); + + query = mySqlHavingExpressionVisitor.Process(query, usePrePostprocessorMode: true); + + // Changes `SelectExpression.IsMutable` from `true` to `false`. query = base.Process(query); + query = mySqlHavingExpressionVisitor.Process(query, usePrePostprocessorMode: false); + query = new SingleStoreJsonParameterExpressionVisitor(_sqlExpressionFactory, _options).Visit(query); if (_options.ServerVersion.Supports.SingleStoreBug96947Workaround) @@ -37,6 +44,8 @@ public override Expression Process(Expression query) query = new SingleStoreBug96947WorkaroundExpressionVisitor(_sqlExpressionFactory).Visit(query); } + query = new BitwiseOperationReturnTypeCorrectingExpressionVisitor(_sqlExpressionFactory).Visit(query); + return query; } } diff --git a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQueryTranslationPostprocessorFactory.cs b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQueryTranslationPostprocessorFactory.cs index 86a6fd1e3..fc9961add 100644 --- a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQueryTranslationPostprocessorFactory.cs +++ b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQueryTranslationPostprocessorFactory.cs @@ -31,7 +31,7 @@ public virtual QueryTranslationPostprocessor Create(QueryCompilationContext quer => new SingleStoreQueryTranslationPostprocessor( _dependencies, _relationalDependencies, - queryCompilationContext, + (SingleStoreQueryCompilationContext)queryCompilationContext, _options, _sqlExpressionFactory); } diff --git a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQueryableMethodNormalizingExpressionVisitor.cs b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQueryableMethodNormalizingExpressionVisitor.cs index 2c09739c3..d8bfdbf51 100644 --- a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQueryableMethodNormalizingExpressionVisitor.cs +++ b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreQueryableMethodNormalizingExpressionVisitor.cs @@ -11,6 +11,10 @@ namespace EntityFrameworkCore.SingleStore.Query.ExpressionVisitors.Internal; +// TODO: 9.0 +// Remove SingleStoreQueryableMethodNormalizingExpressionVisitor, SingleStoreBipolarExpression and +// SingleStoreQueryTranslationPreprocessor.NormalizeQueryableMethod (or the whole class) and use ElementAt() directly in Json translation classes. + /// /// Skips normalization of array[index].Property to array.Select(e => e.Property).ElementAt(index), /// because it messes-up our JSON-Array handling in `SingleStoreSqlTranslatingExpressionVisitor`. @@ -19,7 +23,7 @@ namespace EntityFrameworkCore.SingleStore.Query.ExpressionVisitors.Internal; public class SingleStoreQueryableMethodNormalizingExpressionVisitor : QueryableMethodNormalizingExpressionVisitor { public SingleStoreQueryableMethodNormalizingExpressionVisitor(QueryCompilationContext queryCompilationContext) - : base(queryCompilationContext) + : base(queryCompilationContext, isEfConstantSupported: true) { } @@ -76,7 +80,7 @@ IEnumerable VisitArguments(IEnumerable arguments) { foreach (var expression in arguments) { - yield return VisitExtension(expression); + yield return Visit(expression); } } diff --git a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreSqlTranslatingExpressionVisitor.cs b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreSqlTranslatingExpressionVisitor.cs index 740c762c5..bba144f47 100644 --- a/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.SingleStore/Query/ExpressionVisitors/Internal/SingleStoreSqlTranslatingExpressionVisitor.cs @@ -32,7 +32,8 @@ public class SingleStoreSqlTranslatingExpressionVisitor : RelationalSqlTranslati protected static readonly MethodInfo[] NewArrayExpressionSupportMethodInfos = Array.Empty() .Concat(typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethods().Where(m => m.Name is nameof(SingleStoreDbFunctionsExtensions.Match) or nameof(SingleStoreDbFunctionsExtensions.IsMatch))) - .Concat(typeof(string).GetRuntimeMethods().Where(m => m.Name == nameof(string.Concat))) + .Concat(typeof(string).GetRuntimeMethods().Where(m => m.Name is nameof(string.Concat) + or nameof(string.Join))) .Where(m => m.GetParameters().Any(p => p.ParameterType.IsArray)) .ToArray(); @@ -126,21 +127,7 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression) ResetTranslationErrorDetails(); } - var visitedExpression = base.VisitUnary(unaryExpression); - - if (visitedExpression is SqlUnaryExpression sqlUnaryExpression && - sqlUnaryExpression.OperatorType == ExpressionType.Not && - sqlUnaryExpression.Type != typeof(bool)) - { - // MySQL implicitly casts numbers used in BITWISE NOT operations (~ operator) to BIGINT UNSIGNED. - // We need to cast them back, to get the expected result. - return _sqlExpressionFactory.Convert( - sqlUnaryExpression, - sqlUnaryExpression.Type, - sqlUnaryExpression.TypeMapping); - } - - return visitedExpression; + return base.VisitUnary(unaryExpression); } protected override Expression VisitBinary(BinaryExpression binaryExpression) @@ -327,7 +314,7 @@ private Expression TranslateByteArrayElementAccess(Expression array, Expression protected virtual Expression VisitMethodCallNewArray(NewArrayExpression newArrayExpression) { - // Needed for SingleStoreDbFunctionsExtensions.Match() and String.Concat() translation. + // Needed for SingleStoreDbFunctionsExtensions.Match(), String.Concat() and String.Join() translations. if (newArrayExpression.Type == typeof(string[])) { return _sqlExpressionFactory.ComplexFunctionArgument( @@ -337,7 +324,7 @@ protected virtual Expression VisitMethodCallNewArray(NewArrayExpression newArray typeof(string[])); } - // Needed for String.Concat() translation. + // Needed for String.Concat() translation and String.Join() translations. if (newArrayExpression.Type == typeof(object[])) { var typeMapping = ((SingleStoreStringTypeMapping)Dependencies.TypeMappingSource.GetMapping(typeof(string))).Clone(forceToString: true); @@ -456,6 +443,20 @@ protected virtual void ResetTranslationErrorDetails() base.Translate(Expression.Constant(0)); } + public override SqlExpression GenerateGreatest(IReadOnlyList expressions, Type resultType) + => _sqlExpressionFactory.NullableFunction( + "GREATEST", + expressions, + resultType, + true); + + public override SqlExpression GenerateLeast(IReadOnlyList expressions, Type resultType) + => _sqlExpressionFactory.NullableFunction( + "LEAST", + expressions, + resultType, + true); + #region Copied from RelationalSqlTranslatingExpressionVisitor private static Expression TryRemoveImplicitConvert(Expression expression) diff --git a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreBinaryExpression.cs b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreBinaryExpression.cs index 4e028b386..e681d09a5 100644 --- a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreBinaryExpression.cs +++ b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreBinaryExpression.cs @@ -4,6 +4,7 @@ using System; using System.Linq.Expressions; +using System.Reflection; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; using Microsoft.EntityFrameworkCore.Storage; @@ -28,6 +29,8 @@ public enum SingleStoreBinaryExpressionOperatorType public class SingleStoreBinaryExpression : SqlExpression { + private static ConstructorInfo _quotingConstructor; + public SingleStoreBinaryExpression( SingleStoreBinaryExpressionOperatorType operatorType, SqlExpression left, @@ -62,6 +65,16 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) return Update(left, right); } + public override Expression Quote() + => New( + _quotingConstructor ??= typeof(SingleStoreBinaryExpression).GetConstructor( + [typeof(SingleStoreBinaryExpressionOperatorType), typeof(SqlExpression), typeof(SqlExpression), typeof(Type), typeof(RelationalTypeMapping)])!, + Constant(OperatorType), + Left.Quote(), + Right.Quote(), + Constant(Type), + RelationalExpressionQuotingUtilities.QuoteTypeMapping(TypeMapping)); + public virtual SingleStoreBinaryExpression Update(SqlExpression left, SqlExpression right) => left != Left || right != Right ? new SingleStoreBinaryExpression(OperatorType, left, right, Type, TypeMapping) diff --git a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreCollateExpression.cs b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreCollateExpression.cs index 1d0e221fb..672af0751 100644 --- a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreCollateExpression.cs +++ b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreCollateExpression.cs @@ -5,6 +5,7 @@ using System; using System.Linq; using System.Linq.Expressions; +using System.Reflection; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; @@ -18,6 +19,8 @@ namespace EntityFrameworkCore.SingleStore.Query.Expressions.Internal /// public class SingleStoreCollateExpression : SqlExpression { + private static ConstructorInfo _quotingConstructor; + private readonly SqlExpression _valueExpression; private readonly string _charset; private readonly string _collation; @@ -78,6 +81,15 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) return Update(valueExpression); } + public override Expression Quote() + => New( + _quotingConstructor ??= typeof(SingleStoreInlinedParameterExpression).GetConstructor( + [typeof(SqlExpression), typeof(string), typeof(string), typeof(RelationalTypeMapping)])!, + ValueExpression.Quote(), + Constant(Charset), + Constant(Collation), + RelationalExpressionQuotingUtilities.QuoteTypeMapping(TypeMapping)); + public virtual SingleStoreCollateExpression Update(SqlExpression valueExpression) => valueExpression != _valueExpression && valueExpression != null diff --git a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreColumnAliasReferenceExpression.cs b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreColumnAliasReferenceExpression.cs index 332ac48d8..85ca0625f 100644 --- a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreColumnAliasReferenceExpression.cs +++ b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreColumnAliasReferenceExpression.cs @@ -4,6 +4,7 @@ using System; using System.Linq.Expressions; +using System.Reflection; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; @@ -16,6 +17,8 @@ namespace EntityFrameworkCore.SingleStore.Query.Expressions.Internal /// public class SingleStoreColumnAliasReferenceExpression : SqlExpression, IEquatable { + private static ConstructorInfo _quotingConstructor; + [NotNull] public virtual string Alias { get; } @@ -36,6 +39,15 @@ public SingleStoreColumnAliasReferenceExpression( protected override Expression VisitChildren(ExpressionVisitor visitor) => this; + public override Expression Quote() + => New( + _quotingConstructor ??= typeof(SingleStoreColumnAliasReferenceExpression).GetConstructor( + [typeof(string), typeof(SqlExpression), typeof(Type), typeof(RelationalTypeMapping)])!, + Constant(Alias), + Expression, + Constant(Type), + RelationalExpressionQuotingUtilities.QuoteTypeMapping(TypeMapping)); + public virtual SingleStoreColumnAliasReferenceExpression Update( [NotNull] string alias, [NotNull] SqlExpression expression) diff --git a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreComplexFunctionArgumentExpression.cs b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreComplexFunctionArgumentExpression.cs index 48179e2ca..e29062e64 100644 --- a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreComplexFunctionArgumentExpression.cs +++ b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreComplexFunctionArgumentExpression.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using System.Reflection; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Storage; @@ -15,6 +16,8 @@ namespace EntityFrameworkCore.SingleStore.Query.Expressions.Internal { public class SingleStoreComplexFunctionArgumentExpression : SqlExpression { + private static ConstructorInfo _quotingConstructor; + public SingleStoreComplexFunctionArgumentExpression( IEnumerable argumentParts, string delimiter, @@ -53,6 +56,16 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) return Update(argumentParts, Delimiter); } + /// + public override Expression Quote() + => New( + _quotingConstructor ??= typeof(SingleStoreColumnAliasReferenceExpression).GetConstructor( + [typeof(IReadOnlyList), typeof(string), typeof(Type), typeof(RelationalTypeMapping)])!, + NewArrayInit(typeof(SqlExpression), ArgumentParts.Select(p => p.Quote())), + Constant(Delimiter), + Constant(Type), + RelationalExpressionQuotingUtilities.QuoteTypeMapping(TypeMapping)); + public virtual SingleStoreComplexFunctionArgumentExpression Update(IReadOnlyList argumentParts, string delimiter) => !argumentParts.SequenceEqual(ArgumentParts) ? new SingleStoreComplexFunctionArgumentExpression(argumentParts, delimiter, Type, TypeMapping) diff --git a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreInlinedParameterExpression.cs b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreInlinedParameterExpression.cs index bf4291058..5191bf279 100644 --- a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreInlinedParameterExpression.cs +++ b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreInlinedParameterExpression.cs @@ -4,6 +4,7 @@ using System; using System.Linq.Expressions; +using System.Reflection; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; using Microsoft.EntityFrameworkCore.Utilities; @@ -12,6 +13,8 @@ namespace EntityFrameworkCore.SingleStore.Query.Expressions.Internal; public class SingleStoreInlinedParameterExpression : SqlExpression { + private static ConstructorInfo _quotingConstructor; + public SingleStoreInlinedParameterExpression( SqlParameterExpression parameterExpression, SqlConstantExpression valueExpression) @@ -23,7 +26,7 @@ public SingleStoreInlinedParameterExpression( ValueExpression = valueExpression; } - public virtual Expression ParameterExpression { get; } + public virtual SqlParameterExpression ParameterExpression { get; } public virtual SqlConstantExpression ValueExpression { get; } protected override Expression VisitChildren(ExpressionVisitor visitor) @@ -34,6 +37,14 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) return Update(parameterExpression, valueExpression); } + /// + public override Expression Quote() + => New( + _quotingConstructor ??= typeof(SingleStoreInlinedParameterExpression).GetConstructor( + [typeof(SqlParameterExpression), typeof(SqlConstantExpression)])!, + ParameterExpression.Quote(), + ValueExpression.Quote()); + protected override void Print(ExpressionPrinter expressionPrinter) { expressionPrinter.Visit(ValueExpression); diff --git a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreJsonArrayIndexExpression.cs b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreJsonArrayIndexExpression.cs index da0183806..e0b7cc5a7 100644 --- a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreJsonArrayIndexExpression.cs +++ b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreJsonArrayIndexExpression.cs @@ -4,6 +4,7 @@ using System; using System.Linq.Expressions; +using System.Reflection; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; @@ -16,6 +17,8 @@ namespace EntityFrameworkCore.SingleStore.Query.Expressions.Internal /// public class SingleStoreJsonArrayIndexExpression : SqlExpression, IEquatable { + private static ConstructorInfo _quotingConstructor; + [NotNull] public virtual SqlExpression Expression { get; } @@ -31,6 +34,15 @@ public SingleStoreJsonArrayIndexExpression( protected override Expression VisitChildren(ExpressionVisitor visitor) => Update((SqlExpression)visitor.Visit(Expression)); + /// + public override Expression Quote() + => New( + _quotingConstructor ??= typeof(SingleStoreInlinedParameterExpression).GetConstructor( + [typeof(SqlExpression), typeof(Type), typeof(RelationalTypeMapping)])!, + Expression.Quote(), + Constant(Type), + RelationalExpressionQuotingUtilities.QuoteTypeMapping(TypeMapping)); + public virtual SingleStoreJsonArrayIndexExpression Update( [NotNull] SqlExpression expression) => expression == Expression diff --git a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreJsonTraversalExpression.cs b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreJsonTraversalExpression.cs index ca228bfc5..e24d528ea 100644 --- a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreJsonTraversalExpression.cs +++ b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreJsonTraversalExpression.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using System.Reflection; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; @@ -18,6 +19,8 @@ namespace EntityFrameworkCore.SingleStore.Query.Expressions.Internal /// public class SingleStoreJsonTraversalExpression : SqlExpression, IEquatable { + private static ConstructorInfo _quotingConstructor; + /// /// The JSON column. /// @@ -68,6 +71,16 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) (SqlExpression)visitor.Visit(Expression), Path.Select(p => (SqlExpression)visitor.Visit(p)).ToArray()); + /// + public override Expression Quote() + => New( + _quotingConstructor ??= typeof(SingleStoreInlinedParameterExpression).GetConstructor( + [typeof(SqlExpression), typeof(IReadOnlyList), typeof(bool), typeof(Type), typeof(RelationalTypeMapping)])!, + Expression.Quote(), + NewArrayInit(typeof(SqlExpression), Path.Select(p => p.Quote())), + Constant(ReturnsText), + RelationalExpressionQuotingUtilities.QuoteTypeMapping(TypeMapping)); + public virtual SingleStoreJsonTraversalExpression Update( [NotNull] SqlExpression expression, [NotNull] IReadOnlyList path) diff --git a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreMatchExpression.cs b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreMatchExpression.cs index cd49b836b..efb79acfd 100644 --- a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreMatchExpression.cs +++ b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreMatchExpression.cs @@ -4,6 +4,7 @@ using System; using System.Linq.Expressions; +using System.Reflection; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; @@ -15,6 +16,8 @@ namespace EntityFrameworkCore.SingleStore.Query.Expressions.Internal { public class SingleStoreMatchExpression : SqlExpression { + private static ConstructorInfo _quotingConstructor; + public SingleStoreMatchExpression( SqlExpression match, SqlExpression against, @@ -49,6 +52,15 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) return Update(match, against); } + /// + public override Expression Quote() + => New( + _quotingConstructor ??= typeof(SingleStoreInlinedParameterExpression).GetConstructor( + [typeof(SqlExpression), typeof(SqlExpression), typeof(RelationalTypeMapping)])!, + Match.Quote(), + Against.Quote(), + RelationalExpressionQuotingUtilities.QuoteTypeMapping(TypeMapping)); + public virtual SingleStoreMatchExpression Update(SqlExpression match, SqlExpression against) => match != Match || against != Against ? new SingleStoreMatchExpression( diff --git a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreRegexpExpression.cs b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreRegexpExpression.cs index 49c80f6a2..51f4298ce 100644 --- a/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreRegexpExpression.cs +++ b/src/EFCore.SingleStore/Query/Expressions/Internal/SingleStoreRegexpExpression.cs @@ -3,6 +3,7 @@ // Licensed under the MIT. See LICENSE in the project root for license information. using System.Linq.Expressions; +using System.Reflection; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Utilities; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; @@ -14,6 +15,8 @@ namespace EntityFrameworkCore.SingleStore.Query.Expressions.Internal { public class SingleStoreRegexpExpression : SqlExpression { + private static ConstructorInfo _quotingConstructor; + public SingleStoreRegexpExpression( [NotNull] SqlExpression match, [NotNull] SqlExpression pattern, @@ -47,6 +50,15 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) return Update(match, pattern); } + /// + public override Expression Quote() + => New( + _quotingConstructor ??= typeof(SingleStoreInlinedParameterExpression).GetConstructor( + [typeof(SqlExpression), typeof(SqlExpression), typeof(RelationalTypeMapping)])!, + Match.Quote(), + Pattern.Quote(), + RelationalExpressionQuotingUtilities.QuoteTypeMapping(TypeMapping)); + public virtual SingleStoreRegexpExpression Update(SqlExpression match, SqlExpression pattern) => match != Match || pattern != Pattern diff --git a/src/EFCore.SingleStore/Query/Internal/SingleStoreDateDiffFunctionsTranslator.cs b/src/EFCore.SingleStore/Query/Internal/SingleStoreDateDiffFunctionsTranslator.cs index b283d9cfe..fd0452ce6 100644 --- a/src/EFCore.SingleStore/Query/Internal/SingleStoreDateDiffFunctionsTranslator.cs +++ b/src/EFCore.SingleStore/Query/Internal/SingleStoreDateDiffFunctionsTranslator.cs @@ -27,42 +27,83 @@ private readonly Dictionary _methodInfoDateDiffMapping { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffYear), new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }), "YEAR" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffYear), new[] { typeof(DbFunctions), typeof(DateOnly), typeof(DateOnly) }), "YEAR" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffYear), new[] { typeof(DbFunctions), typeof(DateOnly?), typeof(DateOnly?) }), "YEAR" }, + + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffQuarter), new[] { typeof(DbFunctions), typeof(DateTime), typeof(DateTime) }), "QUARTER" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffQuarter), new[] { typeof(DbFunctions), typeof(DateTime?), typeof(DateTime?) }), "QUARTER" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffQuarter), new[] { typeof(DbFunctions), typeof(DateTimeOffset), typeof(DateTimeOffset) }), "QUARTER" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffQuarter), new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }), "QUARTER" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffQuarter), new[] { typeof(DbFunctions), typeof(DateOnly), typeof(DateOnly) }), "QUARTER" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffQuarter), new[] { typeof(DbFunctions), typeof(DateOnly?), typeof(DateOnly?) }), "QUARTER" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMonth), new[] { typeof(DbFunctions), typeof(DateTime), typeof(DateTime) }), "MONTH" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMonth), new[] { typeof(DbFunctions), typeof(DateTime?), typeof(DateTime?) }), "MONTH" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMonth), new[] { typeof(DbFunctions), typeof(DateTimeOffset), typeof(DateTimeOffset) }), "MONTH" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMonth), new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }), "MONTH" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMonth), new[] { typeof(DbFunctions), typeof(DateOnly), typeof(DateOnly) }), "MONTH" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMonth), new[] { typeof(DbFunctions), typeof(DateOnly?), typeof(DateOnly?) }), "MONTH" }, + + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffWeek), new[] { typeof(DbFunctions), typeof(DateTime), typeof(DateTime) }), "WEEK" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffWeek), new[] { typeof(DbFunctions), typeof(DateTime?), typeof(DateTime?) }), "WEEK" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffWeek), new[] { typeof(DbFunctions), typeof(DateTimeOffset), typeof(DateTimeOffset) }), "WEEK" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffWeek), new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }), "WEEK" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffWeek), new[] { typeof(DbFunctions), typeof(DateOnly), typeof(DateOnly) }), "WEEK" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffWeek), new[] { typeof(DbFunctions), typeof(DateOnly?), typeof(DateOnly?) }), "WEEK" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffDay), new[] { typeof(DbFunctions), typeof(DateTime), typeof(DateTime) }), "DAY" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffDay), new[] { typeof(DbFunctions), typeof(DateTime?), typeof(DateTime?) }), "DAY" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffDay), new[] { typeof(DbFunctions), typeof(DateTimeOffset), typeof(DateTimeOffset) }), "DAY" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffDay), new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }), "DAY" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffDay), new[] { typeof(DbFunctions), typeof(DateOnly), typeof(DateOnly) }), "DAY" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffDay), new[] { typeof(DbFunctions), typeof(DateOnly?), typeof(DateOnly?) }), "DAY" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffHour), new[] { typeof(DbFunctions), typeof(DateTime), typeof(DateTime) }), "HOUR" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffHour), new[] { typeof(DbFunctions), typeof(DateTime?), typeof(DateTime?) }), "HOUR" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffHour), new[] { typeof(DbFunctions), typeof(DateTimeOffset), typeof(DateTimeOffset) }), "HOUR" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffHour), new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }), "HOUR" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffHour), new[] { typeof(DbFunctions), typeof(DateOnly), typeof(DateOnly) }), "HOUR" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffHour), new[] { typeof(DbFunctions), typeof(DateOnly?), typeof(DateOnly?) }), "HOUR" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMinute), new[] { typeof(DbFunctions), typeof(DateTime), typeof(DateTime) }), "MINUTE" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMinute), new[] { typeof(DbFunctions), typeof(DateTime?), typeof(DateTime?) }), "MINUTE" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMinute), new[] { typeof(DbFunctions), typeof(DateTimeOffset), typeof(DateTimeOffset) }), "MINUTE" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMinute), new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }), "MINUTE" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMinute), new[] { typeof(DbFunctions), typeof(DateOnly), typeof(DateOnly) }), "MINUTE" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMinute), new[] { typeof(DbFunctions), typeof(DateOnly?), typeof(DateOnly?) }), "MINUTE" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffSecond), new[] { typeof(DbFunctions), typeof(DateTime), typeof(DateTime) }), "SECOND" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffSecond), new[] { typeof(DbFunctions), typeof(DateTime?), typeof(DateTime?) }), "SECOND" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffSecond), new[] { typeof(DbFunctions), typeof(DateTimeOffset), typeof(DateTimeOffset) }), "SECOND" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffSecond), new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }), "SECOND" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffSecond), new[] { typeof(DbFunctions), typeof(DateOnly), typeof(DateOnly) }), "SECOND" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffSecond), new[] { typeof(DbFunctions), typeof(DateOnly?), typeof(DateOnly?) }), "SECOND" }, + + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMillisecond), new[] { typeof(DbFunctions), typeof(DateTime), typeof(DateTime) }), "MILLISECOND" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMillisecond), new[] { typeof(DbFunctions), typeof(DateTime?), typeof(DateTime?) }), "MILLISECOND" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMillisecond), new[] { typeof(DbFunctions), typeof(DateTimeOffset), typeof(DateTimeOffset) }), "MILLISECOND" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMillisecond), new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }), "MILLISECOND" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMillisecond), new[] { typeof(DbFunctions), typeof(DateOnly), typeof(DateOnly) }), "MILLISECOND" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMillisecond), new[] { typeof(DbFunctions), typeof(DateOnly?), typeof(DateOnly?) }), "MILLISECOND" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMicrosecond), new[] { typeof(DbFunctions), typeof(DateTime), typeof(DateTime) }), "MICROSECOND" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMicrosecond), new[] { typeof(DbFunctions), typeof(DateTime?), typeof(DateTime?) }), "MICROSECOND" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMicrosecond), new[] { typeof(DbFunctions), typeof(DateTimeOffset), typeof(DateTimeOffset) }), "MICROSECOND" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMicrosecond), new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }), "MICROSECOND" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMicrosecond), new[] { typeof(DbFunctions), typeof(DateOnly), typeof(DateOnly) }), "MICROSECOND" }, { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffMicrosecond), new[] { typeof(DbFunctions), typeof(DateOnly?), typeof(DateOnly?) }), "MICROSECOND" }, + + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffTick), new[] { typeof(DbFunctions), typeof(DateTime), typeof(DateTime) }), "TICK" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffTick), new[] { typeof(DbFunctions), typeof(DateTime?), typeof(DateTime?) }), "TICK" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffTick), new[] { typeof(DbFunctions), typeof(DateTimeOffset), typeof(DateTimeOffset) }), "TICK" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffTick), new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }), "TICK" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffTick), new[] { typeof(DbFunctions), typeof(DateOnly), typeof(DateOnly) }), "TICK" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffTick), new[] { typeof(DbFunctions), typeof(DateOnly?), typeof(DateOnly?) }), "TICK" }, + + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffNanosecond), new[] { typeof(DbFunctions), typeof(DateTime), typeof(DateTime) }), "NANOSECOND" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffNanosecond), new[] { typeof(DbFunctions), typeof(DateTime?), typeof(DateTime?) }), "NANOSECOND" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffNanosecond), new[] { typeof(DbFunctions), typeof(DateTimeOffset), typeof(DateTimeOffset) }), "NANOSECOND" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffNanosecond), new[] { typeof(DbFunctions), typeof(DateTimeOffset?), typeof(DateTimeOffset?) }), "NANOSECOND" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffNanosecond), new[] { typeof(DbFunctions), typeof(DateOnly), typeof(DateOnly) }), "NANOSECOND" }, + { typeof(SingleStoreDbFunctionsExtensions).GetRuntimeMethod(nameof(SingleStoreDbFunctionsExtensions.DateDiffNanosecond), new[] { typeof(DbFunctions), typeof(DateOnly?), typeof(DateOnly?) }), "NANOSECOND" }, }; private readonly SingleStoreSqlExpressionFactory _sqlExpressionFactory; @@ -87,18 +128,32 @@ public virtual SqlExpression Translate( startDate = _sqlExpressionFactory.ApplyTypeMapping(startDate, typeMapping); endDate = _sqlExpressionFactory.ApplyTypeMapping(endDate, typeMapping); - return _sqlExpressionFactory.NullableFunction( + var actualDatePart = datePart is "MILLISECOND" + or "TICK" + or "NANOSECOND" + ? "MICROSECOND" + : datePart; + + var timeStampDiffExpression = _sqlExpressionFactory.NullableFunction( "TIMESTAMPDIFF", new[] { - _sqlExpressionFactory.Fragment(datePart), + _sqlExpressionFactory.Fragment(actualDatePart), startDate, endDate }, typeof(int), typeMapping: null, onlyNullWhenAnyNullPropagatingArgumentIsNull: true, - argumentsPropagateNullability: new []{false, true, true}); + argumentsPropagateNullability: new[] { false, true, true }); + + return datePart switch + { + "MILLISECOND" => _sqlExpressionFactory.SingleStoreIntegerDivide(timeStampDiffExpression, _sqlExpressionFactory.Constant(1_000)), + "TICK" => _sqlExpressionFactory.Multiply(timeStampDiffExpression, _sqlExpressionFactory.Constant(10)), + "NANOSECOND" => _sqlExpressionFactory.Multiply(timeStampDiffExpression, _sqlExpressionFactory.Constant(1_000)), + _ => timeStampDiffExpression + }; } return null; diff --git a/src/EFCore.SingleStore/Query/Internal/SingleStoreDateTimeMemberTranslator.cs b/src/EFCore.SingleStore/Query/Internal/SingleStoreDateTimeMemberTranslator.cs index 463925177..e613245e4 100644 --- a/src/EFCore.SingleStore/Query/Internal/SingleStoreDateTimeMemberTranslator.cs +++ b/src/EFCore.SingleStore/Query/Internal/SingleStoreDateTimeMemberTranslator.cs @@ -5,12 +5,12 @@ using System; using System.Collections.Generic; using System.Reflection; -using EntityFrameworkCore.SingleStore.Infrastructure.Internal; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; +using EntityFrameworkCore.SingleStore.Infrastructure.Internal; using EntityFrameworkCore.SingleStore.Utilities; namespace EntityFrameworkCore.SingleStore.Query.Internal @@ -29,11 +29,14 @@ public class SingleStoreDateTimeMemberTranslator : IMemberTranslator { nameof(DateTime.Millisecond), ("microsecond", 1000) }, }; private readonly SingleStoreSqlExpressionFactory _sqlExpressionFactory; + private readonly ISingleStoreOptions _mySqlOptions; + private readonly string _sessionTimeZone; - public SingleStoreDateTimeMemberTranslator(ISqlExpressionFactory sqlExpressionFactory, IDbContextOptions dbContextOptions) + public SingleStoreDateTimeMemberTranslator(ISqlExpressionFactory sqlExpressionFactory, IDbContextOptions dbContextOptions, ISingleStoreOptions mySqlOptions) { _sqlExpressionFactory = (SingleStoreSqlExpressionFactory)sqlExpressionFactory; + _mySqlOptions = mySqlOptions; // Read the configured session time zone offset (e.g. "-08:00") from provider options. // If not configured, we default to "+00:00" (UTC) because SingleStore ignores @@session.time_zone at runtime. @@ -109,13 +112,17 @@ public virtual SqlExpression Translate( declaringType == typeof(DateTimeOffset) ? "UTC_TIMESTAMP" : "CURRENT_TIMESTAMP", - Array.Empty(), + _mySqlOptions.ServerVersion.Supports.DateTime6 ? + new [] { _sqlExpressionFactory.Constant(6)} : + Array.Empty(), returnType); case nameof(DateTime.UtcNow): return _sqlExpressionFactory.NonNullableFunction( "UTC_TIMESTAMP", - Array.Empty(), + _mySqlOptions.ServerVersion.Supports.DateTime6 ? + new [] { _sqlExpressionFactory.Constant(6)} : + ArraySegment.Empty, returnType); case nameof(DateTime.Today): diff --git a/src/EFCore.SingleStore/Query/Internal/SingleStoreDateTimeMethodTranslator.cs b/src/EFCore.SingleStore/Query/Internal/SingleStoreDateTimeMethodTranslator.cs index 2f8cf0de7..704c23ff5 100644 --- a/src/EFCore.SingleStore/Query/Internal/SingleStoreDateTimeMethodTranslator.cs +++ b/src/EFCore.SingleStore/Query/Internal/SingleStoreDateTimeMethodTranslator.cs @@ -46,6 +46,8 @@ public class SingleStoreDateTimeMethodTranslator : IMethodCallTranslator private static readonly MethodInfo _timeOnlyAddHoursMethod = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.AddHours), new[] {typeof(double)})!; private static readonly MethodInfo _timeOnlyAddMinutesMethod = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.AddMinutes), new[] {typeof(double)})!; private static readonly MethodInfo _timeOnlyIsBetweenMethod = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.IsBetween), new[] { typeof(TimeOnly), typeof(TimeOnly) })!; + private static readonly MethodInfo _timeOnlyFromDateTimeMethod = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.FromDateTime), new[] { typeof(DateTime) })!; + private static readonly MethodInfo _timeOnlyFromTimeSpanMethod = typeof(TimeOnly).GetRuntimeMethod(nameof(TimeOnly.FromTimeSpan), new[] { typeof(TimeSpan) })!; private static readonly MethodInfo _dateOnlyFromDateTimeMethod = typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.FromDateTime), new[] { typeof(DateTime) })!; private static readonly MethodInfo _dateOnlyToDateTimeMethod = typeof(DateOnly).GetRuntimeMethod(nameof(DateOnly.ToDateTime), new[] { typeof(TimeOnly) })!; @@ -148,11 +150,31 @@ public virtual SqlExpression Translate( _sqlExpressionFactory.GreaterThanOrEqual(instance, arguments[0]), _sqlExpressionFactory.LessThan(instance, arguments[1])); } + + if (instance is null && + arguments.Count == 1) + { + if (method == _timeOnlyFromDateTimeMethod) + { + return _sqlExpressionFactory.NullableFunction( + "TIME", + arguments, + typeof(TimeOnly), + onlyNullWhenAnyNullPropagatingArgumentIsNull: true); + } + + if (method == _timeOnlyFromTimeSpanMethod) + { + return _sqlExpressionFactory.Convert(arguments[0], method.ReturnType); + } + } } if (method.DeclaringType == typeof(DateOnly)) { - if (method == _dateOnlyFromDateTimeMethod) + if (method == _dateOnlyFromDateTimeMethod && + instance is null && + arguments.Count == 1) { return _sqlExpressionFactory.NullableFunction( "DATE", diff --git a/src/EFCore.SingleStore/Query/Internal/SingleStoreMemberTranslatorProvider.cs b/src/EFCore.SingleStore/Query/Internal/SingleStoreMemberTranslatorProvider.cs index 67c2080b9..77286ea5f 100644 --- a/src/EFCore.SingleStore/Query/Internal/SingleStoreMemberTranslatorProvider.cs +++ b/src/EFCore.SingleStore/Query/Internal/SingleStoreMemberTranslatorProvider.cs @@ -5,19 +5,20 @@ using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Query; +using EntityFrameworkCore.SingleStore.Infrastructure.Internal; namespace EntityFrameworkCore.SingleStore.Query.Internal { public class SingleStoreMemberTranslatorProvider : RelationalMemberTranslatorProvider { - public SingleStoreMemberTranslatorProvider([NotNull] RelationalMemberTranslatorProviderDependencies dependencies, IDbContextOptions dbContextOptions) + public SingleStoreMemberTranslatorProvider([NotNull] RelationalMemberTranslatorProviderDependencies dependencies, IDbContextOptions dbContextOptions, ISingleStoreOptions mySqlOptions) : base(dependencies) { var sqlExpressionFactory = (SingleStoreSqlExpressionFactory)dependencies.SqlExpressionFactory; AddTranslators( new IMemberTranslator[] { - new SingleStoreDateTimeMemberTranslator(sqlExpressionFactory, dbContextOptions), + new SingleStoreDateTimeMemberTranslator(sqlExpressionFactory, dbContextOptions, mySqlOptions), new SingleStoreStringMemberTranslator(sqlExpressionFactory), new SingleStoreTimeSpanMemberTranslator(sqlExpressionFactory), }); diff --git a/src/EFCore.SingleStore/Query/Internal/SingleStoreObjectToStringTranslator.cs b/src/EFCore.SingleStore/Query/Internal/SingleStoreObjectToStringTranslator.cs index d756f8078..bdc09d517 100644 --- a/src/EFCore.SingleStore/Query/Internal/SingleStoreObjectToStringTranslator.cs +++ b/src/EFCore.SingleStore/Query/Internal/SingleStoreObjectToStringTranslator.cs @@ -52,41 +52,49 @@ public virtual SqlExpression Translate( IReadOnlyList arguments, IDiagnosticsLogger logger) { - if (instance == null || - method.Name != nameof(ToString) || - arguments.Count != 0) + if (instance == null || method.Name != nameof(ToString) || arguments.Count != 0) { return null; } + if (instance.TypeMapping?.ClrType == typeof(string)) + { + return instance; + } + if (instance.Type == typeof(bool)) { - return instance is ColumnExpression columnExpression && - columnExpression.IsNullable - ? _sqlExpressionFactory.Case( + if (instance is not ColumnExpression { IsNullable: false }) + { + return _sqlExpressionFactory.Case( + instance, new[] { new CaseWhenClause( - _sqlExpressionFactory.Equal(instance, _sqlExpressionFactory.Constant(false)), + _sqlExpressionFactory.Constant(false), _sqlExpressionFactory.Constant(false.ToString())), new CaseWhenClause( - _sqlExpressionFactory.Equal(instance, _sqlExpressionFactory.Constant(true)), + _sqlExpressionFactory.Constant(true), _sqlExpressionFactory.Constant(true.ToString())) }, - _sqlExpressionFactory.Constant(null)) - : _sqlExpressionFactory.Case( - new[] - { - new CaseWhenClause( - _sqlExpressionFactory.Equal(instance, _sqlExpressionFactory.Constant(false)), - _sqlExpressionFactory.Constant(false.ToString())) - }, - _sqlExpressionFactory.Constant(true.ToString())); + _sqlExpressionFactory.Constant(string.Empty)); + } + + return _sqlExpressionFactory.Case( + new[] + { + new CaseWhenClause( + instance, + _sqlExpressionFactory.Constant(true.ToString())) + }, + _sqlExpressionFactory.Constant(false.ToString())); } - // Translates parameterless Object.ToString() calls. - return _supportedTypes.Contains(instance.Type.UnwrapNullableType()) - ? _sqlExpressionFactory.Convert(instance, typeof(string)) + // Enums are handled by EnumMethodTranslator. + return _supportedTypes.Contains(instance.Type) + ? _sqlExpressionFactory.Coalesce( + _sqlExpressionFactory.Convert(instance, typeof(string)), + _sqlExpressionFactory.Constant(string.Empty)) : null; } } diff --git a/src/EFCore.SingleStore/Query/Internal/SingleStoreParameterBasedSqlProcessor.cs b/src/EFCore.SingleStore/Query/Internal/SingleStoreParameterBasedSqlProcessor.cs index e5373bc35..5d5d10561 100644 --- a/src/EFCore.SingleStore/Query/Internal/SingleStoreParameterBasedSqlProcessor.cs +++ b/src/EFCore.SingleStore/Query/Internal/SingleStoreParameterBasedSqlProcessor.cs @@ -20,9 +20,9 @@ public class SingleStoreParameterBasedSqlProcessor : RelationalParameterBasedSql public SingleStoreParameterBasedSqlProcessor( RelationalParameterBasedSqlProcessorDependencies dependencies, - bool useRelationalNulls, + RelationalParameterBasedSqlProcessorParameters parameters, ISingleStoreOptions options) - : base(dependencies, useRelationalNulls) + : base(dependencies, parameters) { _options = options; } @@ -47,8 +47,6 @@ public override Expression Optimize( queryExpression = new SingleStoreBoolOptimizingExpressionVisitor(Dependencies.SqlExpressionFactory).Visit(queryExpression); } - queryExpression = new SingleStoreHavingExpressionVisitor((SingleStoreSqlExpressionFactory)Dependencies.SqlExpressionFactory).Visit(queryExpression); - queryExpression = new SingleStoreParameterInliningExpressionVisitor( Dependencies.TypeMappingSource, Dependencies.SqlExpressionFactory, @@ -71,7 +69,7 @@ protected override Expression ProcessSqlNullability( Check.NotNull(queryExpression, nameof(queryExpression)); Check.NotNull(parametersValues, nameof(parametersValues)); - queryExpression = new SingleStoreSqlNullabilityProcessor(Dependencies, UseRelationalNulls) + queryExpression = new SingleStoreSqlNullabilityProcessor(Dependencies, Parameters) .Process(queryExpression, parametersValues, out canCache); return queryExpression; diff --git a/src/EFCore.SingleStore/Query/Internal/SingleStoreParameterBasedSqlProcessorFactory.cs b/src/EFCore.SingleStore/Query/Internal/SingleStoreParameterBasedSqlProcessorFactory.cs index d2176ace4..4b4b95a9c 100644 --- a/src/EFCore.SingleStore/Query/Internal/SingleStoreParameterBasedSqlProcessorFactory.cs +++ b/src/EFCore.SingleStore/Query/Internal/SingleStoreParameterBasedSqlProcessorFactory.cs @@ -21,7 +21,7 @@ public SingleStoreParameterBasedSqlProcessorFactory( _options = options; } - public virtual RelationalParameterBasedSqlProcessor Create(bool useRelationalNulls) - => new SingleStoreParameterBasedSqlProcessor(_dependencies, useRelationalNulls, _options); + public virtual RelationalParameterBasedSqlProcessor Create(RelationalParameterBasedSqlProcessorParameters parameters) + => new SingleStoreParameterBasedSqlProcessor(_dependencies, parameters, _options); } } diff --git a/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryCompilationContext.cs b/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryCompilationContext.cs index 0a4658d21..c13085501 100644 --- a/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryCompilationContext.cs +++ b/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryCompilationContext.cs @@ -2,6 +2,7 @@ // Copyright (c) SingleStore Inc. All rights reserved. // Licensed under the MIT. See LICENSE in the project root for license information. +using System.Collections.Generic; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Query; @@ -11,13 +12,27 @@ public class SingleStoreQueryCompilationContext : RelationalQueryCompilationCont { public SingleStoreQueryCompilationContext( [NotNull] QueryCompilationContextDependencies dependencies, - [NotNull] RelationalQueryCompilationContextDependencies relationalDependencies, bool async) + [NotNull] RelationalQueryCompilationContextDependencies relationalDependencies, + bool async) : base(dependencies, relationalDependencies, async) { } + public SingleStoreQueryCompilationContext( + [NotNull] QueryCompilationContextDependencies dependencies, + [NotNull] RelationalQueryCompilationContextDependencies relationalDependencies, + bool async, + bool precompiling, + IReadOnlySet nonNullableReferenceTypeParameters) + : base(dependencies, relationalDependencies, async, precompiling, nonNullableReferenceTypeParameters) + { + } + public override bool IsBuffering => base.IsBuffering || QuerySplittingBehavior == Microsoft.EntityFrameworkCore.QuerySplittingBehavior.SplitQuery; + + /// + public override bool SupportsPrecompiledQuery => false; } } diff --git a/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryCompilationContextFactory.cs b/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryCompilationContextFactory.cs index 633b90532..fbfef9601 100644 --- a/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryCompilationContextFactory.cs +++ b/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryCompilationContextFactory.cs @@ -2,6 +2,7 @@ // Copyright (c) SingleStore Inc. All rights reserved. // Licensed under the MIT. See LICENSE in the project root for license information. +using System.Collections.Generic; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Utilities; @@ -26,5 +27,9 @@ public SingleStoreQueryCompilationContextFactory( public virtual QueryCompilationContext Create(bool async) => new SingleStoreQueryCompilationContext(_dependencies, _relationalDependencies, async); + + public virtual QueryCompilationContext CreatePrecompiled(bool async, IReadOnlySet nonNullableReferenceTypeParameters) + => new SingleStoreQueryCompilationContext( + _dependencies, _relationalDependencies, async, precompiling: true, nonNullableReferenceTypeParameters); } } diff --git a/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryableMethodTranslatingExpressionVisitor.cs index e9d829087..91458adb2 100644 --- a/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryableMethodTranslatingExpressionVisitor.cs @@ -3,12 +3,13 @@ // Licensed under the MIT. See LICENSE in the project root for license information. using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Linq.Expressions; using System.Reflection; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; @@ -16,7 +17,6 @@ using Microsoft.EntityFrameworkCore.Utilities; using EntityFrameworkCore.SingleStore.Infrastructure.Internal; using EntityFrameworkCore.SingleStore.Query.ExpressionTranslators.Internal; -using EntityFrameworkCore.SingleStore.Storage.Internal; namespace EntityFrameworkCore.SingleStore.Query.Internal; @@ -25,16 +25,18 @@ public class SingleStoreQueryableMethodTranslatingExpressionVisitor : Relational private readonly ISingleStoreOptions _options; private readonly SingleStoreSqlExpressionFactory _sqlExpressionFactory; private readonly IRelationalTypeMappingSource _typeMappingSource; + private readonly SqlAliasManager _sqlAliasManager; public SingleStoreQueryableMethodTranslatingExpressionVisitor( QueryableMethodTranslatingExpressionVisitorDependencies dependencies, RelationalQueryableMethodTranslatingExpressionVisitorDependencies relationalDependencies, - QueryCompilationContext queryCompilationContext, + RelationalQueryCompilationContext relationalQueryCompilationContext, ISingleStoreOptions options) - : base(dependencies, relationalDependencies, queryCompilationContext) + : base(dependencies, relationalDependencies, relationalQueryCompilationContext) { _sqlExpressionFactory = (SingleStoreSqlExpressionFactory)relationalDependencies.SqlExpressionFactory; _typeMappingSource = relationalDependencies.TypeMappingSource; + _sqlAliasManager = relationalQueryCompilationContext.SqlAliasManager; _options = options; } @@ -58,19 +60,20 @@ protected override bool IsNaturallyOrdered(SelectExpression selectExpression) Orderings: [ { - Expression: ColumnExpression { Name: "key", Table: var orderingTable } orderingColumn, + Expression: ColumnExpression { Name: "key", TableAlias: var orderingTable } orderingColumn, IsAscending: true } ] } - && orderingTable == mainTable - && IsJsonEachKeyColumn(orderingColumn); - - bool IsJsonEachKeyColumn(ColumnExpression orderingColumn) - => orderingColumn.Table is SingleStoreJsonTableExpression - || (orderingColumn.Table is SelectExpression subquery - && subquery.Projection.FirstOrDefault(p => p.Alias == "key")?.Expression is ColumnExpression projectedColumn - && IsJsonEachKeyColumn(projectedColumn)); + && orderingTable == mainTable.Alias + && IsJsonEachKeyColumn(selectExpression, orderingColumn); + + bool IsJsonEachKeyColumn(SelectExpression selectExpression, ColumnExpression orderingColumn) + => selectExpression.Tables.FirstOrDefault(t => t.Alias == orderingColumn.TableAlias)?.UnwrapJoin() is TableExpressionBase table + && (table is SingleStoreJsonTableExpression + || (table is SelectExpression subquery + && subquery.Projection.FirstOrDefault(p => p.Alias == "key")?.Expression is ColumnExpression projectedColumn + && IsJsonEachKeyColumn(subquery, projectedColumn))); } protected override bool IsValidSelectExpressionForExecuteDelete( @@ -93,11 +96,7 @@ protected override bool IsValidSelectExpressionForExecuteDelete( var projectionBindingExpression = (ProjectionBindingExpression)shaper.ValueBufferExpression; var entityProjectionExpression = (StructuralTypeProjectionExpression)selectExpression.GetProjection(projectionBindingExpression); var column = entityProjectionExpression.BindProperty(shaper.StructuralType.GetProperties().First()); - table = column.Table; - if (table is JoinExpressionBase joinExpressionBase) - { - table = joinExpressionBase.Table; - } + table = selectExpression.GetTable(column).UnwrapJoin(); } if (table is TableExpression te) @@ -175,7 +174,7 @@ protected override ShapedQueryExpression TranslateAny(ShapedQueryExpression sour typeof(int)), _sqlExpressionFactory.Constant(0)); - return source.UpdateQueryExpression(_sqlExpressionFactory.Select(translation)); + return source.UpdateQueryExpression(new SelectExpression(translation, _sqlAliasManager)); } return base.TranslateAny(source, predicate); @@ -203,7 +202,7 @@ protected override ShapedQueryExpression TranslateElementAtOrDefault( Limit: null, Offset: null } selectExpression - && orderingColumn.Table == jsonEachExpression + && orderingColumn.TableAlias == jsonEachExpression.Alias && TranslateExpression(index) is { } translatedIndex) { // Index on JSON array @@ -235,7 +234,7 @@ protected override ShapedQueryExpression TranslateElementAtOrDefault( translation, _sqlExpressionFactory, projectionColumn.TypeMapping, projectionColumn.IsNullable); } - return source.UpdateQueryExpression(_sqlExpressionFactory.Select(translation)); + return source.UpdateQueryExpression(new SelectExpression(translation, _sqlAliasManager)); } } @@ -252,8 +251,10 @@ protected override ShapedQueryExpression TranslatePrimitiveCollection(SqlExpress { if (!_options.PrimitiveCollectionsSupport) { - AddTranslationErrorDetails("Primitive collections support has not been enabled."); - return null; + throw new InvalidOperationException( + CoreStrings.TranslationFailedWithDetails( + sqlExpression.Print(), + "Primitive collections support has not been enabled.")); } // if (!_options.ServerVersion.Supports.JsonTableImplementationUsesImplicitLateralJoin && @@ -293,21 +294,21 @@ elementTypeMapping is not null // which case we only have the CLR type (note that we cannot produce different SQLs based on the nullability of an *element* in // a parameter collection - our caching mechanism only supports varying by the nullability of the parameter itself (i.e. the // collection). - // TODO: if property is non-null, GetElementType() should never be null, but we have #31469 for shadow properties - var isElementNullable = property?.GetElementType() is null - ? elementClrType.IsNullableType() - : property.GetElementType()!.IsNullable; + var isElementNullable = property?.GetElementType()!.IsNullable; + + var keyColumnTypeMapping = _typeMappingSource.FindMapping(typeof(int))!; #pragma warning disable EF1001 // Internal EF Core API usage. var selectExpression = new SelectExpression( - jsonTableExpression, - columnName: "value", - columnType: elementClrType, - columnTypeMapping: elementTypeMapping, - isElementNullable, - identifierColumnName: "key", - identifierColumnType: typeof(uint), - identifierColumnTypeMapping: _typeMappingSource.FindMapping(typeof(uint))); + [jsonTableExpression], + new ColumnExpression( + "value", + tableAlias, + elementClrType.UnwrapNullableType(), + elementTypeMapping, + isElementNullable ?? elementClrType.IsNullableType()), + identifier: [(new ColumnExpression("key", tableAlias, typeof(int), keyColumnTypeMapping, nullable: false), keyColumnTypeMapping.Comparer)], + _sqlAliasManager); #pragma warning restore EF1001 // Internal EF Core API usage. // JSON_TABLE() doesn't guarantee the ordering of the elements coming out; when using JSON_TABLE() without COLUMNS, a [key] column is returned @@ -342,12 +343,6 @@ elementTypeMapping is not null return new ShapedQueryExpression(selectExpression, shaperExpression); } - protected override Expression ApplyInferredTypeMappings( - Expression expression, - IReadOnlyDictionary<(TableExpressionBase, string), RelationalTypeMapping> inferredTypeMappings) - => new SingleStoreInferredTypeMappingApplier( - RelationalDependencies.Model, _typeMappingSource, _sqlExpressionFactory, inferredTypeMappings).Visit(expression); - /// /// Wraps the given expression with any SQL logic necessary to convert a value coming out of a JSON document into the relational value /// represented by the given type mapping. @@ -364,128 +359,6 @@ private static SqlExpression ApplyJsonSqlConversion( _ => expression }; - protected class SingleStoreInferredTypeMappingApplier : RelationalInferredTypeMappingApplier - { - private readonly IRelationalTypeMappingSource _typeMappingSource; - private readonly ISqlExpressionFactory _sqlExpressionFactory; - private Dictionary _currentSelectInferredTypeMappings; - - /// - /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to - /// the same compatibility standards as public APIs. It may be changed or removed without notice in - /// 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 SingleStoreInferredTypeMappingApplier( - IModel model, - IRelationalTypeMappingSource typeMappingSource, - ISqlExpressionFactory sqlExpressionFactory, - IReadOnlyDictionary<(TableExpressionBase, string), RelationalTypeMapping> inferredTypeMappings) - : base(model, sqlExpressionFactory, inferredTypeMappings) - { - (_typeMappingSource, _sqlExpressionFactory) = (typeMappingSource, sqlExpressionFactory); - } - - /// - /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to - /// the same compatibility standards as public APIs. It may be changed or removed without notice in - /// 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. - /// - protected override Expression VisitExtension(Expression expression) - { - switch (expression) - { - case SingleStoreJsonTableExpression { Name: "JSON_TABLE", Schema: null, IsBuiltIn: true } jsonTableExpression - when TryGetInferredTypeMapping(jsonTableExpression, "value", out var typeMapping): - return ApplyTypeMappingsOnJsonTableExpression(jsonTableExpression, typeMapping); - - // Above, we applied the type mapping the the parameter that JSON_TABLE accepts as an argument. - // But the inferred type mapping also needs to be applied as a SQL conversion on the column projections coming out of the - // SelectExpression containing the JSON_TABLE call. So we set state to know about JSON_TABLE tables and their type mappings - // in the immediate SelectExpression, and continue visiting down (see ColumnExpression visitation below). - case SelectExpression selectExpression: - { - Dictionary previousSelectInferredTypeMappings = null; - - foreach (var table in selectExpression.Tables) - { - if (table is TableValuedFunctionExpression { Name: "JSON_TABLE", Schema: null, IsBuiltIn: true } jsonTableExpression - && TryGetInferredTypeMapping(jsonTableExpression, "value", out var inferredTypeMapping)) - { - if (previousSelectInferredTypeMappings is null) - { - previousSelectInferredTypeMappings = _currentSelectInferredTypeMappings; - _currentSelectInferredTypeMappings = new Dictionary(); - } - - _currentSelectInferredTypeMappings![jsonTableExpression] = inferredTypeMapping; - } - } - - var visited = base.VisitExtension(expression); - - _currentSelectInferredTypeMappings = previousSelectInferredTypeMappings; - - return visited; - } - - // Note that we match also ColumnExpressions which already have a type mapping, i.e. coming out of column collections (as - // opposed to parameter collections, where the type mapping needs to be inferred). This is in order to apply SQL conversion - // logic later in the process, see note in TranslateCollection. - case ColumnExpression { Name: "value" } columnExpression - when _currentSelectInferredTypeMappings?.TryGetValue(columnExpression.Table, out var inferredTypeMapping) is true: - return ApplyJsonSqlConversion( - columnExpression.ApplyTypeMapping(inferredTypeMapping), - _sqlExpressionFactory, - inferredTypeMapping, - columnExpression.IsNullable); - - default: - return base.VisitExtension(expression); - } - } - - /// - /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to - /// the same compatibility standards as public APIs. It may be changed or removed without notice in - /// 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. - /// - protected virtual TableValuedFunctionExpression ApplyTypeMappingsOnJsonTableExpression( - SingleStoreJsonTableExpression jsonTableExpression, - RelationalTypeMapping inferredTypeMapping) - { - // Constant queryables are translated to VALUES, no need for JSON. - // Column queryables have their type mapping from the model, so we don't ever need to apply an inferred mapping on them. - if (jsonTableExpression.JsonExpression is not SqlParameterExpression parameterExpression) - { - return jsonTableExpression; - } - - if (_typeMappingSource.FindMapping(parameterExpression.Type, Model, inferredTypeMapping) is not SingleStoreStringTypeMapping - parameterTypeMapping) - { - throw new InvalidOperationException("Type mapping for 'string' could not be found or was not a SingleStoreStringTypeMapping"); - } - - Check.DebugAssert(parameterTypeMapping.ElementTypeMapping != null, "Collection type mapping missing element mapping."); - - return jsonTableExpression.Update( - parameterExpression.ApplyTypeMapping(parameterTypeMapping), - jsonTableExpression.Path, - new[] - { - new SingleStoreJsonTableExpression.ColumnInfo - { - Name = "value", - TypeMapping = (RelationalTypeMapping)parameterTypeMapping.ElementTypeMapping, - Path = new[] { new PathSegment(_sqlExpressionFactory.Constant(0, _typeMappingSource.FindMapping(typeof(int)))) }, - } - }); - } - } - private sealed class FakeMemberInfo : MemberInfo { public FakeMemberInfo(string name) diff --git a/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryableMethodTranslatingExpressionVisitorFactory.cs b/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryableMethodTranslatingExpressionVisitorFactory.cs index 2fdab9391..70bd562ad 100644 --- a/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryableMethodTranslatingExpressionVisitorFactory.cs +++ b/src/EFCore.SingleStore/Query/Internal/SingleStoreQueryableMethodTranslatingExpressionVisitorFactory.cs @@ -44,5 +44,5 @@ public SingleStoreQueryableMethodTranslatingExpressionVisitorFactory( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual QueryableMethodTranslatingExpressionVisitor Create(QueryCompilationContext queryCompilationContext) - => new SingleStoreQueryableMethodTranslatingExpressionVisitor(Dependencies, RelationalDependencies, queryCompilationContext, _options); + => new SingleStoreQueryableMethodTranslatingExpressionVisitor(Dependencies, RelationalDependencies, (SingleStoreQueryCompilationContext)queryCompilationContext, _options); } diff --git a/src/EFCore.SingleStore/Query/Internal/SingleStoreSqlNullabilityProcessor.cs b/src/EFCore.SingleStore/Query/Internal/SingleStoreSqlNullabilityProcessor.cs index 5d436bbc3..bf18ed0ee 100644 --- a/src/EFCore.SingleStore/Query/Internal/SingleStoreSqlNullabilityProcessor.cs +++ b/src/EFCore.SingleStore/Query/Internal/SingleStoreSqlNullabilityProcessor.cs @@ -21,11 +21,11 @@ public class SingleStoreSqlNullabilityProcessor : SqlNullabilityProcessor /// Creates a new instance of the class. /// /// Parameter object containing dependencies for this class. - /// A bool value indicating whether relational null semantics are in use. + /// Parameter object containing parameters for this class. public SingleStoreSqlNullabilityProcessor( [NotNull] RelationalParameterBasedSqlProcessorDependencies dependencies, - bool useRelationalNulls) - : base(dependencies, useRelationalNulls) + RelationalParameterBasedSqlProcessorParameters parameters) + : base(dependencies, parameters) => _sqlExpressionFactory = dependencies.SqlExpressionFactory; /// diff --git a/src/EFCore.SingleStore/Query/Internal/SingleStoreStringMemberTranslator.cs b/src/EFCore.SingleStore/Query/Internal/SingleStoreStringMemberTranslator.cs index 8cc9c91b4..970020313 100644 --- a/src/EFCore.SingleStore/Query/Internal/SingleStoreStringMemberTranslator.cs +++ b/src/EFCore.SingleStore/Query/Internal/SingleStoreStringMemberTranslator.cs @@ -27,7 +27,7 @@ public virtual SqlExpression Translate( IDiagnosticsLogger logger) { if (member.Name == nameof(string.Length) - && instance?.Type == typeof(string)) + && member.DeclaringType == typeof(string)) { return _sqlExpressionFactory.NullableFunction( "CHAR_LENGTH", diff --git a/src/EFCore.SingleStore/Query/Internal/SingleStoreStringMethodTranslator.cs b/src/EFCore.SingleStore/Query/Internal/SingleStoreStringMethodTranslator.cs index 92bcbc606..a35ecf1b0 100644 --- a/src/EFCore.SingleStore/Query/Internal/SingleStoreStringMethodTranslator.cs +++ b/src/EFCore.SingleStore/Query/Internal/SingleStoreStringMethodTranslator.cs @@ -111,6 +111,17 @@ private static readonly MethodInfo _removeMethodInfoWithTwoArgs p.ParameterType.GetGenericTypeDefinition() == typeof(IEnumerable<>)))) .ToArray(); + private static readonly MethodInfo[] _joinMethodInfos = typeof(string).GetRuntimeMethods() + .Where( + m => m is { Name: nameof(string.Join) } && + m.GetParameters() is { Length: 2 } parameters && + (parameters[0].ParameterType == typeof(string) || + parameters[0].ParameterType == typeof(char)) && + (parameters[1].ParameterType == typeof(string[]) || + parameters[1].ParameterType == typeof(object[]) || + parameters[1].ParameterType == typeof(IEnumerable<>))) + .ToArray(); + private readonly SingleStoreSqlExpressionFactory _sqlExpressionFactory; public SingleStoreStringMethodTranslator( @@ -170,7 +181,7 @@ public override SqlExpression Translate( _sqlExpressionFactory.IsNotNull(replacementArgument), replaceCall) }, - _sqlExpressionFactory.Constant(null, RelationalTypeMapping.NullMapping)); + _sqlExpressionFactory.Constant(null, replaceCall.Type, replaceCall.TypeMapping)); } if (_toLowerMethodInfo.Equals(method) @@ -432,6 +443,54 @@ public override SqlExpression Translate( onlyNullWhenAnyNullPropagatingArgumentIsNull: arguments[0] is not SingleStoreComplexFunctionArgumentExpression); } + if (_joinMethodInfos.Contains( + (method.IsGenericMethod + ? method.GetGenericMethodDefinition() + : null) ?? method)) + { + // Handle + // char, object[] + // char, string[] + // char, IEnumerable + // string, object[] + // string, string[] + // string, IEnumerable + // string, IEnumerable + // + // Some call signature variants can never reach this code, because they will be directly called and thus only their result + // is translated. + var concatWsArguments = arguments[1] is SingleStoreComplexFunctionArgumentExpression mySqlComplexFunctionArgumentExpression + ? [ + arguments[0], + // CONCAT_WS filters out nulls, but string.Join treats them as empty strings; so coalesce (which is a no-op for + // non-nullable arguments). + mySqlComplexFunctionArgumentExpression.Update( + mySqlComplexFunctionArgumentExpression.ArgumentParts + .Select(e => _sqlExpressionFactory.Coalesce(e, _sqlExpressionFactory.Constant(string.Empty))) + .ToList(), + mySqlComplexFunctionArgumentExpression.Delimiter)] + : arguments.Select( + e => e switch + { + SqlConstantExpression c => _sqlExpressionFactory.Constant(c.Value.ToString()), + SqlParameterExpression p => p.ApplyTypeMapping( + ((SingleStoreStringTypeMapping)_typeMappingSource.GetMapping(typeof(string))).Clone(forceToString: true)), + _ => e, + }) + .Prepend(arguments[0]) + .ToArray(); + + // We haven't implemented expansion of MySqlComplexFunctionArgumentExpression yet, so the default nullability check would + // result in an invalid SQL generation. + // TODO: Fix at some point. + return _sqlExpressionFactory.NullableFunction( + "CONCAT_WS", + concatWsArguments, + method.ReturnType, + onlyNullWhenAnyNullPropagatingArgumentIsNull: arguments[0] is not SingleStoreComplexFunctionArgumentExpression, + argumentsPropagateNullability: [true, false]); + } + return null; } diff --git a/src/EFCore.SingleStore/Query/Internal/SkipTakeCollapsingExpressionVisitor.cs b/src/EFCore.SingleStore/Query/Internal/SkipTakeCollapsingExpressionVisitor.cs index aa5ad31e6..1d88067d4 100644 --- a/src/EFCore.SingleStore/Query/Internal/SkipTakeCollapsingExpressionVisitor.cs +++ b/src/EFCore.SingleStore/Query/Internal/SkipTakeCollapsingExpressionVisitor.cs @@ -53,7 +53,6 @@ protected override Expression VisitExtension(Expression extensionExpression) && IsZero(selectExpression.Offset)) { return selectExpression.Update( - selectExpression.Projection, selectExpression.Tables, selectExpression.GroupBy.Count > 0 ? selectExpression.Predicate @@ -62,9 +61,10 @@ protected override Expression VisitExtension(Expression extensionExpression) selectExpression.GroupBy.Count > 0 ? _sqlExpressionFactory.ApplyDefaultTypeMapping(_sqlExpressionFactory.Constant(false)) : null, + selectExpression.Projection, new List(0), - limit: null, - offset: null); + offset: null, + limit: null); } bool IsZero(SqlExpression? sqlExpression) diff --git a/src/EFCore.SingleStore/Scaffolding/Internal/SingleStoreDatabaseModelFactory.cs b/src/EFCore.SingleStore/Scaffolding/Internal/SingleStoreDatabaseModelFactory.cs index 3ca095199..ade71c476 100644 --- a/src/EFCore.SingleStore/Scaffolding/Internal/SingleStoreDatabaseModelFactory.cs +++ b/src/EFCore.SingleStore/Scaffolding/Internal/SingleStoreDatabaseModelFactory.cs @@ -114,11 +114,7 @@ protected virtual void SetupSingleStoreOptions(DbConnection connection) protected virtual DatabaseModel GetDatabase(DbConnection connection, DatabaseModelFactoryOptions options) { - var databaseModel = new DatabaseModel - { - DatabaseName = connection.Database, - DefaultSchema = GetDefaultSchema(connection) - }; + var databaseModel = new DatabaseModel { DatabaseName = connection.Database, DefaultSchema = GetDefaultSchema(connection) }; using (var command = connection.CreateCommand()) { @@ -145,7 +141,8 @@ protected virtual DatabaseModel GetDatabase(DbConnection connection, DatabaseMod var tableList = options.Tables.ToList(); var tableFilter = GenerateTableFilter(tableList, schemaList); - var tables = GetTables(connection, tableFilter, (string)databaseModel[SingleStoreAnnotationNames.CharSet], databaseModel.Collation); + var tables = GetTables(connection, tableFilter, (string)databaseModel[SingleStoreAnnotationNames.CharSet], + databaseModel.Collation); foreach (var table in tables) { table.Database = databaseModel; @@ -191,7 +188,7 @@ private static Func GenerateSchemaFilter(IReadOnlyList s FROM `INFORMATION_SCHEMA`.`TABLES` as `t` LEFT JOIN - `INFORMATION_SCHEMA`.`COLLATION_CHARACTER_SET_APPLICABILITY` as `ccsa` ON `ccsa`.`COLLATION_NAME` = `t`.`TABLE_COLLATION` + `INFORMATION_SCHEMA`.`COLLATION_CHARACTER_SET_APPLICABILITY` as `ccsa` ON `ccsa`.`{0}` = `t`.`TABLE_COLLATION` WHERE `TABLE_SCHEMA` = SCHEMA() AND @@ -205,8 +202,12 @@ protected virtual IEnumerable GetTables( { using (var command = connection.CreateCommand()) { + var collationColumnName = _options.ServerVersion.Supports.CollationCharacterSetApplicabilityWithFullCollationNameColumn + ? "FULL_COLLATION_NAME" + : "COLLATION_NAME"; + var tables = new List(); - command.CommandText = GetTablesQuery; + command.CommandText = string.Format(GetTablesQuery, collationColumnName); using (var reader = command.ExecuteReader()) { while (reader.Read()) @@ -225,7 +226,7 @@ protected virtual IEnumerable GetTables( table.Name = name; table.Comment = string.IsNullOrEmpty(comment) ? null : comment; table[SingleStoreAnnotationNames.CharSet] = Settings.CharSet && - charset != defaultCharSet + charset != defaultCharSet ? charset : null; table[RelationalAnnotationNames.Collation] = Settings.Collation && @@ -279,11 +280,7 @@ private static IEnumerable GetSequences(DbConnection connectio { var name = reader.GetValueOrDefault("TABLE_NAME"); - var sequence = new DatabaseSequence - { - Schema = null, - Name = name, - }; + var sequence = new DatabaseSequence { Schema = null, Name = name, }; sequences.Add(sequence); } @@ -291,7 +288,8 @@ private static IEnumerable GetSequences(DbConnection connectio foreach (var sequence in sequences) { - command.CommandText = $"SELECT `START_VALUE`, `MINIMUM_VALUE`, `MAXIMUM_VALUE`, `INCREMENT`, `CYCLE_OPTION` FROM `{sequence.Name}`"; + command.CommandText = + $"SELECT `START_VALUE`, `MINIMUM_VALUE`, `MAXIMUM_VALUE`, `INCREMENT`, `CYCLE_OPTION` FROM `{sequence.Name}`"; using var reader = command.ExecuteReader(); while (reader.Read()) @@ -346,6 +344,7 @@ protected virtual void GetColumns( foreach (var table in tables) { var columnTypeOverrides = GetColumnTypeOverrides(connection, table); + var createTableQuery = GetCreateTableQuery(connection, table); using (var command = connection.CreateCommand()) { @@ -361,24 +360,65 @@ protected virtual void GetColumns( var charset = reader.GetValueOrDefault("CHARACTER_SET_NAME"); var collation = reader.GetValueOrDefault("COLLATION_NAME"); var columnType = reader.GetValueOrDefault("COLUMN_TYPE"); - var extra = reader.GetValueOrDefault("EXTRA"); var comment = reader.GetValueOrDefault("COLUMN_COMMENT"); + var extra = reader.GetValueOrDefault("EXTRA"); - // Generated colums are not supported on every MySQL/MariaDB version. + // Generated columns are not supported on every MySQL/MariaDB version. var generation = reader.HasName("GENERATION_EXPRESSION") ? reader.GetValueOrDefault("GENERATION_EXPRESSION").NullIfEmpty() : null; - // MariaDB does not support SRID column restrictions. var srid = reader.HasName("SRS_ID") ? reader.GetValueOrDefault("SRS_ID") : null; - var isStored = generation != null - ? (bool?)extra.Contains("stored generated", StringComparison.OrdinalIgnoreCase) - : null; + // `SHOW CREATE TABLE` is the most reliable source for explicit column-level CHARACTER SET / COLLATE clauses. + var createTableColumnDefinition = TryGetColumnDefinitionFromCreateTable(createTableQuery, name); + var columnDefinitionForClauseParsing = !string.IsNullOrEmpty(createTableColumnDefinition) + ? createTableColumnDefinition + : columnType; + + // Recover explicit charset/collation when INFORMATION_SCHEMA omits them. + var explicitColumnCharSet = TryParseSingleStoreComputedColumnCharacterSet(columnDefinitionForClauseParsing); + var explicitColumnCollation = TryParseSingleStoreComputedColumnCollation(columnDefinitionForClauseParsing); - generation = extra.Contains("computed") ? columnType : null; + if (charset is null) + { + charset = explicitColumnCharSet; + } + + if (collation is null) + { + collation = explicitColumnCollation; + } + + var hasExplicitColumnCharSet = explicitColumnCharSet != null; + var hasExplicitColumnCollation = explicitColumnCollation != null; + + var isSingleStoreComputed = + extra.Contains("computed", StringComparison.OrdinalIgnoreCase) || + extra.Contains("generated", StringComparison.OrdinalIgnoreCase) || + (!string.IsNullOrEmpty(columnDefinitionForClauseParsing) && + columnDefinitionForClauseParsing.Contains("PERSISTED", StringComparison.OrdinalIgnoreCase)); + + var singleStoreComputedColumnTypeDefinition = columnDefinitionForClauseParsing; + + // SingleStore: generation expression may not be exposed via INFORMATION_SCHEMA, + // but SHOW CREATE TABLE / COLUMN_TYPE contains "... AS PERSISTED ...". + if (generation is null && isSingleStoreComputed) + { + generation = singleStoreComputedColumnTypeDefinition; + } + + // Compute IsStored AFTER generation has been set + bool? isStored = generation is not null + ? (bool?)( + // MySQL/MariaDB signal + extra.Contains("stored generated", StringComparison.OrdinalIgnoreCase) + // SingleStore signal + || singleStoreComputedColumnTypeDefinition.Contains("PERSISTED", StringComparison.OrdinalIgnoreCase) + || isSingleStoreComputed) + : null; // Cleanup the column type, because it might contain trailing C style comments on MariaDB, like the following, // if an explicit cast is being done in the SELECT of a VIEW: @@ -387,32 +427,58 @@ protected virtual void GetColumns( // Override this column's type, if we detected earlier that this column should actually by added to the model // with a different type than the one returned by INFORMATION_SCHEMA.COLUMNS. - // This ensures, that e.g. the `json` alias for the `longtext` type for MariaDB databases will be added to the - // model as `json` instead of as `longtext`. columnType = columnTypeOverrides.TryGetValue(name, out var columnTypeOverride) ? columnTypeOverride((dataType: dataType, charset: charset, collation: collation)) : columnType; // MySQL enforces the `utf8mb4` charset and `utf8mb4_bin` collation for `json` columns and MariaDB will use them // automatically for `json` columns as well. - // Both will refuse explicit specifications of other charsets/collations, even though `json` is just an alias - // for `longtext` for MariaDB and setting `longtext` to other charsets/collations works fine. - // We therefore do not scaffold thouse charsets/collations in the first place, so that users don't get confused. if (columnType == "json") { charset = null; collation = null; + hasExplicitColumnCharSet = false; + hasExplicitColumnCollation = false; } if (generation is not null) { - // SingleStore column type for computed columns looks like 'as (computed expression) PERSISTED' which might cause some issues with the provider - columnType = dataType; + if (isSingleStoreComputed) + { + var match = Regex.Match( + singleStoreComputedColumnTypeDefinition, + @"\bAS\b\s*(?.+?)\s+\bPERSISTED\b", + RegexOptions.IgnoreCase | RegexOptions.Singleline); - int parenthesisStart = generation.IndexOf("("), - parenthesisEnd = generation.IndexOf(")"); + if (match.Success) + { + generation = match.Groups["expr"].Value.Trim(); + } + else + { + // Fallback to previous behavior if format is unexpected. + var pStart = generation.IndexOf("("); + var pEnd = generation.LastIndexOf(")"); + if (pStart >= 0 && pEnd > pStart) + { + generation = generation.Substring(pStart, pEnd - pStart + 1); + } + } - generation = generation.Substring(parenthesisStart, parenthesisEnd - parenthesisStart + 1); + // For SingleStore, keep the store type as the base DATA_TYPE + // (e.g. longtext, int, bigint, ...) + columnType = dataType; + } + else + { + // Previous behavior for MySQL/MariaDB generation strings that include parentheses. + var parenthesisStart = generation.IndexOf("("); + var parenthesisEnd = generation.IndexOf(")"); + if (parenthesisStart >= 0 && parenthesisEnd > parenthesisStart) + { + generation = generation.Substring(parenthesisStart, parenthesisEnd - parenthesisStart + 1); + } + } // MySQL saves the generation expression with enclosing parenthesis, while MariaDB doesn't. generation = _options.ServerVersion.Supports.ParenthesisEnclosedGeneratedColumnExpressions @@ -480,19 +546,23 @@ protected virtual void GetColumns( Name = name, StoreType = columnType, IsNullable = nullable, - DefaultValueSql = CreateDefaultValueString(defaultValue, dataType, isDefaultValueSqlFunction, isDefaultValueExpression), + DefaultValueSql = + CreateDefaultValueString(defaultValue, dataType, isDefaultValueSqlFunction, isDefaultValueExpression), ComputedColumnSql = generation, IsStored = isStored, ValueGenerated = valueGenerated, - Comment = string.IsNullOrEmpty(comment) - ? null - : comment, + Comment = string.IsNullOrEmpty(comment) ? null : comment, [SingleStoreAnnotationNames.CharSet] = Settings.CharSet && - charset != (table[SingleStoreAnnotationNames.CharSet] as string ?? defaultCharSet) + charset != null && + (hasExplicitColumnCharSet || + charset != (table[SingleStoreAnnotationNames.CharSet] as string ?? + defaultCharSet)) ? charset : null, Collation = Settings.Collation && - collation != (table[RelationalAnnotationNames.Collation] as string ?? defaultCollation) + collation != null && + (hasExplicitColumnCollation || + collation != (table[RelationalAnnotationNames.Collation] as string ?? defaultCollation)) ? collation : null, [SingleStoreAnnotationNames.SpatialReferenceSystemId] = srid.HasValue @@ -541,7 +611,8 @@ private bool IsDefaultValueSqlFunction(string defaultValue, string dataType) /// See https://github.com/PomeloFoundation/EntityFrameworkCore.MySql/issues/994#issuecomment-568271740 /// for tables with differences. /// - protected virtual string ConvertDefaultValueFromMariaDbToSingleStore([NotNull] string defaultValue, out bool isDefaultValueExpression) + protected virtual string ConvertDefaultValueFromMariaDbToSingleStore([NotNull] string defaultValue, + out bool isDefaultValueExpression) { isDefaultValueExpression = false; @@ -657,11 +728,7 @@ protected virtual void GetPrimaryKeys( { try { - var key = new DatabasePrimaryKey - { - Table = table, - Name = reader.GetValueOrDefault("INDEX_NAME"), - }; + var key = new DatabasePrimaryKey { Table = table, Name = reader.GetValueOrDefault("INDEX_NAME"), }; foreach (var column in reader.GetValueOrDefault("COLUMNS").Split(',')) { @@ -685,7 +752,8 @@ protected virtual void GetPrimaryKeys( firstKeyColumn.ValueGenerated == null && (firstKeyColumn.DefaultValueSql == null || string.Equals(firstKeyColumn.DefaultValueSql, "uuid()", StringComparison.OrdinalIgnoreCase) || - string.Equals(firstKeyColumn.DefaultValueSql, "uuid_to_bin(uuid())", StringComparison.OrdinalIgnoreCase)) && + string.Equals(firstKeyColumn.DefaultValueSql, "uuid_to_bin(uuid())", + StringComparison.OrdinalIgnoreCase)) && _typeMappingSource.FindMapping(firstKeyColumn.StoreType) is SingleStoreGuidTypeMapping) { firstKeyColumn.ValueGenerated = ValueGenerated.OnAdd; @@ -735,20 +803,16 @@ protected virtual void GetIndexes( { try { - var columns = reader.GetValueOrDefault("COLUMNS").Split(',').Select(s => GetColumn(table, s)).ToList(); + var columns = reader.GetValueOrDefault("COLUMNS").Split(',').Select(s => GetColumn(table, s)) + .ToList(); // Reuse an existing index over the same columns, to workaround an EF Core // bug (EF#11846 and #1189). // The columns could be in a different order. - var index = table.Indexes.FirstOrDefault( - i => i.Columns - .OrderBy(c => c.Name) - .SequenceEqual(columns.OrderBy(c => c.Name))) ?? - new DatabaseIndex - { - Table = table, - Name = reader.GetValueOrDefault("INDEX_NAME"), - }; + var index = table.Indexes.FirstOrDefault(i => i.Columns + .OrderBy(c => c.Name) + .SequenceEqual(columns.OrderBy(c => c.Name))) ?? + new DatabaseIndex { Table = table, Name = reader.GetValueOrDefault("INDEX_NAME"), }; index.IsUnique |= !reader.GetValueOrDefault("NON_UNIQUE"); @@ -776,10 +840,9 @@ protected virtual void GetIndexes( // existing prefix lengths from a previous index with the same set of columns. var newPrefixLengths = index.Columns .Select(indexColumn => columns.IndexOf(indexColumn)) - .Select( - i => i < prefixLengths.Length - ? prefixLengths[i] - : 0) + .Select(i => i < prefixLengths.Length + ? prefixLengths[i] + : 0) .Zip( existingPrefixLengths, (l, r) => l == 0 || r == 0 ? 0 @@ -838,7 +901,7 @@ protected virtual void GetIndexes( // var fullTextIndexes = table.Indexes - .Where(i => ((bool?) i[SingleStoreAnnotationNames.FullTextIndex]).GetValueOrDefault()) + .Where(i => ((bool?)i[SingleStoreAnnotationNames.FullTextIndex]).GetValueOrDefault()) .ToList(); if (fullTextIndexes.Any()) @@ -917,11 +980,19 @@ protected virtual void GetConstraints( // different casing than the actual table name. (#1017) // In the unlikely event that there are multiple tables with the same spelling, differing only in casing, // we can't be certain which is the right match, so rather fail to be safe. - referencedTable = tables.SingleOrDefault(t => string.Equals(t.Name, referencedTableName, StringComparison.OrdinalIgnoreCase)); + referencedTable = tables.SingleOrDefault(t => + string.Equals(t.Name, referencedTableName, StringComparison.OrdinalIgnoreCase)); } + if (referencedTable != null) { - var fkInfo = new DatabaseForeignKey {Name = reader.GetString(0), OnDelete = ConvertToReferentialAction(reader.GetString(4)), Table = table, PrincipalTable = referencedTable}; + var fkInfo = new DatabaseForeignKey + { + Name = reader.GetString(0), + OnDelete = ConvertToReferentialAction(reader.GetString(4)), + Table = table, + PrincipalTable = referencedTable + }; foreach (var pair in reader.GetString(3).Split(',')) { fkInfo.Columns.Add(table.Columns.Single(y => @@ -1005,5 +1076,58 @@ private DatabaseColumn GetColumn(DatabaseTable table, string columnName) private DatabaseColumn FindColumn(DatabaseTable table, string columnName) => table.Columns.SingleOrDefault(c => string.Equals(c.Name, columnName, StringComparison.Ordinal)) ?? table.Columns.SingleOrDefault(c => string.Equals(c.Name, columnName, StringComparison.OrdinalIgnoreCase)); + + private static string TryGetColumnDefinitionFromCreateTable(string createTableQuery, string columnName) + { + if (string.IsNullOrEmpty(createTableQuery) || string.IsNullOrEmpty(columnName)) + { + return null; + } + + var escapedColumnName = Regex.Escape(columnName); + + var match = Regex.Match( + createTableQuery, + $@"^\s*`{escapedColumnName}`\s+(?.+?)(?:,)?\s*$", + RegexOptions.Multiline); + + return match.Success + ? match.Groups["definition"].Value.Trim() + : null; + } + + private static string TryParseSingleStoreComputedColumnCharacterSet(string columnTypeDefinition) + { + if (string.IsNullOrEmpty(columnTypeDefinition)) + { + return null; + } + + var match = Regex.Match( + columnTypeDefinition, + @"\bCHARACTER\s+SET\s+(?[A-Za-z0-9_]+)\b", + RegexOptions.IgnoreCase | RegexOptions.Singleline); + + return match.Success + ? match.Groups["charset"].Value + : null; + } + + private static string TryParseSingleStoreComputedColumnCollation(string columnTypeDefinition) + { + if (string.IsNullOrEmpty(columnTypeDefinition)) + { + return null; + } + + var match = Regex.Match( + columnTypeDefinition, + @"\bCOLLATE\s+(?[A-Za-z0-9_]+)\b", + RegexOptions.IgnoreCase | RegexOptions.Singleline); + + return match.Success + ? match.Groups["collation"].Value + : null; + } } } diff --git a/src/EFCore.SingleStore/Storage/Internal/Json/SingleStoreJsonByteArrayAsHexStringReaderWriter.cs b/src/EFCore.SingleStore/Storage/Internal/Json/SingleStoreJsonByteArrayAsHexStringReaderWriter.cs index f8bc50c02..9153ae2c5 100644 --- a/src/EFCore.SingleStore/Storage/Internal/Json/SingleStoreJsonByteArrayAsHexStringReaderWriter.cs +++ b/src/EFCore.SingleStore/Storage/Internal/Json/SingleStoreJsonByteArrayAsHexStringReaderWriter.cs @@ -3,6 +3,8 @@ // Licensed under the MIT. See LICENSE in the project root for license information. using System; +using System.Linq.Expressions; +using System.Reflection; using System.Text.Json; using Microsoft.EntityFrameworkCore.Storage.Json; @@ -10,6 +12,9 @@ namespace EntityFrameworkCore.SingleStore.Storage.Internal.Json; public sealed class SingleStoreJsonByteArrayAsHexStringReaderWriter : JsonValueReaderWriter { + public static readonly PropertyInfo InstanceProperty = + typeof(SingleStoreJsonByteArrayAsHexStringReaderWriter).GetProperty(nameof(Instance)); + public static SingleStoreJsonByteArrayAsHexStringReaderWriter Instance { get; } = new(); private SingleStoreJsonByteArrayAsHexStringReaderWriter() @@ -21,4 +26,7 @@ public override byte[] FromJsonTyped(ref Utf8JsonReaderManager manager, object e public override void ToJsonTyped(Utf8JsonWriter writer, byte[] value) => writer.WriteStringValue(Convert.ToHexString(value)); + + public override Expression ConstructorExpression + => Expression.Property(null, InstanceProperty); } diff --git a/src/EFCore.SingleStore/Storage/Internal/SingleStoreRelationalConnection.cs b/src/EFCore.SingleStore/Storage/Internal/SingleStoreRelationalConnection.cs index c6617393b..9ea2fc3c8 100644 --- a/src/EFCore.SingleStore/Storage/Internal/SingleStoreRelationalConnection.cs +++ b/src/EFCore.SingleStore/Storage/Internal/SingleStoreRelationalConnection.cs @@ -168,10 +168,10 @@ public virtual ISingleStoreRelationalConnection CreateMasterConnection() // Apply modified connection string. var masterMySqlOptions = _dataSource is not null - ? mySqlOptions.WithConnection(((SingleStoreConnection)CreateDbConnection()).CloneWith(masterConnectionString)) + ? mySqlOptions.WithConnection(((SingleStoreConnection)CreateDbConnection()).CloneWith(masterConnectionString), owned: true) : mySqlOptions.Connection is null ? mySqlOptions.WithConnectionString(masterConnectionString) - : mySqlOptions.WithConnection(DbConnection.CloneWith(masterConnectionString)); + : mySqlOptions.WithConnection(DbConnection.CloneWith(masterConnectionString), owned: true); var optionsBuilder = new DbContextOptionsBuilder(); var optionsBuilderInfrastructure = (IDbContextOptionsBuilderInfrastructure)optionsBuilder; diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 09501c267..3dcc35d0a 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -14,5 +14,6 @@ + diff --git a/test/EFCore.SingleStore.FunctionalTests/BuiltInDataTypesSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/BuiltInDataTypesSingleStoreTest.cs index 97c9d2f83..30804b368 100644 --- a/test/EFCore.SingleStore.FunctionalTests/BuiltInDataTypesSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/BuiltInDataTypesSingleStoreTest.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Linq.Expressions; using System.Text; +using System.Threading.Tasks; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -33,12 +34,12 @@ public BuiltInDataTypesSingleStoreTest(BuiltInDataTypesSingleStoreFixture fixtur //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - public override void Object_to_string_conversion() + public override async Task Object_to_string_conversion() { using var context = CreateContext(); - var expected = context.Set() + var expected = (await context.Set() .Where(e => e.Id == 13) - .AsEnumerable() + .ToListAsync()) .Select( b => new { @@ -57,7 +58,7 @@ public override void Object_to_string_conversion() Fixture.ListLoggerFactory.Clear(); - var query = context.Set() + var query = await context.Set() .Where(e => e.Id == 13) .Select( b => new @@ -78,7 +79,7 @@ public override void Object_to_string_conversion() DateTimeOffset = b.TestDateTimeOffset.ToString(), TimeSpan = b.TestTimeSpan.ToString() }) - .ToList(); + .ToListAsync(); var actual = Assert.Single(query); Assert.Equal(expected.Sbyte, actual.Sbyte); @@ -803,7 +804,7 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_set_to_null() // Overridden because of TestNullableDateTimeOffset, since MySQL does not offer a native data type to save a date/time with // timezone. - public override void Can_insert_and_read_back_all_nullable_data_types_with_values_set_to_non_null() + public override async Task Can_insert_and_read_back_all_nullable_data_types_with_values_set_to_non_null() { using (var context = CreateContext()) { @@ -840,12 +841,12 @@ public override void Can_insert_and_read_back_all_nullable_data_types_with_value EnumS8 = EnumS8.SomeValue }); - Assert.Equal(1, context.SaveChanges()); + Assert.Equal(1, await context.SaveChangesAsync()); } using (var context = CreateContext()) { - var dt = context.Set().Where(ndt => ndt.Id == 101).ToList().Single(); + var dt = (await context.Set().Where(ndt => ndt.Id == 101).ToListAsync()).Single(); var entityType = context.Model.FindEntityType(typeof(BuiltInNullableDataTypes)); AssertEqualIfMapped(entityType, "TestString", () => dt.TestString); @@ -1438,7 +1439,7 @@ public void Can_get_column_types_from_built_model() #region https://github.com/dotnet/efcore/issues/26068 [ConditionalFact] - public override void Can_insert_and_read_back_all_non_nullable_data_types() + public override async Task Can_insert_and_read_back_all_non_nullable_data_types() { using (var context = CreateContext()) { @@ -1473,12 +1474,12 @@ public override void Can_insert_and_read_back_all_non_nullable_data_types() EnumS8 = EnumS8.SomeValue }); - Assert.Equal(1, context.SaveChanges()); + Assert.Equal(1, await context.SaveChangesAsync()); } using (var context = CreateContext()) { - var dt = context.Set().Where(e => e.Id == 1).ToList().Single(); + var dt = (await context.Set().Where(e => e.Id == 1).ToListAsync()).Single(); var entityType = context.Model.FindEntityType(typeof(BuiltInDataTypes)); AssertEqualIfMapped(entityType, (short)-1234, () => dt.TestInt16); @@ -1512,37 +1513,37 @@ public override void Can_insert_and_read_back_all_non_nullable_data_types() } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_insert_and_read_back_with_binary_key() + public override async Task Can_insert_and_read_back_with_binary_key() { - base.Can_insert_and_read_back_with_binary_key(); + await base.Can_insert_and_read_back_with_binary_key(); } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_insert_and_read_back_with_null_binary_foreign_key() + public override async Task Can_insert_and_read_back_with_null_binary_foreign_key() { - base.Can_insert_and_read_back_with_null_binary_foreign_key(); + await base.Can_insert_and_read_back_with_null_binary_foreign_key(); } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_insert_and_read_back_with_null_string_foreign_key() + public override async Task Can_insert_and_read_back_with_null_string_foreign_key() { - base.Can_insert_and_read_back_with_null_string_foreign_key(); + await base.Can_insert_and_read_back_with_null_string_foreign_key(); } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_insert_and_read_back_with_string_key() + public override async Task Can_insert_and_read_back_with_string_key() { - base.Can_insert_and_read_back_with_string_key(); + await base.Can_insert_and_read_back_with_string_key(); } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_read_back_mapped_enum_from_collection_first_or_default() + public override async Task Can_read_back_mapped_enum_from_collection_first_or_default() { - base.Can_read_back_mapped_enum_from_collection_first_or_default(); + await base.Can_read_back_mapped_enum_from_collection_first_or_default(); } [ConditionalFact] - public override void Can_insert_and_read_back_non_nullable_backed_data_types() + public override async Task Can_insert_and_read_back_non_nullable_backed_data_types() { using (var context = CreateContext()) { @@ -1577,12 +1578,12 @@ public override void Can_insert_and_read_back_non_nullable_backed_data_types() EnumS8 = EnumS8.SomeValue }); - Assert.Equal(1, context.SaveChanges()); + Assert.Equal(1, await context.SaveChangesAsync()); } using (var context = CreateContext()) { - var dt = context.Set().Where(ndt => ndt.Id == 101).ToList().Single(); + var dt = (await context.Set().Where(ndt => ndt.Id == 101).ToListAsync()).Single(); var entityType = context.Model.FindEntityType(typeof(NonNullableBackedDataTypes)); AssertEqualIfMapped(entityType, (short)-1234, () => dt.Int16); @@ -1616,7 +1617,7 @@ public override void Can_insert_and_read_back_non_nullable_backed_data_types() } [ConditionalFact] - public override void Can_insert_and_read_back_nullable_backed_data_types() + public override async Task Can_insert_and_read_back_nullable_backed_data_types() { using (var context = CreateContext()) { @@ -1651,12 +1652,12 @@ public override void Can_insert_and_read_back_nullable_backed_data_types() EnumS8 = EnumS8.SomeValue }); - Assert.Equal(1, context.SaveChanges()); + Assert.Equal(1, await context.SaveChangesAsync()); } using (var context = CreateContext()) { - var dt = context.Set().Where(ndt => ndt.Id == 101).ToList().Single(); + var dt = (await context.Set().Where(ndt => ndt.Id == 101).ToListAsync()).Single(); var entityType = context.Model.FindEntityType(typeof(NullableBackedDataTypes)); AssertEqualIfMapped(entityType, (short)-1234, () => dt.Int16); @@ -1689,7 +1690,7 @@ public override void Can_insert_and_read_back_nullable_backed_data_types() } [ConditionalFact] - public override void Can_insert_and_read_back_object_backed_data_types() + public override async Task Can_insert_and_read_back_object_backed_data_types() { using (var context = CreateContext()) { @@ -1726,12 +1727,12 @@ public override void Can_insert_and_read_back_object_backed_data_types() EnumS8 = EnumS8.SomeValue }); - Assert.Equal(1, context.SaveChanges()); + Assert.Equal(1, await context.SaveChangesAsync()); } using (var context = CreateContext()) { - var dt = context.Set().Where(ndt => ndt.Id == 101).ToList().Single(); + var dt = (await context.Set().Where(ndt => ndt.Id == 101).ToListAsync()).Single(); var entityType = context.Model.FindEntityType(typeof(ObjectBackedDataTypes)); AssertEqualIfMapped(entityType, "TestString", () => dt.String); diff --git a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesSingleStoreTest.cs index 6f2e0d782..21aca49d4 100644 --- a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/ComplexTypeBulkUpdatesSingleStoreTest.cs @@ -7,7 +7,7 @@ namespace EntityFrameworkCore.SingleStore.FunctionalTests.BulkUpdates; -public class ComplexTypeBulkUpdatesSingleStoreTest : ComplexTypeBulkUpdatesTestBase< +public class ComplexTypeBulkUpdatesSingleStoreTest : ComplexTypeBulkUpdatesRelationalTestBase< ComplexTypeBulkUpdatesSingleStoreTest.ComplexTypeBulkUpdatesSingleStoreFixture> { public ComplexTypeBulkUpdatesSingleStoreTest(ComplexTypeBulkUpdatesSingleStoreFixture fixture, ITestOutputHelper testOutputHelper) @@ -27,9 +27,9 @@ public override async Task Delete_entity_type_with_complex_type(bool async) """); } - public override async Task Delete_complex_type_throws(bool async) + public override async Task Delete_complex_type(bool async) { - await base.Delete_complex_type_throws(async); + await base.Delete_complex_type(async); AssertSql(); } @@ -95,17 +95,216 @@ public override async Task Update_multiple_projected_complex_types_via_anonymous """); } - public override async Task Update_projected_complex_type_via_OrderBy_Skip_throws(bool async) + public override async Task Update_projected_complex_type_via_OrderBy_Skip(bool async) { - await base.Update_projected_complex_type_via_OrderBy_Skip_throws(async); + await base.Update_projected_complex_type_via_OrderBy_Skip(async); AssertExecuteUpdateSql(); } + public override async Task Update_complex_type_to_parameter(bool async) + { + await base.Update_complex_type_to_parameter(async); + + AssertSql( +""" +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +FROM `Customer` AS `c` +""", + // + """ +@__complex_type_newAddress_0_AddressLine1='New AddressLine1' (Size = 4000) +@__complex_type_newAddress_0_AddressLine2='New AddressLine2' (Size = 4000) +@__complex_type_newAddress_0_Tags='["new_tag1","new_tag2"]' (Size = 4000) +@__complex_type_newAddress_0_ZipCode='99999' (Nullable = true) +@__complex_type_newAddress_0_Code='FR' (Size = 4000) +@__complex_type_newAddress_0_FullName='France' (Size = 4000) + +UPDATE `Customer` AS `c` +SET `c`.`ShippingAddress_AddressLine1` = @__complex_type_newAddress_0_AddressLine1, + `c`.`ShippingAddress_AddressLine2` = @__complex_type_newAddress_0_AddressLine2, + `c`.`ShippingAddress_Tags` = @__complex_type_newAddress_0_Tags, + `c`.`ShippingAddress_ZipCode` = @__complex_type_newAddress_0_ZipCode, + `c`.`ShippingAddress_Country_Code` = @__complex_type_newAddress_0_Code, + `c`.`ShippingAddress_Country_FullName` = @__complex_type_newAddress_0_FullName +""", + // + """ +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +FROM `Customer` AS `c` +"""); + } + + public override async Task Update_nested_complex_type_to_parameter(bool async) + { + await base.Update_nested_complex_type_to_parameter(async); + + AssertSql( +""" +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +FROM `Customer` AS `c` +""", + // + """ +@__complex_type_newCountry_0_Code='FR' (Size = 4000) +@__complex_type_newCountry_0_FullName='France' (Size = 4000) + +UPDATE `Customer` AS `c` +SET `c`.`ShippingAddress_Country_Code` = @__complex_type_newCountry_0_Code, + `c`.`ShippingAddress_Country_FullName` = @__complex_type_newCountry_0_FullName +""", + // + """ +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +FROM `Customer` AS `c` +"""); + } + + public override async Task Update_complex_type_to_another_database_complex_type(bool async) + { + await base.Update_complex_type_to_another_database_complex_type(async); + + AssertSql( +""" +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +FROM `Customer` AS `c` +""", + // + """ +UPDATE `Customer` AS `c` +SET `c`.`ShippingAddress_AddressLine1` = `c`.`BillingAddress_AddressLine1`, + `c`.`ShippingAddress_AddressLine2` = `c`.`BillingAddress_AddressLine2`, + `c`.`ShippingAddress_Tags` = `c`.`BillingAddress_Tags`, + `c`.`ShippingAddress_ZipCode` = `c`.`BillingAddress_ZipCode`, + `c`.`ShippingAddress_Country_Code` = `c`.`ShippingAddress_Country_Code`, + `c`.`ShippingAddress_Country_FullName` = `c`.`ShippingAddress_Country_FullName` +""", + // + """ +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +FROM `Customer` AS `c` +"""); + } + + public override async Task Update_complex_type_to_inline_without_lambda(bool async) + { + await base.Update_complex_type_to_inline_without_lambda(async); + + AssertSql( +""" +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +FROM `Customer` AS `c` +""", + // + """ +UPDATE `Customer` AS `c` +SET `c`.`ShippingAddress_AddressLine1` = 'New AddressLine1', + `c`.`ShippingAddress_AddressLine2` = 'New AddressLine2', + `c`.`ShippingAddress_Tags` = '["new_tag1","new_tag2"]', + `c`.`ShippingAddress_ZipCode` = 99999, + `c`.`ShippingAddress_Country_Code` = 'FR', + `c`.`ShippingAddress_Country_FullName` = 'France' +""", + // + """ +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +FROM `Customer` AS `c` +"""); + } + + public override async Task Update_complex_type_to_inline_with_lambda(bool async) + { + await base.Update_complex_type_to_inline_with_lambda(async); + + AssertSql( +""" +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +FROM `Customer` AS `c` +""", + // + """ +UPDATE `Customer` AS `c` +SET `c`.`ShippingAddress_AddressLine1` = 'New AddressLine1', + `c`.`ShippingAddress_AddressLine2` = 'New AddressLine2', + `c`.`ShippingAddress_Tags` = '["new_tag1","new_tag2"]', + `c`.`ShippingAddress_ZipCode` = 99999, + `c`.`ShippingAddress_Country_Code` = 'FR', + `c`.`ShippingAddress_Country_FullName` = 'France' +""", + // + """ +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +FROM `Customer` AS `c` +"""); + } + + public override async Task Update_complex_type_to_another_database_complex_type_with_subquery(bool async) + { + await base.Update_complex_type_to_another_database_complex_type_with_subquery(async); + + AssertSql( +""" +@__p_0='1' + +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +FROM `Customer` AS `c` +ORDER BY `c`.`Id` +LIMIT 18446744073709551610 OFFSET @__p_0 +""", + // + """ +@__p_0='1' + +UPDATE `Customer` AS `c0` +INNER JOIN ( + SELECT `c`.`Id`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` + FROM `Customer` AS `c` + ORDER BY `c`.`Id` + LIMIT 18446744073709551610 OFFSET @__p_0 +) AS `c1` ON `c0`.`Id` = `c1`.`Id` +SET `c0`.`ShippingAddress_AddressLine1` = `c1`.`BillingAddress_AddressLine1`, + `c0`.`ShippingAddress_AddressLine2` = `c1`.`BillingAddress_AddressLine2`, + `c0`.`ShippingAddress_Tags` = `c1`.`BillingAddress_Tags`, + `c0`.`ShippingAddress_ZipCode` = `c1`.`BillingAddress_ZipCode`, + `c0`.`ShippingAddress_Country_Code` = `c1`.`ShippingAddress_Country_Code`, + `c0`.`ShippingAddress_Country_FullName` = `c1`.`ShippingAddress_Country_FullName` +""", + // + """ +@__p_0='1' + +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +FROM `Customer` AS `c` +ORDER BY `c`.`Id` +LIMIT 18446744073709551610 OFFSET @__p_0 +"""); + } + + public override async Task Update_collection_inside_complex_type(bool async) + { + await base.Update_collection_inside_complex_type(async); + + AssertSql( +""" +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +FROM `Customer` AS `c` +""", + // + """ +UPDATE `Customer` AS `c` +SET `c`.`ShippingAddress_Tags` = '["new_tag1","new_tag2"]' +""", + // + """ +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +FROM `Customer` AS `c` +"""); + } + [ConditionalFact] public virtual void Check_all_tests_overridden() { - TestHelpers.AssertAllMethodsOverridden(GetType()); + SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); } private void AssertExecuteUpdateSql(params string[] expected) @@ -123,7 +322,7 @@ protected void ClearLog() Fixture.TestSqlLoggerFactory.Clear(); } - public class ComplexTypeBulkUpdatesSingleStoreFixture : ComplexTypeBulkUpdatesFixtureBase + public class ComplexTypeBulkUpdatesSingleStoreFixture : ComplexTypeBulkUpdatesRelationalFixtureBase { protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; diff --git a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSingleStoreTest.cs index 214d7a222..70a933f65 100644 --- a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/NonSharedModelBulkUpdatesSingleStoreTest.cs @@ -4,15 +4,20 @@ using Microsoft.EntityFrameworkCore.TestUtilities; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using Microsoft.EntityFrameworkCore; +using SingleStoreConnector; using Xunit; namespace EntityFrameworkCore.SingleStore.FunctionalTests.BulkUpdates; -public class NonSharedModelBulkUpdatesSingleStoreTest : NonSharedModelBulkUpdatesTestBase +public class NonSharedModelBulkUpdatesSingleStoreTest : NonSharedModelBulkUpdatesRelationalTestBase { protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); + public override async Task Delete_aggregate_root_when_eager_loaded_owned_collection(bool async) { await base.Delete_aggregate_root_when_eager_loaded_owned_collection(async); @@ -97,7 +102,7 @@ public override async Task Update_owned_and_non_owned_properties_with_table_shar """ UPDATE `Owner` AS `o` SET `o`.`OwnedReference_Number` = CHAR_LENGTH(`o`.`Title`), - `o`.`Title` = CAST(`o`.`OwnedReference_Number` AS char) + `o`.`Title` = COALESCE(CAST(`o`.`OwnedReference_Number` AS char), '') """); } @@ -123,10 +128,10 @@ public override async Task Update_main_table_in_entity_with_entity_splitting(boo mb.Entity(b => b.Property(p => p.Id).HasColumnType("bigint")); }, - seed: context => + seed: async context => { context.Set().Add(new Blog { Title = "SomeBlog" }); - context.SaveChanges(); + await context.SaveChangesAsync(); }); await AssertUpdate( @@ -143,6 +148,7 @@ await AssertUpdate( """); } + [ConditionalTheory(Skip = "Operation 'Update/Delete right table of a join' is not allowed.")] public override async Task Update_non_main_table_in_entity_with_entity_splitting(bool async) { var contextFactory = await InitializeAsync( @@ -165,10 +171,10 @@ public override async Task Update_non_main_table_in_entity_with_entity_splitting mb.Entity(b => b.Property(p => p.Id).HasColumnType("bigint")); }, - seed: context => + seed: async context => { context.Set().Add(new Blog { Title = "SomeBlog" }); - context.SaveChanges(); + await context.SaveChangesAsync(); }); await AssertUpdate( @@ -182,7 +188,8 @@ await AssertUpdate( AssertSql( """ -UPDATE `BlogsPart1` AS `b0` +UPDATE `Blogs` AS `b` +INNER JOIN `BlogsPart1` AS `b0` ON `b`.`Id` = `b0`.`Id` SET `b0`.`Rating` = CHAR_LENGTH(`b0`.`Title`), `b0`.`Title` = CAST(`b0`.`Rating` AS char) """); @@ -194,6 +201,50 @@ public override async Task Update_with_alias_uniquification_in_setter_subquery(b await base.Update_with_alias_uniquification_in_setter_subquery(async); } + public override async Task Update_non_owned_property_on_entity_with_owned_in_join(bool async) + { + await base.Update_non_owned_property_on_entity_with_owned_in_join(async); + + AssertSql( + """ + UPDATE `Owner` AS `o` + INNER JOIN `Owner` AS `o0` ON `o`.`Id` = `o0`.`Id` + SET `o`.`Title` = 'NewValue' + """); + } + + [ConditionalTheory(Skip = "Operation 'Update/Delete right table of a join' is not allowed.")] + public override async Task Replace_ColumnExpression_in_column_setter(bool async) + { + await base.Replace_ColumnExpression_in_column_setter(async); + + AssertSql( + """ + UPDATE `Owner` AS `o` + INNER JOIN `OwnedCollection` AS `o0` ON `o`.`Id` = `o0`.`OwnerId` + SET `o0`.`Value` = 'SomeValue' + """); + } + + public override async Task Delete_with_owned_collection_and_non_natively_translatable_query(bool async) + { + await base.Delete_with_owned_collection_and_non_natively_translatable_query(async); + + AssertSql( + """ + @__p_0='1' + + DELETE `o` + FROM `Owner` AS `o` + WHERE `o`.`Id` IN ( + SELECT `o0`.`Id` + FROM `Owner` AS `o0` + ORDER BY `o0`.`Title` + LIMIT 18446744073709551610 OFFSET @__p_0 + ) + """); + } + private void AssertSql(params string[] expected) => TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSingleStoreFixture.cs b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSingleStoreFixture.cs index db19e172a..69cfbe7cc 100644 --- a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSingleStoreFixture.cs +++ b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSingleStoreFixture.cs @@ -7,8 +7,8 @@ namespace EntityFrameworkCore.SingleStore.FunctionalTests.BulkUpdates; -public class NorthwindBulkUpdatesSingleStoreFixture : NorthwindBulkUpdatesFixture - where TModelCustomizer : IModelCustomizer, new() +public class NorthwindBulkUpdatesSingleStoreFixture : NorthwindBulkUpdatesRelationalFixture + where TModelCustomizer : ITestModelCustomizer, new() { protected override ITestStoreFactory TestStoreFactory => SingleStoreNorthwindTestStoreFactory.Instance; diff --git a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSingleStoreTest.cs index f627a14b5..d7244f324 100644 --- a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesSingleStoreTest.cs @@ -4,14 +4,16 @@ using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; using SingleStoreConnector; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using EntityFrameworkCore.SingleStore.Infrastructure; using EntityFrameworkCore.SingleStore.Tests; +using EntityFrameworkCore.SingleStore.Tests.TestUtilities.Attributes; using Xunit; using Xunit.Abstractions; namespace EntityFrameworkCore.SingleStore.FunctionalTests.BulkUpdates; -public class NorthwindBulkUpdatesSingleStoreTest : NorthwindBulkUpdatesTestBase> +public class NorthwindBulkUpdatesSingleStoreTest : NorthwindBulkUpdatesRelationalTestBase> { public NorthwindBulkUpdatesSingleStoreTest( NorthwindBulkUpdatesSingleStoreFixture fixture, @@ -19,12 +21,12 @@ public NorthwindBulkUpdatesSingleStoreTest( : base(fixture, testOutputHelper) { ClearLog(); - // Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } [ConditionalFact] public virtual void Check_all_tests_overridden() - => TestHelpers.AssertAllMethodsOverridden(GetType()); + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); public override async Task Delete_Where_TagWith(bool async) { @@ -99,13 +101,13 @@ public override async Task Delete_Where_OrderBy_Skip(bool async) WHERE EXISTS ( SELECT 1 FROM ( - SELECT `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` + SELECT `o0`.`OrderID`, `o0`.`ProductID` FROM `Order Details` AS `o0` WHERE `o0`.`OrderID` < 10300 ORDER BY `o0`.`OrderID` LIMIT 18446744073709551610 OFFSET @__p_0 - ) AS `t` - WHERE (`t`.`OrderID` = `o`.`OrderID`) AND (`t`.`ProductID` = `o`.`ProductID`)) + ) AS `o1` + WHERE (`o1`.`OrderID` = `o`.`OrderID`) AND (`o1`.`ProductID` = `o`.`ProductID`)) """); } @@ -139,13 +141,13 @@ public override async Task Delete_Where_OrderBy_Skip_Take(bool async) WHERE EXISTS ( SELECT 1 FROM ( - SELECT `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` + SELECT `o0`.`OrderID`, `o0`.`ProductID` FROM `Order Details` AS `o0` WHERE `o0`.`OrderID` < 10300 ORDER BY `o0`.`OrderID` LIMIT @__p_0 OFFSET @__p_0 - ) AS `t` - WHERE (`t`.`OrderID` = `o`.`OrderID`) AND (`t`.`ProductID` = `o`.`ProductID`)) + ) AS `o1` + WHERE (`o1`.`OrderID` = `o`.`OrderID`) AND (`o1`.`ProductID` = `o`.`ProductID`)) """); } @@ -162,12 +164,12 @@ public override async Task Delete_Where_Skip(bool async) WHERE EXISTS ( SELECT 1 FROM ( - SELECT `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` + SELECT `o0`.`OrderID`, `o0`.`ProductID` FROM `Order Details` AS `o0` WHERE `o0`.`OrderID` < 10300 LIMIT 18446744073709551610 OFFSET @__p_0 - ) AS `t` - WHERE (`t`.`OrderID` = `o`.`OrderID`) AND (`t`.`ProductID` = `o`.`ProductID`)) + ) AS `o1` + WHERE (`o1`.`OrderID` = `o`.`OrderID`) AND (`o1`.`ProductID` = `o`.`ProductID`)) """); } @@ -199,12 +201,12 @@ public override async Task Delete_Where_Skip_Take(bool async) WHERE EXISTS ( SELECT 1 FROM ( - SELECT `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` + SELECT `o0`.`OrderID`, `o0`.`ProductID` FROM `Order Details` AS `o0` WHERE `o0`.`OrderID` < 10300 LIMIT @__p_0 OFFSET @__p_0 - ) AS `t` - WHERE (`t`.`OrderID` = `o`.`OrderID`) AND (`t`.`ProductID` = `o`.`ProductID`)) + ) AS `o1` + WHERE (`o1`.`OrderID` = `o`.`OrderID`) AND (`o1`.`ProductID` = `o`.`ProductID`)) """); } @@ -281,16 +283,16 @@ public override async Task Delete_Where_Skip_Take_Skip_Take_causing_subquery(boo WHERE EXISTS ( SELECT 1 FROM ( - SELECT `t`.`OrderID`, `t`.`ProductID`, `t`.`Discount`, `t`.`Quantity`, `t`.`UnitPrice` + SELECT `o0`.`OrderID`, `o0`.`ProductID` FROM ( - SELECT `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` - FROM `Order Details` AS `o0` - WHERE `o0`.`OrderID` < 10300 + SELECT `o1`.`OrderID`, `o1`.`ProductID` + FROM `Order Details` AS `o1` + WHERE `o1`.`OrderID` < 10300 LIMIT @__p_0 OFFSET @__p_0 - ) AS `t` + ) AS `o0` LIMIT @__p_2 OFFSET @__p_1 - ) AS `t0` - WHERE (`t0`.`OrderID` = `o`.`OrderID`) AND (`t0`.`ProductID` = `o`.`ProductID`)) + ) AS `o2` + WHERE (`o2`.`OrderID` = `o`.`OrderID`) AND (`o2`.`ProductID` = `o`.`ProductID`)) """); } @@ -332,11 +334,11 @@ WHERE EXISTS ( SELECT 1 FROM `Orders` AS `o0` INNER JOIN ( - SELECT `o1`.`OrderID`, `o1`.`ProductID`, `o1`.`Discount`, `o1`.`Quantity`, `o1`.`UnitPrice` - FROM `Order Details` AS `o1` - WHERE `o1`.`ProductID` > 0 - ) AS `t` ON `o0`.`OrderID` = `t`.`OrderID` - WHERE (`o0`.`OrderID` < 10250) AND ((`t`.`OrderID` = `o`.`OrderID`) AND (`t`.`ProductID` = `o`.`ProductID`))) + SELECT `o2`.`OrderID`, `o2`.`ProductID` + FROM `Order Details` AS `o2` + WHERE `o2`.`ProductID` > 0 + ) AS `o1` ON `o0`.`OrderID` = `o1`.`OrderID` + WHERE (`o0`.`OrderID` < 10250) AND ((`o1`.`OrderID` = `o`.`OrderID`) AND (`o1`.`ProductID` = `o`.`ProductID`))) """); } @@ -385,8 +387,8 @@ SELECT 1 SELECT `o1`.`OrderID`, `o1`.`ProductID`, `o1`.`Discount`, `o1`.`Quantity`, `o1`.`UnitPrice` FROM `Order Details` AS `o1` WHERE `o1`.`OrderID` > 11250 - ) AS `t` - WHERE (`t`.`OrderID` = `o`.`OrderID`) AND (`t`.`ProductID` = `o`.`ProductID`)) + ) AS `u` + WHERE (`u`.`OrderID` = `o`.`OrderID`) AND (`u`.`ProductID` = `o`.`ProductID`)) """); } @@ -401,15 +403,15 @@ public override async Task Delete_Concat(bool async) WHERE EXISTS ( SELECT 1 FROM ( - SELECT `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` + SELECT `o0`.`OrderID`, `o0`.`ProductID` FROM `Order Details` AS `o0` WHERE `o0`.`OrderID` < 10250 UNION ALL - SELECT `o1`.`OrderID`, `o1`.`ProductID`, `o1`.`Discount`, `o1`.`Quantity`, `o1`.`UnitPrice` + SELECT `o1`.`OrderID`, `o1`.`ProductID` FROM `Order Details` AS `o1` WHERE `o1`.`OrderID` > 11250 - ) AS `t` - WHERE (`t`.`OrderID` = `o`.`OrderID`) AND (`t`.`ProductID` = `o`.`ProductID`)) + ) AS `u` + WHERE (`u`.`OrderID` = `o`.`OrderID`) AND (`u`.`ProductID` = `o`.`ProductID`)) """); } @@ -431,8 +433,8 @@ SELECT 1 SELECT `o1`.`OrderID`, `o1`.`ProductID`, `o1`.`Discount`, `o1`.`Quantity`, `o1`.`UnitPrice` FROM `Order Details` AS `o1` WHERE `o1`.`OrderID` > 11250 - ) AS `t` - WHERE (`t`.`OrderID` = `o`.`OrderID`) AND (`t`.`ProductID` = `o`.`ProductID`)) + ) AS `i` + WHERE (`i`.`OrderID` = `o`.`OrderID`) AND (`i`.`ProductID` = `o`.`ProductID`)) """); } @@ -454,8 +456,8 @@ SELECT 1 SELECT `o1`.`OrderID`, `o1`.`ProductID`, `o1`.`Discount`, `o1`.`Quantity`, `o1`.`UnitPrice` FROM `Order Details` AS `o1` WHERE `o1`.`OrderID` > 11250 - ) AS `t` - WHERE (`t`.`OrderID` = `o`.`OrderID`) AND (`t`.`ProductID` = `o`.`ProductID`)) + ) AS `e` + WHERE (`e`.`OrderID` = `o`.`OrderID`) AND (`e`.`ProductID` = `o`.`ProductID`)) """); } @@ -525,12 +527,12 @@ public override async Task Delete_with_join(bool async) DELETE `o` FROM `Order Details` AS `o` INNER JOIN ( - SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` + SELECT `o0`.`OrderID` FROM `Orders` AS `o0` WHERE `o0`.`OrderID` < 10300 ORDER BY `o0`.`OrderID` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` ON `o`.`OrderID` = `t`.`OrderID` +) AS `o1` ON `o`.`OrderID` = `o1`.`OrderID` """); } @@ -546,12 +548,12 @@ public override async Task Delete_with_left_join(bool async) DELETE `o` FROM `Order Details` AS `o` LEFT JOIN ( - SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` + SELECT `o0`.`OrderID` FROM `Orders` AS `o0` WHERE `o0`.`OrderID` < 10300 ORDER BY `o0`.`OrderID` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` ON `o`.`OrderID` = `t`.`OrderID` +) AS `o1` ON `o`.`OrderID` = `o1`.`OrderID` WHERE `o`.`OrderID` < 10276 """); } @@ -565,12 +567,12 @@ public override async Task Delete_with_cross_join(bool async) DELETE `o` FROM `Order Details` AS `o` CROSS JOIN ( - SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` + SELECT 1 FROM `Orders` AS `o0` WHERE `o0`.`OrderID` < 10300 ORDER BY `o0`.`OrderID` LIMIT 100 OFFSET 0 -) AS `t` +) AS `o1` WHERE `o`.`OrderID` < 10276 """); } @@ -584,12 +586,12 @@ public override async Task Delete_with_cross_apply(bool async) DELETE `o` FROM `Order Details` AS `o` JOIN LATERAL ( - SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` + SELECT 1 FROM `Orders` AS `o0` WHERE `o0`.`OrderID` < `o`.`OrderID` ORDER BY `o0`.`OrderID` LIMIT 100 OFFSET 0 -) AS `t` ON TRUE +) AS `o1` ON TRUE WHERE `o`.`OrderID` < 10276 """); } @@ -603,12 +605,12 @@ public override async Task Delete_with_outer_apply(bool async) DELETE `o` FROM `Order Details` AS `o` LEFT JOIN LATERAL ( - SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` + SELECT 1 FROM `Orders` AS `o0` WHERE `o0`.`OrderID` < `o`.`OrderID` ORDER BY `o0`.`OrderID` LIMIT 100 OFFSET 0 -) AS `t` ON TRUE +) AS `o1` ON TRUE WHERE `o`.`OrderID` < 10276 """); } @@ -784,15 +786,15 @@ await AssertUpdate( @__p_1='4' @__p_0='2' -UPDATE `Customers` AS `c` +UPDATE `Customers` AS `c0` INNER JOIN ( - SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` - FROM `Customers` AS `c0` - WHERE `c0`.`CustomerID` LIKE 'F%' - ORDER BY `c0`.`CustomerID` + SELECT `c`.`CustomerID` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'F%' + ORDER BY `c`.`CustomerID` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` ON `c`.`CustomerID` = `t`.`CustomerID` -SET `c`.`ContactName` = 'Updated' +) AS `c1` ON `c0`.`CustomerID` = `c1`.`CustomerID` +SET `c0`.`ContactName` = 'Updated' """); } @@ -802,13 +804,13 @@ public override async Task Update_Where_OrderBy_set_constant(bool async) AssertExecuteUpdateSql( """ -UPDATE `Customers` AS `c` +UPDATE `Customers` AS `c0` INNER JOIN ( - SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` - FROM `Customers` AS `c0` - WHERE `c0`.`CustomerID` LIKE 'F%' -) AS `t` ON `c`.`CustomerID` = `t`.`CustomerID` -SET `c`.`ContactName` = 'Updated' + SELECT `c`.`CustomerID` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'F%' +) AS `c1` ON `c0`.`CustomerID` = `c1`.`CustomerID` +SET `c0`.`ContactName` = 'Updated' """); } @@ -820,15 +822,15 @@ public override async Task Update_Where_OrderBy_Skip_set_constant(bool async) """ @__p_0='4' -UPDATE `Customers` AS `c` +UPDATE `Customers` AS `c0` INNER JOIN ( - SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` - FROM `Customers` AS `c0` - WHERE `c0`.`CustomerID` LIKE 'F%' - ORDER BY `c0`.`City` + SELECT `c`.`CustomerID` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'F%' + ORDER BY `c`.`City` LIMIT 18446744073709551610 OFFSET @__p_0 -) AS `t` ON `c`.`CustomerID` = `t`.`CustomerID` -SET `c`.`ContactName` = 'Updated' +) AS `c1` ON `c0`.`CustomerID` = `c1`.`CustomerID` +SET `c0`.`ContactName` = 'Updated' """); } @@ -840,15 +842,15 @@ public override async Task Update_Where_OrderBy_Take_set_constant(bool async) """ @__p_0='4' -UPDATE `Customers` AS `c` +UPDATE `Customers` AS `c0` INNER JOIN ( - SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` - FROM `Customers` AS `c0` - WHERE `c0`.`CustomerID` LIKE 'F%' - ORDER BY `c0`.`City` + SELECT `c`.`CustomerID` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'F%' + ORDER BY `c`.`City` LIMIT @__p_0 -) AS `t` ON `c`.`CustomerID` = `t`.`CustomerID` -SET `c`.`ContactName` = 'Updated' +) AS `c1` ON `c0`.`CustomerID` = `c1`.`CustomerID` +SET `c0`.`ContactName` = 'Updated' """); } @@ -861,15 +863,15 @@ public override async Task Update_Where_OrderBy_Skip_Take_set_constant(bool asyn @__p_1='4' @__p_0='2' -UPDATE `Customers` AS `c` +UPDATE `Customers` AS `c0` INNER JOIN ( - SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` - FROM `Customers` AS `c0` - WHERE `c0`.`CustomerID` LIKE 'F%' - ORDER BY `c0`.`City` + SELECT `c`.`CustomerID` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'F%' + ORDER BY `c`.`City` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` ON `c`.`CustomerID` = `t`.`CustomerID` -SET `c`.`ContactName` = 'Updated' +) AS `c1` ON `c0`.`CustomerID` = `c1`.`CustomerID` +SET `c0`.`ContactName` = 'Updated' """); } @@ -882,20 +884,20 @@ public override async Task Update_Where_OrderBy_Skip_Take_Skip_Take_set_constant @__p_1='6' @__p_0='2' -UPDATE `Customers` AS `c` +UPDATE `Customers` AS `c1` INNER JOIN ( - SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region` + SELECT `c0`.`CustomerID` FROM ( - SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` - FROM `Customers` AS `c0` - WHERE `c0`.`CustomerID` LIKE 'F%' - ORDER BY `c0`.`City` + SELECT `c`.`CustomerID`, `c`.`City` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'F%' + ORDER BY `c`.`City` LIMIT @__p_1 OFFSET @__p_0 - ) AS `t` - ORDER BY `t`.`City` + ) AS `c0` + ORDER BY `c0`.`City` LIMIT @__p_0 OFFSET @__p_0 -) AS `t0` ON `c`.`CustomerID` = `t0`.`CustomerID` -SET `c`.`ContactName` = 'Updated' +) AS `c2` ON `c1`.`CustomerID` = `c2`.`CustomerID` +SET `c1`.`ContactName` = 'Updated' """); } @@ -973,13 +975,13 @@ public override async Task Update_Where_Distinct_set_constant(bool async) AssertExecuteUpdateSql( """ -UPDATE `Customers` AS `c` +UPDATE `Customers` AS `c0` INNER JOIN ( - SELECT DISTINCT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` - FROM `Customers` AS `c0` - WHERE `c0`.`CustomerID` LIKE 'F%' -) AS `t` ON `c`.`CustomerID` = `t`.`CustomerID` -SET `c`.`ContactName` = 'Updated' + SELECT DISTINCT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'F%' +) AS `c1` ON `c0`.`CustomerID` = `c1`.`CustomerID` +SET `c0`.`ContactName` = 'Updated' """); } @@ -1135,17 +1137,17 @@ public override async Task Update_Union_set_constant(bool async) AssertExecuteUpdateSql( """ -UPDATE `Customers` AS `c` +UPDATE `Customers` AS `c1` INNER JOIN ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'F%' + UNION SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` FROM `Customers` AS `c0` - WHERE `c0`.`CustomerID` LIKE 'F%' - UNION - SELECT `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region` - FROM `Customers` AS `c1` - WHERE `c1`.`CustomerID` LIKE 'A%' -) AS `t` ON `c`.`CustomerID` = `t`.`CustomerID` -SET `c`.`ContactName` = 'Updated' + WHERE `c0`.`CustomerID` LIKE 'A%' +) AS `u` ON `c1`.`CustomerID` = `u`.`CustomerID` +SET `c1`.`ContactName` = 'Updated' """); } @@ -1155,17 +1157,17 @@ public override async Task Update_Concat_set_constant(bool async) AssertExecuteUpdateSql( """ -UPDATE `Customers` AS `c` +UPDATE `Customers` AS `c1` INNER JOIN ( - SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` - FROM `Customers` AS `c0` - WHERE `c0`.`CustomerID` LIKE 'F%' + SELECT `c`.`CustomerID` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'F%' UNION ALL - SELECT `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region` - FROM `Customers` AS `c1` - WHERE `c1`.`CustomerID` LIKE 'A%' -) AS `t` ON `c`.`CustomerID` = `t`.`CustomerID` -SET `c`.`ContactName` = 'Updated' + SELECT `c0`.`CustomerID` + FROM `Customers` AS `c0` + WHERE `c0`.`CustomerID` LIKE 'A%' +) AS `u` ON `c1`.`CustomerID` = `u`.`CustomerID` +SET `c1`.`ContactName` = 'Updated' """); } @@ -1175,17 +1177,17 @@ public override async Task Update_Except_set_constant(bool async) AssertExecuteUpdateSql( """ -UPDATE `Customers` AS `c` +UPDATE `Customers` AS `c1` INNER JOIN ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'F%' + EXCEPT SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` FROM `Customers` AS `c0` - WHERE `c0`.`CustomerID` LIKE 'F%' - EXCEPT - SELECT `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region` - FROM `Customers` AS `c1` - WHERE `c1`.`CustomerID` LIKE 'A%' -) AS `t` ON `c`.`CustomerID` = `t`.`CustomerID` -SET `c`.`ContactName` = 'Updated' + WHERE `c0`.`CustomerID` LIKE 'A%' +) AS `e` ON `c1`.`CustomerID` = `e`.`CustomerID` +SET `c1`.`ContactName` = 'Updated' """); } @@ -1195,17 +1197,17 @@ public override async Task Update_Intersect_set_constant(bool async) AssertExecuteUpdateSql( """ -UPDATE `Customers` AS `c` +UPDATE `Customers` AS `c1` INNER JOIN ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'F%' + INTERSECT SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` FROM `Customers` AS `c0` - WHERE `c0`.`CustomerID` LIKE 'F%' - INTERSECT - SELECT `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region` - FROM `Customers` AS `c1` - WHERE `c1`.`CustomerID` LIKE 'A%' -) AS `t` ON `c`.`CustomerID` = `t`.`CustomerID` -SET `c`.`ContactName` = 'Updated' + WHERE `c0`.`CustomerID` LIKE 'A%' +) AS `i` ON `c1`.`CustomerID` = `i`.`CustomerID` +SET `c1`.`ContactName` = 'Updated' """); } @@ -1217,10 +1219,10 @@ public override async Task Update_with_join_set_constant(bool async) """ UPDATE `Customers` AS `c` INNER JOIN ( - SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + SELECT `o`.`CustomerID` FROM `Orders` AS `o` WHERE `o`.`OrderID` < 10300 -) AS `t` ON `c`.`CustomerID` = `t`.`CustomerID` +) AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` SET `c`.`ContactName` = 'Updated' WHERE `c`.`CustomerID` LIKE 'F%' """); @@ -1234,10 +1236,10 @@ public override async Task Update_with_left_join_set_constant(bool async) """ UPDATE `Customers` AS `c` LEFT JOIN ( - SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + SELECT `o`.`CustomerID` FROM `Orders` AS `o` WHERE `o`.`OrderID` < 10300 -) AS `t` ON `c`.`CustomerID` = `t`.`CustomerID` +) AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` SET `c`.`ContactName` = 'Updated' WHERE `c`.`CustomerID` LIKE 'F%' """); @@ -1251,10 +1253,10 @@ public override async Task Update_with_cross_join_set_constant(bool async) """ UPDATE `Customers` AS `c` CROSS JOIN ( - SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + SELECT 1 FROM `Orders` AS `o` WHERE `o`.`OrderID` < 10300 -) AS `t` +) AS `o0` SET `c`.`ContactName` = 'Updated' WHERE `c`.`CustomerID` LIKE 'F%' """); @@ -1268,10 +1270,10 @@ public override async Task Update_with_cross_apply_set_constant(bool async) """ UPDATE `Customers` AS `c` JOIN LATERAL ( - SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + SELECT 1 FROM `Orders` AS `o` WHERE (`o`.`OrderID` < 10300) AND (EXTRACT(year FROM `o`.`OrderDate`) < CHAR_LENGTH(`c`.`ContactName`)) -) AS `t` ON TRUE +) AS `o0` ON TRUE SET `c`.`ContactName` = 'Updated' WHERE `c`.`CustomerID` LIKE 'F%' """); @@ -1285,10 +1287,10 @@ public override async Task Update_with_outer_apply_set_constant(bool async) """ UPDATE `Customers` AS `c` LEFT JOIN LATERAL ( - SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + SELECT 1 FROM `Orders` AS `o` WHERE (`o`.`OrderID` < 10300) AND (EXTRACT(year FROM `o`.`OrderDate`) < CHAR_LENGTH(`c`.`ContactName`)) -) AS `t` ON TRUE +) AS `o0` ON TRUE SET `c`.`ContactName` = 'Updated' WHERE `c`.`CustomerID` LIKE 'F%' """); @@ -1302,15 +1304,15 @@ public override async Task Update_with_cross_join_left_join_set_constant(bool as """ UPDATE `Customers` AS `c` CROSS JOIN ( - SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` + SELECT 1 FROM `Customers` AS `c0` WHERE `c0`.`City` LIKE 'S%' -) AS `t` +) AS `c1` LEFT JOIN ( - SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + SELECT `o`.`CustomerID` FROM `Orders` AS `o` WHERE `o`.`OrderID` < 10300 -) AS `t0` ON `c`.`CustomerID` = `t0`.`CustomerID` +) AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` SET `c`.`ContactName` = 'Updated' WHERE `c`.`CustomerID` LIKE 'F%' """); @@ -1324,15 +1326,15 @@ public override async Task Update_with_cross_join_cross_apply_set_constant(bool """ UPDATE `Customers` AS `c` CROSS JOIN ( - SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` + SELECT 1 FROM `Customers` AS `c0` WHERE `c0`.`City` LIKE 'S%' -) AS `t` +) AS `c1` JOIN LATERAL ( - SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + SELECT 1 FROM `Orders` AS `o` WHERE (`o`.`OrderID` < 10300) AND (EXTRACT(year FROM `o`.`OrderDate`) < CHAR_LENGTH(`c`.`ContactName`)) -) AS `t0` ON TRUE +) AS `o0` ON TRUE SET `c`.`ContactName` = 'Updated' WHERE `c`.`CustomerID` LIKE 'F%' """); @@ -1346,15 +1348,15 @@ public override async Task Update_with_cross_join_outer_apply_set_constant(bool """ UPDATE `Customers` AS `c` CROSS JOIN ( - SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` + SELECT 1 FROM `Customers` AS `c0` WHERE `c0`.`City` LIKE 'S%' -) AS `t` +) AS `c1` LEFT JOIN LATERAL ( - SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + SELECT 1 FROM `Orders` AS `o` WHERE (`o`.`OrderID` < 10300) AND (EXTRACT(year FROM `o`.`OrderDate`) < CHAR_LENGTH(`c`.`ContactName`)) -) AS `t0` ON TRUE +) AS `o0` ON TRUE SET `c`.`ContactName` = 'Updated' WHERE `c`.`CustomerID` LIKE 'F%' """); @@ -1373,18 +1375,18 @@ public override async Task Update_Where_SelectMany_subquery_set_null(bool async) AssertExecuteUpdateSql( """ -UPDATE `Orders` AS `o` +UPDATE `Orders` AS `o1` INNER JOIN ( - SELECT `t`.`OrderID`, `t`.`CustomerID`, `t`.`EmployeeID`, `t`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0` + SELECT `o0`.`OrderID` FROM `Customers` AS `c` INNER JOIN ( - SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` - FROM `Orders` AS `o0` - WHERE EXTRACT(year FROM `o0`.`OrderDate`) = 1997 - ) AS `t` ON `c`.`CustomerID` = `t`.`CustomerID` + SELECT `o`.`OrderID`, `o`.`CustomerID` + FROM `Orders` AS `o` + WHERE EXTRACT(year FROM `o`.`OrderDate`) = 1997 + ) AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` WHERE `c`.`CustomerID` LIKE 'F%' -) AS `t0` ON `o`.`OrderID` = `t0`.`OrderID` -SET `o`.`OrderDate` = NULL +) AS `s` ON `o1`.`OrderID` = `s`.`OrderID` +SET `o1`.`OrderDate` = NULL """); } @@ -1414,11 +1416,11 @@ public override async Task Update_Where_Join_set_property_from_joined_table(bool """ UPDATE `Customers` AS `c` CROSS JOIN ( - SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` + SELECT `c0`.`City` FROM `Customers` AS `c0` WHERE `c0`.`CustomerID` = 'ALFKI' -) AS `t` -SET `c`.`City` = `t`.`City` +) AS `c1` +SET `c`.`City` = `c1`.`City` WHERE `c`.`CustomerID` LIKE 'F%' """); } diff --git a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesSingleStoreTest.cs index bfbb8980b..cce565ca8 100644 --- a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPCFiltersInheritanceBulkUpdatesSingleStoreTest.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.BulkUpdates; using Microsoft.EntityFrameworkCore.TestUtilities; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using Xunit; using Xunit.Abstractions; @@ -19,7 +20,7 @@ public TPCFiltersInheritanceBulkUpdatesSingleStoreTest( [ConditionalFact] public virtual void Check_all_tests_overridden() - => TestHelpers.AssertAllMethodsOverridden(GetType()); + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); public override async Task Delete_where_hierarchy(bool async) { @@ -51,13 +52,13 @@ public override async Task Delete_where_using_hierarchy(bool async) WHERE ( SELECT COUNT(*) FROM ( - SELECT `e`.`Id`, `e`.`CountryId`, `e`.`Name`, `e`.`Species`, `e`.`EagleId`, `e`.`IsFlightless`, `e`.`Group`, NULL AS `FoundOn`, 'Eagle' AS `Discriminator` + SELECT `e`.`CountryId` FROM `Eagle` AS `e` UNION ALL - SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` + SELECT `k`.`CountryId` FROM `Kiwi` AS `k` - ) AS `t` - WHERE ((`t`.`CountryId` = 1) AND (`c`.`Id` = `t`.`CountryId`)) AND (`t`.`CountryId` > 0)) > 0 + ) AS `u` + WHERE ((`u`.`CountryId` = 1) AND (`c`.`Id` = `u`.`CountryId`)) AND (`u`.`CountryId` > 0)) > 0 """); } @@ -72,10 +73,10 @@ public override async Task Delete_where_using_hierarchy_derived(bool async) WHERE ( SELECT COUNT(*) FROM ( - SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` + SELECT `k`.`CountryId` FROM `Kiwi` AS `k` - ) AS `t` - WHERE ((`t`.`CountryId` = 1) AND (`c`.`Id` = `t`.`CountryId`)) AND (`t`.`CountryId` > 0)) > 0 + ) AS `u` + WHERE ((`u`.`CountryId` = 1) AND (`c`.`Id` = `u`.`CountryId`)) AND (`u`.`CountryId` > 0)) > 0 """); } @@ -132,13 +133,13 @@ public override async Task Update_where_using_hierarchy(bool async) WHERE ( SELECT COUNT(*) FROM ( - SELECT `e`.`Id`, `e`.`CountryId`, `e`.`Name`, `e`.`Species`, `e`.`EagleId`, `e`.`IsFlightless`, `e`.`Group`, NULL AS `FoundOn`, 'Eagle' AS `Discriminator` + SELECT `e`.`CountryId` FROM `Eagle` AS `e` UNION ALL - SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` + SELECT `k`.`CountryId` FROM `Kiwi` AS `k` - ) AS `t` - WHERE ((`t`.`CountryId` = 1) AND (`c`.`Id` = `t`.`CountryId`)) AND (`t`.`CountryId` > 0)) > 0 + ) AS `u` + WHERE ((`u`.`CountryId` = 1) AND (`c`.`Id` = `u`.`CountryId`)) AND (`u`.`CountryId` > 0)) > 0 """); } @@ -153,10 +154,10 @@ public override async Task Update_where_using_hierarchy_derived(bool async) WHERE ( SELECT COUNT(*) FROM ( - SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` + SELECT `k`.`CountryId` FROM `Kiwi` AS `k` - ) AS `t` - WHERE ((`t`.`CountryId` = 1) AND (`c`.`Id` = `t`.`CountryId`)) AND (`t`.`CountryId` > 0)) > 0 + ) AS `u` + WHERE ((`u`.`CountryId` = 1) AND (`c`.`Id` = `u`.`CountryId`)) AND (`u`.`CountryId` > 0)) > 0 """); } @@ -173,15 +174,15 @@ public override async Task Update_base_type(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`CountryId`, `t`.`Name`, `t`.`Species`, `t`.`EagleId`, `t`.`IsFlightless`, `t`.`Group`, `t`.`FoundOn`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`CountryId`, `u`.`Name`, `u`.`Species`, `u`.`EagleId`, `u`.`IsFlightless`, `u`.`Group`, `u`.`FoundOn`, `u`.`Discriminator` FROM ( SELECT `e`.`Id`, `e`.`CountryId`, `e`.`Name`, `e`.`Species`, `e`.`EagleId`, `e`.`IsFlightless`, `e`.`Group`, NULL AS `FoundOn`, 'Eagle' AS `Discriminator` FROM `Eagle` AS `e` UNION ALL SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` FROM `Kiwi` AS `k` -) AS `t` -WHERE (`t`.`CountryId` = 1) AND (`t`.`Name` = 'Great spotted kiwi') +) AS `u` +WHERE (`u`.`CountryId` = 1) AND (`u`.`Name` = 'Great spotted kiwi') """); } @@ -191,12 +192,12 @@ public override async Task Update_base_type_with_OfType(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`CountryId`, `t`.`Name`, `t`.`Species`, `t`.`EagleId`, `t`.`IsFlightless`, `t`.`FoundOn`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`CountryId`, `u`.`Name`, `u`.`Species`, `u`.`EagleId`, `u`.`IsFlightless`, `u`.`FoundOn`, `u`.`Discriminator` FROM ( SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` FROM `Kiwi` AS `k` -) AS `t` -WHERE `t`.`CountryId` = 1 +) AS `u` +WHERE `u`.`CountryId` = 1 """); } diff --git a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesSingleStoreTest.cs index dc28a5585..d37e0666f 100644 --- a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPCInheritanceBulkUpdatesSingleStoreTest.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.BulkUpdates; using Microsoft.EntityFrameworkCore.TestUtilities; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using Xunit; using Xunit.Abstractions; @@ -16,6 +17,10 @@ public TPCInheritanceBulkUpdatesSingleStoreTest( ClearLog(); } + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); + public override async Task Delete_where_hierarchy(bool async) { await base.Delete_where_hierarchy(async); @@ -46,13 +51,13 @@ public override async Task Delete_where_using_hierarchy(bool async) WHERE ( SELECT COUNT(*) FROM ( - SELECT `e`.`Id`, `e`.`CountryId`, `e`.`Name`, `e`.`Species`, `e`.`EagleId`, `e`.`IsFlightless`, `e`.`Group`, NULL AS `FoundOn`, 'Eagle' AS `Discriminator` + SELECT `e`.`CountryId` FROM `Eagle` AS `e` UNION ALL - SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` + SELECT `k`.`CountryId` FROM `Kiwi` AS `k` - ) AS `t` - WHERE (`c`.`Id` = `t`.`CountryId`) AND (`t`.`CountryId` > 0)) > 0 + ) AS `u` + WHERE (`c`.`Id` = `u`.`CountryId`) AND (`u`.`CountryId` > 0)) > 0 """); } @@ -67,10 +72,10 @@ public override async Task Delete_where_using_hierarchy_derived(bool async) WHERE ( SELECT COUNT(*) FROM ( - SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` + SELECT `k`.`CountryId` FROM `Kiwi` AS `k` - ) AS `t` - WHERE (`c`.`Id` = `t`.`CountryId`) AND (`t`.`CountryId` > 0)) > 0 + ) AS `u` + WHERE (`c`.`Id` = `u`.`CountryId`) AND (`u`.`CountryId` > 0)) > 0 """); } @@ -127,13 +132,13 @@ public override async Task Update_where_using_hierarchy(bool async) WHERE ( SELECT COUNT(*) FROM ( - SELECT `e`.`Id`, `e`.`CountryId`, `e`.`Name`, `e`.`Species`, `e`.`EagleId`, `e`.`IsFlightless`, `e`.`Group`, NULL AS `FoundOn`, 'Eagle' AS `Discriminator` + SELECT `e`.`CountryId` FROM `Eagle` AS `e` UNION ALL - SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` + SELECT `k`.`CountryId` FROM `Kiwi` AS `k` - ) AS `t` - WHERE (`c`.`Id` = `t`.`CountryId`) AND (`t`.`CountryId` > 0)) > 0 + ) AS `u` + WHERE (`c`.`Id` = `u`.`CountryId`) AND (`u`.`CountryId` > 0)) > 0 """); } @@ -148,10 +153,10 @@ public override async Task Update_where_using_hierarchy_derived(bool async) WHERE ( SELECT COUNT(*) FROM ( - SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` + SELECT `k`.`CountryId` FROM `Kiwi` AS `k` - ) AS `t` - WHERE (`c`.`Id` = `t`.`CountryId`) AND (`t`.`CountryId` > 0)) > 0 + ) AS `u` + WHERE (`c`.`Id` = `u`.`CountryId`) AND (`u`.`CountryId` > 0)) > 0 """); } @@ -168,15 +173,15 @@ public override async Task Update_base_type(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`CountryId`, `t`.`Name`, `t`.`Species`, `t`.`EagleId`, `t`.`IsFlightless`, `t`.`Group`, `t`.`FoundOn`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`CountryId`, `u`.`Name`, `u`.`Species`, `u`.`EagleId`, `u`.`IsFlightless`, `u`.`Group`, `u`.`FoundOn`, `u`.`Discriminator` FROM ( SELECT `e`.`Id`, `e`.`CountryId`, `e`.`Name`, `e`.`Species`, `e`.`EagleId`, `e`.`IsFlightless`, `e`.`Group`, NULL AS `FoundOn`, 'Eagle' AS `Discriminator` FROM `Eagle` AS `e` UNION ALL SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` FROM `Kiwi` AS `k` -) AS `t` -WHERE `t`.`Name` = 'Great spotted kiwi' +) AS `u` +WHERE `u`.`Name` = 'Great spotted kiwi' """); } diff --git a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPHFiltersInheritanceBulkUpdatesSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPHFiltersInheritanceBulkUpdatesSingleStoreTest.cs index d583bf4a9..18b509770 100644 --- a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPHFiltersInheritanceBulkUpdatesSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPHFiltersInheritanceBulkUpdatesSingleStoreTest.cs @@ -1,11 +1,7 @@ -using System; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.BulkUpdates; -using Microsoft.EntityFrameworkCore.TestUtilities; -using SingleStoreConnector; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using EntityFrameworkCore.SingleStore.Infrastructure; -using EntityFrameworkCore.SingleStore.Tests; using EntityFrameworkCore.SingleStore.Tests.TestUtilities.Attributes; using Xunit; @@ -22,7 +18,7 @@ public TPHFiltersInheritanceBulkUpdatesSingleStoreTest(TPHFiltersInheritanceBulk [ConditionalFact] public virtual void Check_all_tests_overridden() - => TestHelpers.AssertAllMethodsOverridden(GetType()); + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); public override async Task Delete_where_hierarchy(bool async) { @@ -151,13 +147,6 @@ SELECT COUNT(*) """); } - public override async Task Update_where_keyless_entity_mapped_to_sql_query(bool async) - { - await base.Update_where_keyless_entity_mapped_to_sql_query(async); - - AssertExecuteUpdateSql(); - } - public override async Task Update_base_type(bool async) { await base.Update_base_type(async); @@ -227,19 +216,12 @@ public override async Task Delete_where_hierarchy_subquery(bool async) AssertSql(); } - public override async Task Delete_where_keyless_entity_mapped_to_sql_query(bool async) - { - await base.Delete_where_keyless_entity_mapped_to_sql_query(async); - - AssertSql(); - } - - protected override void ClearLog() - => Fixture.TestSqlLoggerFactory.Clear(); - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); private void AssertExecuteUpdateSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected, forUpdate: true); + + private void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); } diff --git a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPHInheritanceBulkUpdatesSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPHInheritanceBulkUpdatesSingleStoreTest.cs index 6f1a7005b..4d3234189 100644 --- a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPHInheritanceBulkUpdatesSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPHInheritanceBulkUpdatesSingleStoreTest.cs @@ -2,20 +2,28 @@ using Microsoft.EntityFrameworkCore.BulkUpdates; using Microsoft.EntityFrameworkCore.TestUtilities; using SingleStoreConnector; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using EntityFrameworkCore.SingleStore.Infrastructure; using EntityFrameworkCore.SingleStore.Tests.TestUtilities.Attributes; using Xunit; +using Xunit.Abstractions; namespace EntityFrameworkCore.SingleStore.FunctionalTests.BulkUpdates; public class TPHInheritanceBulkUpdatesSingleStoreTest : TPHInheritanceBulkUpdatesTestBase { - public TPHInheritanceBulkUpdatesSingleStoreTest(TPHInheritanceBulkUpdatesSingleStoreFixture fixture) - : base(fixture) + public TPHInheritanceBulkUpdatesSingleStoreTest( + TPHInheritanceBulkUpdatesSingleStoreFixture fixture, + ITestOutputHelper testOutputHelper) + : base(fixture, testOutputHelper) { ClearLog(); } + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); + public override async Task Delete_where_hierarchy(bool async) { await base.Delete_where_hierarchy(async); diff --git a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesSingleStoreTest.cs index 2a13f3b3b..ba58d338f 100644 --- a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPTFiltersInheritanceBulkUpdatesSingleStoreTest.cs @@ -2,6 +2,7 @@ using EntityFrameworkCore.SingleStore.Tests; using Microsoft.EntityFrameworkCore.BulkUpdates; using Microsoft.EntityFrameworkCore.TestUtilities; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using Xunit; using Xunit.Abstractions; @@ -20,7 +21,7 @@ public TPTFiltersInheritanceBulkUpdatesSingleStoreTest( [ConditionalFact] public virtual void Check_all_tests_overridden() - => TestHelpers.AssertAllMethodsOverridden(GetType()); + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); public override async Task Delete_where_hierarchy(bool async) { @@ -47,9 +48,6 @@ public override async Task Delete_where_using_hierarchy(bool async) WHERE ( SELECT COUNT(*) FROM `Animals` AS `a` - LEFT JOIN `Birds` AS `b` ON `a`.`Id` = `b`.`Id` - LEFT JOIN `Eagle` AS `e` ON `a`.`Id` = `e`.`Id` - LEFT JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id` WHERE ((`a`.`CountryId` = 1) AND (`c`.`Id` = `a`.`CountryId`)) AND (`a`.`CountryId` > 0)) > 0 """); } @@ -72,8 +70,6 @@ public override async Task Delete_where_using_hierarchy_derived(bool async) WHERE ( SELECT COUNT(*) FROM `Animals` AS `a` - LEFT JOIN `Birds` AS `b` ON `a`.`Id` = `b`.`Id` - LEFT JOIN `Eagle` AS `e` ON `a`.`Id` = `e`.`Id` LEFT JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id` WHERE (((`a`.`CountryId` = 1) AND (`c`.`Id` = `a`.`CountryId`)) AND `k`.`Id` IS NOT NULL) AND (`a`.`CountryId` > 0)) > 0 """); @@ -139,9 +135,6 @@ public override async Task Update_where_using_hierarchy(bool async) WHERE ( SELECT COUNT(*) FROM `Animals` AS `a` - LEFT JOIN `Birds` AS `b` ON `a`.`Id` = `b`.`Id` - LEFT JOIN `Eagle` AS `e` ON `a`.`Id` = `e`.`Id` - LEFT JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id` WHERE ((`a`.`CountryId` = 1) AND (`c`.`Id` = `a`.`CountryId`)) AND (`a`.`CountryId` > 0)) > 0 """); } @@ -164,8 +157,6 @@ public override async Task Update_where_using_hierarchy_derived(bool async) WHERE ( SELECT COUNT(*) FROM `Animals` AS `a` - LEFT JOIN `Birds` AS `b` ON `a`.`Id` = `b`.`Id` - LEFT JOIN `Eagle` AS `e` ON `a`.`Id` = `e`.`Id` LEFT JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id` WHERE (((`a`.`CountryId` = 1) AND (`c`.`Id` = `a`.`CountryId`)) AND `k`.`Id` IS NOT NULL) AND (`a`.`CountryId` > 0)) > 0 """); diff --git a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSingleStoreTest.cs index 117f81abd..e87499a0e 100644 --- a/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/BulkUpdates/TPTInheritanceBulkUpdatesSingleStoreTest.cs @@ -2,6 +2,7 @@ using EntityFrameworkCore.SingleStore.Tests; using Microsoft.EntityFrameworkCore.BulkUpdates; using Microsoft.EntityFrameworkCore.TestUtilities; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using Xunit; using Xunit.Abstractions; @@ -17,6 +18,10 @@ public TPTInheritanceBulkUpdatesSingleStoreTest( ClearLog(); } + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); + public override async Task Delete_where_hierarchy(bool async) { await base.Delete_where_hierarchy(async); @@ -105,9 +110,6 @@ public override async Task Update_where_using_hierarchy(bool async) WHERE ( SELECT COUNT(*) FROM `Animals` AS `a` - LEFT JOIN `Birds` AS `b` ON `a`.`Id` = `b`.`Id` - LEFT JOIN `Eagle` AS `e` ON `a`.`Id` = `e`.`Id` - LEFT JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id` WHERE (`c`.`Id` = `a`.`CountryId`) AND (`a`.`CountryId` > 0)) > 0 """); } @@ -130,8 +132,6 @@ public override async Task Update_where_using_hierarchy_derived(bool async) WHERE ( SELECT COUNT(*) FROM `Animals` AS `a` - LEFT JOIN `Birds` AS `b` ON `a`.`Id` = `b`.`Id` - LEFT JOIN `Eagle` AS `e` ON `a`.`Id` = `e`.`Id` LEFT JOIN `Kiwi` AS `k` ON `a`.`Id` = `k`.`Id` WHERE ((`c`.`Id` = `a`.`CountryId`) AND `k`.`Id` IS NOT NULL) AND (`a`.`CountryId` > 0)) > 0 """); diff --git a/test/EFCore.SingleStore.FunctionalTests/ConnectionSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/ConnectionSingleStoreTest.cs index b8fb5c9d9..3cf5df7bc 100644 --- a/test/EFCore.SingleStore.FunctionalTests/ConnectionSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/ConnectionSingleStoreTest.cs @@ -1,4 +1,6 @@ using System; +using System.Threading; +using System.Threading.Tasks; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -82,11 +84,11 @@ public virtual void ConnectionAttributes() } [Fact] - public void UseSingleStore_IncludesConnectorAttributes_InConnectionString() + public async Task UseSingleStore_IncludesConnectorAttributes_InConnectionString() { - using var _ = ((SingleStoreTestStore)SingleStoreNorthwindTestStoreFactory.Instance + await using var _ = await ((SingleStoreTestStore)SingleStoreNorthwindTestStoreFactory.Instance .GetOrCreate("ConnectionAttributesTest")) - .Initialize(null, (Func)null); + .InitializeAsync(null, (Func)null); var cs = SingleStoreTestStore.CreateConnectionString("ConnectionAttributesTest"); var optionsBuilder = new DbContextOptionsBuilder(); @@ -109,65 +111,65 @@ public void UseSingleStore_IncludesConnectorAttributes_InConnectionString() } [Fact] - public void Can_create_admin_connection_with_data_source() + public async Task Can_create_admin_connection_with_data_source() { - using var _ = ((SingleStoreTestStore)SingleStoreNorthwindTestStoreFactory.Instance + await using var _ = await ((SingleStoreTestStore)SingleStoreNorthwindTestStoreFactory.Instance .GetOrCreate("ConnectionTest")) - .Initialize(null, (Func)null); + .InitializeAsync(null, (Func)null); - using var dataSource = new SingleStoreDataSourceBuilder(SingleStoreTestStore.CreateConnectionString("ConnectionTest")).Build(); + await using var dataSource = new SingleStoreDataSourceBuilder(SingleStoreTestStore.CreateConnectionString("ConnectionTest")).Build(); var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseSingleStore(dataSource, b => b.ApplyConfiguration()); - using var context = new GeneralOptionsContext(optionsBuilder.Options); + await using var context = new GeneralOptionsContext(optionsBuilder.Options); var relationalConnection = context.GetService(); - using var masterConnection = relationalConnection.CreateMasterConnection(); + await using var masterConnection = relationalConnection.CreateMasterConnection(); Assert.Equal(string.Empty, new SingleStoreConnectionStringBuilder(masterConnection.ConnectionString).Database); - masterConnection.Open(); + await masterConnection.OpenAsync(default); } [Fact] - public void Can_create_admin_connection_with_connection_string() + public async Task Can_create_admin_connection_with_connection_string() { - using var _ = ((SingleStoreTestStore)SingleStoreNorthwindTestStoreFactory.Instance + await using var _ = await ((SingleStoreTestStore)SingleStoreNorthwindTestStoreFactory.Instance .GetOrCreate("ConnectionTest")) - .Initialize(null, (Func)null); + .InitializeAsync(null, (Func)null); var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseSingleStore(SingleStoreTestStore.CreateConnectionString("ConnectionTest"), b => b.ApplyConfiguration()); - using var context = new GeneralOptionsContext(optionsBuilder.Options); + await using var context = new GeneralOptionsContext(optionsBuilder.Options); var relationalConnection = context.GetService(); - using var masterConnection = relationalConnection.CreateMasterConnection(); + await using var masterConnection = relationalConnection.CreateMasterConnection(); Assert.Equal(string.Empty, new SingleStoreConnectionStringBuilder(masterConnection.ConnectionString).Database); - masterConnection.Open(); + await masterConnection.OpenAsync(default); } [Fact] - public void Can_create_admin_connection_with_connection() + public async Task Can_create_admin_connection_with_connection() { - using var _ = ((SingleStoreTestStore)SingleStoreNorthwindTestStoreFactory.Instance + await using var _ = await ((SingleStoreTestStore)SingleStoreNorthwindTestStoreFactory.Instance .GetOrCreate("ConnectionTestWithConnection")) - .Initialize(null, (Func)null); + .InitializeAsync(null, (Func)null); - using var connection = new SingleStoreConnection(SingleStoreTestStore.CreateConnectionString("ConnectionTestWithConnection")); + await using var connection = new SingleStoreConnection(SingleStoreTestStore.CreateConnectionString("ConnectionTestWithConnection")); var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseSingleStore(connection, b => b.ApplyConfiguration()); - using var context = new GeneralOptionsContext(optionsBuilder.Options); + await using var context = new GeneralOptionsContext(optionsBuilder.Options); var relationalConnection = context.GetService(); - using var masterConnection = relationalConnection.CreateMasterConnection(); + await using var masterConnection = relationalConnection.CreateMasterConnection(); Assert.Equal(string.Empty, new SingleStoreConnectionStringBuilder(masterConnection.ConnectionString).Database); - masterConnection.Open(); + await masterConnection.OpenAsync(default); } diff --git a/test/EFCore.SingleStore.FunctionalTests/ConvertToProviderTypesSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/ConvertToProviderTypesSingleStoreTest.cs index ba58d25d1..e094c8d9b 100644 --- a/test/EFCore.SingleStore.FunctionalTests/ConvertToProviderTypesSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/ConvertToProviderTypesSingleStoreTest.cs @@ -2,6 +2,7 @@ using System.Globalization; using System.Linq; using System.Linq.Expressions; +using System.Threading.Tasks; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; @@ -24,43 +25,44 @@ public ConvertToProviderTypesSingleStoreTest(ConvertToProviderTypesSingleStoreFi } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_read_back_mapped_enum_from_collection_first_or_default() + public override async Task Can_read_back_mapped_enum_from_collection_first_or_default() { - base.Can_read_back_mapped_enum_from_collection_first_or_default(); + await base.Can_read_back_mapped_enum_from_collection_first_or_default(); } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_insert_and_read_back_with_binary_key() + public override async Task Can_insert_and_read_back_with_binary_key() { - base.Can_insert_and_read_back_with_binary_key(); + await base.Can_insert_and_read_back_with_binary_key(); } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_insert_and_read_back_with_null_binary_foreign_key() + public override async Task Can_insert_and_read_back_with_null_binary_foreign_key() { - base.Can_insert_and_read_back_with_null_binary_foreign_key(); + await base.Can_insert_and_read_back_with_null_binary_foreign_key(); } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_insert_and_read_back_with_null_string_foreign_key() + public override async Task Can_insert_and_read_back_with_null_string_foreign_key() { - base.Can_insert_and_read_back_with_null_string_foreign_key(); + await base.Can_insert_and_read_back_with_null_string_foreign_key(); } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_insert_and_read_back_with_string_key() + public override async Task Can_insert_and_read_back_with_string_key() { - base.Can_insert_and_read_back_with_string_key(); + await base.Can_insert_and_read_back_with_string_key(); } [ConditionalFact(Skip = "Further investigation is needed to determine why it is failing with SingleStore")] - public override void Optional_datetime_reading_null_from_database() + public override async Task Optional_datetime_reading_null_from_database() { - base.Optional_datetime_reading_null_from_database(); + await base.Optional_datetime_reading_null_from_database(); } - public override void Can_perform_query_with_ansi_strings_test() + public override Task Can_perform_query_with_ansi_strings_test() { + return Task.CompletedTask; } // TODO: Needed to customize: @@ -69,7 +71,7 @@ public override void Can_perform_query_with_ansi_strings_test() #region https://github.com/dotnet/efcore/issues/26068 [ConditionalFact] - public override void Can_insert_and_read_back_all_non_nullable_data_types() + public override async Task Can_insert_and_read_back_all_non_nullable_data_types() { using (var context = CreateContext()) { @@ -104,12 +106,12 @@ public override void Can_insert_and_read_back_all_non_nullable_data_types() EnumS8 = EnumS8.SomeValue }); - Assert.Equal(1, context.SaveChanges()); + Assert.Equal(1, await context.SaveChangesAsync()); } using (var context = CreateContext()) { - var dt = context.Set().Where(e => e.Id == 1).ToList().Single(); + var dt = (await context.Set().Where(e => e.Id == 1).ToListAsync()).Single(); var entityType = context.Model.FindEntityType(typeof(BuiltInDataTypes)); AssertEqualIfMapped(entityType, (short)-1234, () => dt.TestInt16); @@ -143,7 +145,7 @@ public override void Can_insert_and_read_back_all_non_nullable_data_types() } [ConditionalFact] - public override void Can_insert_and_read_back_non_nullable_backed_data_types() + public override async Task Can_insert_and_read_back_non_nullable_backed_data_types() { using (var context = CreateContext()) { @@ -178,12 +180,12 @@ public override void Can_insert_and_read_back_non_nullable_backed_data_types() EnumS8 = EnumS8.SomeValue }); - Assert.Equal(1, context.SaveChanges()); + Assert.Equal(1, await context.SaveChangesAsync()); } using (var context = CreateContext()) { - var dt = context.Set().Where(ndt => ndt.Id == 101).ToList().Single(); + var dt = (await context.Set().Where(ndt => ndt.Id == 101).ToListAsync()).Single(); var entityType = context.Model.FindEntityType(typeof(NonNullableBackedDataTypes)); AssertEqualIfMapped(entityType, (short)-1234, () => dt.Int16); @@ -217,7 +219,7 @@ public override void Can_insert_and_read_back_non_nullable_backed_data_types() } [ConditionalFact] - public override void Can_insert_and_read_back_nullable_backed_data_types() + public override async Task Can_insert_and_read_back_nullable_backed_data_types() { using (var context = CreateContext()) { @@ -252,12 +254,12 @@ public override void Can_insert_and_read_back_nullable_backed_data_types() EnumS8 = EnumS8.SomeValue }); - Assert.Equal(1, context.SaveChanges()); + Assert.Equal(1, await context.SaveChangesAsync()); } using (var context = CreateContext()) { - var dt = context.Set().Where(ndt => ndt.Id == 101).ToList().Single(); + var dt = (await context.Set().Where(ndt => ndt.Id == 101).ToListAsync()).Single(); var entityType = context.Model.FindEntityType(typeof(NullableBackedDataTypes)); AssertEqualIfMapped(entityType, (short)-1234, () => dt.Int16); @@ -290,7 +292,7 @@ public override void Can_insert_and_read_back_nullable_backed_data_types() } [ConditionalFact] - public override void Can_insert_and_read_back_object_backed_data_types() + public override async Task Can_insert_and_read_back_object_backed_data_types() { using (var context = CreateContext()) { @@ -327,12 +329,12 @@ public override void Can_insert_and_read_back_object_backed_data_types() EnumS8 = EnumS8.SomeValue }); - Assert.Equal(1, context.SaveChanges()); + Assert.Equal(1, await context.SaveChangesAsync()); } using (var context = CreateContext()) { - var dt = context.Set().Where(ndt => ndt.Id == 101).ToList().Single(); + var dt = (await context.Set().Where(ndt => ndt.Id == 101).ToListAsync()).Single(); var entityType = context.Model.FindEntityType(typeof(ObjectBackedDataTypes)); AssertEqualIfMapped(entityType, "TestString", () => dt.String); diff --git a/test/EFCore.SingleStore.FunctionalTests/CustomConvertersSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/CustomConvertersSingleStoreTest.cs index 500a39d65..5759d632f 100644 --- a/test/EFCore.SingleStore.FunctionalTests/CustomConvertersSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/CustomConvertersSingleStoreTest.cs @@ -2,6 +2,7 @@ using System.Globalization; using System.Linq; using System.Linq.Expressions; +using System.Threading.Tasks; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ChangeTracking; @@ -27,9 +28,9 @@ public override void Value_conversion_on_enum_collection_contains() } [ConditionalFact(Skip = "Further investigation is needed to determine why it is failing with SingleStore")] - public override void Optional_datetime_reading_null_from_database() + public override async Task Optional_datetime_reading_null_from_database() { - base.Optional_datetime_reading_null_from_database(); + await base.Optional_datetime_reading_null_from_database(); } // TODO: Needed to customize: @@ -38,43 +39,43 @@ public override void Optional_datetime_reading_null_from_database() #region https://github.com/dotnet/efcore/issues/26068 [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_insert_and_read_back_with_binary_key() + public override async Task Can_insert_and_read_back_with_binary_key() { - base.Can_insert_and_read_back_with_binary_key(); + await base.Can_insert_and_read_back_with_binary_key(); } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_insert_and_read_back_with_null_binary_foreign_key() + public override async Task Can_insert_and_read_back_with_null_binary_foreign_key() { - base.Can_insert_and_read_back_with_null_binary_foreign_key(); + await base.Can_insert_and_read_back_with_null_binary_foreign_key(); } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_insert_and_read_back_with_null_string_foreign_key() + public override async Task Can_insert_and_read_back_with_null_string_foreign_key() { - base.Can_insert_and_read_back_with_null_string_foreign_key(); + await base.Can_insert_and_read_back_with_null_string_foreign_key(); } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_insert_and_read_back_with_string_key() + public override async Task Can_insert_and_read_back_with_string_key() { - base.Can_insert_and_read_back_with_string_key(); + await base.Can_insert_and_read_back_with_string_key(); } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_read_back_mapped_enum_from_collection_first_or_default() + public override async Task Can_read_back_mapped_enum_from_collection_first_or_default() { - base.Can_read_back_mapped_enum_from_collection_first_or_default(); + await base.Can_read_back_mapped_enum_from_collection_first_or_default(); } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Can_insert_and_read_back_with_case_insensitive_string_key() + public override async Task Can_insert_and_read_back_with_case_insensitive_string_key() { - base.Can_insert_and_read_back_with_case_insensitive_string_key(); + await base.Can_insert_and_read_back_with_case_insensitive_string_key(); } [ConditionalFact] - public override void Can_insert_and_read_back_all_non_nullable_data_types() + public override async Task Can_insert_and_read_back_all_non_nullable_data_types() { using (var context = CreateContext()) { @@ -109,12 +110,12 @@ public override void Can_insert_and_read_back_all_non_nullable_data_types() EnumS8 = EnumS8.SomeValue }); - Assert.Equal(1, context.SaveChanges()); + Assert.Equal(1, await context.SaveChangesAsync()); } using (var context = CreateContext()) { - var dt = context.Set().Where(e => e.Id == 1).ToList().Single(); + var dt = (await context.Set().Where(e => e.Id == 1).ToListAsync()).Single(); var entityType = context.Model.FindEntityType(typeof(BuiltInDataTypes)); AssertEqualIfMapped(entityType, (short)-1234, () => dt.TestInt16); @@ -148,7 +149,7 @@ public override void Can_insert_and_read_back_all_non_nullable_data_types() } [ConditionalFact] - public override void Can_insert_and_read_back_non_nullable_backed_data_types() + public override async Task Can_insert_and_read_back_non_nullable_backed_data_types() { using (var context = CreateContext()) { @@ -183,12 +184,12 @@ public override void Can_insert_and_read_back_non_nullable_backed_data_types() EnumS8 = EnumS8.SomeValue }); - Assert.Equal(1, context.SaveChanges()); + Assert.Equal(1, await context.SaveChangesAsync()); } using (var context = CreateContext()) { - var dt = context.Set().Where(ndt => ndt.Id == 101).ToList().Single(); + var dt = (await context.Set().Where(ndt => ndt.Id == 101).ToListAsync()).Single(); var entityType = context.Model.FindEntityType(typeof(NonNullableBackedDataTypes)); AssertEqualIfMapped(entityType, (short)-1234, () => dt.Int16); @@ -222,7 +223,7 @@ public override void Can_insert_and_read_back_non_nullable_backed_data_types() } [ConditionalFact] - public override void Can_insert_and_read_back_nullable_backed_data_types() + public override async Task Can_insert_and_read_back_nullable_backed_data_types() { using (var context = CreateContext()) { @@ -257,12 +258,12 @@ public override void Can_insert_and_read_back_nullable_backed_data_types() EnumS8 = EnumS8.SomeValue }); - Assert.Equal(1, context.SaveChanges()); + Assert.Equal(1, await context.SaveChangesAsync()); } using (var context = CreateContext()) { - var dt = context.Set().Where(ndt => ndt.Id == 101).ToList().Single(); + var dt = (await context.Set().Where(ndt => ndt.Id == 101).ToListAsync()).Single(); var entityType = context.Model.FindEntityType(typeof(NullableBackedDataTypes)); AssertEqualIfMapped(entityType, (short)-1234, () => dt.Int16); @@ -295,7 +296,7 @@ public override void Can_insert_and_read_back_nullable_backed_data_types() } [ConditionalFact] - public override void Can_insert_and_read_back_object_backed_data_types() + public override async Task Can_insert_and_read_back_object_backed_data_types() { using (var context = CreateContext()) { @@ -332,12 +333,12 @@ public override void Can_insert_and_read_back_object_backed_data_types() EnumS8 = EnumS8.SomeValue }); - Assert.Equal(1, context.SaveChanges()); + Assert.Equal(1, await context.SaveChangesAsync()); } using (var context = CreateContext()) { - var dt = context.Set().Where(ndt => ndt.Id == 101).ToList().Single(); + var dt = (await context.Set().Where(ndt => ndt.Id == 101).ToListAsync()).Single(); var entityType = context.Model.FindEntityType(typeof(ObjectBackedDataTypes)); AssertEqualIfMapped(entityType, "TestString", () => dt.String); diff --git a/test/EFCore.SingleStore.FunctionalTests/DataAnnotationSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/DataAnnotationSingleStoreTest.cs index 7479bbe84..cd8aab252 100644 --- a/test/EFCore.SingleStore.FunctionalTests/DataAnnotationSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/DataAnnotationSingleStoreTest.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using EntityFrameworkCore.SingleStore.Tests; using Microsoft.EntityFrameworkCore; @@ -110,29 +111,31 @@ public override IModel TableNameAttribute_affects_table_name_in_TPH() return model; } - public override void TimestampAttribute_throws_if_value_in_database_changed() + public override Task TimestampAttribute_throws_if_value_in_database_changed() { // We're skipping this test when we're running tests on Managed Service due to the specifics of // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) if (AppConfig.ManagedService) { - return; + return Task.CompletedTask; } - base.TimestampAttribute_throws_if_value_in_database_changed(); + + return base.TimestampAttribute_throws_if_value_in_database_changed(); } - public override void Table_can_configure_TPT_with_Owned() + public override Task Table_can_configure_TPT_with_Owned() { // We're skipping this test when we're running tests on Managed Service due to the specifics of // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) if (AppConfig.ManagedService) { - return; + return Task.CompletedTask; } - base.Table_can_configure_TPT_with_Owned(); + + return base.Table_can_configure_TPT_with_Owned(); } - public override void ConcurrencyCheckAttribute_throws_if_value_in_database_changed() + public override async Task ConcurrencyCheckAttribute_throws_if_value_in_database_changed() { // We're skipping this test when we're running tests on Managed Service due to the specifics of // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) @@ -140,7 +143,8 @@ public override void ConcurrencyCheckAttribute_throws_if_value_in_database_chang { return; } - base.ConcurrencyCheckAttribute_throws_if_value_in_database_changed(); + + await base.ConcurrencyCheckAttribute_throws_if_value_in_database_changed(); AssertSql( """ @@ -182,9 +186,9 @@ LIMIT 1 """); } - public override void DatabaseGeneratedAttribute_autogenerates_values_when_set_to_identity() + public override async Task DatabaseGeneratedAttribute_autogenerates_values_when_set_to_identity() { - base.DatabaseGeneratedAttribute_autogenerates_values_when_set_to_identity(); + await base.DatabaseGeneratedAttribute_autogenerates_values_when_set_to_identity(); if (AppConfig.ServerVersion.Supports.Returning) { @@ -310,15 +314,15 @@ protected class TableWithCollation } [ConditionalFact(Skip = "SingleStore truncates the data if VARCHAR column is too short to store this data.")] - public override void MaxLengthAttribute_throws_while_inserting_value_longer_than_max_length() + public override async Task MaxLengthAttribute_throws_while_inserting_value_longer_than_max_length() { - base.MaxLengthAttribute_throws_while_inserting_value_longer_than_max_length(); + await base.MaxLengthAttribute_throws_while_inserting_value_longer_than_max_length(); } [ConditionalFact(Skip = "SingleStore truncates the data if VARCHAR column is too short to store this data.")] - public override void StringLengthAttribute_throws_while_inserting_value_longer_than_max_length() + public override async Task StringLengthAttribute_throws_while_inserting_value_longer_than_max_length() { - base.StringLengthAttribute_throws_while_inserting_value_longer_than_max_length(); + await base.StringLengthAttribute_throws_while_inserting_value_longer_than_max_length(); } protected static IMutableEntityType GetEntityType(ModelBuilder modelBuilder) diff --git a/test/EFCore.SingleStore.FunctionalTests/EFCore.SingleStore.FunctionalTests.csproj b/test/EFCore.SingleStore.FunctionalTests/EFCore.SingleStore.FunctionalTests.csproj index 453bdacbe..940479468 100644 --- a/test/EFCore.SingleStore.FunctionalTests/EFCore.SingleStore.FunctionalTests.csproj +++ b/test/EFCore.SingleStore.FunctionalTests/EFCore.SingleStore.FunctionalTests.csproj @@ -19,20 +19,21 @@ $(DefineConstants);SPECIFIC_TEST_ORDER + + + + + - - - - - + @@ -67,11 +68,17 @@ $(LocalEFCoreRepository)\artifacts\bin\EFCore.Design.Tests\$(LocalEFCoreRepositoryConfiguration)\$(EfCoreTestTargetFramework)\Microsoft.EntityFrameworkCore.Design.dll + + + + + + + - - + diff --git a/test/EFCore.SingleStore.FunctionalTests/ExistingConnectionSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/ExistingConnectionSingleStoreTest.cs index ffec5067f..3f99c4247 100644 --- a/test/EFCore.SingleStore.FunctionalTests/ExistingConnectionSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/ExistingConnectionSingleStoreTest.cs @@ -23,16 +23,16 @@ private static async Task Can_use_an_existing_closed_connection(bool openConnect .AddEntityFrameworkSingleStore() .BuildServiceProvider(); - using (var store = (SingleStoreTestStore)SingleStoreNorthwindTestStoreFactory.Instance + await using (var store = (SingleStoreTestStore)await SingleStoreNorthwindTestStoreFactory.Instance .GetOrCreate(null) - .Initialize(null, (Func)null)) + .InitializeAsync(null, (Func)null)) { store.CloseConnection(); var openCount = 0; var closeCount = 0; - using (var connection = new SingleStoreConnection(store.ConnectionString)) + await using (var connection = new SingleStoreConnection(store.ConnectionString)) { if (openConnection) { @@ -56,7 +56,7 @@ private static async Task Can_use_an_existing_closed_connection(bool openConnect .UseInternalServiceProvider(serviceProvider) .Options; - using (var context = new NorthwindContext(options)) + await using (var context = new NorthwindContext(options)) { Assert.Equal(91, await context.Customers.CountAsync()); } @@ -84,9 +84,9 @@ private static async Task Closed_connection_missing_AllowUserVariables_true_in_o .AddEntityFrameworkSingleStore() .BuildServiceProvider(); - await using (var store = (SingleStoreTestStore)SingleStoreNorthwindTestStoreFactory.Instance + await using (var store = (SingleStoreTestStore)await SingleStoreNorthwindTestStoreFactory.Instance .GetOrCreate(null) - .Initialize(null, (Func)null)) + .InitializeAsync(null, (Func)null)) { store.CloseConnection(); @@ -99,7 +99,7 @@ private static async Task Closed_connection_missing_AllowUserVariables_true_in_o .UseInternalServiceProvider(serviceProvider) .Options; - using var context = new NorthwindContext(options); + await using var context = new NorthwindContext(options); Assert.Equal(91, await context.Customers.CountAsync()); } @@ -109,9 +109,9 @@ private static async Task Closed_connection_missing_AllowUserVariables_true_in_o [Fact] private static async Task Opened_connection_missing_AllowUserVariables_true_in_original_connection_string_throws() { - await using (var store = (SingleStoreTestStore)SingleStoreNorthwindTestStoreFactory.Instance + await using (var store = (SingleStoreTestStore)await SingleStoreNorthwindTestStoreFactory.Instance .GetOrCreate(null) - .Initialize(null, (Func)null)) + .InitializeAsync(null, (Func)null)) { store.CloseConnection(); @@ -145,9 +145,9 @@ private static async Task Closed_connection_missing_UseAffectedRows_false_in_ori .AddEntityFrameworkSingleStore() .BuildServiceProvider(); - await using (var store = (SingleStoreTestStore)SingleStoreNorthwindTestStoreFactory.Instance + await using (var store = (SingleStoreTestStore)await SingleStoreNorthwindTestStoreFactory.Instance .GetOrCreate(null) - .Initialize(null, (Func)null)) + .InitializeAsync(null, (Func)null)) { store.CloseConnection(); @@ -160,7 +160,7 @@ private static async Task Closed_connection_missing_UseAffectedRows_false_in_ori .UseInternalServiceProvider(serviceProvider) .Options; - using var context = new NorthwindContext(options); + await using var context = new NorthwindContext(options); Assert.Equal(91, await context.Customers.CountAsync()); } @@ -170,9 +170,9 @@ private static async Task Closed_connection_missing_UseAffectedRows_false_in_ori [Fact] private static async Task Opened_connection_missing_UseAffectedRows_false_in_original_connection_string_throws() { - await using (var store = (SingleStoreTestStore)SingleStoreNorthwindTestStoreFactory.Instance + await using (var store = (SingleStoreTestStore)await SingleStoreNorthwindTestStoreFactory.Instance .GetOrCreate(null) - .Initialize(null, (Func)null)) + .InitializeAsync(null, (Func)null)) { store.CloseConnection(); diff --git a/test/EFCore.SingleStore.FunctionalTests/FullMigrationsSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/FullMigrationsSingleStoreTest.cs index a82d0d344..198eeafa1 100644 --- a/test/EFCore.SingleStore.FunctionalTests/FullMigrationsSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/FullMigrationsSingleStoreTest.cs @@ -3,6 +3,7 @@ using System.Text.RegularExpressions; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; @@ -48,15 +49,17 @@ public virtual void Can_create_stored_procedure_script_without_custom_delimiter_ fromMigration: Migration.InitialDatabase, toMigration: "00000000000002_MigrationPrimaryKeyChange2")); + // TODO: 9.0 + // Pomelo helper stored procedure statements should be inside the transaction scope. Assert.Equal( - @"CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory` ( +""" +CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory` ( `MigrationId` varchar(150) CHARACTER SET utf8mb4 NOT NULL, `ProductVersion` varchar(32) CHARACTER SET utf8mb4 NOT NULL, CONSTRAINT `PK___EFMigrationsHistory` PRIMARY KEY (`MigrationId`) ) CHARACTER SET=utf8mb4; START TRANSACTION; - CREATE TABLE `Table1` ( `Id` int NOT NULL, `AlternatePK` int NOT NULL, @@ -66,10 +69,6 @@ public virtual void Can_create_stored_procedure_script_without_custom_delimiter_ INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) VALUES ('00000000000001_MigrationPrimaryKeyChange1', '7.0.0-test'); -COMMIT; - -START TRANSACTION; - DROP PROCEDURE IF EXISTS `POMELO_BEFORE_DROP_PRIMARY_KEY`; CREATE PROCEDURE `POMELO_BEFORE_DROP_PRIMARY_KEY`(IN `SCHEMA_NAME_ARGUMENT` VARCHAR(255), IN `TABLE_NAME_ARGUMENT` VARCHAR(255)) BEGIN @@ -120,7 +119,7 @@ INTO HAS_AUTO_INCREMENT_ID WHERE `TABLE_SCHEMA` = (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())) AND `TABLE_NAME` = TABLE_NAME_ARGUMENT AND `COLUMN_NAME` = COLUMN_NAME_ARGUMENT - AND `COLUMN_TYPE` LIKE '%int%' + AND `COLUMN_TYPE` LIKE '%bigint%' AND `COLUMN_KEY` = 'PRI'; IF HAS_AUTO_INCREMENT_ID THEN SELECT `COLUMN_TYPE` @@ -129,7 +128,7 @@ INTO PRIMARY_KEY_TYPE WHERE `TABLE_SCHEMA` = (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())) AND `TABLE_NAME` = TABLE_NAME_ARGUMENT AND `COLUMN_NAME` = COLUMN_NAME_ARGUMENT - AND `COLUMN_TYPE` LIKE '%int%' + AND `COLUMN_TYPE` LIKE '%bigint%' AND `COLUMN_KEY` = 'PRI'; SELECT `COLUMN_NAME` INTO PRIMARY_KEY_COLUMN_NAME @@ -137,7 +136,7 @@ INTO PRIMARY_KEY_COLUMN_NAME WHERE `TABLE_SCHEMA` = (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())) AND `TABLE_NAME` = TABLE_NAME_ARGUMENT AND `COLUMN_NAME` = COLUMN_NAME_ARGUMENT - AND `COLUMN_TYPE` LIKE '%int%' + AND `COLUMN_TYPE` LIKE '%bigint%' AND `COLUMN_KEY` = 'PRI'; SET SQL_EXP = CONCAT('ALTER TABLE `', (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())), '`.`', TABLE_NAME_ARGUMENT, '` MODIFY COLUMN `', PRIMARY_KEY_COLUMN_NAME, '` ', PRIMARY_KEY_TYPE, ' NOT NULL AUTO_INCREMENT;'); SET @SQL_EXP = SQL_EXP; @@ -159,7 +158,8 @@ INTO PRIMARY_KEY_COLUMN_NAME DROP PROCEDURE `POMELO_AFTER_ADD_PRIMARY_KEY`; COMMIT; -", + +""", Sql, ignoreLineEndingDifferences: true); } @@ -188,7 +188,8 @@ public virtual void Can_generate_idempotent_up_scripts_with_primary_key_related_ h => Assert.Equal("00000000000002_MigrationPrimaryKeyChange2", h.MigrationId)); Assert.Equal( - @"DROP PROCEDURE IF EXISTS `POMELO_BEFORE_DROP_PRIMARY_KEY`; +""" +DROP PROCEDURE IF EXISTS `POMELO_BEFORE_DROP_PRIMARY_KEY`; DELIMITER // CREATE PROCEDURE `POMELO_BEFORE_DROP_PRIMARY_KEY`(IN `SCHEMA_NAME_ARGUMENT` VARCHAR(255), IN `TABLE_NAME_ARGUMENT` VARCHAR(255)) BEGIN @@ -277,7 +278,6 @@ INTO PRIMARY_KEY_COLUMN_NAME ) CHARACTER SET=utf8mb4; START TRANSACTION; - DROP PROCEDURE IF EXISTS MigrationsScript; DELIMITER // CREATE PROCEDURE MigrationsScript() @@ -311,10 +311,6 @@ IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000 CALL MigrationsScript(); DROP PROCEDURE MigrationsScript; -COMMIT; - -START TRANSACTION; - DROP PROCEDURE IF EXISTS MigrationsScript; DELIMITER // CREATE PROCEDURE MigrationsScript() @@ -366,7 +362,137 @@ IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000 DROP PROCEDURE `POMELO_AFTER_ADD_PRIMARY_KEY`; -", +""", + Sql, + ignoreLineEndingDifferences: true); + } + + [ConditionalFact] + public virtual void Alter_column_change_primary_key_will_not_try_to_declare_default_value_in_sql() + { + using var db = Fixture.CreateContext( + new ServiceCollection() + .AddScoped()); + + db.Database.EnsureDeleted(); + db.Database.EnsureCreated(); + + var migrator = (SingleStoreTestMigrator)db.GetService(); + migrator.MigrationsSqlGenerationOptionsOverrider = options => options & ~MigrationsSqlGenerationOptions.Script; + + SetSql(migrator.GenerateScript()); + + //Assert.False(Sql.Contains("DEFAULT 0")); + Assert.Equal( +""" +CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory` ( + `MigrationId` varchar(150) CHARACTER SET utf8mb4 NOT NULL, + `ProductVersion` varchar(32) CHARACTER SET utf8mb4 NOT NULL, + CONSTRAINT `PK___EFMigrationsHistory` PRIMARY KEY (`MigrationId`) +) CHARACTER SET=utf8mb4; + +START TRANSACTION; +CREATE TABLE `IceCreams` ( + `Name` varchar(32) NOT NULL, + CONSTRAINT `PK_IceCreams` PRIMARY KEY (`Name`) +); + +INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) +VALUES ('00000000000001_Migration1', '7.0.0-test'); + +DROP PROCEDURE IF EXISTS `POMELO_BEFORE_DROP_PRIMARY_KEY`; +CREATE PROCEDURE `POMELO_BEFORE_DROP_PRIMARY_KEY`(IN `SCHEMA_NAME_ARGUMENT` VARCHAR(255), IN `TABLE_NAME_ARGUMENT` VARCHAR(255)) +BEGIN + DECLARE HAS_AUTO_INCREMENT_ID TINYINT(1); + DECLARE PRIMARY_KEY_COLUMN_NAME VARCHAR(255); + DECLARE PRIMARY_KEY_TYPE VARCHAR(255); + DECLARE SQL_EXP VARCHAR(1000); + SELECT COUNT(*) + INTO HAS_AUTO_INCREMENT_ID + FROM `information_schema`.`COLUMNS` + WHERE `TABLE_SCHEMA` = (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())) + AND `TABLE_NAME` = TABLE_NAME_ARGUMENT + AND `Extra` = 'auto_increment' + AND `COLUMN_KEY` = 'PRI' + LIMIT 1; + IF HAS_AUTO_INCREMENT_ID THEN + SELECT `COLUMN_TYPE` + INTO PRIMARY_KEY_TYPE + FROM `information_schema`.`COLUMNS` + WHERE `TABLE_SCHEMA` = (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())) + AND `TABLE_NAME` = TABLE_NAME_ARGUMENT + AND `COLUMN_KEY` = 'PRI' + LIMIT 1; + SELECT `COLUMN_NAME` + INTO PRIMARY_KEY_COLUMN_NAME + FROM `information_schema`.`COLUMNS` + WHERE `TABLE_SCHEMA` = (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())) + AND `TABLE_NAME` = TABLE_NAME_ARGUMENT + AND `COLUMN_KEY` = 'PRI' + LIMIT 1; + SET SQL_EXP = CONCAT('ALTER TABLE `', (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())), '`.`', TABLE_NAME_ARGUMENT, '` MODIFY COLUMN `', PRIMARY_KEY_COLUMN_NAME, '` ', PRIMARY_KEY_TYPE, ' NOT NULL;'); + SET @SQL_EXP = SQL_EXP; + PREPARE SQL_EXP_EXECUTE FROM @SQL_EXP; + EXECUTE SQL_EXP_EXECUTE; + DEALLOCATE PREPARE SQL_EXP_EXECUTE; + END IF; +END; +DROP PROCEDURE IF EXISTS `POMELO_AFTER_ADD_PRIMARY_KEY`; +CREATE PROCEDURE `POMELO_AFTER_ADD_PRIMARY_KEY`(IN `SCHEMA_NAME_ARGUMENT` VARCHAR(255), IN `TABLE_NAME_ARGUMENT` VARCHAR(255), IN `COLUMN_NAME_ARGUMENT` VARCHAR(255)) +BEGIN + DECLARE HAS_AUTO_INCREMENT_ID INT(11); + DECLARE PRIMARY_KEY_COLUMN_NAME VARCHAR(255); + DECLARE PRIMARY_KEY_TYPE VARCHAR(255); + DECLARE SQL_EXP VARCHAR(1000); + SELECT COUNT(*) + INTO HAS_AUTO_INCREMENT_ID + FROM `information_schema`.`COLUMNS` + WHERE `TABLE_SCHEMA` = (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())) + AND `TABLE_NAME` = TABLE_NAME_ARGUMENT + AND `COLUMN_NAME` = COLUMN_NAME_ARGUMENT + AND `COLUMN_TYPE` LIKE '%bigint%' + AND `COLUMN_KEY` = 'PRI'; + IF HAS_AUTO_INCREMENT_ID THEN + SELECT `COLUMN_TYPE` + INTO PRIMARY_KEY_TYPE + FROM `information_schema`.`COLUMNS` + WHERE `TABLE_SCHEMA` = (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())) + AND `TABLE_NAME` = TABLE_NAME_ARGUMENT + AND `COLUMN_NAME` = COLUMN_NAME_ARGUMENT + AND `COLUMN_TYPE` LIKE '%bigint%' + AND `COLUMN_KEY` = 'PRI'; + SELECT `COLUMN_NAME` + INTO PRIMARY_KEY_COLUMN_NAME + FROM `information_schema`.`COLUMNS` + WHERE `TABLE_SCHEMA` = (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())) + AND `TABLE_NAME` = TABLE_NAME_ARGUMENT + AND `COLUMN_NAME` = COLUMN_NAME_ARGUMENT + AND `COLUMN_TYPE` LIKE '%bigint%' + AND `COLUMN_KEY` = 'PRI'; + SET SQL_EXP = CONCAT('ALTER TABLE `', (SELECT IFNULL(SCHEMA_NAME_ARGUMENT, SCHEMA())), '`.`', TABLE_NAME_ARGUMENT, '` MODIFY COLUMN `', PRIMARY_KEY_COLUMN_NAME, '` ', PRIMARY_KEY_TYPE, ' NOT NULL AUTO_INCREMENT;'); + SET @SQL_EXP = SQL_EXP; + PREPARE SQL_EXP_EXECUTE FROM @SQL_EXP; + EXECUTE SQL_EXP_EXECUTE; + DEALLOCATE PREPARE SQL_EXP_EXECUTE; + END IF; +END; +CALL POMELO_BEFORE_DROP_PRIMARY_KEY(NULL, 'IceCreams'); +ALTER TABLE `IceCreams` DROP PRIMARY KEY; + +ALTER TABLE `IceCreams` ADD `IceCreamId` bigint NOT NULL; + +ALTER TABLE `IceCreams` ADD CONSTRAINT `PK_IceCreams` PRIMARY KEY (`IceCreamId`); +CALL POMELO_AFTER_ADD_PRIMARY_KEY(NULL, 'IceCreams', 'IceCreamId'); + +INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) +VALUES ('00000000000002_Migration2', '7.0.0-test'); + +DROP PROCEDURE `POMELO_BEFORE_DROP_PRIMARY_KEY`; +DROP PROCEDURE `POMELO_AFTER_ADD_PRIMARY_KEY`; +COMMIT; + + +""", Sql, ignoreLineEndingDifferences: true); } @@ -394,14 +520,14 @@ public virtual void Drop_primary_key_with_recreating_foreign_keys() h => Assert.Equal("00000000000002_MigrationDropPrimaryKeyWithRecreatingForeignKeys2", h.MigrationId)); Assert.Equal( - @"CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory` ( +""" +CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory` ( `MigrationId` varchar(150) CHARACTER SET utf8mb4 NOT NULL, `ProductVersion` varchar(32) CHARACTER SET utf8mb4 NOT NULL, CONSTRAINT `PK___EFMigrationsHistory` PRIMARY KEY (`MigrationId`) ) CHARACTER SET=utf8mb4; START TRANSACTION; - CREATE TABLE `Foo` ( `FooId` int NOT NULL, CONSTRAINT `PK_Foo` PRIMARY KEY (`FooId`) @@ -423,10 +549,6 @@ public virtual void Drop_primary_key_with_recreating_foreign_keys() INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) VALUES ('00000000000001_MigrationDropPrimaryKeyWithRecreatingForeignKeys1', '7.0.0-test'); -COMMIT; - -START TRANSACTION; - DROP PROCEDURE IF EXISTS `POMELO_BEFORE_DROP_PRIMARY_KEY`; DELIMITER // CREATE PROCEDURE `POMELO_BEFORE_DROP_PRIMARY_KEY`(IN `SCHEMA_NAME_ARGUMENT` VARCHAR(255), IN `TABLE_NAME_ARGUMENT` VARCHAR(255)) @@ -533,7 +655,7 @@ INTO PRIMARY_KEY_COLUMN_NAME COMMIT; -", +""", Sql, ignoreLineEndingDifferences: true); } @@ -656,6 +778,82 @@ protected override void Down(MigrationBuilder migrationBuilder) #endregion MigrationPrimaryKeyChange + public class MigrationPrimaryKeyChangeFromStringToIntContext : DbContext + { + public MigrationPrimaryKeyChangeFromStringToIntContext(DbContextOptions options) + : base(options) + { + } + + public static class Migrations + { + [DbContext(typeof(MigrationPrimaryKeyChangeFromStringToIntContext))] + [Migration("00000000000001_Migration1")] + private class Migration1 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + MigrationsInfrastructureFixtureBase.ActiveProvider = migrationBuilder.ActiveProvider; + + migrationBuilder + .CreateTable( + name: "IceCreams", + columns: table => new + { + Name = table.Column(type: "varchar(32)", maxLength: 32, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IceCreams", x => x.Name); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + => migrationBuilder.DropTable("IceCreams"); + } + + [DbContext(typeof(MigrationPrimaryKeyChangeFromStringToIntContext))] + [Migration("00000000000002_Migration2")] + private class Migration2 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_IceCreams", + table: "IceCreams"); + + migrationBuilder.AddColumn( + name: "IceCreamId", + table: "IceCreams", + type: "bigint", + nullable: false) + .Annotation("MySql:ValueGenerationStrategy", SingleStoreValueGenerationStrategy.IdentityColumn); + + migrationBuilder.AddPrimaryKey( + name: "PK_IceCreams", + table: "IceCreams", + column: "IceCreamId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropPrimaryKey( + name: "PK_IceCreams", + table: "IceCreams"); + + migrationBuilder.DropColumn( + name: "IceCreamId", + table: "IceCreams"); + + migrationBuilder.AddPrimaryKey( + name: "PK_IceCreams", + table: "IceCreams", + column: "Name"); + } + } + } + } + #region MigrationDropPrimaryKeyWithRecreatingForeignKeys public class MigrationDropPrimaryKeyWithRecreatingForeignKeysContext : PoolableDbContext diff --git a/test/EFCore.SingleStore.FunctionalTests/GraphUpdatesSingleStoreTestBase.cs b/test/EFCore.SingleStore.FunctionalTests/GraphUpdatesSingleStoreTestBase.cs index 93731f89f..a71432e7a 100644 --- a/test/EFCore.SingleStore.FunctionalTests/GraphUpdatesSingleStoreTestBase.cs +++ b/test/EFCore.SingleStore.FunctionalTests/GraphUpdatesSingleStoreTestBase.cs @@ -63,6 +63,24 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con modelBuilder.Entity().Property("CategoryId").HasDefaultValue(1); modelBuilder.Entity().Property(e => e.CategoryId).HasDefaultValue(2); + + modelBuilder.Entity>( + b => + { + b.Property(e => e.PrimaryGroup).HasDefaultValue(1).HasSentinel(1); + }); + + modelBuilder.Entity>( + b => + { + b.Property(e => e.PrimaryGroup).HasDefaultValue(true); + }); + + modelBuilder.Entity>( + b => + { + b.Property(e => e.PrimaryGroup).HasDefaultValue(true); + }); } } } diff --git a/test/EFCore.SingleStore.FunctionalTests/ManyToManyLoadSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/ManyToManyLoadSingleStoreTest.cs index 9a0f90c71..00860a048 100644 --- a/test/EFCore.SingleStore.FunctionalTests/ManyToManyLoadSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/ManyToManyLoadSingleStoreTest.cs @@ -14,7 +14,7 @@ public ManyToManyLoadSingleStoreTest(ManyToManyLoadSingleStoreFixture fixture) { } - public class ManyToManyLoadSingleStoreFixture : ManyToManyLoadFixtureBase + public class ManyToManyLoadSingleStoreFixture : ManyToManyLoadFixtureBase, ITestSqlLoggerFactory { public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; diff --git a/test/EFCore.SingleStore.FunctionalTests/ManyToManyTrackingSingleStoreTestBase.cs b/test/EFCore.SingleStore.FunctionalTests/ManyToManyTrackingSingleStoreTestBase.cs index 61472a5c6..ea97f0dac 100644 --- a/test/EFCore.SingleStore.FunctionalTests/ManyToManyTrackingSingleStoreTestBase.cs +++ b/test/EFCore.SingleStore.FunctionalTests/ManyToManyTrackingSingleStoreTestBase.cs @@ -26,8 +26,10 @@ protected ManyToManyTrackingSingleStoreTestBase(TFixture fixture) protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); - public class ManyToManyTrackingSingleStoreFixtureBase : ManyToManyTrackingRelationalFixture + public class ManyToManyTrackingSingleStoreFixtureBase : ManyToManyTrackingRelationalFixture, ITestSqlLoggerFactory { + public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; + protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) diff --git a/test/EFCore.SingleStore.FunctionalTests/MaterializationInterceptionSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/MaterializationInterceptionSingleStoreTest.cs index 22aebb204..5bbe680a8 100644 --- a/test/EFCore.SingleStore.FunctionalTests/MaterializationInterceptionSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/MaterializationInterceptionSingleStoreTest.cs @@ -1,28 +1,22 @@ +using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.Extensions.DependencyInjection; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; -using EntityFrameworkCore.SingleStore.Storage.Internal; using EntityFrameworkCore.SingleStore.Tests; +using Microsoft.EntityFrameworkCore.Diagnostics; using Xunit; namespace EntityFrameworkCore.SingleStore.FunctionalTests; -public class MaterializationInterceptionSingleStoreTest : - MaterializationInterceptionTestBase, - IClassFixture +public class MaterializationInterceptionSingleStoreTest : MaterializationInterceptionTestBase { - public MaterializationInterceptionSingleStoreTest(MaterializationInterceptionSingleStoreFixture fixture) - : base(fixture) - { - } + private int _id = 1; [ConditionalTheory] - public override async Task Intercept_query_materialization_with_owned_types_projecting_collection(bool async) + public override async Task Intercept_query_materialization_with_owned_types_projecting_collection(bool async, bool usePooling) { // We're skipping this test when we're running tests on Managed Service due to the specifics of // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) @@ -31,7 +25,93 @@ public override async Task Intercept_query_materialization_with_owned_types_proj return; } - await base.Intercept_query_materialization_with_owned_types_projecting_collection(async); + var creatingInstanceCounts = new Dictionary(); + var createdInstanceCounts = new Dictionary(); + var initializingInstanceCounts = new Dictionary(); + var initializedInstanceCounts = new Dictionary(); + LibraryContext context = null; + + var interceptors = new[] + { + new ValidatingMaterializationInterceptor( + (data, instance, method) => + { + Assert.Same(context, data.Context); + Assert.Equal(QueryTrackingBehavior.NoTracking, data.QueryTrackingBehavior); + + int count; + var clrType = data.EntityType.ClrType; + switch (method) + { + case nameof(IMaterializationInterceptor.CreatingInstance): + count = creatingInstanceCounts.GetOrAddNew(clrType); + creatingInstanceCounts[clrType] = count + 1; + Assert.Null(instance); + break; + case nameof(IMaterializationInterceptor.CreatedInstance): + count = createdInstanceCounts.GetOrAddNew(clrType); + createdInstanceCounts[clrType] = count + 1; + Assert.Same(clrType, instance!.GetType()); + break; + case nameof(IMaterializationInterceptor.InitializingInstance): + count = initializingInstanceCounts.GetOrAddNew(clrType); + initializingInstanceCounts[clrType] = count + 1; + Assert.Same(clrType, instance!.GetType()); + break; + case nameof(IMaterializationInterceptor.InitializedInstance): + count = initializedInstanceCounts.GetOrAddNew(clrType); + initializedInstanceCounts[clrType] = count + 1; + Assert.Same(clrType, instance!.GetType()); + break; + } + }) + }; + + using (context = await CreateContext(interceptors, inject: true, usePooling)) + { + context.Add( + new TestEntity30244 + { + Id = _id++, + Title = "TestIssue", + Settings = { new KeyValueSetting30244("Value1", "1"), new KeyValueSetting30244("Value2", "9") } + }); + + _ = async + ? await context.SaveChangesAsync() + : context.SaveChanges(); + + context.ChangeTracker.Clear(); + + var query = context.Set() + .AsNoTracking() + .OrderBy(e => e.Id) + .Select(x => x.Settings + .Where(s => s.Key != "Foo") + .OrderBy(s => s.Key) + .ToList()); + + var collection = async + ? await query.FirstOrDefaultAsync() + : query.FirstOrDefault(); + + Assert.NotNull(collection); + Assert.Equal("Value1", collection[0].Key); + Assert.Equal("1", collection[0].Value); + Assert.Contains(("Value2", "9"), collection.Select(x => (x.Key, x.Value))); + + Assert.Equal(1, creatingInstanceCounts.Count); + Assert.Equal(2, creatingInstanceCounts[typeof(KeyValueSetting30244)]); + + Assert.Equal(1, createdInstanceCounts.Count); + Assert.Equal(2, createdInstanceCounts[typeof(KeyValueSetting30244)]); + + Assert.Equal(1, initializingInstanceCounts.Count); + Assert.Equal(2, initializingInstanceCounts[typeof(KeyValueSetting30244)]); + + Assert.Equal(1, initializedInstanceCounts.Count); + Assert.Equal(2, initializedInstanceCounts[typeof(KeyValueSetting30244)]); + } } public class SingleStoreLibraryContext : LibraryContext @@ -64,27 +144,24 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) } } - public override LibraryContext CreateContext(IEnumerable interceptors, bool inject) - => new SingleStoreLibraryContext(Fixture.CreateOptions(interceptors, inject)); + protected override ITestStoreFactory TestStoreFactory + => SingleStoreTestStoreFactory.Instance; +} - public class MaterializationInterceptionSingleStoreFixture : SingletonInterceptorsFixtureBase +internal static class DictionaryExtensions +{ + public static TValue GetOrAddNew( + this IDictionary dictionary, + TKey key) + where TKey : notnull + where TValue : new() { - protected override string StoreName - => "MaterializationInterception"; - - protected override ITestStoreFactory TestStoreFactory - => SingleStoreTestStoreFactory.Instance; - - protected override IServiceCollection InjectInterceptors( - IServiceCollection serviceCollection, - IEnumerable injectedInterceptors) - => base.InjectInterceptors(serviceCollection.AddEntityFrameworkSingleStore(), injectedInterceptors); - - public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) + if (!dictionary.TryGetValue(key, out var value)) { - new SingleStoreDbContextOptionsBuilder(base.AddOptions(builder)) - .ExecutionStrategy(d => new SingleStoreExecutionStrategy(d)); - return builder; + value = new TValue(); + dictionary[key] = value; } + + return value; } } diff --git a/test/EFCore.SingleStore.FunctionalTests/MigrationsInfrastructureSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/MigrationsInfrastructureSingleStoreTest.cs index d09bdcdda..359dc06ef 100644 --- a/test/EFCore.SingleStore.FunctionalTests/MigrationsInfrastructureSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/MigrationsInfrastructureSingleStoreTest.cs @@ -52,140 +52,44 @@ public override void Can_generate_no_migration_script() ignoreLineEndingDifferences: true); } - public override void Can_generate_up_scripts() + public override void Can_apply_one_migration() { - base.Can_generate_up_scripts(); - - Assert.Equal( -""" -CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory` ( - `MigrationId` varchar(150) CHARACTER SET utf8mb4 NOT NULL, - `ProductVersion` varchar(32) CHARACTER SET utf8mb4 NOT NULL, - CONSTRAINT `PK___EFMigrationsHistory` PRIMARY KEY (`MigrationId`) -) CHARACTER SET=utf8mb4; - -START TRANSACTION; - -CREATE TABLE `Table1` ( - `Id` int NOT NULL, - `Foo` int NOT NULL, - `Description` longtext NOT NULL, - CONSTRAINT `PK_Table1` PRIMARY KEY (`Id`) -); - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('00000000000001_Migration1', '7.0.0-test'); - -COMMIT; - -START TRANSACTION; - -ALTER TABLE `Table1` CHANGE `Foo` `Bar`; - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('00000000000002_Migration2', '7.0.0-test'); - -COMMIT; - -START TRANSACTION; - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('00000000000003_Migration3', '7.0.0-test'); - -COMMIT; - -START TRANSACTION; - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('00000000000004_Migration4', '7.0.0-test'); - -COMMIT; - -START TRANSACTION; - -INSERT INTO Table1 (Id, Bar, Description) VALUES (-1, ' ', 'Value With - -Empty Lines') - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('00000000000005_Migration5', '7.0.0-test'); - -COMMIT; - -START TRANSACTION; - -INSERT INTO Table1 (Id, Bar, Description) VALUES (-2, ' ', 'GO -Value With - -Empty Lines') - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('00000000000006_Migration6', '7.0.0-test'); - -COMMIT; - -START TRANSACTION; - -INSERT INTO Table1 (Id, Bar, Description) VALUES (-3, ' ', 'GO -Value With - -GO - -Empty Lines -GO') - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('00000000000007_Migration7', '7.0.0-test'); - -COMMIT; - + base.Can_apply_one_migration(); -""", - Sql, - ignoreLineEndingDifferences: true); + Assert.Null(Sql); } - public override void Can_generate_one_up_script() + public override void Can_apply_one_migration_in_parallel() { - base.Can_generate_one_up_script(); - - Assert.Equal( - @"START TRANSACTION; + base.Can_apply_one_migration_in_parallel(); -ALTER TABLE `Table1` CHANGE `Foo` `Bar`; - -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('00000000000002_Migration2', '7.0.0-test'); - -COMMIT; - -", - Sql, - ignoreLineEndingDifferences: true); + Assert.Null(Sql); } - public override void Can_generate_up_script_using_names() + public override void Can_apply_second_migration_in_parallel() { - base.Can_generate_up_script_using_names(); + base.Can_apply_second_migration_in_parallel(); - Assert.Equal( - @"START TRANSACTION; + Assert.Null(Sql); + } -ALTER TABLE `Table1` CHANGE `Foo` `Bar`; + public override async Task Can_apply_one_migration_in_parallel_async() + { + await base.Can_apply_one_migration_in_parallel_async(); -INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('00000000000002_Migration2', '7.0.0-test'); + Assert.Null(Sql); + } -COMMIT; + public override async Task Can_apply_second_migration_in_parallel_async() + { + await base.Can_apply_second_migration_in_parallel_async(); -", - Sql, - ignoreLineEndingDifferences: true); + Assert.Null(Sql); } - public override void Can_generate_idempotent_up_scripts() + public override async Task Can_generate_up_and_down_scripts() { - base.Can_generate_idempotent_up_scripts(); + await base.Can_generate_up_and_down_scripts(); Assert.Equal( """ @@ -196,382 +100,75 @@ public override void Can_generate_idempotent_up_scripts() ) CHARACTER SET=utf8mb4; START TRANSACTION; +CREATE TABLE `Table1` ( + `Id` int NOT NULL, + `Foo` int NOT NULL, + `Description` longtext NOT NULL, + CONSTRAINT `PK_Table1` PRIMARY KEY (`Id`) +); -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000001_Migration1') THEN - - CREATE TABLE `Table1` ( - `Id` int NOT NULL, - `Foo` int NOT NULL, - `Description` longtext NOT NULL, - CONSTRAINT `PK_Table1` PRIMARY KEY (`Id`) - ); - - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; - -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000001_Migration1') THEN - - INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) - VALUES ('00000000000001_Migration1', '7.0.0-test'); - - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; - -COMMIT; - -START TRANSACTION; - -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000002_Migration2') THEN - - ALTER TABLE `Table1` CHANGE `Foo` `Bar`; - - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; - -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000002_Migration2') THEN - - INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) - VALUES ('00000000000002_Migration2', '7.0.0-test'); - - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; - -COMMIT; - -START TRANSACTION; - -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000003_Migration3') THEN - - INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) - VALUES ('00000000000003_Migration3', '7.0.0-test'); - - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; - -COMMIT; - -START TRANSACTION; - -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000004_Migration4') THEN - - INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) - VALUES ('00000000000004_Migration4', '7.0.0-test'); - - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; - -COMMIT; - -START TRANSACTION; - -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000005_Migration5') THEN - - INSERT INTO Table1 (Id, Bar, Description) VALUES (-1, ' ', 'Value With - - Empty Lines') - - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; - -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000005_Migration5') THEN - - INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) - VALUES ('00000000000005_Migration5', '7.0.0-test'); - - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; - -COMMIT; - -START TRANSACTION; - -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000006_Migration6') THEN - - INSERT INTO Table1 (Id, Bar, Description) VALUES (-2, ' ', 'GO - Value With - - Empty Lines') - - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; - -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000006_Migration6') THEN - - INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) - VALUES ('00000000000006_Migration6', '7.0.0-test'); - - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; - -COMMIT; - -START TRANSACTION; - -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000007_Migration7') THEN - - INSERT INTO Table1 (Id, Bar, Description) VALUES (-3, ' ', 'GO - Value With - - GO - - Empty Lines - GO') - - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; - -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000007_Migration7') THEN - - INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) - VALUES ('00000000000007_Migration7', '7.0.0-test'); - - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; - -COMMIT; - - -""", - Sql, - ignoreLineEndingDifferences: true); - } - - public override void Can_generate_down_scripts() - { - base.Can_generate_down_scripts(); - - Assert.Equal( - @"START TRANSACTION; - -ALTER TABLE `Table1` CHANGE `Bar` `Foo`; - -DELETE FROM `__EFMigrationsHistory` -WHERE `MigrationId` = '00000000000002_Migration2'; - -COMMIT; - -START TRANSACTION; - -DROP TABLE `Table1`; - -DELETE FROM `__EFMigrationsHistory` -WHERE `MigrationId` = '00000000000001_Migration1'; - -COMMIT; - -", - Sql, - ignoreLineEndingDifferences: true); - } - - public override void Can_generate_one_down_script() - { - base.Can_generate_one_down_script(); - - Assert.Equal( - @"START TRANSACTION; - -ALTER TABLE `Table1` CHANGE `Bar` `Foo`; - -DELETE FROM `__EFMigrationsHistory` -WHERE `MigrationId` = '00000000000002_Migration2'; - -COMMIT; - -", - Sql, - ignoreLineEndingDifferences: true); - } - - public override void Can_generate_down_script_using_names() - { - base.Can_generate_down_script_using_names(); - - Assert.Equal( - @"START TRANSACTION; - -ALTER TABLE `Table1` CHANGE `Bar` `Foo`; - -DELETE FROM `__EFMigrationsHistory` -WHERE `MigrationId` = '00000000000002_Migration2'; - -COMMIT; - -", - Sql, - ignoreLineEndingDifferences: true); - } - - public override void Can_generate_idempotent_down_scripts() - { - base.Can_generate_idempotent_down_scripts(); +INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) +VALUES ('00000000000001_Migration1', '7.0.0-test'); - Assert.Equal( - @"START TRANSACTION; +ALTER TABLE `Table1` CHANGE `Foo` `Bar`; -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000002_Migration2') THEN +INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) +VALUES ('00000000000002_Migration2', '7.0.0-test'); - ALTER TABLE `Table1` CHANGE `Bar` `Foo`; +INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) +VALUES ('00000000000003_Migration3', '7.0.0-test'); - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; +INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) +VALUES ('00000000000004_Migration4', '7.0.0-test'); -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000002_Migration2') THEN +INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) +VALUES ('00000000000005_Migration5', '7.0.0-test'); - DELETE FROM `__EFMigrationsHistory` - WHERE `MigrationId` = '00000000000002_Migration2'; +INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) +VALUES ('00000000000006_Migration6', '7.0.0-test'); - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; +INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) +VALUES ('00000000000007_Migration7', '7.0.0-test'); COMMIT; START TRANSACTION; +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000007_Migration7'; -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000001_Migration1') THEN +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000006_Migration6'; - DROP TABLE `Table1`; +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000005_Migration5'; - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000004_Migration4'; -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000001_Migration1') THEN +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000003_Migration3'; - DELETE FROM `__EFMigrationsHistory` - WHERE `MigrationId` = '00000000000001_Migration1'; +ALTER TABLE `Table1` CHANGE `Bar` `Foo`; - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000002_Migration2'; + +DROP TABLE `Table1`; + +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000001_Migration1'; COMMIT; -", + +""", Sql, ignoreLineEndingDifferences: true); } - public override void Can_get_active_provider() - { - base.Can_get_active_provider(); - - Assert.Equal("EntityFrameworkCore.SingleStore", ActiveProvider); - } - - public override void Can_generate_up_scripts_noTransactions() + public override async Task Can_generate_up_and_down_scripts_noTransactions() { - base.Can_generate_up_scripts_noTransactions(); + await base.Can_generate_up_and_down_scripts_noTransactions(); Assert.Equal( """ @@ -602,31 +199,95 @@ public override void Can_generate_up_scripts_noTransactions() INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) VALUES ('00000000000004_Migration4', '7.0.0-test'); -INSERT INTO Table1 (Id, Bar, Description) VALUES (-1, ' ', 'Value With +INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) +VALUES ('00000000000005_Migration5', '7.0.0-test'); -Empty Lines') +INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) +VALUES ('00000000000006_Migration6', '7.0.0-test'); INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('00000000000005_Migration5', '7.0.0-test'); +VALUES ('00000000000007_Migration7', '7.0.0-test'); + +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000007_Migration7'; + +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000006_Migration6'; + +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000005_Migration5'; + +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000004_Migration4'; + +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000003_Migration3'; + +ALTER TABLE `Table1` CHANGE `Bar` `Foo`; + +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000002_Migration2'; -INSERT INTO Table1 (Id, Bar, Description) VALUES (-2, ' ', 'GO -Value With +DROP TABLE `Table1`; + +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000001_Migration1'; + + +""", + Sql, + ignoreLineEndingDifferences: true); + } + + public override async Task Can_generate_one_up_and_down_script() + { + await base.Can_generate_one_up_and_down_script(); -Empty Lines') + Assert.Equal( +""" +START TRANSACTION; +ALTER TABLE `Table1` CHANGE `Foo` `Bar`; INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('00000000000006_Migration6', '7.0.0-test'); +VALUES ('00000000000002_Migration2', '7.0.0-test'); + +COMMIT; + +START TRANSACTION; +ALTER TABLE `Table1` CHANGE `Bar` `Foo`; + +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000002_Migration2'; + +COMMIT; -INSERT INTO Table1 (Id, Bar, Description) VALUES (-3, ' ', 'GO -Value With -GO +""", + Sql, + ignoreLineEndingDifferences: true); + } + + public override async Task Can_generate_up_and_down_script_using_names() + { + await base.Can_generate_up_and_down_script_using_names(); -Empty Lines -GO') + Assert.Equal( +""" +START TRANSACTION; +ALTER TABLE `Table1` CHANGE `Foo` `Bar`; INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) -VALUES ('00000000000007_Migration7', '7.0.0-test'); +VALUES ('00000000000002_Migration2', '7.0.0-test'); + +COMMIT; + +START TRANSACTION; +ALTER TABLE `Table1` CHANGE `Bar` `Foo`; + +DELETE FROM `__EFMigrationsHistory` +WHERE `MigrationId` = '00000000000002_Migration2'; + +COMMIT; """, @@ -634,10 +295,11 @@ Empty Lines ignoreLineEndingDifferences: true); } - public override void Can_generate_idempotent_up_scripts_noTransactions() + public override async Task Can_generate_idempotent_up_and_down_scripts() { - base.Can_generate_idempotent_up_scripts_noTransactions(); + var exception = await Assert.ThrowsAsync(() => base.Can_generate_idempotent_up_and_down_scripts()); + Assert.Equal("'DELIMITER' should not be used with SingleStoreConnector. See https://mysqlconnector.net/delimiter", exception.Message); Assert.Equal( """ CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory` ( @@ -646,6 +308,7 @@ public override void Can_generate_idempotent_up_scripts_noTransactions() CONSTRAINT `PK___EFMigrationsHistory` PRIMARY KEY (`MigrationId`) ) CHARACTER SET=utf8mb4; +START TRANSACTION; DROP PROCEDURE IF EXISTS MigrationsScript; DELIMITER // CREATE PROCEDURE MigrationsScript() @@ -709,77 +372,39 @@ IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000 CALL MigrationsScript(); DROP PROCEDURE MigrationsScript; -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000003_Migration3') THEN - - INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) - VALUES ('00000000000003_Migration3', '7.0.0-test'); - - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; - -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000004_Migration4') THEN - - INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) - VALUES ('00000000000004_Migration4', '7.0.0-test'); - - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; - -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000005_Migration5') THEN - - INSERT INTO Table1 (Id, Bar, Description) VALUES (-1, ' ', 'Value With - - Empty Lines') +COMMIT; - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; -DROP PROCEDURE IF EXISTS MigrationsScript; -DELIMITER // -CREATE PROCEDURE MigrationsScript() -BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000005_Migration5') THEN +""", + Sql, + ignoreLineEndingDifferences: true); + } - INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) - VALUES ('00000000000005_Migration5', '7.0.0-test'); + public override async Task Can_generate_idempotent_up_and_down_scripts_noTransactions() + { + var exception = await Assert.ThrowsAsync(() => base.Can_generate_idempotent_up_and_down_scripts_noTransactions()); - END IF; -END // -DELIMITER ; -CALL MigrationsScript(); -DROP PROCEDURE MigrationsScript; + Assert.Equal("'DELIMITER' should not be used with SingleStoreConnector. See https://mysqlconnector.net/delimiter", exception.Message); + Assert.Equal( +""" +CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory` ( + `MigrationId` varchar(150) CHARACTER SET utf8mb4 NOT NULL, + `ProductVersion` varchar(32) CHARACTER SET utf8mb4 NOT NULL, + CONSTRAINT `PK___EFMigrationsHistory` PRIMARY KEY (`MigrationId`) +) CHARACTER SET=utf8mb4; DROP PROCEDURE IF EXISTS MigrationsScript; DELIMITER // CREATE PROCEDURE MigrationsScript() BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000006_Migration6') THEN - - INSERT INTO Table1 (Id, Bar, Description) VALUES (-2, ' ', 'GO - Value With + IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000001_Migration1') THEN - Empty Lines') + CREATE TABLE `Table1` ( + `Id` int NOT NULL, + `Foo` int NOT NULL, + `Description` longtext NOT NULL, + CONSTRAINT `PK_Table1` PRIMARY KEY (`Id`) + ); END IF; END // @@ -791,10 +416,10 @@ Value With DELIMITER // CREATE PROCEDURE MigrationsScript() BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000006_Migration6') THEN + IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000001_Migration1') THEN INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) - VALUES ('00000000000006_Migration6', '7.0.0-test'); + VALUES ('00000000000001_Migration1', '7.0.0-test'); END IF; END // @@ -806,15 +431,9 @@ IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000 DELIMITER // CREATE PROCEDURE MigrationsScript() BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000007_Migration7') THEN - - INSERT INTO Table1 (Id, Bar, Description) VALUES (-3, ' ', 'GO - Value With - - GO + IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000002_Migration2') THEN - Empty Lines - GO') + ALTER TABLE `Table1` CHANGE `Foo` `Bar`; END IF; END // @@ -826,10 +445,10 @@ Empty Lines DELIMITER // CREATE PROCEDURE MigrationsScript() BEGIN - IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000007_Migration7') THEN + IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000000000002_Migration2') THEN INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) - VALUES ('00000000000007_Migration7', '7.0.0-test'); + VALUES ('00000000000002_Migration2', '7.0.0-test'); END IF; END // @@ -843,17 +462,13 @@ IF NOT EXISTS(SELECT 1 FROM `__EFMigrationsHistory` WHERE `MigrationId` = '00000 ignoreLineEndingDifferences: true); } - public override void Can_apply_one_migration() + public override void Can_get_active_provider() { - base.Can_apply_one_migration(); + base.Can_get_active_provider(); - Assert.Null(Sql); + Assert.Equal("EntityFrameworkCore.SingleStore", ActiveProvider); } - // Issue https://github.com/dotnet/efcore/issues/33331 isn’t applicable in our CI runs because the - // test environment sets `data_conversion_compatibility_level = '6.0'`, which avoids the overflow - // behavior the tests were asserting. - [ConditionalFact(Skip = "TODO: Implement")] public override void Can_diff_against_2_2_model() { @@ -878,6 +493,44 @@ public override void Can_diff_against_2_1_ASP_NET_Identity_model() throw new NotImplementedException(); } + public override void Can_apply_all_migrations() + { + base.Can_apply_all_migrations(); + + Assert.Null(Sql); + } + + public override void Can_apply_range_of_migrations() + { + base.Can_apply_range_of_migrations(); + + Assert.Null(Sql); + } + + public override void Can_revert_all_migrations() + { + base.Can_revert_all_migrations(); + + Assert.Null(Sql); + } + + public override void Can_revert_one_migrations() + { + base.Can_revert_one_migrations(); + + Assert.Null(Sql); + } + + protected override Task ExecuteSqlAsync(string value) + => ((SingleStoreTestStore)Fixture.TestStore).ExecuteNonQueryAsync(value); + + public override async Task Can_apply_all_migrations_async() + { + await base.Can_apply_all_migrations_async(); + + Assert.Null(Sql); + } + public class MigrationsInfrastructureSingleStoreFixture : MigrationsInfrastructureFixtureBase { protected override ITestStoreFactory TestStoreFactory diff --git a/test/EFCore.SingleStore.FunctionalTests/MigrationsSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/MigrationsSingleStoreTest.cs index 33388293b..ca4cd3cd7 100644 --- a/test/EFCore.SingleStore.FunctionalTests/MigrationsSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/MigrationsSingleStoreTest.cs @@ -28,6 +28,8 @@ namespace EntityFrameworkCore.SingleStore.FunctionalTests { public class MigrationsSingleStoreTest : MigrationsTestBase { + private readonly IRelationalTypeMappingSource _typeMappingSource; + public MigrationsSingleStoreTest(MigrationsSingleStoreFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { @@ -41,6 +43,8 @@ public MigrationsSingleStoreTest(MigrationsSingleStoreFixture fixture, ITestOutp command.ExecuteNonQuery(); } //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + + _typeMappingSource = Fixture.ServiceProvider.GetService(); } [ConditionalTheory(Skip = "SingleStore only supports online ALTER TABLE")] @@ -55,34 +59,58 @@ public override Task Alter_index_make_unique() return base.Alter_index_make_unique(); } - [ConditionalTheory(Skip = "TODO")] - public override Task Alter_column_change_computed_recreates_indexes() + [ConditionalFact(Skip = "SingleStore doesn't support CHECK constraints.")] + public override async Task Alter_check_constraint() { - return base.Alter_column_change_computed_recreates_indexes(); - } + await base.Alter_check_constraint(); - [ConditionalTheory(Skip = "TODO")] - public override Task Alter_column_reset_collation() - { - return base.Alter_column_reset_collation(); + AssertSql( + """ + ALTER TABLE `People` DROP CONSTRAINT `CK_People_Foo`; + """, + // + """ + ALTER TABLE `People` ADD CONSTRAINT `CK_People_Foo` CHECK (`DriverLicense` > 1); + """); } - [ConditionalTheory(Skip = "TODO: Syntax issue in MySQL 7 only.")] - public override Task Alter_check_constraint() + public override async Task Alter_column_make_computed(bool? stored) { - return base.Alter_check_constraint(); - } + // SingleStore computed columns are PERSISTED; virtual computed columns aren't supported/observable + if (stored == false) + { + return; + } - [ConditionalTheory(Skip = "TODO")] - public override Task Alter_column_make_computed(bool? stored) - { - return base.Alter_column_make_computed(stored); + await base.Alter_column_make_computed(stored); + + AssertSql( + """ + ALTER TABLE `People` DROP COLUMN `Sum`; + """, + // + """ + ALTER TABLE `People` ADD `Sum` AS (`X` + `Y`) PERSISTED int; + """); } - [ConditionalTheory(Skip = "TODO")] - public override Task Add_column_computed_with_collation(bool stored) + public override async Task Add_column_computed_with_collation(bool stored) { - return base.Add_column_computed_with_collation(stored); + // SingleStore computed columns are PERSISTED; virtual computed columns aren't supported/observable. + if (!stored) + { + return; + } + + await base.Add_column_computed_with_collation(stored); + + var nullableGeneratedColumnSql = + AppConfig.ServerVersion.Supports.NullableGeneratedColumns ? " NULL" : string.Empty; + + AssertSql( + $""" + ALTER TABLE `People` ADD `Name` AS ('hello') PERSISTED longtext CHARACTER SET utf8mb4 COLLATE {NonDefaultCollation}{nullableGeneratedColumnSql}; + """); } [ConditionalFact(Skip = "BLOB/TEXT columns can't have a default value in SingleStore.")] @@ -308,12 +336,6 @@ await Test( }); } - [ConditionalTheory(Skip = "TODO")] - public override Task Add_primary_key_int() - { - return base.Add_primary_key_int(); - } - [ConditionalTheory(Skip = "TODO")] public override async Task Add_primary_key_string() { @@ -321,45 +343,70 @@ public override async Task Add_primary_key_string() } [ConditionalTheory(Skip = "TODO")] - public override Task Add_primary_key_composite_with_name() + public override async Task Add_primary_key_composite_with_name() { - return base.Add_primary_key_composite_with_name(); + await base.Add_primary_key_composite_with_name(); + + AssertSql( +""" +ALTER TABLE `People` ADD CONSTRAINT `PK_Foo` PRIMARY KEY (`SomeField1`, `SomeField2`); +"""); } [ConditionalTheory(Skip = "TODO")] - public override Task Add_primary_key_with_name() + public override async Task Add_primary_key_with_name() { - return base.Add_primary_key_with_name(); + await base.Add_primary_key_with_name(); } [ConditionalTheory(Skip = "TODO")] - public override Task Add_unique_constraint() + public override async Task Add_unique_constraint() { - return base.Add_unique_constraint(); + await base.Add_unique_constraint(); } [ConditionalTheory(Skip = "TODO")] - public override Task Add_unique_constraint_composite_with_name() + public override async Task Add_unique_constraint_composite_with_name() { - return base.Add_unique_constraint_composite_with_name(); + await base.Add_unique_constraint_composite_with_name(); } - [ConditionalTheory(Skip = "TODO")] - public override Task Alter_column_change_computed_type() + public override async Task Alter_column_change_computed_type() { - return base.Alter_column_change_computed_type(); + await base.Alter_column_change_computed_type(); + /*var exception = await Assert.ThrowsAsync(() => base.Alter_column_change_computed_type()); + Assert.True(exception.Message is "'Changing the STORED status' is not supported for generated columns." + or "This is not yet supported for generated columns");*/ } - [ConditionalTheory(Skip = "TODO")] - public override Task Alter_column_change_type() + public override async Task Alter_column_change_type() { - return base.Alter_column_change_type(); + // await base.Alter_column_change_type(); + await Test( + builder => builder.Entity("People").Property("Id"), + builder => builder.Entity("People").Property("SomeColumn"), + builder => builder.Entity("People").Property("SomeColumn"), + model => + { + var table = Assert.Single(model.Tables); + var column = Assert.Single(table.Columns, c => c.Name == "SomeColumn"); + Assert.StartsWith(_typeMappingSource.FindMapping(typeof(long)).StoreTypeNameBase, column.StoreType); + }); + + AssertSql( +""" +ALTER TABLE `People` MODIFY COLUMN `SomeColumn` bigint NOT NULL; +"""); } - [ConditionalTheory(Skip = "TODO")] - public override Task Alter_column_set_collation() + public override async Task Alter_column_set_collation() { - return base.Alter_column_set_collation(); + await base.Alter_column_set_collation(); + + AssertSql( + $""" + ALTER TABLE `People` MODIFY COLUMN `Name` longtext CHARACTER SET utf8mb4 COLLATE {NonDefaultCollation} NULL; + """); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.Sequences))] @@ -368,19 +415,24 @@ public override async Task Alter_sequence_all_settings() await base.Alter_sequence_all_settings(); AssertSql( - """ +""" ALTER SEQUENCE `foo` INCREMENT BY 2 MINVALUE -5 MAXVALUE 10 CYCLE; """, // - """ +""" ALTER SEQUENCE `foo` START WITH -3 RESTART; """); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.Sequences))] - public override Task Alter_sequence_increment_by() + public override async Task Alter_sequence_increment_by() { - return base.Alter_sequence_increment_by(); + await base.Alter_sequence_increment_by(); + + AssertSql( +""" +ALTER SEQUENCE `foo` INCREMENT BY 2 NO MINVALUE NO MAXVALUE NOCYCLE; +"""); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.Sequences))] @@ -404,7 +456,7 @@ public override async Task Alter_table_add_comment_non_default_schema() await base.Alter_table_add_comment_non_default_schema(); AssertSql( - @"ALTER TABLE `SomeOtherSchema_People` COMMENT 'Table comment';"); + @"ALTER TABLE `People` COMMENT 'Table comment';"); } [ConditionalFact(Skip = "SingleStore's ALTER TABLE command doesn't work with comments")] @@ -425,34 +477,58 @@ public override Task Create_index_unique() return base.Create_index_unique(); } - [ConditionalTheory(Skip = "TODO")] - public override Task Create_index_with_filter() + [ConditionalFact(Skip = "SingleStore does not support filtered indices.")] + public override async Task Create_index_with_filter() { - return base.Create_index_with_filter(); + await base.Create_index_with_filter(); + + AssertSql(""); } - [ConditionalTheory(Skip = "TODO")] - public override Task Create_schema() + public override async Task Create_schema() { - return base.Create_schema(); + await base.Create_schema(); + + AssertSql( + """ + CREATE TABLE `SomeOtherSchema_People` ( + `Id` int NOT NULL, + CONSTRAINT `PK_People` PRIMARY KEY (`Id`) + ) CHARACTER SET=utf8mb4; + """); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.Sequences))] - public override Task Create_sequence() + public override async Task Create_sequence() { - return base.Create_sequence(); + await base.Create_sequence(); + + AssertSql( +""" +CREATE SEQUENCE `TestSequence` START WITH 1 INCREMENT BY 1 NOCYCLE; +"""); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.Sequences))] - public override Task Create_sequence_long() + public override async Task Create_sequence_long() { - return base.Create_sequence_long(); + await base.Create_sequence_long(); + + AssertSql( +""" +CREATE SEQUENCE `TestSequence` START WITH 1 INCREMENT BY 1 NOCYCLE; +"""); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.Sequences))] - public override Task Create_sequence_short() + public override async Task Create_sequence_short() { - return base.Create_sequence_short(); + await base.Create_sequence_short(); + + AssertSql( +""" +CREATE SEQUENCE `TestSequence` START WITH 1 INCREMENT BY 1 NOCYCLE; +"""); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.Sequences))] @@ -472,7 +548,7 @@ await Test( // Assert.Equal("TestSequence", sequence.Name); // Assert.Equal("dbo2", sequence.Schema); - Assert.Equal("dbo2_TestSequence", sequence.Name); + Assert.Equal("TestSequence", sequence.Name); Assert.Equal(3, sequence.StartValue); Assert.Equal(2, sequence.IncrementBy); @@ -483,14 +559,14 @@ await Test( AssertSql( """ -CREATE SEQUENCE `dbo2_TestSequence` START WITH 3 INCREMENT BY 2 MINVALUE 2 MAXVALUE 916 CYCLE; +CREATE SEQUENCE `TestSequence` START WITH 3 INCREMENT BY 2 MINVALUE 2 MAXVALUE 916 CYCLE; """); } [ConditionalTheory(Skip = "TODO")] - public override Task Create_table_all_settings() + public override async Task Create_table_all_settings() { - return base.Create_table_all_settings(); + await base.Create_table_all_settings(); } public override async Task Create_table_with_multiline_comments() @@ -511,10 +587,12 @@ More information can be found in the docs.';"); } - [ConditionalTheory(Skip = "TODO")] - public override Task Create_unique_index_with_filter() + [ConditionalFact(Skip = "SingleStore does not support filtered indices.")] + public override async Task Create_unique_index_with_filter() { - return base.Create_unique_index_with_filter(); + await base.Create_unique_index_with_filter(); + + AssertSql(""); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.DescendingIndexes))] @@ -546,10 +624,15 @@ public override async Task Alter_index_change_sort_order() @"CREATE INDEX `IX_People_X_Y_Z` ON `People` (`X`, `Y` DESC, `Z`);"); } - [ConditionalTheory(Skip = "TODO: Syntax issue in MySQL 7 only.")] - public override Task Drop_check_constraint() + [ConditionalFact(Skip = "SingleStore doesn't support CHECK constraints.")] + public override async Task Drop_check_constraint() { - return base.Drop_check_constraint(); + await base.Drop_check_constraint(); + + AssertSql( + """ + ALTER TABLE `People` DROP CONSTRAINT `CK_People_Foo`; + """); } [ConditionalTheory(Skip = "TODO")] @@ -571,9 +654,14 @@ public override async Task Drop_primary_key_string() } [SupportedServerVersionCondition(nameof(ServerVersionSupport.Sequences))] - public override Task Drop_sequence() + public override async Task Drop_sequence() { - return base.Drop_sequence(); + await base.Drop_sequence(); + + AssertSql( +""" +DROP SEQUENCE `TestSequence`; +"""); } [ConditionalFact(Skip = "Unique indexes won't be created due to the suppression of foreign keys implementation.")] @@ -582,6 +670,7 @@ public override Task Drop_unique_constraint() return base.Drop_unique_constraint(); } + [ConditionalFact(Skip = "There are no schemas in SingleStore, that a sequence can be moved between.")] [SupportedServerVersionCondition(nameof(ServerVersionSupport.Sequences))] public override async Task Move_sequence() { @@ -593,19 +682,51 @@ await Test( var sequence = Assert.Single(model.Sequences); // Assert.Equal("TestSequenceSchema", sequence.Schema); // Assert.Equal("TestSequence", sequence.Name); - Assert.Equal("TestSequenceSchema_TestSequenceMove", sequence.Name); + Assert.Equal("TestSequenceMove", sequence.Name); }); + AssertSql(""); + } + + [SupportedServerVersionCondition(nameof(ServerVersionSupport.DefaultExpression), nameof(ServerVersionSupport.AlternativeDefaultExpression))] + public override async Task Add_required_primitive_collection_with_custom_default_value_sql_to_existing_table() + { + await base.Add_required_primitive_collection_with_custom_default_value_sql_to_existing_table_core("'[3, 2, 1]'"); + AssertSql( """ -ALTER TABLE `TestSequenceMove` RENAME `TestSequenceSchema_TestSequenceMove`; +ALTER TABLE `Customers` ADD `Numbers` longtext CHARACTER SET utf8mb4 NOT NULL DEFAULT '[3, 2, 1]'; """); } - [ConditionalTheory(Skip = "TODO")] - public override Task Move_table() + public override async Task Add_required_primitve_collection_with_custom_default_value_sql_to_existing_table() + { + await base.Add_required_primitve_collection_with_custom_default_value_sql_to_existing_table_core("'[3, 2, 1]'"); + + AssertSql( +""" +ALTER TABLE `Customers` ADD `Numbers` longtext CHARACTER SET utf8mb4 NOT NULL DEFAULT '[3, 2, 1]'; +"""); + } + + public override async Task Move_table() { - return base.Move_table(); + await Test( + builder => builder.Entity("TestTable").Property("Id"), + builder => { }, + builder => builder.Entity("TestTable").ToTable("TestTable", "TestTableSchema"), + model => + { + var table = Assert.Single(model.Tables); + + Assert.Equal("TestTableSchema_TestTable", table.Name); + Assert.Null(table.Schema); + }); + + AssertSql( + """ + ALTER TABLE `TestTable` RENAME TO `TestTableSchema_TestTable`; + """); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.Sequences))] @@ -649,15 +770,47 @@ public override Task Rename_table_with_primary_key() } [SupportedServerVersionCondition(nameof(ServerVersionSupport.GeneratedColumns))] - public override Task Add_column_with_computedSql(bool? stored) + public override async Task Add_column_with_computedSql(bool? stored) { - return base.Add_column_with_computedSql(null); + // SingleStore computed columns are PERSISTED; virtual computed columns aren't supported/observable. + if (stored == false) + { + return; + } + + await base.Add_column_with_computedSql(stored); + + var nullableGeneratedColumnSql = AppConfig.ServerVersion.Supports.NullableGeneratedColumns ? " NULL" : string.Empty; + + AssertSql( + $""" + ALTER TABLE `People` ADD `Sum` AS (`X` + `Y`) PERSISTED longtext CHARACTER SET utf8mb4{nullableGeneratedColumnSql}; + """); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.GeneratedColumns))] - public override Task Create_table_with_computed_column(bool? stored) + public override async Task Create_table_with_computed_column(bool? stored) { - return base.Create_table_with_computed_column(null); + // SingleStore computed columns are PERSISTED; virtual computed columns aren't supported/observable + if (stored == false) + { + return; + } + + await base.Create_table_with_computed_column(stored); + + var nullableGeneratedColumnSql = AppConfig.ServerVersion.Supports.NullableGeneratedColumns ? " NULL" : string.Empty; + + AssertSql( + $""" + CREATE TABLE `People` ( + `Id` int NOT NULL, + `Sum` AS (`X` + `Y`) PERSISTED longtext CHARACTER SET utf8mb4{nullableGeneratedColumnSql}, + `X` int NOT NULL, + `Y` int NOT NULL, + CONSTRAINT `PK_People` PRIMARY KEY (`Id`) + ) CHARACTER SET=utf8mb4; + """); } [ConditionalFact(Skip = "ALTER TABLE doesn't support changing computed columns.'")] @@ -721,7 +874,7 @@ await Test( var nameColumn = Assert.Single(table.Columns.Where(c => c.Name == "Name")); var brandColumn = Assert.Single(table.Columns.Where(c => c.Name == "Brand")); - Assert.Null(nameColumn.Collation); + Assert.Equal(DefaultCollation, nameColumn.Collation); Assert.Equal(NonDefaultCollation, brandColumn.Collation); }); @@ -860,7 +1013,7 @@ await Test( var table = Assert.Single(result.Tables); var iceCreamIdColumn = Assert.Single(table.Columns.Where(c => c.Name == "IceCreamId")); - Assert.Null(iceCreamIdColumn.Collation); + Assert.Equal(iceCreamIdColumn.Collation, DefaultCollation); }); AssertSql( @@ -903,7 +1056,7 @@ await Test( var brandColumn = Assert.Single(table.Columns.Where(c => c.Name == "Brand")); Assert.Equal(NonDefaultCollation, nameColumn.Collation); - Assert.Null(brandColumn.Collation); + Assert.Equal(DefaultCollation, brandColumn.Collation); }); AssertSql( @@ -950,6 +1103,8 @@ await Test( }); AssertSql( + $@"ALTER TABLE `IceCream` COLLATE {NonDefaultCollation2};", + // $@"ALTER TABLE `IceCream` MODIFY COLUMN `Name` longtext COLLATE {NonDefaultCollation} NULL;", // $@"ALTER TABLE `IceCream` MODIFY COLUMN `Brand` longtext COLLATE {NonDefaultCollation2} NULL;"); @@ -1104,17 +1259,24 @@ await Test( e.Property("Name"); e.Property("Brand") .HasCharSet(NonDefaultCharSet); + + e.ComplexProperty>("ComplexProperty") + .Property("Brand") + .HasCharSet(NonDefaultCharSet); }), result => { var table = Assert.Single(result.Tables); var nameColumn = Assert.Single(table.Columns.Where(c => c.Name == "Name")); var brandColumn = Assert.Single(table.Columns.Where(c => c.Name == "Brand")); + var complexBrandColumn = Assert.Single(table.Columns.Where(c => c.Name == "ComplexProperty_Brand")); Assert.Null(nameColumn[SingleStoreAnnotationNames.CharSet]); Assert.Equal(NonDefaultCollation2, nameColumn.Collation); Assert.Equal(S2ServerVersion.Supports.DefaultCharSetUtf8Mb4? null : NonDefaultCharSet, brandColumn[SingleStoreAnnotationNames.CharSet]); Assert.NotEqual(DefaultCollation, brandColumn.Collation); + Assert.Equal(NonDefaultCharSet, complexBrandColumn[SingleStoreAnnotationNames.CharSet]); + Assert.NotEqual(DefaultCollation, complexBrandColumn.Collation); }); } @@ -1157,8 +1319,9 @@ await Test( } [ConditionalFact] - public override Task Add_column_with_collation() - => Test( + public override async Task Add_column_with_collation() + { + await Test( builder => builder.Entity("People").Property("Id"), builder => { }, builder => builder.Entity("People").Property("Name") @@ -1174,6 +1337,10 @@ public override Task Add_column_with_collation() } }); + AssertSql( + $@"ALTER TABLE `People` ADD `Name` longtext CHARACTER SET {DefaultCharSet} COLLATE {NonDefaultCollation2} NULL;"); + } + [ConditionalFact] public virtual async Task Create_table_longtext_column_with_string_length_and_legacy_charset_definition_in_column_type() { @@ -1249,6 +1416,8 @@ await Test( result => { }); AssertSql( + $@"ALTER TABLE `IceCream` CHARACTER SET {DefaultCharSet};", + // $@"ALTER TABLE `IceCream` MODIFY COLUMN `Name` longtext CHARACTER SET {NonDefaultCharSet} NULL;", // $@"ALTER TABLE `IceCream` MODIFY COLUMN `Brand` longtext CHARACTER SET {NonDefaultCharSet2} NULL;"); @@ -1402,16 +1571,6 @@ public override Task Rename_table() }, withConventions: false); - public override async Task Add_required_primitve_collection_with_custom_default_value_sql_to_existing_table() - { - await Add_required_primitve_collection_with_custom_default_value_sql_to_existing_table_core("'[3, 2, 1]'"); - - AssertSql( - """ - ALTER TABLE `Customers` ADD `Numbers` varchar(127) CHARACTER SET utf8mb4 NOT NULL DEFAULT '[3, 2, 1]'; - """); - } - protected override Task Add_required_primitve_collection_with_custom_default_value_sql_to_existing_table_core(string defaultValueSql) => Test( builder => builder.Entity( @@ -1447,93 +1606,612 @@ protected override Task Add_required_primitve_collection_with_custom_default_val Assert.Single(customersTable.PrimaryKey!.Columns)); }); - public override Task Add_required_primitve_collection_with_custom_converter_and_custom_default_value_to_existing_table() - => Test( - builder => builder.Entity( - "Customer", e => - { - e.Property("Id").ValueGeneratedOnAdd(); - e.HasKey("Id"); - e.Property("Name"); - e.ToTable("Customers"); - }), - builder => builder.Entity( - "Customer", e => - { - e.Property("Id").ValueGeneratedOnAdd(); - e.HasKey("Id"); - e.Property("Name"); - e.Property>("Numbers") - .HasMaxLength(127) // <-- MySQL requires a `varchar(n)` instead of a `longtext` type for default value support - .HasConversion(new ValueConverter, string>( - convertToProviderExpression: x => x != null && x.Count > 0 ? "some numbers" : "nothing", - convertFromProviderExpression: x => x == "nothing" ? new List { } : new List { 7, 8, 9 })) - .HasDefaultValue(new List { 42 }) - .IsRequired(); - e.ToTable("Customers"); - }), - model => - { - var customersTable = Assert.Single(model.Tables.Where(t => t.Name == "Customers")); + public override async Task Create_table() + { + await base.Create_table(); + AssertSql( + """ + CREATE TABLE `People` ( + `Id` int NOT NULL, + `Name` longtext CHARACTER SET utf8mb4 NULL, + CONSTRAINT `PK_People` PRIMARY KEY (`Id`) + ) CHARACTER SET=utf8mb4; + """); + } - Assert.Collection( - customersTable.Columns, - c => Assert.Equal("Id", c.Name), - c => Assert.Equal("Name", c.Name), - c => Assert.Equal("Numbers", c.Name)); - Assert.Same( - customersTable.Columns.Single(c => c.Name == "Id"), - Assert.Single(customersTable.PrimaryKey!.Columns)); - }); + public override async Task Create_table_no_key() + { + await base.Create_table_no_key(); - public override Task Add_required_primitve_collection_with_custom_default_value_to_existing_table() - => Test( - builder => builder.Entity( - "Customer", e => - { - e.Property("Id").ValueGeneratedOnAdd(); - e.HasKey("Id"); - e.Property("Name"); - e.ToTable("Customers"); - }), - builder => builder.Entity( - "Customer", e => - { - e.Property("Id").ValueGeneratedOnAdd(); - e.HasKey("Id"); - e.Property("Name"); - e.Property>("Numbers") - .HasMaxLength(127) // <-- MySQL requires a `varchar(n)` instead of a `longtext` type for default value support - .IsRequired().HasDefaultValue(new List { 1, 2, 3 }); - e.ToTable("Customers"); - }), - model => - { - var customersTable = Assert.Single(model.Tables.Where(t => t.Name == "Customers")); + AssertSql( + """ + CREATE TABLE `Anonymous` ( + `SomeColumn` int NOT NULL + ) CHARACTER SET=utf8mb4; + """); + } - Assert.Collection( - customersTable.Columns, - c => Assert.Equal("Id", c.Name), - c => Assert.Equal("Name", c.Name), - c => Assert.Equal("Numbers", c.Name)); - Assert.Same( - customersTable.Columns.Single(c => c.Name == "Id"), - Assert.Single(customersTable.PrimaryKey!.Columns)); - }); + public override async Task Create_table_with_comments() + { + await base.Create_table_with_comments(); - // The constraint name for a primary key is always PRIMARY in MySQL. - protected override bool AssertConstraintNames - => false; + AssertSql( + """ + CREATE TABLE `People` ( + `Id` int NOT NULL, + `Name` longtext CHARACTER SET utf8mb4 NULL COMMENT 'Column comment', + CONSTRAINT `PK_People` PRIMARY KEY (`Id`) + ) CHARACTER SET=utf8mb4 COMMENT='Table comment'; + """); + } - protected virtual string DefaultCollation => ((SingleStoreTestStore)Fixture.TestStore).DatabaseCollation; + public override async Task Drop_table() + { + await base.Drop_table(); - protected override string NonDefaultCollation - => DefaultCollation == ((SingleStoreTestStore)Fixture.TestStore).ServerVersion.Value.DefaultUtf8CsCollation - ? ((SingleStoreTestStore)Fixture.TestStore).ServerVersion.Value.DefaultUtf8CiCollation - : ((SingleStoreTestStore)Fixture.TestStore).ServerVersion.Value.DefaultUtf8CsCollation; + AssertSql( + """ + DROP TABLE `People`; + """); + } - protected virtual string NonDefaultCollation2 - => "utf8_latvian_ci"; + public override async Task Add_column_with_defaultValueSql_unspecified() + { + await base.Add_column_with_defaultValueSql_unspecified(); + + AssertSql(); + } + + public override async Task Add_column_with_defaultValue_unspecified() + { + await base.Add_column_with_defaultValue_unspecified(); + + AssertSql(); + } + + public override async Task Add_column_with_computedSql_unspecified() + { + await base.Add_column_with_computedSql_unspecified(); + + AssertSql(); + } + + public override async Task Add_column_with_required() + { + await base.Add_column_with_required(); + + AssertSql( +""" +ALTER TABLE `People` ADD `Name` longtext CHARACTER SET utf8mb4 NOT NULL; +"""); + } + + public override async Task Add_column_with_ansi() + { + await base.Add_column_with_ansi(); + + AssertSql( +""" +ALTER TABLE `People` ADD `Name` longtext CHARACTER SET utf8mb4 NULL; +"""); + } + + public override async Task Add_column_with_max_length() + { + await base.Add_column_with_max_length(); + + AssertSql( +""" +ALTER TABLE `People` ADD `Name` varchar(30) CHARACTER SET utf8mb4 NULL; +"""); + } + + public override async Task Add_column_with_unbounded_max_length() + { + await base.Add_column_with_unbounded_max_length(); + + AssertSql( +""" +ALTER TABLE `People` ADD `Name` longtext CHARACTER SET utf8mb4 NULL; +"""); + } + + public override async Task Add_column_with_max_length_on_derived() + { + await base.Add_column_with_max_length_on_derived(); + + AssertSql(); + } + + public override async Task Add_column_with_fixed_length() + { + await base.Add_column_with_fixed_length(); + + AssertSql( +""" +ALTER TABLE `People` ADD `Name` char(100) CHARACTER SET utf8mb4 NULL; +"""); + } + + public override async Task Add_column_with_comment() + { + await base.Add_column_with_comment(); + + AssertSql( +""" +ALTER TABLE `People` ADD `FullName` longtext CHARACTER SET utf8mb4 NULL COMMENT 'My comment'; +"""); + } + + public override async Task Add_column_shared() + { + await base.Add_column_shared(); + + AssertSql(); + } + + public override async Task Alter_column_change_computed_recreates_indexes() + { + await base.Alter_column_change_computed_recreates_indexes(); + + AssertSql( +""" +ALTER TABLE `People` DROP INDEX `IX_People_Sum`; +""", + // +""" +ALTER TABLE `People` DROP COLUMN `Sum`; +""", + // +""" +ALTER TABLE `People` ADD `Sum` AS (`X` - `Y`) PERSISTED int; +""", + // +""" +CREATE INDEX `IX_People_Sum` ON `People` (`Sum`); +"""); + } + + public override async Task Alter_column_add_comment() + { + await base.Alter_column_add_comment(); + + AssertSql( +""" +ALTER TABLE `People` MODIFY COLUMN `Id` int NOT NULL COMMENT 'Some comment'; +"""); + } + + public override async Task Alter_column_change_comment() + { + await base.Alter_column_change_comment(); + + AssertSql( +""" +ALTER TABLE `People` MODIFY COLUMN `Id` int NOT NULL COMMENT 'Some comment2'; +"""); + } + + public override async Task Alter_column_remove_comment() + { + await base.Alter_column_remove_comment(); + + AssertSql( +""" +ALTER TABLE `People` MODIFY COLUMN `Id` int NOT NULL; +"""); + } + + public override async Task Alter_column_reset_collation() + { + await Test( + builder => builder.Entity("People").Property("Name"), + builder => builder.Entity("People").Property("Name") + .UseCollation(NonDefaultCollation), + builder => { }, + model => + { + var nameColumn = Assert.Single(Assert.Single(model.Tables).Columns); + + var expectedCollation = S2ServerVersion.Supports.Version(ServerVersion.Parse("9.0")) + ? "utf8mb4_bin" + : DefaultCollation; + + Assert.Equal(expectedCollation, nameColumn.Collation); + }); + + AssertSql( + """ + ALTER TABLE `People` MODIFY COLUMN `Name` longtext CHARACTER SET utf8mb4 NULL; + """); + } + + public override async Task Drop_column() + { + await base.Drop_column(); + + AssertSql( +""" +ALTER TABLE `People` DROP COLUMN `SomeColumn`; +"""); + } + + public override async Task Drop_column_computed_and_non_computed_with_dependency() + { + await base.Drop_column_computed_and_non_computed_with_dependency(); + + AssertSql( +""" +ALTER TABLE `People` DROP COLUMN `Y`; +""", + // + """ +ALTER TABLE `People` DROP COLUMN `X`; +"""); + } + + public override async Task Rename_column() + { + await base.Rename_column(); + + AssertSql( +""" +ALTER TABLE `People` CHANGE `SomeColumn` `SomeOtherColumn`; +"""); + } + + public override async Task Create_index() + { + await base.Create_index(); + + AssertSql( +""" +ALTER TABLE `People` MODIFY COLUMN `FirstName` varchar(255) CHARACTER SET utf8mb4 NULL; +""", + // + """ +CREATE INDEX `IX_People_FirstName` ON `People` (`FirstName`); +"""); + } + + public override async Task Drop_index() + { + await base.Drop_index(); + + AssertSql( +""" +ALTER TABLE `People` DROP INDEX `IX_People_SomeField`; +"""); + } + + public override async Task Add_primary_key_int() + { + // SingleStore can't support this migration on an existing distributed table: + // the source table starts keylessly sharded, PRIMARY/UNIQUE keys must be compatible + // with the shard key, shard keys can't be added/changed later, and AUTO_INCREMENT on + // distributed tables requires BIGINT. + var exception = await Assert.ThrowsAsync( + () => Test( + builder => builder.Entity("People").Property("SomeField"), + builder => { }, + builder => builder.Entity("People").HasKey("SomeField"), + model => + { + var table = Assert.Single(model.Tables); + var primaryKey = table.PrimaryKey; + Assert.NotNull(primaryKey); + Assert.Same(table, primaryKey!.Table); + Assert.Same(table.Columns.Single(), Assert.Single(primaryKey.Columns)); + if (AssertConstraintNames) + { + Assert.Equal("PK_People", primaryKey.Name); + } + })); + + Assert.Contains("unique keys must contain all columns of the shard key", exception.Message); + } + + public override async Task InsertDataOperation() + { + await base.InsertDataOperation(); + + AssertSql( +""" +INSERT INTO `Person` (`Id`, `Name`) +VALUES (1, 'Daenerys Targaryen'), +(2, 'John Snow'), +(3, 'Arya Stark'), +(4, 'Harry Strickland'), +(5, NULL); +"""); + } + + public override async Task DeleteDataOperation_simple_key() + { + await base.DeleteDataOperation_simple_key(); + + AssertSql( + AppConfig.ServerVersion.Supports.Returning + ? """ +DELETE FROM `Person` +WHERE `Id` = 2 +RETURNING 1; +""" + : """ +DELETE FROM `Person` +WHERE `Id` = 2; +SELECT ROW_COUNT(); +"""); + } + + public override async Task DeleteDataOperation_composite_key() + { + await base.DeleteDataOperation_composite_key(); + + AssertSql( + AppConfig.ServerVersion.Supports.Returning + ? """ +DELETE FROM `Person` +WHERE `AnotherId` = 12 AND `Id` = 2 +RETURNING 1; +""" + : """ +DELETE FROM `Person` +WHERE `AnotherId` = 12 AND `Id` = 2; +SELECT ROW_COUNT(); +"""); + } + + public override async Task UpdateDataOperation_simple_key() + { + await base.UpdateDataOperation_simple_key(); + + AssertSql( +""" +UPDATE `Person` SET `Name` = 'Another John Snow' +WHERE `Id` = 2; +SELECT ROW_COUNT(); +"""); + } + + public override async Task UpdateDataOperation_composite_key() + { + await base.UpdateDataOperation_composite_key(); + + AssertSql( +""" +UPDATE `Person` SET `Name` = 'Another John Snow' +WHERE `AnotherId` = 11 AND `Id` = 2; +SELECT ROW_COUNT(); +"""); + } + + public override async Task UpdateDataOperation_multiple_columns() + { + await base.UpdateDataOperation_multiple_columns(); + + AssertSql( +""" +UPDATE `Person` SET `Age` = 21, `Name` = 'Another John Snow' +WHERE `Id` = 2; +SELECT ROW_COUNT(); +"""); + } + + public override async Task SqlOperation() + { + await base.SqlOperation(); + + AssertSql( +""" +-- I <3 DDL +"""); + } + + public override async Task Create_table_with_complex_type_with_required_properties_on_derived_entity_in_TPH() + { + await base.Create_table_with_complex_type_with_required_properties_on_derived_entity_in_TPH(); + + AssertSql( +""" +CREATE TABLE `Contacts` ( + `Id` int NOT NULL, + `Discriminator` varchar(8) CHARACTER SET utf8mb4 NOT NULL, + `Name` longtext CHARACTER SET utf8mb4 NULL, + `Number` int NULL, + `MyComplex_Prop` longtext NULL, + `MyComplex_MyNestedComplex_Bar` datetime(6) NULL, + `MyComplex_MyNestedComplex_Foo` int NULL, + CONSTRAINT `PK_Contacts` PRIMARY KEY (`Id`) +) CHARACTER SET=utf8mb4; +"""); + } + + public override async Task Add_required_primitive_collection_to_existing_table() + { + await base.Add_required_primitive_collection_to_existing_table(); + + AssertSql( +""" +ALTER TABLE `Customers` ADD `Numbers` longtext CHARACTER SET utf8mb4 NOT NULL; +"""); + } + + public override async Task Add_required_primitive_collection_with_custom_default_value_to_existing_table() + { + await base.Add_required_primitive_collection_with_custom_default_value_to_existing_table(); + + AssertSql( +""" +ALTER TABLE `Customers` ADD `Numbers` longtext CHARACTER SET utf8mb4 NOT NULL DEFAULT '[1,2,3]'; +"""); + } + + public override async Task Add_required_primitive_collection_with_custom_converter_to_existing_table() + { + await base.Add_required_primitive_collection_with_custom_converter_to_existing_table(); + + AssertSql(); + } + + public override async Task Add_required_primitive_collection_with_custom_converter_and_custom_default_value_to_existing_table() + { + await base.Add_required_primitive_collection_with_custom_converter_and_custom_default_value_to_existing_table(); + + AssertSql( +""" +ALTER TABLE `Customers` ADD `Numbers` longtext CHARACTER SET utf8mb4 NOT NULL DEFAULT 'some numbers'; +"""); + } + + public override async Task Add_optional_primitive_collection_to_existing_table() + { + await base.Add_optional_primitive_collection_to_existing_table(); + + AssertSql( +""" +ALTER TABLE `Customers` ADD `Numbers` longtext CHARACTER SET utf8mb4 NULL; +"""); + } + + public override async Task Create_table_with_required_primitive_collection() + { + await base.Create_table_with_required_primitive_collection(); + + AssertSql( +""" +CREATE TABLE `Customers` ( + `Id` int NOT NULL, + `Name` longtext CHARACTER SET utf8mb4 NULL, + `Numbers` longtext CHARACTER SET utf8mb4 NOT NULL, + CONSTRAINT `PK_Customers` PRIMARY KEY (`Id`) +) CHARACTER SET=utf8mb4; +"""); + } + + public override async Task Create_table_with_optional_primitive_collection() + { + await base.Create_table_with_optional_primitive_collection(); + + AssertSql( +""" +CREATE TABLE `Customers` ( + `Id` int NOT NULL, + `Name` longtext CHARACTER SET utf8mb4 NULL, + `Numbers` longtext CHARACTER SET utf8mb4 NULL, + CONSTRAINT `PK_Customers` PRIMARY KEY (`Id`) +) CHARACTER SET=utf8mb4; +"""); + } + + public override async Task Add_required_primitve_collection_to_existing_table() + { + await base.Add_required_primitve_collection_to_existing_table(); + + AssertSql( +""" +ALTER TABLE `Customers` ADD `Numbers` longtext CHARACTER SET utf8mb4 NOT NULL; +"""); + } + + public override async Task Add_required_primitve_collection_with_custom_default_value_to_existing_table() + { + await base.Add_required_primitve_collection_with_custom_default_value_to_existing_table(); + + AssertSql( +""" +ALTER TABLE `Customers` ADD `Numbers` longtext CHARACTER SET utf8mb4 NOT NULL DEFAULT '[1,2,3]'; +"""); + } + + public override async Task Add_required_primitve_collection_with_custom_converter_to_existing_table() + { + await base.Add_required_primitve_collection_with_custom_converter_to_existing_table(); + + AssertSql(); + } + + public override async Task Add_required_primitve_collection_with_custom_converter_and_custom_default_value_to_existing_table() + { + await base.Add_required_primitve_collection_with_custom_converter_and_custom_default_value_to_existing_table(); + + AssertSql( +""" +ALTER TABLE `Customers` ADD `Numbers` longtext CHARACTER SET utf8mb4 NOT NULL DEFAULT 'some numbers'; +"""); + } + + #region ToJson + + public override Task Create_table_with_json_column() + => Assert.ThrowsAsync(() => base.Create_table_with_json_column()); + + public override Task Create_table_with_json_column_explicit_json_column_names() + => Assert.ThrowsAsync(() => base.Create_table_with_json_column_explicit_json_column_names()); + + public override Task Rename_table_with_json_column() + => Assert.ThrowsAsync(() => base.Rename_table_with_json_column()); + + public override Task Add_json_columns_to_existing_table() + => Assert.ThrowsAsync(() => base.Add_json_columns_to_existing_table()); + + public override Task Convert_json_entities_to_regular_owned() + => Assert.ThrowsAsync(() => base.Convert_json_entities_to_regular_owned()); + + public override Task Convert_regular_owned_entities_to_json() + => Assert.ThrowsAsync(() => base.Convert_regular_owned_entities_to_json()); + + public override Task Convert_string_column_to_a_json_column_containing_reference() + => Assert.ThrowsAsync(() => base.Convert_string_column_to_a_json_column_containing_reference()); + + public override Task Convert_string_column_to_a_json_column_containing_required_reference() + => Assert.ThrowsAsync(() => base.Convert_string_column_to_a_json_column_containing_required_reference()); + + public override Task Convert_string_column_to_a_json_column_containing_collection() + => Assert.ThrowsAsync(() => base.Convert_string_column_to_a_json_column_containing_collection()); + + public override Task Drop_json_columns_from_existing_table() + => Assert.ThrowsAsync(() => base.Drop_json_columns_from_existing_table()); + + public override Task Rename_json_column() + => Assert.ThrowsAsync(() => base.Rename_json_column()); + + #endregion ToJson + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); + + // The constraint name for a primary key is always PRIMARY in MySQL. + protected override bool AssertConstraintNames + => false; + + // SingleStore does not support the concept of schemas. + protected override bool AssertSchemaNames + => false; + + protected virtual string DefaultCollation => ((SingleStoreTestStore)Fixture.TestStore).DatabaseCollation; + + protected override string NonDefaultCollation + => DefaultCollation == ((SingleStoreTestStore)Fixture.TestStore).ServerVersion.Value.DefaultUtf8CsCollation + ? ((SingleStoreTestStore)Fixture.TestStore).ServerVersion.Value.DefaultUtf8CiCollation + : ((SingleStoreTestStore)Fixture.TestStore).ServerVersion.Value.DefaultUtf8CsCollation; + + protected virtual string NonDefaultCollation2 + { + get + { + foreach (var candidate in new[] { "utf8mb4_unicode_ci", "utf8mb4_general_ci", "utf8mb4_bin" }) + { + if (candidate != DefaultCollation && candidate != NonDefaultCollation) + { + return candidate; + } + } + + return "utf8mb4_unicode_ci"; + } + } protected virtual string DefaultCharSet => ((SingleStoreTestStore)Fixture.TestStore).DatabaseCharSet; protected virtual string NonDefaultCharSet => DefaultCharSet == "utf8"? "utf8mb4" : "utf8"; diff --git a/test/EFCore.SingleStore.FunctionalTests/ModelBuilding/SingleStoreModelBuilderGenericTest.cs b/test/EFCore.SingleStore.FunctionalTests/ModelBuilding/SingleStoreModelBuilderGenericTest.cs new file mode 100644 index 000000000..a042e0620 --- /dev/null +++ b/test/EFCore.SingleStore.FunctionalTests/ModelBuilding/SingleStoreModelBuilderGenericTest.cs @@ -0,0 +1,69 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ModelBuilding; +using Xunit; + +namespace EntityFrameworkCore.SingleStore.FunctionalTests.ModelBuilding; + +public class SingleStoreModelBuilderGenericTest : SingleStoreModelBuilderTestBase +{ + public class SingleStoreGenericNonRelationship(SingleStoreModelBuilderFixture fixture) : SingleStoreNonRelationship(fixture) + { + protected override TestModelBuilder CreateModelBuilder( + Action configure) + => new ModelBuilderTest.GenericTestModelBuilder(Fixture, configure); + } + + public class SingleStoreGenericComplexType(SingleStoreModelBuilderFixture fixture) : SingleStoreComplexType(fixture) + { + protected override TestModelBuilder CreateModelBuilder( + Action configure) + => new ModelBuilderTest.GenericTestModelBuilder(Fixture, configure); + } + + public class SingleStoreGenericInheritance(SingleStoreModelBuilderFixture fixture) : SingleStoreInheritance(fixture) + { + protected override TestModelBuilder CreateModelBuilder( + Action configure) + => new ModelBuilderTest.GenericTestModelBuilder(Fixture, configure); + } + + public class SingleStoreGenericOneToMany(SingleStoreModelBuilderFixture fixture) : SingleStoreOneToMany(fixture) + { + protected override TestModelBuilder CreateModelBuilder( + Action configure) + => new ModelBuilderTest.GenericTestModelBuilder(Fixture, configure); + } + + public class SingleStoreGenericManyToOne(SingleStoreModelBuilderFixture fixture) : SingleStoreManyToOne(fixture) + { + protected override TestModelBuilder CreateModelBuilder( + Action configure) + => new ModelBuilderTest.GenericTestModelBuilder(Fixture, configure); + } + + public class SingleStoreGenericOneToOne(SingleStoreModelBuilderFixture fixture) : SingleStoreOneToOne(fixture) + { + protected override TestModelBuilder CreateModelBuilder( + Action configure) + => new ModelBuilderTest.GenericTestModelBuilder(Fixture, configure); + } + + public class SingleStoreGenericManyToMany(SingleStoreModelBuilderFixture fixture) : SingleStoreManyToMany(fixture) + { + protected override TestModelBuilder CreateModelBuilder( + Action configure) + => new ModelBuilderTest.GenericTestModelBuilder(Fixture, configure); + } + + internal class SingleStoreGenericOwnedTypes(SingleStoreModelBuilderFixture fixture) : SingleStoreOwnedTypes(fixture) + { + // MySQL stored procedures do not support result columns. + public override void Can_use_sproc_mapping_with_owned_reference() + => Assert.Throws(() => base.Can_use_sproc_mapping_with_owned_reference()); + + protected override TestModelBuilder CreateModelBuilder( + Action configure) + => new ModelBuilderTest.GenericTestModelBuilder(Fixture, configure); + } +} diff --git a/test/EFCore.SingleStore.FunctionalTests/ModelBuilding/SingleStoreModelBuilderTestBase.cs b/test/EFCore.SingleStore.FunctionalTests/ModelBuilding/SingleStoreModelBuilderTestBase.cs new file mode 100644 index 000000000..82b439589 --- /dev/null +++ b/test/EFCore.SingleStore.FunctionalTests/ModelBuilding/SingleStoreModelBuilderTestBase.cs @@ -0,0 +1,39 @@ +using Microsoft.EntityFrameworkCore.ModelBuilding; +using Microsoft.EntityFrameworkCore.TestUtilities; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; +using Xunit; + +namespace EntityFrameworkCore.SingleStore.FunctionalTests.ModelBuilding; + +public class SingleStoreModelBuilderTestBase : RelationalModelBuilderTest +{ + public abstract class SingleStoreNonRelationship(SingleStoreModelBuilderFixture fixture) + : RelationalNonRelationshipTestBase(fixture), IClassFixture; + + public abstract class SingleStoreComplexType(SingleStoreModelBuilderFixture fixture) + : RelationalComplexTypeTestBase(fixture), IClassFixture; + + public abstract class SingleStoreInheritance(SingleStoreModelBuilderFixture fixture) + : RelationalInheritanceTestBase(fixture), IClassFixture; + + public abstract class SingleStoreOneToMany(SingleStoreModelBuilderFixture fixture) + : RelationalOneToManyTestBase(fixture), IClassFixture; + + public abstract class SingleStoreManyToOne(SingleStoreModelBuilderFixture fixture) + : RelationalManyToOneTestBase(fixture), IClassFixture; + + public abstract class SingleStoreOneToOne(SingleStoreModelBuilderFixture fixture) + : RelationalOneToOneTestBase(fixture), IClassFixture; + + public abstract class SingleStoreManyToMany(SingleStoreModelBuilderFixture fixture) + : RelationalManyToManyTestBase(fixture), IClassFixture; + + public abstract class SingleStoreOwnedTypes(SingleStoreModelBuilderFixture fixture) + : RelationalOwnedTypesTestBase(fixture), IClassFixture; + + public class SingleStoreModelBuilderFixture : RelationalModelBuilderFixture + { + public override TestHelpers TestHelpers + => SingleStoreTestHelpers.Instance; + } +} diff --git a/test/EFCore.SingleStore.FunctionalTests/MusicStoreSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/MusicStoreSingleStoreTest.cs index aa6693d4b..03df8f8f4 100644 --- a/test/EFCore.SingleStore.FunctionalTests/MusicStoreSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/MusicStoreSingleStoreTest.cs @@ -109,7 +109,7 @@ public override async Task Browse_ReturnsViewWithGenre() await base.Browse_ReturnsViewWithGenre(); } - public override void Music_store_project_to_mapped_entity() + public override async Task Music_store_project_to_mapped_entity() { // We're skipping this test when we're running tests on Managed Service due to the specifics of // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) @@ -117,7 +117,7 @@ public override void Music_store_project_to_mapped_entity() { return; } - base.Music_store_project_to_mapped_entity(); + await base.Music_store_project_to_mapped_entity(); } public override async Task RemoveFromCart_removes_items_from_cart() diff --git a/test/EFCore.SingleStore.FunctionalTests/OptimisticConcurrencySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/OptimisticConcurrencySingleStoreTest.cs index bdcaf248c..41d5cbcad 100644 --- a/test/EFCore.SingleStore.FunctionalTests/OptimisticConcurrencySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/OptimisticConcurrencySingleStoreTest.cs @@ -1,9 +1,7 @@ -using System; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.TestModels.ConcurrencyModel; using Xunit; namespace EntityFrameworkCore.SingleStore.FunctionalTests @@ -18,19 +16,6 @@ public OptimisticConcurrencySingleStoreTest(F1SingleStoreFixture fixture) protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); - protected override Task ConcurrencyTestAsync( - Action storeChange, Action clientChange, - Action resolver, Action validator) - { - return base.ConcurrencyTestAsync(c => - { - storeChange(c); - // CHECK: Is this still/really needed? - // Need to wait to make CURRENT_TIMESTAMP return different values reliably - Task.Delay(100); - }, clientChange, resolver, validator); - } - [ConditionalFact(Skip = "#588")] public override Task Updating_then_deleting_the_same_entity_results_in_DbUpdateConcurrencyException_which_can_be_resolved_with_store_values() { diff --git a/test/EFCore.SingleStore.FunctionalTests/PropertyValuesSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/PropertyValuesSingleStoreTest.cs index e8f356670..104786a04 100644 --- a/test/EFCore.SingleStore.FunctionalTests/PropertyValuesSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/PropertyValuesSingleStoreTest.cs @@ -2,6 +2,8 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.TestUtilities; using System.Collections.Generic; +using System.Threading.Tasks; +using EntityFrameworkCore.SingleStore.Tests; namespace EntityFrameworkCore.SingleStore.FunctionalTests { @@ -12,6 +14,19 @@ public PropertyValuesSingleStoreTest(PropertyValuesSingleStoreFixture fixture) { } + public override async Task Values_can_be_reloaded_from_database_for_entity_in_any_state_with_inheritance(EntityState state, + bool async) + { + // We're skipping this test when we're running tests on Managed Service due to the specifics of + // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) + if (AppConfig.ManagedService) + { + return; + } + + await base.Values_can_be_reloaded_from_database_for_entity_in_any_state_with_inheritance(state, async); + } + public class PropertyValuesSingleStoreFixture : PropertyValuesFixtureBase { protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; @@ -23,6 +38,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con modelBuilder.Entity() .Property(e => e.Id) .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); base.OnModelCreating(modelBuilder, context); } diff --git a/test/EFCore.SingleStore.FunctionalTests/ProxyGraphUpdatesSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/ProxyGraphUpdatesSingleStoreTest.cs index 8c78cd258..5148315b5 100644 --- a/test/EFCore.SingleStore.FunctionalTests/ProxyGraphUpdatesSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/ProxyGraphUpdatesSingleStoreTest.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -64,9 +65,8 @@ public ChangeTracking(ProxyGraphUpdatesWithChangeTrackingSingleStoreFixture fixt } // Needs lazy loading - public override void Save_two_entity_cycle_with_lazy_loading() - { - } + public override Task Save_two_entity_cycle_with_lazy_loading() + => Task.CompletedTask; protected override bool DoesLazyLoading => false; diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/AdHocAdvancedMappingsQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/AdHocAdvancedMappingsQuerySingleStoreTest.cs index d690d2375..e11f4f69e 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/AdHocAdvancedMappingsQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/AdHocAdvancedMappingsQuerySingleStoreTest.cs @@ -1,7 +1,13 @@ +using System; +using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; +using EntityFrameworkCore.SingleStore.Tests; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Diagnostics; +using Xunit; namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query; @@ -10,6 +16,39 @@ public class AdHocAdvancedMappingsQuerySingleStoreTest : AdHocAdvancedMappingsQu protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; + [SkippableTheory] + public override async Task Query_generates_correct_datetime2_parameter_definition(int? fractionalSeconds, string postfix) + { + if (fractionalSeconds is not (0 or 6)) + { + Skip.If(true, "SingleStore supports DATETIME precision only 0 or 6."); + } + + await base.Query_generates_correct_datetime2_parameter_definition(fractionalSeconds, postfix); + } + + [SkippableTheory] + public override async Task Query_generates_correct_datetimeoffset_parameter_definition(int? fractionalSeconds, string postfix) + { + if (fractionalSeconds is not (0 or 6)) + { + Skip.If(true, "SingleStore supports DATETIME precision only 0 or 6."); + } + + await base.Query_generates_correct_datetimeoffset_parameter_definition(fractionalSeconds, postfix); + } + + [SkippableTheory] + public override async Task Query_generates_correct_timespan_parameter_definition(int? fractionalSeconds, string postfix) + { + if (fractionalSeconds is not (0 or 6)) + { + Skip.If(true, "SingleStore supports DATETIME precision only 0 or 6."); + } + + await base.Query_generates_correct_timespan_parameter_definition(fractionalSeconds, postfix); + } + public override async Task Two_similar_complex_properties_projected_with_split_query1() { await base.Two_similar_complex_properties_projected_with_split_query1(); @@ -22,13 +61,13 @@ ORDER BY `o`.`Id` """, // """ -SELECT `t`.`Id`, `t`.`NestedId`, `t`.`OfferId`, `t`.`payment_brutto`, `t`.`payment_netto`, `t`.`Id0`, `t`.`payment_brutto0`, `t`.`payment_netto0`, `o`.`Id` +SELECT `s`.`Id`, `s`.`NestedId`, `s`.`OfferId`, `s`.`payment_brutto`, `s`.`payment_netto`, `s`.`Id0`, `s`.`payment_brutto0`, `s`.`payment_netto0`, `o`.`Id` FROM `Offers` AS `o` INNER JOIN ( SELECT `v`.`Id`, `v`.`NestedId`, `v`.`OfferId`, `v`.`payment_brutto`, `v`.`payment_netto`, `n`.`Id` AS `Id0`, `n`.`payment_brutto` AS `payment_brutto0`, `n`.`payment_netto` AS `payment_netto0` FROM `Variation` AS `v` LEFT JOIN `NestedEntity` AS `n` ON `v`.`NestedId` = `n`.`Id` -) AS `t` ON `o`.`Id` = `t`.`OfferId` +) AS `s` ON `o`.`Id` = `s`.`OfferId` ORDER BY `o`.`Id` """); } @@ -47,19 +86,19 @@ LIMIT 2 """, // """ -SELECT `t0`.`Id`, `t0`.`NestedId`, `t0`.`OfferId`, `t0`.`payment_brutto`, `t0`.`payment_netto`, `t0`.`Id0`, `t0`.`payment_brutto0`, `t0`.`payment_netto0`, `t`.`Id` +SELECT `s`.`Id`, `s`.`NestedId`, `s`.`OfferId`, `s`.`payment_brutto`, `s`.`payment_netto`, `s`.`Id0`, `s`.`payment_brutto0`, `s`.`payment_netto0`, `o0`.`Id` FROM ( SELECT `o`.`Id` FROM `Offers` AS `o` WHERE `o`.`Id` = 1 LIMIT 1 -) AS `t` +) AS `o0` INNER JOIN ( SELECT `v`.`Id`, `v`.`NestedId`, `v`.`OfferId`, `v`.`payment_brutto`, `v`.`payment_netto`, `n`.`Id` AS `Id0`, `n`.`payment_brutto` AS `payment_brutto0`, `n`.`payment_netto` AS `payment_netto0` FROM `Variation` AS `v` LEFT JOIN `NestedEntity` AS `n` ON `v`.`NestedId` = `n`.`Id` -) AS `t0` ON `t`.`Id` = `t0`.`OfferId` -ORDER BY `t`.`Id` +) AS `s` ON `o0`.`Id` = `s`.`OfferId` +ORDER BY `o0`.`Id` """); } @@ -71,7 +110,7 @@ public override async Task Projecting_one_of_two_similar_complex_types_picks_the """ @__p_0='10' -SELECT `a`.`Id`, `t`.`Info_Created0` AS `Created` +SELECT `a`.`Id`, `s`.`Info_Created0` AS `Created` FROM ( SELECT `c`.`Id`, `b`.`AId`, `b`.`Info_Created` AS `Info_Created0` FROM `Cs` AS `c` @@ -79,9 +118,179 @@ public override async Task Projecting_one_of_two_similar_complex_types_picks_the WHERE `b`.`AId` = 1 ORDER BY `c`.`Id` LIMIT @__p_0 -) AS `t` -LEFT JOIN `As` AS `a` ON `t`.`AId` = `a`.`Id` -ORDER BY `t`.`Id` +) AS `s` +LEFT JOIN `As` AS `a` ON `s`.`AId` = `a`.`Id` +ORDER BY `s`.`Id` """); } + + public override async Task Projection_failing_with_EnumToStringConverter() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using var context = contextFactory.CreateContext(); + var query = from p in context.Products + join c in context.Categories on p.CategoryId equals c.Id into grouping + from c in grouping.DefaultIfEmpty() + select new Context15684.ProductDto + { + Id = p.Id, + Name = p.Name, + CategoryName = c == null ? "Other" : c.Name, + CategoryStatus = c == null ? Context15684.CategoryStatus.Active : c.Status + }; + var result = query.ToList(); + Assert.Equal(2, result.Count); + } + + public override async Task Projecting_correlated_collection_along_with_non_mapped_property() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var result = context.Blogs.Select( + e => new + { + e.Id, + e.Title, + FirstPostName = e.Posts.Where(i => i.Name.Contains("2")).ToList() + }).ToList(); + } + + using (var context = contextFactory.CreateContext()) + { + var result = context.Blogs.Select( + e => new + { + e.Id, + e.Title, + FirstPostName = e.Posts.OrderBy(i => i.Id).FirstOrDefault().Name + }).ToList(); + } + } + + [ConditionalFact] + public override async Task Double_convert_interface_created_expression_tree() + { + // We're skipping this test when we're running tests on Managed Service due to the specifics of + // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) + if (AppConfig.ManagedService) + { + return; + } + + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using var context = contextFactory.CreateContext(); + var expression = Context17794.HasAction17794(Context17794.Actions.Accepted); + var query = context.Offers.Where(expression).Count(); + + Assert.Equal(1, query); + } + + public override async Task Casts_are_removed_from_expression_tree_when_redundant() + { + var contextFactory = await InitializeAsync( + seed: c => c.SeedAsync(), + onModelCreating: modelBuilder => + { + // We're changing the data type of the field from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column. + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var expected = context.MockEntities + .OrderBy(e => e.Id) + .Select(e => e.Id) + .First(); + + var queryBase = (IQueryable)context.MockEntities; + var query = queryBase + .Cast() + .OrderBy(x => x.Id) + .FirstOrDefault(); + + Assert.NotNull(query); + Assert.Equal(expected, query.Id); + } + + using (var context = contextFactory.CreateContext()) + { + var queryBase = (IQueryable)context.MockEntities; + var query = queryBase.Cast().Count(); + + Assert.Equal(3, query); + } + + using (var context = contextFactory.CreateContext()) + { + var queryBase = (IQueryable)context.MockEntities; + var id = context.MockEntities + .OrderBy(e => e.Id) + .Select(e => e.Id) + .First(); + + var message = Assert.Throws( + () => queryBase.Cast().FirstOrDefault(x => x.Id == id)).Message; + + Assert.Equal( + CoreStrings.TranslationFailed( + @"DbSet() .Cast() .Where(e => e.Id == __id_0)"), + message.Replace("\r", "").Replace("\n", "")); + } + } + + public override async Task Can_query_hierarchy_with_non_nullable_property_on_derived() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using var context = contextFactory.CreateContext(); + var query = context.Businesses.ToList(); + Assert.Equal(3, query.Count); + } } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/AdHocJsonQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/AdHocJsonQuerySingleStoreTest.cs new file mode 100644 index 000000000..bc679edb9 --- /dev/null +++ b/test/EFCore.SingleStore.FunctionalTests/Query/AdHocJsonQuerySingleStoreTest.cs @@ -0,0 +1,396 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.EntityFrameworkCore.Diagnostics.Internal; +using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.TestUtilities; +using SingleStoreConnector; +using EntityFrameworkCore.SingleStore.Diagnostics.Internal; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; +using Xunit; + +namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query; + +// Disabled via internal access. The EF Core 7.0 JSON support isn't currently implemented. +internal class AdHocJsonQuerySingleStoreTest : AdHocJsonQueryTestBase +{ + protected override ITestStoreFactory TestStoreFactory + => SingleStoreTestStoreFactory.Instance; + + protected override async Task Seed29219(DbContext ctx) + { + var entity1 = new MyEntity29219 + { + Id = 1, + Reference = new MyJsonEntity29219 { NonNullableScalar = 10, NullableScalar = 11 }, + Collection = + [ + new MyJsonEntity29219 { NonNullableScalar = 100, NullableScalar = 101 }, + new MyJsonEntity29219 { NonNullableScalar = 200, NullableScalar = 201 }, + new MyJsonEntity29219 { NonNullableScalar = 300, NullableScalar = null } + ] + }; + + var entity2 = new MyEntity29219 + { + Id = 2, + Reference = new MyJsonEntity29219 { NonNullableScalar = 20, NullableScalar = null }, + Collection = [new MyJsonEntity29219 { NonNullableScalar = 1001, NullableScalar = null }] + }; + + ctx.AddRange(entity1, entity2); + await ctx.SaveChangesAsync(); + + await ctx.Database.ExecuteSqlAsync( + $$""" +INSERT INTO `Entities` (`Id`, `Reference`, `Collection`) +VALUES(3, N'{ "NonNullableScalar" : 30 }', N'[{ "NonNullableScalar" : 10001 }]') +"""); + } + + protected override async Task Seed30028(DbContext ctx) + { + // complete + await ctx.Database.ExecuteSqlAsync( + $$$$""" +INSERT INTO `Entities` (`Id`, `Json`) +VALUES( +1, +N'{"RootName":"e1","Collection":[{"BranchName":"e1 c1","Nested":{"LeafName":"e1 c1 l"}},{"BranchName":"e1 c2","Nested":{"LeafName":"e1 c2 l"}}],"OptionalReference":{"BranchName":"e1 or","Nested":{"LeafName":"e1 or l"}},"RequiredReference":{"BranchName":"e1 rr","Nested":{"LeafName":"e1 rr l"}}}') +"""); + + // missing collection + await ctx.Database.ExecuteSqlAsync( + $$$$""" +INSERT INTO `Entities` (`Id`, `Json`) +VALUES( +2, +N'{"RootName":"e2","OptionalReference":{"BranchName":"e2 or","Nested":{"LeafName":"e2 or l"}},"RequiredReference":{"BranchName":"e2 rr","Nested":{"LeafName":"e2 rr l"}}}') +"""); + + // missing optional reference + await ctx.Database.ExecuteSqlAsync( + $$$$""" +INSERT INTO `Entities` (`Id`, `Json`) +VALUES( +3, +N'{"RootName":"e3","Collection":[{"BranchName":"e3 c1","Nested":{"LeafName":"e3 c1 l"}},{"BranchName":"e3 c2","Nested":{"LeafName":"e3 c2 l"}}],"RequiredReference":{"BranchName":"e3 rr","Nested":{"LeafName":"e3 rr l"}}}') +"""); + + // missing required reference + await ctx.Database.ExecuteSqlAsync( + $$$$""" +INSERT INTO `Entities` (`Id`, `Json`) +VALUES( +4, +N'{"RootName":"e4","Collection":[{"BranchName":"e4 c1","Nested":{"LeafName":"e4 c1 l"}},{"BranchName":"e4 c2","Nested":{"LeafName":"e4 c2 l"}}],"OptionalReference":{"BranchName":"e4 or","Nested":{"LeafName":"e4 or l"}}}') +"""); + } + + protected override Task Seed33046(DbContext ctx) + => ctx.Database.ExecuteSqlAsync( + $$""" +INSERT INTO `Reviews` (`Rounds`, `Id`) +VALUES(N'[{"RoundNumber":11,"SubRounds":[{"SubRoundNumber":111},{"SubRoundNumber":112}]}]', 1) +"""); + + protected override Task SeedArrayOfPrimitives(DbContext ctx) + { + var entity1 = new MyEntityArrayOfPrimitives + { + Id = 1, + Reference = new MyJsonEntityArrayOfPrimitives + { + IntArray = [1, 2, 3], + ListOfString = + [ + "Foo", + "Bar", + "Baz" + ] + }, + Collection = + [ + new MyJsonEntityArrayOfPrimitives { IntArray = [111, 112, 113], ListOfString = ["Foo11", "Bar11"] }, + new MyJsonEntityArrayOfPrimitives { IntArray = [211, 212, 213], ListOfString = ["Foo12", "Bar12"] } + ] + }; + + var entity2 = new MyEntityArrayOfPrimitives + { + Id = 2, + Reference = new MyJsonEntityArrayOfPrimitives + { + IntArray = [10, 20, 30], + ListOfString = + [ + "A", + "B", + "C" + ] + }, + Collection = + [ + new MyJsonEntityArrayOfPrimitives { IntArray = [110, 120, 130], ListOfString = ["A1", "Z1"] }, + new MyJsonEntityArrayOfPrimitives { IntArray = [210, 220, 230], ListOfString = ["A2", "Z2"] } + ] + }; + + ctx.AddRange(entity1, entity2); + return ctx.SaveChangesAsync(); + } + + protected override Task SeedJunkInJson(DbContext ctx) + => ctx.Database.ExecuteSqlAsync( + $$$$""" +INSERT INTO `Entities` (`Collection`, `CollectionWithCtor`, `Reference`, `ReferenceWithCtor`, `Id`) +VALUES( +N'[{"JunkReference":{"Something":"SomeValue" },"Name":"c11","JunkProperty1":50,"Number":11.5,"JunkCollection1":[],"JunkCollection2":[{"Foo":"junk value"}],"NestedCollection":[{"DoB":"2002-04-01T00:00:00","DummyProp":"Dummy value"},{"DoB":"2002-04-02T00:00:00","DummyReference":{"Foo":5}}],"NestedReference":{"DoB":"2002-03-01T00:00:00"}},{"Name":"c12","Number":12.5,"NestedCollection":[{"DoB":"2002-06-01T00:00:00"},{"DoB":"2002-06-02T00:00:00"}],"NestedDummy":59,"NestedReference":{"DoB":"2002-05-01T00:00:00"}}]', +N'[{"MyBool":true,"Name":"c11 ctor","JunkReference":{"Something":"SomeValue","JunkCollection":[{"Foo":"junk value"}]},"NestedCollection":[{"DoB":"2002-08-01T00:00:00"},{"DoB":"2002-08-02T00:00:00"}],"NestedReference":{"DoB":"2002-07-01T00:00:00"}},{"MyBool":false,"Name":"c12 ctor","NestedCollection":[{"DoB":"2002-10-01T00:00:00"},{"DoB":"2002-10-02T00:00:00"}],"JunkCollection":[{"Foo":"junk value"}],"NestedReference":{"DoB":"2002-09-01T00:00:00"}}]', +N'{"Name":"r1","JunkCollection":[{"Foo":"junk value"}],"JunkReference":{"Something":"SomeValue" },"Number":1.5,"NestedCollection":[{"DoB":"2000-02-01T00:00:00","JunkReference":{"Something":"SomeValue"}},{"DoB":"2000-02-02T00:00:00"}],"NestedReference":{"DoB":"2000-01-01T00:00:00"}}', +N'{"MyBool":true,"JunkCollection":[{"Foo":"junk value"}],"Name":"r1 ctor","JunkReference":{"Something":"SomeValue" },"NestedCollection":[{"DoB":"2001-02-01T00:00:00"},{"DoB":"2001-02-02T00:00:00"}],"NestedReference":{"JunkCollection":[{"Foo":"junk value"}],"DoB":"2001-01-01T00:00:00"}}', +1) +"""); + + protected override Task SeedTrickyBuffering(DbContext ctx) + => ctx.Database.ExecuteSqlAsync( + $$$""" +INSERT INTO `Entities` (`Reference`, `Id`) +VALUES( +N'{"Name": "r1", "Number": 7, "JunkReference":{"Something": "SomeValue" }, "JunkCollection": [{"Foo": "junk value"}], "NestedReference": {"DoB": "2000-01-01T00:00:00"}, "NestedCollection": [{"DoB": "2000-02-01T00:00:00", "JunkReference": {"Something": "SomeValue"}}, {"DoB": "2000-02-02T00:00:00"}]}',1) +"""); + + protected override Task SeedShadowProperties(DbContext ctx) + => ctx.Database.ExecuteSqlAsync( + $$""" +INSERT INTO `Entities` (`Collection`, `CollectionWithCtor`, `Reference`, `ReferenceWithCtor`, `Id`, `Name`) +VALUES( +N'[{"Name":"e1_c1","ShadowDouble":5.5},{"ShadowDouble":20.5,"Name":"e1_c2"}]', +N'[{"Name":"e1_c1 ctor","ShadowNullableByte":6},{"ShadowNullableByte":null,"Name":"e1_c2 ctor"}]', +N'{"Name":"e1_r", "ShadowString":"Foo"}', +N'{"ShadowInt":143,"Name":"e1_r ctor"}', +1, +N'e1') +"""); + + protected override async Task SeedNotICollection(DbContext ctx) + { + await ctx.Database.ExecuteSqlAsync( + $$""" +INSERT INTO `Entities` (`Json`, `Id`) +VALUES( +N'{"Collection":[{"Bar":11,"Foo":"c11"},{"Bar":12,"Foo":"c12"},{"Bar":13,"Foo":"c13"}]}', +1) +"""); + + await ctx.Database.ExecuteSqlAsync( + $$$""" +INSERT INTO `Entities` (`Json`, `Id`) +VALUES( +N'{"Collection":[{"Bar":21,"Foo":"c21"},{"Bar":22,"Foo":"c22"}]}', +2) +"""); + } + + #region EnumLegacyValues + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Read_enum_property_with_legacy_values(bool async) + { + var contextFactory = await InitializeAsync( + onModelCreating: BuildModelEnumLegacyValues, + onConfiguring: b => b.ConfigureWarnings(ConfigureWarnings), + seed: SeedEnumLegacyValues); + + using (var context = contextFactory.CreateContext()) + { + var query = context.Set().Select( + x => new + { + x.Reference.IntEnum, + x.Reference.ByteEnum, + x.Reference.LongEnum, + x.Reference.NullableEnum + }); + + var exception = async + ? await (Assert.ThrowsAsync(() => query.ToListAsync())) + : Assert.Throws(() => query.ToList()); + + // Conversion failed when converting the nvarchar value '...' to data type int + Assert.Equal(245, exception.Number); + } + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Read_json_entity_with_enum_properties_with_legacy_values(bool async) + { + var contextFactory = await InitializeAsync( + onModelCreating: BuildModelEnumLegacyValues, + onConfiguring: b => b.ConfigureWarnings(ConfigureWarnings), + seed: SeedEnumLegacyValues, + shouldLogCategory: c => c == DbLoggerCategory.Query.Name); + + using (var context = contextFactory.CreateContext()) + { + var query = context.Set().Select(x => x.Reference).AsNoTracking(); + + var result = async + ? await query.ToListAsync() + : query.ToList(); + + Assert.Equal(1, result.Count); + Assert.Equal(ByteEnumLegacyValues.Redmond, result[0].ByteEnum); + Assert.Equal(IntEnumLegacyValues.Foo, result[0].IntEnum); + Assert.Equal(LongEnumLegacyValues.Three, result[0].LongEnum); + Assert.Equal(ULongEnumLegacyValues.Three, result[0].ULongEnum); + Assert.Equal(IntEnumLegacyValues.Bar, result[0].NullableEnum); + } + + var testLogger = new TestLogger(); + Assert.Single( + ListLoggerFactory.Log.Where( + l => l.Message == CoreResources.LogStringEnumValueInJson(testLogger).GenerateMessage(nameof(ByteEnumLegacyValues)))); + Assert.Single( + ListLoggerFactory.Log.Where( + l => l.Message == CoreResources.LogStringEnumValueInJson(testLogger).GenerateMessage(nameof(IntEnumLegacyValues)))); + Assert.Single( + ListLoggerFactory.Log.Where( + l => l.Message == CoreResources.LogStringEnumValueInJson(testLogger).GenerateMessage(nameof(LongEnumLegacyValues)))); + Assert.Single( + ListLoggerFactory.Log.Where( + l => l.Message == CoreResources.LogStringEnumValueInJson(testLogger).GenerateMessage(nameof(ULongEnumLegacyValues)))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Read_json_entity_collection_with_enum_properties_with_legacy_values(bool async) + { + var contextFactory = await InitializeAsync( + onModelCreating: BuildModelEnumLegacyValues, + onConfiguring: b => b.ConfigureWarnings(ConfigureWarnings), + seed: SeedEnumLegacyValues, + shouldLogCategory: c => c == DbLoggerCategory.Query.Name); + + using (var context = contextFactory.CreateContext()) + { + var query = context.Set().Select(x => x.Collection).AsNoTracking(); + + var result = async + ? await query.ToListAsync() + : query.ToList(); + + Assert.Equal(1, result.Count); + Assert.Equal(2, result[0].Count); + Assert.Equal(ByteEnumLegacyValues.Bellevue, result[0][0].ByteEnum); + Assert.Equal(IntEnumLegacyValues.Foo, result[0][0].IntEnum); + Assert.Equal(LongEnumLegacyValues.One, result[0][0].LongEnum); + Assert.Equal(ULongEnumLegacyValues.One, result[0][0].ULongEnum); + Assert.Equal(IntEnumLegacyValues.Bar, result[0][0].NullableEnum); + Assert.Equal(ByteEnumLegacyValues.Seattle, result[0][1].ByteEnum); + Assert.Equal(IntEnumLegacyValues.Baz, result[0][1].IntEnum); + Assert.Equal(LongEnumLegacyValues.Two, result[0][1].LongEnum); + Assert.Equal(ULongEnumLegacyValues.Two, result[0][1].ULongEnum); + Assert.Null(result[0][1].NullableEnum); + } + + var testLogger = new TestLogger(); + Assert.Single( + ListLoggerFactory.Log.Where( + l => l.Message == CoreResources.LogStringEnumValueInJson(testLogger).GenerateMessage(nameof(ByteEnumLegacyValues)))); + Assert.Single( + ListLoggerFactory.Log.Where( + l => l.Message == CoreResources.LogStringEnumValueInJson(testLogger).GenerateMessage(nameof(IntEnumLegacyValues)))); + Assert.Single( + ListLoggerFactory.Log.Where( + l => l.Message == CoreResources.LogStringEnumValueInJson(testLogger).GenerateMessage(nameof(LongEnumLegacyValues)))); + Assert.Single( + ListLoggerFactory.Log.Where( + l => l.Message == CoreResources.LogStringEnumValueInJson(testLogger).GenerateMessage(nameof(ULongEnumLegacyValues)))); + } + + private Task SeedEnumLegacyValues(DbContext ctx) + => ctx.Database.ExecuteSqlAsync( + $$""" +INSERT INTO `Entities` (`Collection`, `Reference`, `Id`, `Name`) +VALUES( +N'[{"ByteEnum":"Bellevue","IntEnum":"Foo","LongEnum":"One","ULongEnum":"One","Name":"e1_c1","NullableEnum":"Bar"},{"ByteEnum":"Seattle","IntEnum":"Baz","LongEnum":"Two","ULongEnum":"Two","Name":"e1_c2","NullableEnum":null}]', +N'{"ByteEnum":"Redmond","IntEnum":"Foo","LongEnum":"Three","ULongEnum":"Three","Name":"e1_r","NullableEnum":"Bar"}', +1, +N'e1') +"""); + + protected virtual void BuildModelEnumLegacyValues(ModelBuilder modelBuilder) + => modelBuilder.Entity( + b => + { + b.ToTable("Entities"); + b.Property(x => x.Id).ValueGeneratedNever(); + b.OwnsOne(x => x.Reference, b => b.ToJson().HasColumnType(JsonColumnType)); + b.OwnsMany(x => x.Collection, b => b.ToJson().HasColumnType(JsonColumnType)); + }); + + private class MyEntityEnumLegacyValues + { + public int Id { get; set; } + public string Name { get; set; } + + public MyJsonEntityEnumLegacyValues Reference { get; set; } + public List Collection { get; set; } + } + + private class MyJsonEntityEnumLegacyValues + { + public string Name { get; set; } + + // ReSharper disable once UnusedAutoPropertyAccessor.Local + public IntEnumLegacyValues IntEnum { get; set; } + + // ReSharper disable once UnusedAutoPropertyAccessor.Local + public ByteEnumLegacyValues ByteEnum { get; set; } + + // ReSharper disable once UnusedAutoPropertyAccessor.Local + public LongEnumLegacyValues LongEnum { get; set; } + + // ReSharper disable once UnusedAutoPropertyAccessor.Local + public ULongEnumLegacyValues ULongEnum { get; set; } + + // ReSharper disable once UnusedAutoPropertyAccessor.Local + public IntEnumLegacyValues? NullableEnum { get; set; } + } + + private enum IntEnumLegacyValues + { + Foo = int.MinValue, + Bar, + Baz = int.MaxValue, + } + + private enum ByteEnumLegacyValues : byte + { + Seattle, + Redmond, + Bellevue = 255, + } + + private enum LongEnumLegacyValues : long + { + One = long.MinValue, + Two = 1, + Three = long.MaxValue, + } + + private enum ULongEnumLegacyValues : ulong + { + One = ulong.MinValue, + Two = 1, + Three = ulong.MaxValue, + } + + #endregion +} diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/AdHocManyToManyQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/AdHocManyToManyQuerySingleStoreTest.cs new file mode 100644 index 000000000..0cd7a5609 --- /dev/null +++ b/test/EFCore.SingleStore.FunctionalTests/Query/AdHocManyToManyQuerySingleStoreTest.cs @@ -0,0 +1,142 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.TestUtilities; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; +using EntityFrameworkCore.SingleStore.Tests; +using Microsoft.EntityFrameworkCore; +using Xunit; + +namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query; + +public class AdHocManyToManyQuerySingleStoreTest : AdHocManyToManyQueryRelationalTestBase +{ + [ConditionalFact] + public override async Task SelectMany_with_collection_selector_having_subquery() + { + // We're skipping this test when we're running tests on Managed Service due to the specifics of + // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) + if (AppConfig.ManagedService) + { + return; + } + + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.OrganisationId) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.UserId) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + var users = (from user in context.Users + from organisation in context.Organisations.Where(o => o.OrganisationUsers.Any()).DefaultIfEmpty() + select new { UserId = user.Id, OrgId = organisation.Id }).ToList(); + + Assert.Equal(2, users.Count); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override async Task Many_to_many_load_works_when_join_entity_has_custom_key(bool async) + { + // We're skipping this test when we're running tests on Managed Service due to the specifics of + // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) + if (AppConfig.ManagedService) + { + return; + } + + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.ManyM_Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.ManyN_Id) + .HasColumnType("bigint"); + }); + + int id; + using (var context = contextFactory.CreateContext()) + { + var m = new ManyM_DB(); + var n = new ManyN_DB(); + context.AddRange(m, n); + m.ManyN_DB = new List { n }; + + context.SaveChanges(); + + id = m.Id; + } + + ClearLog(); + + using (var context = contextFactory.CreateContext()) + { + var m = context.Find(id); + + if (async) + { + await context.Entry(m).Collection(x => x.ManyN_DB).LoadAsync(); + } + else + { + context.Entry(m).Collection(x => x.ManyN_DB).Load(); + } + + Assert.Equal(3, context.ChangeTracker.Entries().Count()); + Assert.Equal(1, m.ManyN_DB.Count); + Assert.Equal(1, m.ManyN_DB.Single().ManyM_DB.Count); + Assert.Equal(1, m.ManyNM_DB.Count); + Assert.Equal(1, m.ManyN_DB.Single().ManyNM_DB.Count); + + id = m.ManyN_DB.Single().Id; + } + + using (var context = contextFactory.CreateContext()) + { + var n = context.Find(id); + + if (async) + { + await context.Entry(n).Collection(x => x.ManyM_DB).LoadAsync(); + } + else + { + context.Entry(n).Collection(x => x.ManyM_DB).Load(); + } + + Assert.Equal(3, context.ChangeTracker.Entries().Count()); + Assert.Equal(1, n.ManyM_DB.Count); + Assert.Equal(1, n.ManyM_DB.Single().ManyN_DB.Count); + Assert.Equal(1, n.ManyNM_DB.Count); + Assert.Equal(1, n.ManyM_DB.Single().ManyNM_DB.Count); + } + } + + protected override ITestStoreFactory TestStoreFactory + => SingleStoreTestStoreFactory.Instance; +} diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/AdHocMiscellaneousQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/AdHocMiscellaneousQuerySingleStoreTest.cs new file mode 100644 index 000000000..e2ac47c29 --- /dev/null +++ b/test/EFCore.SingleStore.FunctionalTests/Query/AdHocMiscellaneousQuerySingleStoreTest.cs @@ -0,0 +1,923 @@ +using System; +using System.Linq; +using System.Linq.Expressions; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.TestUtilities; +using NameSpace1; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; +using EntityFrameworkCore.SingleStore.Tests; +using Xunit; + +namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query; + +public class AdHocMiscellaneousQuerySingleStoreTest : AdHocMiscellaneousQueryRelationalTestBase +{ + protected override ITestStoreFactory TestStoreFactory + => SingleStoreTestStoreFactory.Instance; + + protected override Task Seed2951(Context2951 context) + => context.Database.ExecuteSqlRawAsync( + """ + CREATE TABLE `ZeroKey` (`Id` int); + INSERT INTO `ZeroKey` VALUES (NULL) + """); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override async Task Aggregate_over_subquery_in_group_by_projection(bool async) + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using var context = contextFactory.CreateContext(); + + Expression> someFilterFromOutside = x => x.Number != "A1"; + + var query = context + .Set() + .Where(someFilterFromOutside) + .GroupBy(x => new { x.CustomerId, x.Number }) + .Select( + x => new + { + x.Key.CustomerId, + CustomerMinHourlyRate = + context.Set().Where(n => n.CustomerId == x.Key.CustomerId).Min(h => h.HourlyRate), + HourlyRate = x.Min(f => f.HourlyRate), + Count = x.Count() + }); + + var orders = async + ? await query.ToListAsync() + : query.ToList(); + + Assert.Collection( + orders.OrderBy(x => x.CustomerId), + t => + { + Assert.Equal(1, t.CustomerId); + Assert.Equal(10, t.CustomerMinHourlyRate); + Assert.Equal(11, t.HourlyRate); + Assert.Equal(1, t.Count); + }, + t => + { + Assert.Equal(2, t.CustomerId); + Assert.Equal(20, t.CustomerMinHourlyRate); + Assert.Equal(20, t.HourlyRate); + Assert.Equal(1, t.Count); + }); + } + + [SkippableTheory(Skip = "Feature 'Dependent aggregate inside subselect' is not supported by SingleStore.")] + [MemberData(nameof(IsAsyncData))] + public override async Task Aggregate_over_subquery_in_group_by_projection_2(bool async) + { + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + + var query = from t in context.Tables + group t.Id by t.Value + into tg + select new + { + A = tg.Key, B = context.Tables.Where(t => t.Value == tg.Max() * 6).Max(t => (int?)t.Id), + }; + + var orders = async + ? await query.ToListAsync() + : query.ToList(); + } + + public override async Task Average_with_cast() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + var prices = context.Prices.ToList(); + + Assert.Equal(prices.Average(e => e.Price), context.Prices.Average(e => e.Price)); + Assert.Equal(prices.Average(e => e.IntColumn), context.Prices.Average(e => e.IntColumn)); + Assert.Equal(prices.Average(e => e.NullableIntColumn), context.Prices.Average(e => e.NullableIntColumn)); + Assert.Equal(prices.Average(e => e.LongColumn), context.Prices.Average(e => e.LongColumn)); + Assert.Equal(prices.Average(e => e.NullableLongColumn), context.Prices.Average(e => e.NullableLongColumn)); + Assert.Equal(prices.Average(e => e.FloatColumn), context.Prices.Average(e => e.FloatColumn)); + Assert.Equal(prices.Average(e => e.NullableFloatColumn), context.Prices.Average(e => e.NullableFloatColumn)); + Assert.Equal(prices.Average(e => e.DoubleColumn), context.Prices.Average(e => e.DoubleColumn)); + Assert.Equal(prices.Average(e => e.NullableDoubleColumn), context.Prices.Average(e => e.NullableDoubleColumn)); + Assert.Equal(prices.Average(e => e.DecimalColumn), context.Prices.Average(e => e.DecimalColumn)); + Assert.Equal(prices.Average(e => e.NullableDecimalColumn), context.Prices.Average(e => e.NullableDecimalColumn)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override async Task Bool_discriminator_column_works(bool async) + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + + var query = context.Authors.Include(e => e.Blog); + + var authors = async + ? await query.ToListAsync() + : query.ToList(); + + Assert.Equal(2, authors.Count); + } + + [ConditionalFact] + public override async Task Conditional_expression_with_conditions_does_not_collapse_if_nullable_bool() + { + // We're skipping this test when we're running tests on Managed Service due to the specifics of + // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) + if (AppConfig.ManagedService) + { + return; + } + + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + var query = context.Carts.Select( + t => new { Processing = t.Configuration != null ? !t.Configuration.Processed : (bool?)null }).ToList(); + + Assert.Single(query.Where(t => t.Processing == null)); + Assert.Single(query.Where(t => t.Processing == true)); + Assert.Single(query.Where(t => t.Processing == false)); + } + + [ConditionalFact] + public override async Task Discriminator_type_is_handled_correctly() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var ctx = contextFactory.CreateContext()) + { + var query = ctx.Products.OfType().ToList(); + + Assert.Single(query); + } + + using (var ctx = contextFactory.CreateContext()) + { + var query = ctx.Products.Where(p => p is Context7359.SpecialProduct).ToList(); + + Assert.Single(query); + } + } + + [ConditionalFact] + public override async Task Enum_has_flag_applies_explicit_cast_for_constant() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var query = context.Entities.Where(e => e.Permission.HasFlag(Context8538.Permission.READ_WRITE)).ToList(); + Assert.Single(query); + } + + using (var context = contextFactory.CreateContext()) + { + var query = context.Entities.Where(e => e.PermissionShort.HasFlag(Context8538.PermissionShort.READ_WRITE)).ToList(); + Assert.Single(query); + } + } + + [ConditionalFact] + public override async Task Enum_has_flag_does_not_apply_explicit_cast_for_non_constant() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var query = context.Entities.Where(e => e.Permission.HasFlag(e.Permission)).ToList(); + Assert.Equal(3, query.Count); + } + + using (var context = contextFactory.CreateContext()) + { + var query = context.Entities.Where(e => e.PermissionByte.HasFlag(e.PermissionByte)).ToList(); + Assert.Equal(3, query.Count); + } + } + + [ConditionalFact] + public override async Task First_FirstOrDefault_ix_async() + { + // We're skipping this test when we're running tests on Managed Service due to the specifics of + // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) + if (AppConfig.ManagedService) + { + return; + } + + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using (var context = contextFactory.CreateContext()) + { + var product = await context.Products.OrderBy(p => p.Id).FirstAsync(); + context.Products.Remove(product); + await context.SaveChangesAsync(); + } + + using (var context = contextFactory.CreateContext()) + { + context.Products.Add(new Context603.Product { Name = "Product 1" }); + await context.SaveChangesAsync(); + } + + using (var context = contextFactory.CreateContext()) + { + var product = await context.Products.OrderBy(p => p.Id).FirstOrDefaultAsync(); + context.Products.Remove(product); + await context.SaveChangesAsync(); + } + } + + [SkippableTheory(Skip = "Feature 'Dependent aggregate inside subselect' is not supported by SingleStore.")] + [MemberData(nameof(IsAsyncData))] + public override async Task Group_by_aggregate_in_subquery_projection_after_group_by(bool async) + { + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + + var query = from t in context.Tables + group t.Id by t.Value + into tg + select new + { + A = tg.Key, + B = tg.Sum(), + C = (from t in context.Tables + group t.Id by t.Value + into tg2 + select tg.Sum() + tg2.Sum() + ).OrderBy(e => 1).FirstOrDefault() + }; + + var orders = async + ? await query.ToListAsync() + : query.ToList(); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override async Task GroupBy_Aggregate_over_navigations_repeated(bool async) + { + // We're skipping this test when we're running tests on Managed Service due to the specifics of + // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) + if (AppConfig.ManagedService) + { + return; + } + + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + + var query = context + .Set() + .Where(x => x.OrderId != null) + .GroupBy(x => x.OrderId) + .Select( + x => new + { + HourlyRate = x.Min(f => f.Order.HourlyRate), + CustomerId = x.Min(f => f.Project.Customer.Id), + CustomerName = x.Min(f => f.Project.Customer.Name), + }); + + var timeSheets = async + ? await query.ToListAsync() + : query.ToList(); + + Assert.Equal(2, timeSheets.Count); + } + + [ConditionalFact] + public override async Task New_instances_in_projection_are_not_shared_across_results() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + var list = context.Posts.Select(p => new Context7983.PostDTO().From(p)).ToList(); + + Assert.Equal(3, list.Count); + Assert.Equal(new[] { "First", "Second", "Third" }, list.OrderBy(dto => dto.Title).Select(dto => dto.Title)); + } + + [ConditionalFact] + public override async Task Operators_combine_nullability_of_entity_shapers() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + Expression> leftKeySelector = x => x.forkey; + Expression> rightKeySelector = y => y.forkey; + + var query = context.As.GroupJoin( + context.Bs, + leftKeySelector, + rightKeySelector, + (left, rightg) => new { left, rightg }) + .SelectMany( + r => r.rightg.DefaultIfEmpty(), + (x, y) => new Context19253.JoinResult { Left = x.left, Right = y }) + .Concat( + context.Bs.GroupJoin( + context.As, + rightKeySelector, + leftKeySelector, + (right, leftg) => new { leftg, right }) + .SelectMany( + l => l.leftg.DefaultIfEmpty(), + (x, y) => new Context19253.JoinResult { Left = y, Right = x.right }) + .Where(z => z.Left.Equals(null))) + .ToList(); + + Assert.Equal(3, query.Count); + } + + using (var context = contextFactory.CreateContext()) + { + Expression> leftKeySelector = x => x.forkey; + Expression> rightKeySelector = y => y.forkey; + + var query = context.As.GroupJoin( + context.Bs, + leftKeySelector, + rightKeySelector, + (left, rightg) => new { left, rightg }) + .SelectMany( + r => r.rightg.DefaultIfEmpty(), + (x, y) => new Context19253.JoinResult { Left = x.left, Right = y }) + .Union( + context.Bs.GroupJoin( + context.As, + rightKeySelector, + leftKeySelector, + (right, leftg) => new { leftg, right }) + .SelectMany( + l => l.leftg.DefaultIfEmpty(), + (x, y) => new Context19253.JoinResult { Left = y, Right = x.right }) + .Where(z => z.Left.Equals(null))) + .ToList(); + + Assert.Equal(3, query.Count); + } + + using (var context = contextFactory.CreateContext()) + { + Expression> leftKeySelector = x => x.forkey; + Expression> rightKeySelector = y => y.forkey; + + var query = context.As.GroupJoin( + context.Bs, + leftKeySelector, + rightKeySelector, + (left, rightg) => new { left, rightg }) + .SelectMany( + r => r.rightg.DefaultIfEmpty(), + (x, y) => new Context19253.JoinResult { Left = x.left, Right = y }) + .Except( + context.Bs.GroupJoin( + context.As, + rightKeySelector, + leftKeySelector, + (right, leftg) => new { leftg, right }) + .SelectMany( + l => l.leftg.DefaultIfEmpty(), + (x, y) => new Context19253.JoinResult { Left = y, Right = x.right })) + .ToList(); + + Assert.Single(query); + } + + using (var context = contextFactory.CreateContext()) + { + Expression> leftKeySelector = x => x.forkey; + Expression> rightKeySelector = y => y.forkey; + + var query = context.As.GroupJoin( + context.Bs, + leftKeySelector, + rightKeySelector, + (left, rightg) => new { left, rightg }) + .SelectMany( + r => r.rightg.DefaultIfEmpty(), + (x, y) => new Context19253.JoinResult { Left = x.left, Right = y }) + .Intersect( + context.Bs.GroupJoin( + context.As, + rightKeySelector, + leftKeySelector, + (right, leftg) => new { leftg, right }) + .SelectMany( + l => l.leftg.DefaultIfEmpty(), + (x, y) => new Context19253.JoinResult { Left = y, Right = x.right })) + .ToList(); + + Assert.Single(query); + } + } + + [ConditionalFact] + public override async Task Parameterless_ctor_on_inner_DTO_gets_called_for_every_row() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + var results = context.Entities.Select( + x => + new Context12274.OuterDTO + { + Id = x.Id, + Name = x.Name, + Inner = new Context12274.InnerDTO() + }).ToList(); + Assert.Equal(4, results.Count); + Assert.False(ReferenceEquals(results[0].Inner, results[1].Inner)); + Assert.False(ReferenceEquals(results[1].Inner, results[2].Inner)); + Assert.False(ReferenceEquals(results[2].Inner, results[3].Inner)); + } + + [ConditionalFact] + public override async Task QueryBuffer_requirement_is_computed_when_querying_base_type_while_derived_type_has_shadow_prop() + { + // We're skipping this test when we're running tests on Managed Service due to the specifics of + // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) + if (AppConfig.ManagedService) + { + return; + } + + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + var query = context.Bases.ToList(); + + var derived1 = Assert.Single(query); + Assert.Equal(typeof(Context11104.Derived1), derived1.GetType()); + } + + [ConditionalFact] + public override async Task Repeated_parameters_in_generated_query_sql() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + var k = 1; + var a = context.Autos.Where(e => e.Id == k).First(); + var b = context.Autos.Where(e => e.Id == k + 1).First(); + + var equalQuery = (from d in context.EqualAutos + where (d.Auto == a && d.AnotherAuto == b) + || (d.Auto == b && d.AnotherAuto == a) + select d).ToList(); + + Assert.Single(equalQuery); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override async Task SelectMany_where_Select(bool async) + { + // We're skipping this test when we're running tests on Managed Service due to the specifics of + // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) + if (AppConfig.ManagedService) + { + return; + } + + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + + var query = context.Parents + .SelectMany( + p => p.Children + .Where(c => c.SomeNullableDateTime == null) + .OrderBy(c => c.SomeInteger) + .Take(1)) + .Where(c => c.SomeOtherNullableDateTime != null) + .Select(c => c.SomeNullableDateTime); + + var result = async + ? await query.ToListAsync() + : query.ToList(); + + Assert.Single(result); + } + + [ConditionalFact] + public override async Task Shadow_property_with_inheritance() + { + // We're skipping this test when we're running tests on Managed Service due to the specifics of + // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) + if (AppConfig.ManagedService) + { + return; + } + + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + // can_query_base_type_when_derived_types_contain_shadow_properties + var query = context.Contacts.ToList(); + + Assert.Equal(4, query.Count); + Assert.Equal(2, query.OfType().Count()); + Assert.Single(query.OfType()); + } + + using (var context = contextFactory.CreateContext()) + { + // can_include_dependent_to_principal_navigation_of_derived_type_with_shadow_fk + var query = context.Contacts.OfType().Include(e => e.ServiceOperator) + .ToList(); + + Assert.Single(query); + Assert.NotNull(query[0].ServiceOperator); + } + + using (var context = contextFactory.CreateContext()) + { + // can_project_shadow_property_using_ef_property + var query = context.Contacts.OfType().Select( + c => new { c, Prop = EF.Property(c, "ServiceOperatorId") }).ToList(); + + Assert.Single(query); + Assert.Equal(1, query[0].Prop); + } + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override async Task Subquery_first_member_compared_to_null(bool async) + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + + var query = context.Parents + .Where( + p => p.Children.Any(c => c.SomeNullableDateTime == null) + && p.Children.Where(c => c.SomeNullableDateTime == null) + .OrderBy(c => c.SomeInteger) + .First().SomeOtherNullableDateTime + != null) + .Select( + p => p.Children.Where(c => c.SomeNullableDateTime == null) + .OrderBy(c => c.SomeInteger) + .First().SomeOtherNullableDateTime); + + var result = async + ? await query.ToListAsync() + : query.ToList(); + + Assert.Single(result); + } + + [ConditionalFact] + public override async Task Union_and_insert_works_correctly_together() + { + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var id1 = 1; + var id2 = 2; + + var ids1 = context.Set() + .Where(x => x.Id == id1) + .Select(x => x.Id); + + var ids2 = context.Set() + .Where(x => x.Id == id2) + .Select(x => x.Id); + + var results = ids1.Union(ids2).ToList(); + + context.AddRange( + new Context12549.Table1(), + new Context12549.Table2(), + new Context12549.Table1(), + new Context12549.Table2()); + + await context.SaveChangesAsync(); + } + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override async Task Unwrap_convert_node_over_projection_when_translating_contains_over_subquery(bool async) + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + + var currentUserId = 1; + + var currentUserGroupIds = context.Memberships + .Where(m => m.UserId == currentUserId) + .Select(m => m.GroupId); + + var hasMembership = context.Memberships + .Where(m => currentUserGroupIds.Contains(m.GroupId)) + .Select(m => m.User); + + var query = context.Users + .Select(u => new { HasAccess = hasMembership.Contains(u) }); + + var users = async + ? await query.ToListAsync() + : query.ToList(); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override async Task Unwrap_convert_node_over_projection_when_translating_contains_over_subquery_2(bool async) + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + + var currentUserId = 1; + + var currentUserGroupIds = context.Memberships + .Where(m => m.UserId == currentUserId) + .Select(m => m.Group); + + var hasMembership = context.Memberships + .Where(m => currentUserGroupIds.Contains(m.Group)) + .Select(m => m.User); + + var query = context.Users + .Select(u => new { HasAccess = hasMembership.Contains(u) }); + + var users = async + ? await query.ToListAsync() + : query.ToList(); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override async Task Unwrap_convert_node_over_projection_when_translating_contains_over_subquery_3(bool async) + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + + var currentUserId = 1; + + var currentUserGroupIds = context.Memberships + .Where(m => m.UserId == currentUserId) + .Select(m => m.GroupId); + + var hasMembership = context.Memberships + .Where(m => currentUserGroupIds.Contains(m.GroupId)) + .Select(m => m.User); + + var query = context.Users + .Select(u => new { HasAccess = hasMembership.Any(e => e == u) }); + + var users = async + ? await query.ToListAsync() + : query.ToList(); + } + + public override async Task Multiple_different_entity_type_from_different_namespaces(bool async) + { + // The only change is the FromSqlRaw SQL string: + // Original: SELECT cast(null as int) AS MyValue + // Changed: SELECT cast(null as signed) AS MyValue + // The other comments are part of the base implementation. + + var contextFactory = await InitializeAsync(); + using var context = contextFactory.CreateContext(); + //var good1 = context.Set().FromSqlRaw(@"SELECT 1 AS MyValue").ToList(); // OK + //var good2 = context.Set().FromSqlRaw(@"SELECT 1 AS MyValue").ToList(); // OK + var bad = context.Set().FromSqlRaw(@"SELECT cast(null as signed) AS MyValue").ToList(); // Exception + } +} diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/AdHocNavigationsQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/AdHocNavigationsQuerySingleStoreTest.cs new file mode 100644 index 000000000..de978340a --- /dev/null +++ b/test/EFCore.SingleStore.FunctionalTests/Query/AdHocNavigationsQuerySingleStoreTest.cs @@ -0,0 +1,871 @@ +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using System.Linq; +using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.TestUtilities; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.EntityFrameworkCore.Diagnostics.Internal; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Xunit; + +namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query; + +public class AdHocNavigationsQuerySingleStoreTest : AdHocNavigationsQueryRelationalTestBase +{ + [ConditionalFact] + public override async Task ThenInclude_with_interface_navigations() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var results = context.Parents + .Include(p => p.ChildCollection) + .ThenInclude(c => c.SelfReferenceCollection) + .ToList(); + + Assert.Single(results); + Assert.Equal(1, results[0].ChildCollection.Count); + Assert.Equal(2, results[0].ChildCollection.Single().SelfReferenceCollection.Count); + } + + using (var context = contextFactory.CreateContext()) + { + var results = context.Children + .Select( + c => new { c.SelfReferenceBackNavigation, c.SelfReferenceBackNavigation.ParentBackNavigation }) + .ToList(); + + Assert.Equal(3, results.Count); + Assert.Equal(2, results.Count(c => c.SelfReferenceBackNavigation != null)); + Assert.Equal(2, results.Count(c => c.ParentBackNavigation != null)); + } + + using (var context = contextFactory.CreateContext()) + { + var results = context.Children + .Select( + c => new + { + SelfReferenceBackNavigation + = EF.Property(c, "SelfReferenceBackNavigation"), + ParentBackNavigationB + = EF.Property( + EF.Property(c, "SelfReferenceBackNavigation"), + "ParentBackNavigation") + }) + .ToList(); + + Assert.Equal(3, results.Count); + Assert.Equal(2, results.Count(c => c.SelfReferenceBackNavigation != null)); + Assert.Equal(2, results.Count(c => c.ParentBackNavigationB != null)); + } + + using (var context = contextFactory.CreateContext()) + { + var results = context.Children + .Include(c => c.SelfReferenceBackNavigation) + .ThenInclude(c => c.ParentBackNavigation) + .ToList(); + + Assert.Equal(3, results.Count); + Assert.Equal(2, results.Count(c => c.SelfReferenceBackNavigation != null)); + Assert.Equal(1, results.Count(c => c.ParentBackNavigation != null)); + } + } + + [ConditionalFact] + public override async Task Customer_collections_materialize_properly() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using var ctx = contextFactory.CreateContext(); + + var query1 = ctx.Customers.Select(c => c.Orders1); + var result1 = query1.ToList(); + + Assert.Equal(2, result1.Count); + Assert.IsType>(result1[0]); + Assert.Equal(2, result1[0].Count); + Assert.Equal(2, result1[1].Count); + + var query2 = ctx.Customers.Select(c => c.Orders2); + var result2 = query2.ToList(); + + Assert.Equal(2, result2.Count); + Assert.IsType>(result2[0]); + Assert.Equal(2, result2[0].Count); + Assert.Equal(2, result2[1].Count); + + var query3 = ctx.Customers.Select(c => c.Orders3); + var result3 = query3.ToList(); + + Assert.Equal(2, result3.Count); + Assert.IsType(result3[0]); + Assert.Equal(2, result3[0].Count); + Assert.Equal(2, result3[1].Count); + + var query4 = ctx.Customers.Select(c => c.Orders4); + + Assert.Equal( + CoreStrings.NavigationCannotCreateType( + "Orders4", typeof(Context3758.Customer).Name, + typeof(Context3758.MyInvalidCollection).ShortDisplayName()), + Assert.Throws(() => query4.ToList()).Message); + } + + [ConditionalFact] + public override async Task Reference_include_on_derived_type_with_sibling_works() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var query = context.Proposals.OfType().Include(l => l.LeaveType).ToList(); + + Assert.Single(query); + } + } + + [ConditionalFact] + public override async Task Include_collection_optional_reference_collection() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var result = await context.People.OfType() + .Include(m => m.Students) + .ThenInclude(m => m.Family) + .ThenInclude(m => m.Members) + .ToListAsync(); + + Assert.Equal(2, result.Count); + Assert.True(result.All(r => r.Students.Count > 0)); + } + + using (var context = contextFactory.CreateContext()) + { + var result = await context.Set() + .Include(m => m.Family.Members) + .Include(m => m.Students) + .ToListAsync(); + + Assert.Equal(2, result.Count); + Assert.True(result.All(r => r.Students.Count > 0)); + Assert.Null(result.Single(t => t.Name == "Ms. Frizzle").Family); + Assert.NotNull(result.Single(t => t.Name == "Mr. Garrison").Family); + } + } + + [ConditionalFact] + public override async Task Include_with_order_by_on_interface_key() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using (var context = contextFactory.CreateContext()) + { + var query = context.Parents.Include(p => p.Children).OrderBy(p => p.Id).ToList(); + } + + using (var context = contextFactory.CreateContext()) + { + var query = context.Parents.OrderBy(p => p.Id).Select(p => p.Children.ToList()).ToList(); + } + } + + [ConditionalTheory] + public override async Task Select_enumerable_navigation_backed_by_collection(bool async, bool split) + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + var query = context.Set().Select(appEntity => appEntity.OtherEntities); + + if (split) + { + query = query.AsSplitQuery(); + } + + if (async) + { + await query.ToListAsync(); + } + else + { + query.ToList(); + } + } + + [ConditionalFact] + public override async Task Collection_without_setter_materialized_correctly() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + var query1 = context.Blogs + .Select( + b => new + { + Collection1 = b.Posts1, + Collection2 = b.Posts2, + Collection3 = b.Posts3 + }).ToList(); + + var query2 = context.Blogs + .Select( + b => new + { + Collection1 = b.Posts1.OrderBy(p => p.Id).First().Comments.Count, + Collection2 = b.Posts2.OrderBy(p => p.Id).First().Comments.Count, + Collection3 = b.Posts3.OrderBy(p => p.Id).First().Comments.Count + }).ToList(); + + Assert.Throws( + () => context.Blogs + .Select( + b => new + { + Collection1 = b.Posts1.OrderBy(p => p.Id), + Collection2 = b.Posts2.OrderBy(p => p.Id), + Collection3 = b.Posts3.OrderBy(p => p.Id) + }).ToList()); + } + + [ConditionalFact] + public override async Task Include_collection_works_when_defined_on_intermediate_type() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var query = context.Schools.Include(s => ((Context11944.ElementarySchool)s).Students); + var result = query.ToList(); + + Assert.Equal(2, result.Count); + Assert.Equal(2, result.OfType().Single().Students.Count); + } + + using (var context = contextFactory.CreateContext()) + { + var query = context.Schools.Select(s => ((Context11944.ElementarySchool)s).Students.Where(ss => true).ToList()); + var result = query.ToList(); + + Assert.Equal(2, result.Count); + Assert.Contains(result, r => r.Count() == 2); + } + } + + [ConditionalFact] + public override async Task Let_multiple_references_with_reference_to_outer() + { + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using (var context = contextFactory.CreateContext()) + { + var users = (from a in context.Activities + let cs = context.CompetitionSeasons.First(s => s.StartDate <= a.DateTime && a.DateTime < s.EndDate) + select new { cs.Id, Points = a.ActivityType.Points.Where(p => p.CompetitionSeason == cs) }).ToList(); + } + + using (var context = contextFactory.CreateContext()) + { + var users = context.Activities + .Select( + a => new + { + Activity = a, + CompetitionSeason = context.CompetitionSeasons + .First(s => s.StartDate <= a.DateTime && a.DateTime < s.EndDate) + }) + .Select( + a => new + { + a.Activity, + CompetitionSeasonId = a.CompetitionSeason.Id, + Points = a.Activity.Points + ?? a.Activity.ActivityType.Points + .Where(p => p.CompetitionSeason == a.CompetitionSeason) + .Select(p => p.Points).SingleOrDefault() + }).ToList(); + } + } + + [ConditionalFact] + public override async Task Include_collection_with_OfType_base() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var query = context.Employees + .Include(i => i.Devices) + .OfType() + .ToList(); + + Assert.Single(query); + + var employee = (Context12582.Employee)query[0]; + Assert.Equal(2, employee.Devices.Count); + } + + using (var context = contextFactory.CreateContext()) + { + var query = context.Employees + .Select(e => e.Devices.Where(d => d.Device != "foo").Cast()) + .ToList(); + + Assert.Single(query); + var result = query[0]; + Assert.Equal(2, result.Count()); + } + } + + [ConditionalFact] + public override async Task Correlated_collection_correctly_associates_entities_with_byte_array_keys() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + var query = from blog in context.Blogs + select new + { + blog.Name, + Comments = blog.Comments.Select( + u => new { u.Id }).ToArray() + }; + var result = query.ToList(); + Assert.Single(result[0].Comments); + } + + [ConditionalFact] + public override async Task Cycles_in_auto_include() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using (var context = contextFactory.CreateContext()) + { + var principals = context.Set().ToList(); + Assert.Single(principals); + Assert.NotNull(principals[0].Dependent); + Assert.NotNull(principals[0].Dependent.Principal); + + var dependents = context.Set().ToList(); + Assert.Single(dependents); + Assert.NotNull(dependents[0].Principal); + Assert.NotNull(dependents[0].Principal.Dependent); + } + + using (var context = contextFactory.CreateContext()) + { + var principals = context.Set().ToList(); + Assert.Single(principals); + Assert.NotNull(principals[0].Dependents); + Assert.True(principals[0].Dependents.All(e => e.Principal != null)); + + var dependents = context.Set().ToList(); + Assert.Equal(2, dependents.Count); + Assert.True(dependents.All(e => e.Principal != null)); + Assert.True(dependents.All(e => e.Principal.Dependents != null)); + Assert.True(dependents.All(e => e.Principal.Dependents.All(i => i.Principal != null))); + } + + using (var context = contextFactory.CreateContext()) + { + Assert.Equal( + CoreStrings.AutoIncludeNavigationCycle("'PrincipalManyToMany.Dependents', 'DependentManyToMany.Principals'"), + Assert.Throws(() => context.Set().ToList()).Message); + + Assert.Equal( + CoreStrings.AutoIncludeNavigationCycle("'DependentManyToMany.Principals', 'PrincipalManyToMany.Dependents'"), + Assert.Throws(() => context.Set().ToList()).Message); + + context.Set().IgnoreAutoIncludes().ToList(); + context.Set().IgnoreAutoIncludes().ToList(); + } + + using (var context = contextFactory.CreateContext()) + { + Assert.Equal( + CoreStrings.AutoIncludeNavigationCycle("'CycleA.Bs', 'CycleB.C', 'CycleC.As'"), + Assert.Throws(() => context.Set().ToList()).Message); + + Assert.Equal( + CoreStrings.AutoIncludeNavigationCycle("'CycleB.C', 'CycleC.As', 'CycleA.Bs'"), + Assert.Throws(() => context.Set().ToList()).Message); + + Assert.Equal( + CoreStrings.AutoIncludeNavigationCycle("'CycleC.As', 'CycleA.Bs', 'CycleB.C'"), + Assert.Throws(() => context.Set().ToList()).Message); + + context.Set().IgnoreAutoIncludes().ToList(); + context.Set().IgnoreAutoIncludes().ToList(); + context.Set().IgnoreAutoIncludes().ToList(); + } + } + + [ConditionalFact] + public override async Task Can_ignore_invalid_include_path_error() + { + var contextFactory = await InitializeAsync( + onConfiguring: o => o.ConfigureWarnings(x => x.Ignore(CoreEventId.InvalidIncludePathError)), + onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using var context = contextFactory.CreateContext(); + var result = context.Set().Include("SubB").ToList(); + } + + [ConditionalFact] + public override async Task SelectMany_and_collection_in_projection_in_FirstOrDefault() + { + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // Nothing to override - uses Guid IDs + }); + + using var context = contextFactory.CreateContext(); + var referenceId = "a"; + var customerId = new Guid("1115c816-6c4c-4016-94df-d8b60a22ffa1"); + var query = context.Orders + .Where(o => o.ExternalReferenceId == referenceId && o.CustomerId == customerId) + .Select( + o => new + { + IdentityDocuments = o.IdentityDocuments.Select( + id => new + { + Images = o.IdentityDocuments + .SelectMany(id => id.Images) + .Select(i => new { i.Image }), + }) + }).SingleOrDefault(); + } + + [ConditionalFact] + public override async Task Using_explicit_interface_implementation_as_navigation_works() + { + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + Expression> projection = + b => new Context21768.BookViewModel + { + FirstPage = b.FrontCover.Illustrations.FirstOrDefault( + i => i.State >= Context21768.IllustrationState.Approved) + != null + ? new Context21768.PageViewModel + { + Uri = b.FrontCover.Illustrations + .FirstOrDefault(i => i.State >= Context21768.IllustrationState.Approved).Uri + } + : null, + }; + + var result = context.Books.Where(b => b.Id == 1).Select(projection).SingleOrDefault(); + } + + [ConditionalFact] + public override async Task Walking_back_include_tree_is_not_allowed_1() + { + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var query = context.Set() + .Include(p => p.ManyDependents) + .ThenInclude(m => m.Principal.SingleDependent); + + Assert.Equal( + CoreStrings.WarningAsErrorTemplate( + CoreEventId.NavigationBaseIncludeIgnored.ToString(), + CoreResources.LogNavigationBaseIncludeIgnored(new TestLogger()) + .GenerateMessage("ManyDependent.Principal"), + "CoreEventId.NavigationBaseIncludeIgnored"), + Assert.Throws( + () => query.ToList()).Message); + } + } + + [ConditionalFact] + public override async Task Walking_back_include_tree_is_not_allowed_2() + { + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var query = context.Set().Include(p => p.SingleDependent.Principal.ManyDependents); + + Assert.Equal( + CoreStrings.WarningAsErrorTemplate( + CoreEventId.NavigationBaseIncludeIgnored.ToString(), + CoreResources.LogNavigationBaseIncludeIgnored(new TestLogger()) + .GenerateMessage("SingleDependent.Principal"), + "CoreEventId.NavigationBaseIncludeIgnored"), + Assert.Throws( + () => query.ToList()).Message); + } + } + + [ConditionalFact] + public override async Task Walking_back_include_tree_is_not_allowed_3() + { + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + // This does not warn because after round-tripping from one-to-many from dependent side, the number of dependents could be larger. + var query = context.Set() + .Include(p => p.Principal.ManyDependents) + .ThenInclude(m => m.SingleDependent) + .ToList(); + } + } + + [ConditionalFact] + public override async Task Walking_back_include_tree_is_not_allowed_4() + { + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var query = context.Set().Include(p => p.ManyDependent.SingleDependent.Principal); + + Assert.Equal( + CoreStrings.WarningAsErrorTemplate( + CoreEventId.NavigationBaseIncludeIgnored.ToString(), + CoreResources.LogNavigationBaseIncludeIgnored(new TestLogger()) + .GenerateMessage("ManyDependent.SingleDependent"), + "CoreEventId.NavigationBaseIncludeIgnored"), + Assert.Throws( + () => query.ToList()).Message); + } + } + + [ConditionalFact] + public override async Task Projection_with_multiple_includes_and_subquery_with_set_operation() + { + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using var context = contextFactory.CreateContext(); + var id = 1; + var person = await context.Persons + .Include(p => p.Images) + .Include(p => p.Actor) + .ThenInclude(a => a.Movies) + .ThenInclude(p => p.Movie) + .Include(p => p.Director) + .ThenInclude(a => a.Movies) + .ThenInclude(p => p.Movie) + .Select( + x => new + { + x.Id, + x.Name, + x.Surname, + x.Birthday, + x.Hometown, + x.Bio, + x.AvatarUrl, + Images = x.Images + .Select( + i => new + { + i.Id, + i.ImageUrl, + i.Height, + i.Width + }).ToList(), + KnownByFilms = x.Actor.Movies + .Select(m => m.Movie) + .Union( + x.Director.Movies + .Select(m => m.Movie)) + .Select( + m => new + { + m.Id, + m.Name, + m.PosterUrl, + m.Rating + }).ToList() + }) + .FirstOrDefaultAsync(x => x.Id == id); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override async Task Count_member_over_IReadOnlyCollection_works(bool async) + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.AuthorId) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.BookId) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + + var query = context.Authors + .Select(a => new { BooksCount = a.Books.Count }); + + var authors = async + ? await query.ToListAsync() + : query.ToList(); + + Assert.Equal(3, Assert.Single(authors).BooksCount); + } + + protected override ITestStoreFactory TestStoreFactory + => SingleStoreTestStoreFactory.Instance; +} diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/AdHocQueryFiltersQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/AdHocQueryFiltersQuerySingleStoreTest.cs new file mode 100644 index 000000000..85814d205 --- /dev/null +++ b/test/EFCore.SingleStore.FunctionalTests/Query/AdHocQueryFiltersQuerySingleStoreTest.cs @@ -0,0 +1,348 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.TestUtilities; +using SingleStoreConnector; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; +using EntityFrameworkCore.SingleStore.Tests; +using Xunit; + +namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query; + +public class AdHocQueryFiltersQuerySingleStoreTest : AdHocQueryFiltersQueryRelationalTestBase +{ + [ConditionalFact] + public override async Task Query_filter_with_contains_evaluates_correctly() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + var result = context.Entities.ToList(); + Assert.Single(result); + } + + [ConditionalFact] + public override async Task MultiContext_query_filter_test() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + Assert.Empty(context.Blogs.ToList()); + + context.Tenant = 1; + Assert.Single(context.Blogs.ToList()); + + context.Tenant = 2; + Assert.Equal(2, context.Blogs.Count()); + } + } + + [ConditionalFact] + public override async Task Query_filter_with_pk_fk_optimization() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + context.Entities.Select( + s => + new Context13517.EntityDto13517 + { + Id = s.Id, + RefEntity = s.RefEntity == null + ? null + : new Context13517.RefEntityDto13517 { Id = s.RefEntity.Id, Public = s.RefEntity.Public }, + RefEntityId = s.RefEntityId + }).Single(p => p.Id == 1); + } + + [ConditionalFact] + public override async Task Self_reference_in_query_filter_works() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var query = context.EntitiesWithQueryFilterSelfReference.Where(e => e.Name != "Foo"); + var result = query.ToList(); + } + + using (var context = contextFactory.CreateContext()) + { + var query = context.EntitiesReferencingEntityWithQueryFilterSelfReference.Where(e => e.Name != "Foo"); + var result = query.ToList(); + } + } + + [ConditionalFact] + public override async Task Invoke_inside_query_filter_gets_correctly_evaluated_during_translation() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + context.TenantId = 1; + + var query1 = context.Entities.ToList(); + Assert.True(query1.All(x => x.TenantId == 1)); + + context.TenantId = 2; + var query2 = context.Entities.ToList(); + Assert.True(query2.All(x => x.TenantId == 2)); + } + + [ConditionalFact] + public override async Task GroupJoin_SelectMany_gets_flattened() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using (var context = contextFactory.CreateContext()) + { + var query = context.CustomerFilters.ToList(); + } + + using (var context = contextFactory.CreateContext()) + { + var query = context.Set() + .OrderBy(e => e.Id) + .ThenBy(e => e.CustomerMembershipId) + .ToList(); + + Assert.Collection( + query, + t => AssertCustomerView(t, 1, "First", 1, "FirstChild"), + t => AssertCustomerView(t, 2, "Second", 2, "SecondChild1"), + t => AssertCustomerView(t, 2, "Second", 3, "SecondChild2"), + t => AssertCustomerView(t, 3, "Third", null, "")); + + static void AssertCustomerView( + Context19708.CustomerView19708 actual, + int id, + string name, + int? customerMembershipId, + string customerMembershipName) + { + Assert.Equal(id, actual.Id); + Assert.Equal(name, actual.Name); + Assert.Equal(customerMembershipId, actual.CustomerMembershipId); + Assert.Equal(customerMembershipName, actual.CustomerMembershipName); + } + } + } + + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override async Task Group_by_multiple_aggregate_joining_different_tables(bool async) + { + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + if (!AppConfig.ServerVersion.Supports.OuterReferenceInMultiLevelSubquery) + { + using var context = contextFactory.CreateContext(); + await Assert.ThrowsAsync(() => async + ? context.Parents + .GroupBy(x => new { }) + .Select( + g => new + { + Test1 = g + .Select(x => x.Child1.Value1) + .Distinct() + .Count(), + Test2 = g + .Select(x => x.Child2.Value2) + .Distinct() + .Count() + }).ToListAsync() + : Task.FromResult(context.Parents + .GroupBy(x => new { }) + .Select( + g => new + { + Test1 = g + .Select(x => x.Child1.Value1) + .Distinct() + .Count(), + Test2 = g + .Select(x => x.Child2.Value2) + .Distinct() + .Count() + }).ToList())); + return; + } + + using (var context = contextFactory.CreateContext()) + { + var query = context.Parents + .GroupBy(x => new { }) + .Select( + g => new + { + Test1 = g + .Select(x => x.Child1.Value1) + .Distinct() + .Count(), + Test2 = g + .Select(x => x.Child2.Value2) + .Distinct() + .Count() + }); + + var orders = async + ? await query.ToListAsync() + : query.ToList(); + } + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override async Task Group_by_multiple_aggregate_joining_different_tables_with_query_filter(bool async) + { + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + if (!AppConfig.ServerVersion.Supports.OuterReferenceInMultiLevelSubquery) + { + using var context = contextFactory.CreateContext(); + await Assert.ThrowsAsync(() => async + ? context.Parents + .GroupBy(x => new { }) + .Select( + g => new + { + Test1 = g + .Select(x => x.ChildFilter1.Value1) + .Distinct() + .Count(), + Test2 = g + .Select(x => x.ChildFilter2.Value2) + .Distinct() + .Count() + }).ToListAsync() + : Task.FromResult(context.Parents + .GroupBy(x => new { }) + .Select( + g => new + { + Test1 = g + .Select(x => x.ChildFilter1.Value1) + .Distinct() + .Count(), + Test2 = g + .Select(x => x.ChildFilter2.Value2) + .Distinct() + .Count() + }).ToList())); + return; + } + + using (var context = contextFactory.CreateContext()) + { + var query = context.Parents + .GroupBy(x => new { }) + .Select( + g => new + { + Test1 = g + .Select(x => x.ChildFilter1.Value1) + .Distinct() + .Count(), + Test2 = g + .Select(x => x.ChildFilter2.Value2) + .Distinct() + .Count() + }); + + var orders = async + ? await query.ToListAsync() + : query.ToList(); + } + } + + protected override ITestStoreFactory TestStoreFactory + => SingleStoreTestStoreFactory.Instance; +} + diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/AdHocQuerySplittingQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/AdHocQuerySplittingQuerySingleStoreTest.cs new file mode 100644 index 000000000..b0e4f264a --- /dev/null +++ b/test/EFCore.SingleStore.FunctionalTests/Query/AdHocQuerySplittingQuerySingleStoreTest.cs @@ -0,0 +1,243 @@ +using System; +using System.Data; +using System.Reflection; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.TestUtilities; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; +using EntityFrameworkCore.SingleStore.Infrastructure.Internal; +using Microsoft.EntityFrameworkCore.Diagnostics.Internal; +using Xunit; + +namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query; + +public class AdHocQuerySplittingQuerySingleStoreTest : AdHocQuerySplittingQueryTestBase +{ + [ConditionalFact] + public override async Task Can_configure_SingleQuery_at_context_level() + { + var contextFactory = await InitializeAsync( + seed: c => c.SeedAsync(), + onConfiguring: o => SetQuerySplittingBehavior(o, QuerySplittingBehavior.SingleQuery), + onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var result = context.Parents.Include(p => p.Children1).ToList(); + } + + using (var context = contextFactory.CreateContext()) + { + var result = context.Parents.Include(p => p.Children1).AsSplitQuery().ToList(); + } + + using (var context = contextFactory.CreateContext()) + { + context.Parents.Include(p => p.Children1).Include(p => p.Children2).ToList(); + } + } + + [ConditionalFact] + public override async Task Can_configure_SplitQuery_at_context_level() + { + var contextFactory = await InitializeAsync( + seed: c => c.SeedAsync(), + onConfiguring: o => SetQuerySplittingBehavior(o, QuerySplittingBehavior.SplitQuery), + onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var result = context.Parents.Include(p => p.Children1).ToList(); + } + + using (var context = contextFactory.CreateContext()) + { + var result = context.Parents.Include(p => p.Children1).AsSingleQuery().ToList(); + } + + using (var context = contextFactory.CreateContext()) + { + context.Parents.Include(p => p.Children1).Include(p => p.Children2).ToList(); + } + } + + [ConditionalFact] + public override async Task Unconfigured_query_splitting_behavior_throws_a_warning() + { + var contextFactory = await InitializeAsync( + seed: c => c.SeedAsync(), + onConfiguring: o => ClearQuerySplittingBehavior(o), + onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + context.Parents.Include(p => p.Children1).Include(p => p.Children2).AsSplitQuery().ToList(); + } + + using (var context = contextFactory.CreateContext()) + { + Assert.Contains( + RelationalResources.LogMultipleCollectionIncludeWarning(new TestLogger()) + .GenerateMessage(), + Assert.Throws( + () => context.Parents.Include(p => p.Children1).Include(p => p.Children2).ToList()).Message); + } + } + + [ConditionalFact] + public override async Task Using_AsSingleQuery_without_context_configuration_does_not_throw_warning() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + context.Parents.Include(p => p.Children1).Include(p => p.Children2).AsSingleQuery().ToList(); + } + + [ConditionalFact] + public override async Task SplitQuery_disposes_inner_data_readers() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + ((RelationalTestStore)contextFactory.TestStore).CloseConnection(); + + using (var context = contextFactory.CreateContext()) + { + context.Parents.Include(p => p.Children1).Include(p => p.Children2).AsSplitQuery().ToList(); + + Assert.Equal(ConnectionState.Closed, context.Database.GetDbConnection().State); + } + + using (var context = contextFactory.CreateContext()) + { + await context.Parents.Include(p => p.Children1).Include(p => p.Children2).AsSplitQuery().ToListAsync(); + + Assert.Equal(ConnectionState.Closed, context.Database.GetDbConnection().State); + } + + using (var context = contextFactory.CreateContext()) + { + context.Parents.Include(p => p.Children1).Include(p => p.Children2).OrderBy(e => e.Id).AsSplitQuery().Single(); + + Assert.Equal(ConnectionState.Closed, context.Database.GetDbConnection().State); + } + + using (var context = contextFactory.CreateContext()) + { + await context.Parents.Include(p => p.Children1).Include(p => p.Children2).OrderBy(e => e.Id).AsSplitQuery().SingleAsync(); + + Assert.Equal(ConnectionState.Closed, context.Database.GetDbConnection().State); + } + } + + [ConditionalTheory] + [InlineData(true)] + [InlineData(false)] + public override async Task NoTracking_split_query_creates_only_required_instances(bool async) + { + var contextFactory = await InitializeAsync( + seed: c => c.SeedAsync(), + onConfiguring: o => SetQuerySplittingBehavior(o, QuerySplittingBehavior.SplitQuery), + onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using var context = contextFactory.CreateContext(); + Context25400.Test.ConstructorCallCount = 0; + + var query = context.Set().AsNoTracking().OrderBy(e => e.Id); + var test = async + ? await query.FirstOrDefaultAsync() + : query.FirstOrDefault(); + + Assert.Equal(1, Context25400.Test.ConstructorCallCount); + } + + protected override DbContextOptionsBuilder SetQuerySplittingBehavior( + DbContextOptionsBuilder optionsBuilder, + QuerySplittingBehavior splittingBehavior) + { + new SingleStoreDbContextOptionsBuilder(optionsBuilder).UseQuerySplittingBehavior(splittingBehavior); + + return optionsBuilder; + } + + protected override DbContextOptionsBuilder ClearQuerySplittingBehavior(DbContextOptionsBuilder optionsBuilder) + { + var extension = optionsBuilder.Options.FindExtension(); + if (extension == null) + { + extension = new SingleStoreOptionsExtension(); + } + else + { + _querySplittingBehaviorFieldInfo.SetValue(extension, null); + } + + ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension); + + return optionsBuilder; + } + + private static readonly FieldInfo _querySplittingBehaviorFieldInfo = + typeof(RelationalOptionsExtension).GetField("_querySplittingBehavior", BindingFlags.NonPublic | BindingFlags.Instance); + + protected override ITestStoreFactory TestStoreFactory + => SingleStoreTestStoreFactory.Instance; +} diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/CaseSensitiveNorthwindQuerySingleStoreFixture.cs b/test/EFCore.SingleStore.FunctionalTests/Query/CaseSensitiveNorthwindQuerySingleStoreFixture.cs index 7fbbf7a5d..a8c7ef146 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/CaseSensitiveNorthwindQuerySingleStoreFixture.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/CaseSensitiveNorthwindQuerySingleStoreFixture.cs @@ -1,21 +1,13 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.TestUtilities; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query { public class CaseSensitiveNorthwindQuerySingleStoreFixture : NorthwindQuerySingleStoreFixture - where TModelCustomizer : IModelCustomizer, new() + where TModelCustomizer : ITestModelCustomizer, new() { protected override string StoreName => "NorthwindCs"; protected override ITestStoreFactory TestStoreFactory => SingleStoreNorthwindTestStoreFactory.InstanceCs; - - public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) - { - var optionsBuilder = base.AddOptions(builder); - new SingleStoreDbContextOptionsBuilder(optionsBuilder).EnableStringComparisonTranslations(); - return optionsBuilder; - } } } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/CaseSensitiveWithStringComparisonNorthwindQuerySingleStoreFixture.cs b/test/EFCore.SingleStore.FunctionalTests/Query/CaseSensitiveWithStringComparisonNorthwindQuerySingleStoreFixture.cs new file mode 100644 index 000000000..ba9cb4b8d --- /dev/null +++ b/test/EFCore.SingleStore.FunctionalTests/Query/CaseSensitiveWithStringComparisonNorthwindQuerySingleStoreFixture.cs @@ -0,0 +1,15 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; + +namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query; + +public class CaseSensitiveWithStringComparisonNorthwindQuerySingleStoreFixture : CaseSensitiveNorthwindQuerySingleStoreFixture + where TModelCustomizer : ITestModelCustomizer, new() +{ + public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) + { + var optionsBuilder = base.AddOptions(builder); + new SingleStoreDbContextOptionsBuilder(optionsBuilder).EnableStringComparisonTranslations(); + return optionsBuilder; + } +} diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsCollectionsQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsCollectionsQuerySingleStoreTest.cs index 045e19e5f..1a8330c4f 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsCollectionsQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsCollectionsQuerySingleStoreTest.cs @@ -25,14 +25,16 @@ public override async Task Multi_level_include_one_to_many_optional_and_one_to_m await base.Multi_level_include_one_to_many_optional_and_one_to_many_optional_produces_valid_sql(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `t`.`Id0`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id` FROM `LevelOne` AS `l` LEFT JOIN ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` FROM `LevelTwo` AS `l0` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t`.`Id`"); +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `s`.`Id` +"""); } public override async Task Multi_level_include_correct_PK_is_chosen_as_the_join_predicate_for_queries_that_join_same_table_multiple_times(bool async) @@ -40,19 +42,21 @@ public override async Task Multi_level_include_correct_PK_is_chosen_as_the_join_ await base.Multi_level_include_correct_PK_is_chosen_as_the_join_predicate_for_queries_that_join_same_table_multiple_times(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `t0`.`Id0`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id`, `t0`.`Id00`, `t0`.`Date0`, `t0`.`Level1_Optional_Id0`, `t0`.`Level1_Required_Id0`, `t0`.`Name00`, `t0`.`OneToMany_Optional_Inverse2Id0`, `t0`.`OneToMany_Optional_Self_Inverse2Id0`, `t0`.`OneToMany_Required_Inverse2Id0`, `t0`.`OneToMany_Required_Self_Inverse2Id0`, `t0`.`OneToOne_Optional_PK_Inverse2Id0`, `t0`.`OneToOne_Optional_Self2Id0`, `t0`.`Id1`, `t0`.`Level2_Optional_Id0`, `t0`.`Level2_Required_Id0`, `t0`.`Name1`, `t0`.`OneToMany_Optional_Inverse3Id0`, `t0`.`OneToMany_Optional_Self_Inverse3Id0`, `t0`.`OneToMany_Required_Inverse3Id0`, `t0`.`OneToMany_Required_Self_Inverse3Id0`, `t0`.`OneToOne_Optional_PK_Inverse3Id0`, `t0`.`OneToOne_Optional_Self3Id0` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `s0`.`Id`, `s0`.`Date`, `s0`.`Level1_Optional_Id`, `s0`.`Level1_Required_Id`, `s0`.`Name`, `s0`.`OneToMany_Optional_Inverse2Id`, `s0`.`OneToMany_Optional_Self_Inverse2Id`, `s0`.`OneToMany_Required_Inverse2Id`, `s0`.`OneToMany_Required_Self_Inverse2Id`, `s0`.`OneToOne_Optional_PK_Inverse2Id`, `s0`.`OneToOne_Optional_Self2Id`, `s0`.`Id0`, `s0`.`Level2_Optional_Id`, `s0`.`Level2_Required_Id`, `s0`.`Name0`, `s0`.`OneToMany_Optional_Inverse3Id`, `s0`.`OneToMany_Optional_Self_Inverse3Id`, `s0`.`OneToMany_Required_Inverse3Id`, `s0`.`OneToMany_Required_Self_Inverse3Id`, `s0`.`OneToOne_Optional_PK_Inverse3Id`, `s0`.`OneToOne_Optional_Self3Id`, `s0`.`Id00`, `s0`.`Date0`, `s0`.`Level1_Optional_Id0`, `s0`.`Level1_Required_Id0`, `s0`.`Name00`, `s0`.`OneToMany_Optional_Inverse2Id0`, `s0`.`OneToMany_Optional_Self_Inverse2Id0`, `s0`.`OneToMany_Required_Inverse2Id0`, `s0`.`OneToMany_Required_Self_Inverse2Id0`, `s0`.`OneToOne_Optional_PK_Inverse2Id0`, `s0`.`OneToOne_Optional_Self2Id0`, `s0`.`Id1`, `s0`.`Level2_Optional_Id0`, `s0`.`Level2_Required_Id0`, `s0`.`Name1`, `s0`.`OneToMany_Optional_Inverse3Id0`, `s0`.`OneToMany_Optional_Self_Inverse3Id0`, `s0`.`OneToMany_Required_Inverse3Id0`, `s0`.`OneToMany_Required_Self_Inverse3Id0`, `s0`.`OneToOne_Optional_PK_Inverse3Id0`, `s0`.`OneToOne_Optional_Self3Id0` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `t`.`Id` AS `Id0`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name` AS `Name0`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id`, `t`.`Id0` AS `Id00`, `t`.`Date` AS `Date0`, `t`.`Level1_Optional_Id` AS `Level1_Optional_Id0`, `t`.`Level1_Required_Id` AS `Level1_Required_Id0`, `t`.`Name0` AS `Name00`, `t`.`OneToMany_Optional_Inverse2Id` AS `OneToMany_Optional_Inverse2Id0`, `t`.`OneToMany_Optional_Self_Inverse2Id` AS `OneToMany_Optional_Self_Inverse2Id0`, `t`.`OneToMany_Required_Inverse2Id` AS `OneToMany_Required_Inverse2Id0`, `t`.`OneToMany_Required_Self_Inverse2Id` AS `OneToMany_Required_Self_Inverse2Id0`, `t`.`OneToOne_Optional_PK_Inverse2Id` AS `OneToOne_Optional_PK_Inverse2Id0`, `t`.`OneToOne_Optional_Self2Id` AS `OneToOne_Optional_Self2Id0`, `t`.`Id1`, `t`.`Level2_Optional_Id0`, `t`.`Level2_Required_Id0`, `t`.`Name1`, `t`.`OneToMany_Optional_Inverse3Id0`, `t`.`OneToMany_Optional_Self_Inverse3Id0`, `t`.`OneToMany_Required_Inverse3Id0`, `t`.`OneToMany_Required_Self_Inverse3Id0`, `t`.`OneToOne_Optional_PK_Inverse3Id0`, `t`.`OneToOne_Optional_Self3Id0` + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `s`.`Id` AS `Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name` AS `Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `s`.`Id0` AS `Id00`, `s`.`Date` AS `Date0`, `s`.`Level1_Optional_Id` AS `Level1_Optional_Id0`, `s`.`Level1_Required_Id` AS `Level1_Required_Id0`, `s`.`Name0` AS `Name00`, `s`.`OneToMany_Optional_Inverse2Id` AS `OneToMany_Optional_Inverse2Id0`, `s`.`OneToMany_Optional_Self_Inverse2Id` AS `OneToMany_Optional_Self_Inverse2Id0`, `s`.`OneToMany_Required_Inverse2Id` AS `OneToMany_Required_Inverse2Id0`, `s`.`OneToMany_Required_Self_Inverse2Id` AS `OneToMany_Required_Self_Inverse2Id0`, `s`.`OneToOne_Optional_PK_Inverse2Id` AS `OneToOne_Optional_PK_Inverse2Id0`, `s`.`OneToOne_Optional_Self2Id` AS `OneToOne_Optional_Self2Id0`, `s`.`Id1`, `s`.`Level2_Optional_Id0`, `s`.`Level2_Required_Id0`, `s`.`Name1`, `s`.`OneToMany_Optional_Inverse3Id0`, `s`.`OneToMany_Optional_Self_Inverse3Id0`, `s`.`OneToMany_Required_Inverse3Id0`, `s`.`OneToMany_Required_Self_Inverse3Id0`, `s`.`OneToOne_Optional_PK_Inverse3Id0`, `s`.`OneToOne_Optional_Self3Id0` FROM `LevelTwo` AS `l0` LEFT JOIN ( SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l2`.`Id` AS `Id0`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name` AS `Name0`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l3`.`Id` AS `Id1`, `l3`.`Level2_Optional_Id` AS `Level2_Optional_Id0`, `l3`.`Level2_Required_Id` AS `Level2_Required_Id0`, `l3`.`Name` AS `Name1`, `l3`.`OneToMany_Optional_Inverse3Id` AS `OneToMany_Optional_Inverse3Id0`, `l3`.`OneToMany_Optional_Self_Inverse3Id` AS `OneToMany_Optional_Self_Inverse3Id0`, `l3`.`OneToMany_Required_Inverse3Id` AS `OneToMany_Required_Inverse3Id0`, `l3`.`OneToMany_Required_Self_Inverse3Id` AS `OneToMany_Required_Self_Inverse3Id0`, `l3`.`OneToOne_Optional_PK_Inverse3Id` AS `OneToOne_Optional_PK_Inverse3Id0`, `l3`.`OneToOne_Optional_Self3Id` AS `OneToOne_Optional_Self3Id0` FROM `LevelThree` AS `l1` INNER JOIN `LevelTwo` AS `l2` ON `l1`.`OneToMany_Required_Inverse3Id` = `l2`.`Id` LEFT JOIN `LevelThree` AS `l3` ON `l2`.`Id` = `l3`.`OneToMany_Optional_Inverse3Id` - ) AS `t` ON `l0`.`Id` = `t`.`OneToMany_Optional_Inverse3Id` -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`Id`, `t0`.`Id0`, `t0`.`Id00`"); + ) AS `s` ON `l0`.`Id` = `s`.`OneToMany_Optional_Inverse3Id` +) AS `s0` ON `l`.`Id` = `s0`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `s0`.`Id`, `s0`.`Id0`, `s0`.`Id00` +"""); } public override async Task Multiple_complex_includes(bool async) @@ -60,7 +64,8 @@ public override async Task Multiple_complex_includes(bool async) await base.Multiple_complex_includes(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `t`.`Id0`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` @@ -68,8 +73,9 @@ LEFT JOIN ( SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l3`.`Id` AS `Id0`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name` AS `Name0`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id` FROM `LevelTwo` AS `l2` LEFT JOIN `LevelThree` AS `l3` ON `l2`.`Id` = `l3`.`Level2_Optional_Id` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `t`.`Id`"); +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `s`.`Id` +"""); } public override async Task Multiple_complex_includes_self_ref(bool async) @@ -77,7 +83,8 @@ public override async Task Multiple_complex_includes_self_ref(bool async) await base.Multiple_complex_includes_self_ref(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Name`, `l0`.`OneToMany_Optional_Self_Inverse1Id`, `l0`.`OneToMany_Required_Self_Inverse1Id`, `l0`.`OneToOne_Optional_Self1Id`, `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `t`.`Id`, `t`.`Date`, `t`.`Name`, `t`.`OneToMany_Optional_Self_Inverse1Id`, `t`.`OneToMany_Required_Self_Inverse1Id`, `t`.`OneToOne_Optional_Self1Id`, `t`.`Id0`, `t`.`Date0`, `t`.`Name0`, `t`.`OneToMany_Optional_Self_Inverse1Id0`, `t`.`OneToMany_Required_Self_Inverse1Id0`, `t`.`OneToOne_Optional_Self1Id0` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Name`, `l0`.`OneToMany_Optional_Self_Inverse1Id`, `l0`.`OneToMany_Required_Self_Inverse1Id`, `l0`.`OneToOne_Optional_Self1Id`, `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `s`.`Id`, `s`.`Date`, `s`.`Name`, `s`.`OneToMany_Optional_Self_Inverse1Id`, `s`.`OneToMany_Required_Self_Inverse1Id`, `s`.`OneToOne_Optional_Self1Id`, `s`.`Id0`, `s`.`Date0`, `s`.`Name0`, `s`.`OneToMany_Optional_Self_Inverse1Id0`, `s`.`OneToMany_Required_Self_Inverse1Id0`, `s`.`OneToOne_Optional_Self1Id0` FROM `LevelOne` AS `l` LEFT JOIN `LevelOne` AS `l0` ON `l`.`OneToOne_Optional_Self1Id` = `l0`.`Id` LEFT JOIN `LevelOne` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Optional_Self_Inverse1Id` @@ -85,8 +92,9 @@ LEFT JOIN ( SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Name`, `l2`.`OneToMany_Optional_Self_Inverse1Id`, `l2`.`OneToMany_Required_Self_Inverse1Id`, `l2`.`OneToOne_Optional_Self1Id`, `l3`.`Id` AS `Id0`, `l3`.`Date` AS `Date0`, `l3`.`Name` AS `Name0`, `l3`.`OneToMany_Optional_Self_Inverse1Id` AS `OneToMany_Optional_Self_Inverse1Id0`, `l3`.`OneToMany_Required_Self_Inverse1Id` AS `OneToMany_Required_Self_Inverse1Id0`, `l3`.`OneToOne_Optional_Self1Id` AS `OneToOne_Optional_Self1Id0` FROM `LevelOne` AS `l2` LEFT JOIN `LevelOne` AS `l3` ON `l2`.`OneToOne_Optional_Self1Id` = `l3`.`Id` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Self_Inverse1Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `t`.`Id`"); +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Self_Inverse1Id` +ORDER BY `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `s`.`Id` +"""); } public override async Task Include_reference_and_collection_order_by(bool async) @@ -118,14 +126,16 @@ public override async Task Include_collection_then_reference(bool async) await base.Include_collection_then_reference(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `t`.`Id0`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id` FROM `LevelOne` AS `l` LEFT JOIN ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` FROM `LevelTwo` AS `l0` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Level2_Optional_Id` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t`.`Id`"); +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `s`.`Id` +"""); } public override async Task Include_collection_with_conditional_order_by(bool async) @@ -149,7 +159,8 @@ public override async Task Multiple_complex_include_select(bool async) await base.Multiple_complex_include_select(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `t`.`Id0`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` @@ -157,8 +168,9 @@ LEFT JOIN ( SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l3`.`Id` AS `Id0`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name` AS `Name0`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id` FROM `LevelTwo` AS `l2` LEFT JOIN `LevelThree` AS `l3` ON `l2`.`Id` = `l3`.`Level2_Optional_Id` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `t`.`Id`"); +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `s`.`Id` +"""); } public override async Task Include_nested_with_optional_navigation(bool async) @@ -166,16 +178,18 @@ public override async Task Include_nested_with_optional_navigation(bool async) await base.Include_nested_with_optional_navigation(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `t`.`Id`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id`, `t`.`Id0`, `t`.`Level3_Optional_Id`, `t`.`Level3_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse4Id`, `t`.`OneToMany_Optional_Self_Inverse4Id`, `t`.`OneToMany_Required_Inverse4Id`, `t`.`OneToMany_Required_Self_Inverse4Id`, `t`.`OneToOne_Optional_PK_Inverse4Id`, `t`.`OneToOne_Optional_Self4Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `s`.`Id`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `s`.`Id0`, `s`.`Level3_Optional_Id`, `s`.`Level3_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse4Id`, `s`.`OneToMany_Optional_Self_Inverse4Id`, `s`.`OneToMany_Required_Inverse4Id`, `s`.`OneToMany_Required_Self_Inverse4Id`, `s`.`OneToOne_Optional_PK_Inverse4Id`, `s`.`OneToOne_Optional_Self4Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` LEFT JOIN ( SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l2`.`Id` AS `Id0`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name` AS `Name0`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id` FROM `LevelThree` AS `l1` LEFT JOIN `LevelFour` AS `l2` ON `l1`.`Id` = `l2`.`Level3_Required_Id` -) AS `t` ON `l0`.`Id` = `t`.`OneToMany_Required_Inverse3Id` +) AS `s` ON `l0`.`Id` = `s`.`OneToMany_Required_Inverse3Id` WHERE (`l0`.`Name` <> 'L2 09') OR `l0`.`Name` IS NULL -ORDER BY `l`.`Id`, `l0`.`Id`, `t`.`Id`"); +ORDER BY `l`.`Id`, `l0`.`Id`, `s`.`Id` +"""); } public override async Task Complex_multi_include_with_order_by_and_paging(bool async) @@ -183,20 +197,22 @@ public override async Task Complex_multi_include_with_order_by_and_paging(bool a await base.Complex_multi_include_with_order_by_and_paging(async); AssertSql( - @"@__p_1='10' +""" +@__p_1='10' @__p_0='0' -SELECT `t`.`Id`, `t`.`Date`, `t`.`Name`, `t`.`OneToMany_Optional_Self_Inverse1Id`, `t`.`OneToMany_Required_Self_Inverse1Id`, `t`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id` +SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id`, `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` -LEFT JOIN `LevelTwo` AS `l0` ON `t`.`Id` = `l0`.`Level1_Required_Id` -LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` -LEFT JOIN `LevelThree` AS `l2` ON `l0`.`Id` = `l2`.`OneToMany_Required_Inverse3Id` -ORDER BY `t`.`Name`, `t`.`Id`, `l0`.`Id`, `l1`.`Id`"); +) AS `l1` +LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Required_Id` +LEFT JOIN `LevelThree` AS `l2` ON `l0`.`Id` = `l2`.`OneToMany_Optional_Inverse3Id` +LEFT JOIN `LevelThree` AS `l3` ON `l0`.`Id` = `l3`.`OneToMany_Required_Inverse3Id` +ORDER BY `l1`.`Name`, `l1`.`Id`, `l0`.`Id`, `l2`.`Id` +"""); } public override async Task Complex_multi_include_with_order_by_and_paging_joins_on_correct_key(bool async) @@ -204,21 +220,23 @@ public override async Task Complex_multi_include_with_order_by_and_paging_joins_ await base.Complex_multi_include_with_order_by_and_paging_joins_on_correct_key(async); AssertSql( - @"@__p_1='10' +""" +@__p_1='10' @__p_0='0' -SELECT `t`.`Id`, `t`.`Date`, `t`.`Name`, `t`.`OneToMany_Optional_Self_Inverse1Id`, `t`.`OneToMany_Required_Self_Inverse1Id`, `t`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id`, `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id`, `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id` +SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l2`.`Id`, `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l4`.`Id`, `l4`.`Level2_Optional_Id`, `l4`.`Level2_Required_Id`, `l4`.`Name`, `l4`.`OneToMany_Optional_Inverse3Id`, `l4`.`OneToMany_Optional_Self_Inverse3Id`, `l4`.`OneToMany_Required_Inverse3Id`, `l4`.`OneToMany_Required_Self_Inverse3Id`, `l4`.`OneToOne_Optional_PK_Inverse3Id`, `l4`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` -LEFT JOIN `LevelTwo` AS `l0` ON `t`.`Id` = `l0`.`Level1_Optional_Id` -LEFT JOIN `LevelTwo` AS `l1` ON `t`.`Id` = `l1`.`Level1_Required_Id` -LEFT JOIN `LevelThree` AS `l2` ON `l0`.`Id` = `l2`.`OneToMany_Optional_Inverse3Id` -LEFT JOIN `LevelThree` AS `l3` ON `l1`.`Id` = `l3`.`OneToMany_Required_Inverse3Id` -ORDER BY `t`.`Name`, `t`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`"); +) AS `l1` +LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Optional_Id` +LEFT JOIN `LevelTwo` AS `l2` ON `l1`.`Id` = `l2`.`Level1_Required_Id` +LEFT JOIN `LevelThree` AS `l3` ON `l0`.`Id` = `l3`.`OneToMany_Optional_Inverse3Id` +LEFT JOIN `LevelThree` AS `l4` ON `l2`.`Id` = `l4`.`OneToMany_Required_Inverse3Id` +ORDER BY `l1`.`Name`, `l1`.`Id`, `l0`.`Id`, `l2`.`Id`, `l3`.`Id` +"""); } public override async Task Complex_multi_include_with_order_by_and_paging_joins_on_correct_key2(bool async) @@ -226,20 +244,22 @@ public override async Task Complex_multi_include_with_order_by_and_paging_joins_ await base.Complex_multi_include_with_order_by_and_paging_joins_on_correct_key2(async); AssertSql( - @"@__p_1='10' +""" +@__p_1='10' @__p_0='0' -SELECT `t`.`Id`, `t`.`Date`, `t`.`Name`, `t`.`OneToMany_Optional_Self_Inverse1Id`, `t`.`OneToMany_Required_Self_Inverse1Id`, `t`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id` +SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id`, `l3`.`Id`, `l3`.`Level3_Optional_Id`, `l3`.`Level3_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse4Id`, `l3`.`OneToMany_Optional_Self_Inverse4Id`, `l3`.`OneToMany_Required_Inverse4Id`, `l3`.`OneToMany_Required_Self_Inverse4Id`, `l3`.`OneToOne_Optional_PK_Inverse4Id`, `l3`.`OneToOne_Optional_Self4Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` -LEFT JOIN `LevelTwo` AS `l0` ON `t`.`Id` = `l0`.`Level1_Optional_Id` -LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Level2_Required_Id` -LEFT JOIN `LevelFour` AS `l2` ON `l1`.`Id` = `l2`.`OneToMany_Optional_Inverse4Id` -ORDER BY `t`.`Name`, `t`.`Id`, `l0`.`Id`, `l1`.`Id`"); +) AS `l1` +LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Optional_Id` +LEFT JOIN `LevelThree` AS `l2` ON `l0`.`Id` = `l2`.`Level2_Required_Id` +LEFT JOIN `LevelFour` AS `l3` ON `l2`.`Id` = `l3`.`OneToMany_Optional_Inverse4Id` +ORDER BY `l1`.`Name`, `l1`.`Id`, `l0`.`Id`, `l2`.`Id` +"""); } public override async Task Multiple_include_with_multiple_optional_navigations(bool async) @@ -349,15 +369,17 @@ public override async Task Optional_navigation_with_Include_ThenInclude(bool asy await base.Optional_navigation_with_Include_ThenInclude(async); AssertSql( - @"SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `t`.`Id`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id`, `t`.`Id0`, `t`.`Level3_Optional_Id`, `t`.`Level3_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse4Id`, `t`.`OneToMany_Optional_Self_Inverse4Id`, `t`.`OneToMany_Required_Inverse4Id`, `t`.`OneToMany_Required_Self_Inverse4Id`, `t`.`OneToOne_Optional_PK_Inverse4Id`, `t`.`OneToOne_Optional_Self4Id` +""" +SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `s`.`Id`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `s`.`Id0`, `s`.`Level3_Optional_Id`, `s`.`Level3_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse4Id`, `s`.`OneToMany_Optional_Self_Inverse4Id`, `s`.`OneToMany_Required_Inverse4Id`, `s`.`OneToMany_Required_Self_Inverse4Id`, `s`.`OneToOne_Optional_PK_Inverse4Id`, `s`.`OneToOne_Optional_Self4Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` LEFT JOIN ( SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l2`.`Id` AS `Id0`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name` AS `Name0`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id` FROM `LevelThree` AS `l1` LEFT JOIN `LevelFour` AS `l2` ON `l1`.`Id` = `l2`.`Level3_Optional_Id` -) AS `t` ON `l0`.`Id` = `t`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `t`.`Id`"); +) AS `s` ON `l0`.`Id` = `s`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l0`.`Id`, `s`.`Id` +"""); } public override async Task Multiple_optional_navigation_with_Include(bool async) @@ -439,14 +461,16 @@ public override async Task SelectMany_with_navigation_and_Distinct(bool async) await base.SelectMany_with_navigation_and_Distinct(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t`.`Id`, `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l1`.`Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` INNER JOIN ( SELECT DISTINCT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` FROM `LevelTwo` AS `l0` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -LEFT JOIN `LevelTwo` AS `l1` ON `l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t`.`Id`"); +) AS `l1` ON `l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` +LEFT JOIN `LevelTwo` AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l1`.`Id` +"""); } public override async Task SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(bool async) @@ -454,14 +478,16 @@ public override async Task SelectMany_with_navigation_and_Distinct_projecting_co await base.SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t`.`Id`, `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l1`.`Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` INNER JOIN ( SELECT DISTINCT `l0`.`Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id` AS `FK` FROM `LevelTwo` AS `l0` -) AS `t` ON `l`.`Id` = `t`.`FK` -LEFT JOIN `LevelTwo` AS `l1` ON `l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t`.`Id`"); +) AS `l1` ON `l`.`Id` = `l1`.`FK` +LEFT JOIN `LevelTwo` AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l1`.`Id` +"""); } public override async Task Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(bool async) @@ -469,7 +495,8 @@ public override async Task Complex_SelectMany_with_nested_navigations_and_explic await base.Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(async); AssertSql( - @"SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `t`.`Id`, `t`.`Id0`, `t`.`Id1`, `t`.`Id2`, `t0`.`Id`, `t0`.`Id0`, `t0`.`Id1`, `t0`.`Id2`, `l11`.`Id`, `l12`.`Id`, `l13`.`Id`, `l14`.`Id`, `t1`.`Id`, `t1`.`Date`, `t1`.`Level1_Optional_Id`, `t1`.`Level1_Required_Id`, `t1`.`Name`, `t1`.`OneToMany_Optional_Inverse2Id`, `t1`.`OneToMany_Optional_Self_Inverse2Id`, `t1`.`OneToMany_Required_Inverse2Id`, `t1`.`OneToMany_Required_Self_Inverse2Id`, `t1`.`OneToOne_Optional_PK_Inverse2Id`, `t1`.`OneToOne_Optional_Self2Id`, `l14`.`Name` +""" +SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Id2`, `s0`.`Id`, `s0`.`Id0`, `s0`.`Id1`, `s0`.`Id2`, `l11`.`Id`, `l12`.`Id`, `l13`.`Id`, `l14`.`Id`, `l16`.`Id`, `l16`.`Date`, `l16`.`Level1_Optional_Id`, `l16`.`Level1_Required_Id`, `l16`.`Name`, `l16`.`OneToMany_Optional_Inverse2Id`, `l16`.`OneToMany_Optional_Self_Inverse2Id`, `l16`.`OneToMany_Required_Inverse2Id`, `l16`.`OneToMany_Required_Self_Inverse2Id`, `l16`.`OneToOne_Optional_PK_Inverse2Id`, `l16`.`OneToOne_Optional_Self2Id`, `l14`.`Name` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Required_Id` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Level2_Optional_Id` @@ -480,25 +507,26 @@ INNER JOIN ( INNER JOIN `LevelThree` AS `l4` ON `l3`.`Level3_Required_Id` = `l4`.`Id` LEFT JOIN `LevelTwo` AS `l5` ON `l4`.`Level2_Optional_Id` = `l5`.`Id` LEFT JOIN `LevelTwo` AS `l6` ON `l5`.`Id` = `l6`.`OneToMany_Required_Self_Inverse2Id` -) AS `t` ON `l2`.`Id` = `t`.`Id2` +) AS `s` ON `l2`.`Id` = `s`.`Id2` LEFT JOIN ( SELECT `l7`.`Id`, `l8`.`Id` AS `Id0`, `l9`.`Id` AS `Id1`, `l10`.`Id` AS `Id2`, `l10`.`Level2_Optional_Id` AS `Level2_Optional_Id0` FROM `LevelFour` AS `l7` INNER JOIN `LevelThree` AS `l8` ON `l7`.`Level3_Required_Id` = `l8`.`Id` INNER JOIN `LevelTwo` AS `l9` ON `l8`.`Level2_Required_Id` = `l9`.`Id` LEFT JOIN `LevelThree` AS `l10` ON `l9`.`Id` = `l10`.`OneToMany_Required_Inverse3Id` -) AS `t0` ON `t`.`Id2` = `t0`.`Id2` +) AS `s0` ON `s`.`Id2` = `s0`.`Id2` LEFT JOIN `LevelThree` AS `l11` ON `l2`.`OneToMany_Optional_Inverse4Id` = `l11`.`Id` -LEFT JOIN `LevelThree` AS `l12` ON `t`.`Id2` = `l12`.`Level2_Optional_Id` -LEFT JOIN `LevelTwo` AS `l13` ON `t0`.`Level2_Optional_Id0` = `l13`.`Id` +LEFT JOIN `LevelThree` AS `l12` ON `s`.`Id2` = `l12`.`Level2_Optional_Id` +LEFT JOIN `LevelTwo` AS `l13` ON `s0`.`Level2_Optional_Id0` = `l13`.`Id` LEFT JOIN `LevelThree` AS `l14` ON `l13`.`Id` = `l14`.`Level2_Required_Id` LEFT JOIN ( SELECT `l15`.`Id`, `l15`.`Date`, `l15`.`Level1_Optional_Id`, `l15`.`Level1_Required_Id`, `l15`.`Name`, `l15`.`OneToMany_Optional_Inverse2Id`, `l15`.`OneToMany_Optional_Self_Inverse2Id`, `l15`.`OneToMany_Required_Inverse2Id`, `l15`.`OneToMany_Required_Self_Inverse2Id`, `l15`.`OneToOne_Optional_PK_Inverse2Id`, `l15`.`OneToOne_Optional_Self2Id` FROM `LevelTwo` AS `l15` WHERE `l15`.`Id` <> 42 -) AS `t1` ON `t`.`Id2` = `t1`.`OneToMany_Optional_Self_Inverse2Id` +) AS `l16` ON `s`.`Id2` = `l16`.`OneToMany_Optional_Self_Inverse2Id` WHERE (`l11`.`Name` <> 'Foo') OR `l11`.`Name` IS NULL -ORDER BY `l12`.`Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `t`.`Id`, `t`.`Id0`, `t`.`Id1`, `t`.`Id2`, `t0`.`Id`, `t0`.`Id0`, `t0`.`Id1`, `t0`.`Id2`, `l11`.`Id`, `l13`.`Id`, `l14`.`Id`"); +ORDER BY `l12`.`Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Id2`, `s0`.`Id`, `s0`.`Id0`, `s0`.`Id1`, `s0`.`Id2`, `l11`.`Id`, `l13`.`Id`, `l14`.`Id` +"""); } public override async Task Project_collection_navigation(bool async) @@ -553,15 +581,17 @@ public override async Task Project_collection_navigation_composed(bool async) await base.Project_collection_navigation_composed(async); AssertSql( - @"SELECT `l`.`Id`, `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` FROM `LevelTwo` AS `l0` WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` +) AS `l1` ON `l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` WHERE `l`.`Id` < 3 -ORDER BY `l`.`Id`"); +ORDER BY `l`.`Id` +"""); } public override async Task Project_collection_and_root_entity(bool async) @@ -604,16 +634,18 @@ public override async Task Include_inside_subquery(bool async) await base.Include_inside_subquery(async); AssertSql( - @"SELECT `l`.`Id`, `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `t`.`Id0`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id` +""" +SELECT `l`.`Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id` FROM `LevelOne` AS `l` LEFT JOIN LATERAL ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` FROM `LevelTwo` AS `l0` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` WHERE `l0`.`Id` > 0 -) AS `t` ON TRUE +) AS `s` ON TRUE WHERE `l`.`Id` < 3 -ORDER BY `l`.`Id`, `t`.`Id`"); +ORDER BY `l`.`Id`, `s`.`Id` +"""); } public override async Task Include_collection_with_multiple_orderbys_member(bool async) @@ -717,14 +749,16 @@ public override async Task Null_check_in_anonymous_type_projection_should_not_be await base.Null_check_in_anonymous_type_projection_should_not_be_removed(async); AssertSql( - @"SELECT `l`.`Id`, `t`.`c`, `t`.`Name`, `t`.`Id`, `t`.`Id0` +""" +SELECT `l`.`Id`, `s`.`c`, `s`.`Name`, `s`.`Id`, `s`.`Id0` FROM `LevelOne` AS `l` LEFT JOIN ( SELECT `l1`.`Id` IS NULL AS `c`, `l1`.`Name`, `l0`.`Id`, `l1`.`Id` AS `Id0`, `l0`.`OneToMany_Optional_Inverse2Id` FROM `LevelTwo` AS `l0` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Level2_Required_Id` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t`.`Id`"); +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `s`.`Id` +"""); } public override async Task Null_check_in_Dto_projection_should_not_be_removed(bool async) @@ -732,14 +766,16 @@ public override async Task Null_check_in_Dto_projection_should_not_be_removed(bo await base.Null_check_in_Dto_projection_should_not_be_removed(async); AssertSql( - @"SELECT `l`.`Id`, `t`.`c`, `t`.`Name`, `t`.`Id`, `t`.`Id0` +""" +SELECT `l`.`Id`, `s`.`c`, `s`.`Name`, `s`.`Id`, `s`.`Id0` FROM `LevelOne` AS `l` LEFT JOIN ( SELECT `l1`.`Id` IS NULL AS `c`, `l1`.`Name`, `l0`.`Id`, `l1`.`Id` AS `Id0`, `l0`.`OneToMany_Optional_Inverse2Id` FROM `LevelTwo` AS `l0` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Level2_Required_Id` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t`.`Id`"); +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `s`.`Id` +"""); } public override async Task SelectMany_navigation_property_followed_by_select_collection_navigation(bool async) @@ -785,24 +821,26 @@ public override async Task Lift_projection_mapping_when_pushing_down_subquery(bo await base.Lift_projection_mapping_when_pushing_down_subquery(async); AssertSql( - @"@__p_0='25' +""" +@__p_0='25' -SELECT `t`.`Id`, `t0`.`Id`, `l1`.`Id`, `t0`.`c` +SELECT `l2`.`Id`, `l4`.`Id`, `l1`.`Id`, `l4`.`c` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` LIMIT @__p_0 -) AS `t` +) AS `l2` LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`c`, `t1`.`OneToMany_Required_Inverse2Id` + SELECT `l3`.`Id`, `l3`.`c`, `l3`.`OneToMany_Required_Inverse2Id` FROM ( SELECT `l0`.`Id`, 1 AS `c`, `l0`.`OneToMany_Required_Inverse2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Required_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`Id` = `t0`.`OneToMany_Required_Inverse2Id` -LEFT JOIN `LevelTwo` AS `l1` ON `t`.`Id` = `l1`.`OneToMany_Required_Inverse2Id` -ORDER BY `t`.`Id`, `t0`.`Id`"); + ) AS `l3` + WHERE `l3`.`row` <= 1 +) AS `l4` ON `l2`.`Id` = `l4`.`OneToMany_Required_Inverse2Id` +LEFT JOIN `LevelTwo` AS `l1` ON `l2`.`Id` = `l1`.`OneToMany_Required_Inverse2Id` +ORDER BY `l2`.`Id`, `l4`.`Id` +"""); } public override async Task Including_reference_navigation_and_projecting_collection_navigation(bool async) @@ -865,18 +903,20 @@ public override async Task Select_subquery_single_nested_subquery(bool async) await base.Select_subquery_single_nested_subquery(async); AssertSql( - @"SELECT `l`.`Id`, `t0`.`Id`, `l1`.`Id`, `t0`.`c` +""" +SELECT `l`.`Id`, `l3`.`Id`, `l1`.`Id`, `l3`.`c` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`c`, `t`.`Id`, `t`.`OneToMany_Optional_Inverse2Id` + SELECT `l2`.`c`, `l2`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id` FROM ( SELECT 1 AS `c`, `l0`.`Id`, `l0`.`OneToMany_Optional_Inverse2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -LEFT JOIN `LevelThree` AS `l1` ON `t0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `t0`.`Id`, `l1`.`Id`"); + ) AS `l2` + WHERE `l2`.`row` <= 1 +) AS `l3` ON `l`.`Id` = `l3`.`OneToMany_Optional_Inverse2Id` +LEFT JOIN `LevelThree` AS `l1` ON `l3`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l3`.`Id`, `l1`.`Id` +"""); } public override async Task Select_subquery_single_nested_subquery2(bool async) @@ -884,22 +924,25 @@ public override async Task Select_subquery_single_nested_subquery2(bool async) await base.Select_subquery_single_nested_subquery2(async); AssertSql( - $@"SELECT `l`.`Id`, `t1`.`Id`, `t1`.`Id0`, `t1`.`Id1`, `t1`.`c` +""" +SELECT `l`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1`, `s`.`c` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `l0`.`Id`, `t0`.`Id` AS `Id0`, `l1`.`Id` AS `Id1`, `t0`.`c`, `l0`.`OneToMany_Optional_Inverse2Id` + SELECT `l0`.`Id`, `l4`.`Id` AS `Id0`, `l2`.`Id` AS `Id1`, `l4`.`c`, `l0`.`OneToMany_Optional_Inverse2Id` FROM `LevelTwo` AS `l0` LEFT JOIN ( - SELECT `t`.`c`, `t`.`Id`, `t`.`OneToMany_Optional_Inverse3Id` + SELECT `l3`.`c`, `l3`.`Id`, `l3`.`OneToMany_Optional_Inverse3Id` FROM ( - SELECT {(AppConfig.ServerVersion.Supports.SingleStoreBug96947Workaround ? "CAST(1 AS signed)" : "1")} AS `c`, `l2`.`Id`, `l2`.`OneToMany_Optional_Inverse3Id`, ROW_NUMBER() OVER(PARTITION BY `l2`.`OneToMany_Optional_Inverse3Id` ORDER BY `l2`.`Id`) AS `row` - FROM `LevelThree` AS `l2` - ) AS `t` - WHERE `t`.`row` <= 1 - ) AS `t0` ON `l0`.`Id` = `t0`.`OneToMany_Optional_Inverse3Id` - LEFT JOIN `LevelFour` AS `l1` ON `t0`.`Id` = `l1`.`OneToMany_Optional_Inverse4Id` -) AS `t1` ON `l`.`Id` = `t1`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t1`.`Id`, `t1`.`Id0`, `t1`.`Id1`"); + SELECT 1 AS `c`, `l1`.`Id`, `l1`.`OneToMany_Optional_Inverse3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Optional_Inverse3Id` ORDER BY `l1`.`Id`) AS `row` + FROM `LevelThree` AS `l1` + ) AS `l3` + WHERE `l3`.`row` <= 1 + ) AS `l4` ON `l0`.`Id` = `l4`.`OneToMany_Optional_Inverse3Id` + LEFT JOIN `LevelFour` AS `l2` ON `l4`.`Id` = `l2`.`OneToMany_Optional_Inverse4Id` +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1` +"""); + } public override async Task Filtered_include_basic_Where(bool async) @@ -907,16 +950,16 @@ public override async Task Filtered_include_basic_Where(bool async) await base.Filtered_include_basic_Where(async); AssertSql( - """ - SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` - FROM `LevelOne` AS `l` - LEFT JOIN ( - SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` - FROM `LevelTwo` AS `l0` - WHERE `l0`.`Id` > 5 - ) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` - ORDER BY `l`.`Id` - """); +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` +FROM `LevelOne` AS `l` +LEFT JOIN ( + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` + FROM `LevelTwo` AS `l0` + WHERE `l0`.`Id` > 5 +) AS `l1` ON `l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id` +"""); } public override async Task Filtered_include_OrderBy(bool async) @@ -935,14 +978,16 @@ public override async Task Filtered_ThenInclude_OrderBy(bool async) await base.Filtered_ThenInclude_OrderBy(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `t`.`Id0`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id` FROM `LevelOne` AS `l` LEFT JOIN ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` FROM `LevelTwo` AS `l0` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t`.`Id`, `t`.`Name0`"); +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `s`.`Id`, `s`.`Name0` +"""); } public override async Task Filtered_include_ThenInclude_OrderBy(bool async) @@ -950,14 +995,16 @@ public override async Task Filtered_include_ThenInclude_OrderBy(bool async) await base.Filtered_include_ThenInclude_OrderBy(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `t`.`Id0`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id` FROM `LevelOne` AS `l` LEFT JOIN ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` FROM `LevelTwo` AS `l0` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t`.`Name`, `t`.`Id`, `t`.`Name0` DESC"); +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `s`.`Name`, `s`.`Id`, `s`.`Name0` DESC +"""); } public override async Task Filtered_include_basic_OrderBy_Take(bool async) @@ -965,17 +1012,19 @@ public override async Task Filtered_include_basic_OrderBy_Take(bool async) await base.Filtered_include_basic_OrderBy_Take(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Name`) AS `row` FROM `LevelTwo` AS `l0` - ) AS `t` - WHERE `t`.`row` <= 3 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Name`"); + ) AS `l1` + WHERE `l1`.`row` <= 3 +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`Name` +"""); } public override async Task Filtered_include_basic_OrderBy_Skip(bool async) @@ -983,17 +1032,19 @@ public override async Task Filtered_include_basic_OrderBy_Skip(bool async) await base.Filtered_include_basic_OrderBy_Skip(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Name`) AS `row` FROM `LevelTwo` AS `l0` - ) AS `t` - WHERE 1 < `t`.`row` -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Name`"); + ) AS `l1` + WHERE 1 < `l1`.`row` +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`Name` +"""); } public override async Task Filtered_include_basic_OrderBy_Skip_Take(bool async) @@ -1001,17 +1052,19 @@ public override async Task Filtered_include_basic_OrderBy_Skip_Take(bool async) await base.Filtered_include_basic_OrderBy_Skip_Take(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Name`) AS `row` FROM `LevelTwo` AS `l0` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 4) -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Name`"); + ) AS `l1` + WHERE (1 < `l1`.`row`) AND (`l1`.`row` <= 4) +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`Name` +"""); } public override async Task Filtered_include_Skip_without_OrderBy(bool async) @@ -1019,17 +1072,19 @@ public override async Task Filtered_include_Skip_without_OrderBy(bool async) await base.Filtered_include_Skip_without_OrderBy(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` - ) AS `t` - WHERE 1 < `t`.`row` -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`"); + ) AS `l1` + WHERE 1 < `l1`.`row` +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id` +"""); } public override async Task Filtered_include_Take_without_OrderBy(bool async) @@ -1037,17 +1092,19 @@ public override async Task Filtered_include_Take_without_OrderBy(bool async) await base.Filtered_include_Take_without_OrderBy(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`"); + ) AS `l1` + WHERE `l1`.`row` <= 1 +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id` +"""); } public override async Task Filtered_include_on_ThenInclude(bool async) @@ -1055,19 +1112,21 @@ public override async Task Filtered_include_on_ThenInclude(bool async) await base.Filtered_include_on_ThenInclude(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `t0`.`Id`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id` + SELECT `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Optional_Inverse3Id` ORDER BY `l1`.`Name`) AS `row` FROM `LevelThree` AS `l1` WHERE (`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 4) -) AS `t0` ON `l0`.`Id` = `t0`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`Name`"); + ) AS `l2` + WHERE (1 < `l2`.`row`) AND (`l2`.`row` <= 4) +) AS `l3` ON `l0`.`Id` = `l3`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l0`.`Id`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`Name` +"""); } public override async Task Filtered_include_after_reference_navigation(bool async) @@ -1075,19 +1134,21 @@ public override async Task Filtered_include_after_reference_navigation(bool asyn await base.Filtered_include_after_reference_navigation(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `t0`.`Id`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id` -FROM `LevelOne` AS `l` -LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` -LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id` - FROM ( - SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Optional_Inverse3Id` ORDER BY `l1`.`Name`) AS `row` - FROM `LevelThree` AS `l1` - WHERE (`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 4) -) AS `t0` ON `l0`.`Id` = `t0`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`Name`"); + """ + SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id` + FROM `LevelOne` AS `l` + LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` + LEFT JOIN ( + SELECT `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id` + FROM ( + SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Optional_Inverse3Id` ORDER BY `l1`.`Name`) AS `row` + FROM `LevelThree` AS `l1` + WHERE (`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL + ) AS `l2` + WHERE (1 < `l2`.`row`) AND (`l2`.`row` <= 4) + ) AS `l3` ON `l0`.`Id` = `l3`.`OneToMany_Optional_Inverse3Id` + ORDER BY `l`.`Id`, `l0`.`Id`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`Name` + """); } public override async Task Filtered_include_after_different_filtered_include_same_level(bool async) @@ -1095,56 +1156,60 @@ public override async Task Filtered_include_after_different_filtered_include_sam await base.Filtered_include_after_different_filtered_include_same_level(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `t1`.`Id`, `t1`.`Date`, `t1`.`Level1_Optional_Id`, `t1`.`Level1_Required_Id`, `t1`.`Name`, `t1`.`OneToMany_Optional_Inverse2Id`, `t1`.`OneToMany_Optional_Self_Inverse2Id`, `t1`.`OneToMany_Required_Inverse2Id`, `t1`.`OneToMany_Required_Self_Inverse2Id`, `t1`.`OneToOne_Optional_PK_Inverse2Id`, `t1`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l3`.`Id`, `l3`.`Date`, `l3`.`Level1_Optional_Id`, `l3`.`Level1_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse2Id`, `l3`.`OneToMany_Optional_Self_Inverse2Id`, `l3`.`OneToMany_Required_Inverse2Id`, `l3`.`OneToMany_Required_Self_Inverse2Id`, `l3`.`OneToOne_Optional_PK_Inverse2Id`, `l3`.`OneToOne_Optional_Self2Id`, `l5`.`Id`, `l5`.`Date`, `l5`.`Level1_Optional_Id`, `l5`.`Level1_Required_Id`, `l5`.`Name`, `l5`.`OneToMany_Optional_Inverse2Id`, `l5`.`OneToMany_Optional_Self_Inverse2Id`, `l5`.`OneToMany_Required_Inverse2Id`, `l5`.`OneToMany_Required_Self_Inverse2Id`, `l5`.`OneToOne_Optional_PK_Inverse2Id`, `l5`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Name`) AS `row` FROM `LevelTwo` AS `l0` WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 3 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` + ) AS `l2` + WHERE `l2`.`row` <= 3 +) AS `l3` ON `l`.`Id` = `l3`.`OneToMany_Optional_Inverse2Id` LEFT JOIN ( - SELECT `t2`.`Id`, `t2`.`Date`, `t2`.`Level1_Optional_Id`, `t2`.`Level1_Required_Id`, `t2`.`Name`, `t2`.`OneToMany_Optional_Inverse2Id`, `t2`.`OneToMany_Optional_Self_Inverse2Id`, `t2`.`OneToMany_Required_Inverse2Id`, `t2`.`OneToMany_Required_Self_Inverse2Id`, `t2`.`OneToOne_Optional_PK_Inverse2Id`, `t2`.`OneToOne_Optional_Self2Id` + SELECT `l4`.`Id`, `l4`.`Date`, `l4`.`Level1_Optional_Id`, `l4`.`Level1_Required_Id`, `l4`.`Name`, `l4`.`OneToMany_Optional_Inverse2Id`, `l4`.`OneToMany_Optional_Self_Inverse2Id`, `l4`.`OneToMany_Required_Inverse2Id`, `l4`.`OneToMany_Required_Self_Inverse2Id`, `l4`.`OneToOne_Optional_PK_Inverse2Id`, `l4`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Required_Inverse2Id` ORDER BY `l1`.`Name` DESC) AS `row` FROM `LevelTwo` AS `l1` WHERE (`l1`.`Name` <> 'Bar') OR `l1`.`Name` IS NULL - ) AS `t2` - WHERE 1 < `t2`.`row` -) AS `t1` ON `l`.`Id` = `t1`.`OneToMany_Required_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Name`, `t0`.`Id`, `t1`.`OneToMany_Required_Inverse2Id`, `t1`.`Name` DESC"); + ) AS `l4` + WHERE 1 < `l4`.`row` +) AS `l5` ON `l`.`Id` = `l5`.`OneToMany_Required_Inverse2Id` +ORDER BY `l`.`Id`, `l3`.`OneToMany_Optional_Inverse2Id`, `l3`.`Name`, `l3`.`Id`, `l5`.`OneToMany_Required_Inverse2Id`, `l5`.`Name` DESC +"""); } public override async Task Filtered_include_after_different_filtered_include_different_level(bool async) { await base.Filtered_include_after_different_filtered_include_different_level(async); - AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t2`.`Id`, `t2`.`Date`, `t2`.`Level1_Optional_Id`, `t2`.`Level1_Required_Id`, `t2`.`Name`, `t2`.`OneToMany_Optional_Inverse2Id`, `t2`.`OneToMany_Optional_Self_Inverse2Id`, `t2`.`OneToMany_Required_Inverse2Id`, `t2`.`OneToMany_Required_Self_Inverse2Id`, `t2`.`OneToOne_Optional_PK_Inverse2Id`, `t2`.`OneToOne_Optional_Self2Id`, `t2`.`Id0`, `t2`.`Level2_Optional_Id`, `t2`.`Level2_Required_Id`, `t2`.`Name0`, `t2`.`OneToMany_Optional_Inverse3Id`, `t2`.`OneToMany_Optional_Self_Inverse3Id`, `t2`.`OneToMany_Required_Inverse3Id`, `t2`.`OneToMany_Required_Self_Inverse3Id`, `t2`.`OneToOne_Optional_PK_Inverse3Id`, `t2`.`OneToOne_Optional_Self3Id` + AssertSql( +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id` FROM `LevelOne` AS `l` LEFT JOIN LATERAL ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `t0`.`Id` AS `Id0`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name` AS `Name0`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l4`.`Id` AS `Id0`, `l4`.`Level2_Optional_Id`, `l4`.`Level2_Required_Id`, `l4`.`Name` AS `Name0`, `l4`.`OneToMany_Optional_Inverse3Id`, `l4`.`OneToMany_Optional_Self_Inverse3Id`, `l4`.`OneToMany_Required_Inverse3Id`, `l4`.`OneToMany_Required_Self_Inverse3Id`, `l4`.`OneToOne_Optional_PK_Inverse3Id`, `l4`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` FROM `LevelTwo` AS `l0` WHERE (`l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id`) AND ((`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL) ORDER BY `l0`.`Name` LIMIT 3 - ) AS `t` + ) AS `l2` LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`Level2_Optional_Id`, `t1`.`Level2_Required_Id`, `t1`.`Name`, `t1`.`OneToMany_Optional_Inverse3Id`, `t1`.`OneToMany_Optional_Self_Inverse3Id`, `t1`.`OneToMany_Required_Inverse3Id`, `t1`.`OneToMany_Required_Self_Inverse3Id`, `t1`.`OneToOne_Optional_PK_Inverse3Id`, `t1`.`OneToOne_Optional_Self3Id` + SELECT `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Required_Inverse3Id` ORDER BY `l1`.`Name` DESC) AS `row` FROM `LevelThree` AS `l1` WHERE (`l1`.`Name` <> 'Bar') OR `l1`.`Name` IS NULL - ) AS `t1` - WHERE 1 < `t1`.`row` - ) AS `t0` ON `t`.`Id` = `t0`.`OneToMany_Required_Inverse3Id` -) AS `t2` ON TRUE -ORDER BY `l`.`Id`, `t2`.`Name`, `t2`.`Id`, `t2`.`OneToMany_Required_Inverse3Id`, `t2`.`Name0` DESC"); + ) AS `l3` + WHERE 1 < `l3`.`row` + ) AS `l4` ON `l2`.`Id` = `l4`.`OneToMany_Required_Inverse3Id` +) AS `s` ON TRUE +ORDER BY `l`.`Id`, `s`.`Name`, `s`.`Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`Name0` DESC +"""); } public override async Task Filtered_include_same_filter_set_on_same_navigation_twice(bool async) @@ -1152,18 +1217,20 @@ public override async Task Filtered_include_same_filter_set_on_same_navigation_t await base.Filtered_include_same_filter_set_on_same_navigation_twice(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id` DESC) AS `row` FROM `LevelTwo` AS `l0` WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 2 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Id` DESC"); + ) AS `l1` + WHERE `l1`.`row` <= 2 +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`Id` DESC +"""); } public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) @@ -1171,21 +1238,23 @@ public override async Task Filtered_include_same_filter_set_on_same_navigation_t await base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `t0`.`Id0`, `t0`.`Id1`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id`, `t0`.`Level2_Optional_Id0`, `t0`.`Level2_Required_Id0`, `t0`.`Name1`, `t0`.`OneToMany_Optional_Inverse3Id0`, `t0`.`OneToMany_Optional_Self_Inverse3Id0`, `t0`.`OneToMany_Required_Inverse3Id0`, `t0`.`OneToMany_Required_Self_Inverse3Id0`, `t0`.`OneToOne_Optional_PK_Inverse3Id0`, `t0`.`OneToOne_Optional_Self3Id0` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `s`.`Level2_Optional_Id0`, `s`.`Level2_Required_Id0`, `s`.`Name1`, `s`.`OneToMany_Optional_Inverse3Id0`, `s`.`OneToMany_Optional_Self_Inverse3Id0`, `s`.`OneToMany_Required_Inverse3Id0`, `s`.`OneToMany_Required_Self_Inverse3Id0`, `s`.`OneToOne_Optional_PK_Inverse3Id0`, `s`.`OneToOne_Optional_Self3Id0` FROM `LevelOne` AS `l` LEFT JOIN LATERAL ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `l0`.`Id` AS `Id0`, `l1`.`Id` AS `Id1`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l0`.`Level2_Optional_Id` AS `Level2_Optional_Id0`, `l0`.`Level2_Required_Id` AS `Level2_Required_Id0`, `l0`.`Name` AS `Name1`, `l0`.`OneToMany_Optional_Inverse3Id` AS `OneToMany_Optional_Inverse3Id0`, `l0`.`OneToMany_Optional_Self_Inverse3Id` AS `OneToMany_Optional_Self_Inverse3Id0`, `l0`.`OneToMany_Required_Inverse3Id` AS `OneToMany_Required_Inverse3Id0`, `l0`.`OneToMany_Required_Self_Inverse3Id` AS `OneToMany_Required_Self_Inverse3Id0`, `l0`.`OneToOne_Optional_PK_Inverse3Id` AS `OneToOne_Optional_PK_Inverse3Id0`, `l0`.`OneToOne_Optional_Self3Id` AS `OneToOne_Optional_Self3Id0` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l3`.`Id` AS `Id1`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name` AS `Name0`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id`, `l1`.`Level2_Optional_Id` AS `Level2_Optional_Id0`, `l1`.`Level2_Required_Id` AS `Level2_Required_Id0`, `l1`.`Name` AS `Name1`, `l1`.`OneToMany_Optional_Inverse3Id` AS `OneToMany_Optional_Inverse3Id0`, `l1`.`OneToMany_Optional_Self_Inverse3Id` AS `OneToMany_Optional_Self_Inverse3Id0`, `l1`.`OneToMany_Required_Inverse3Id` AS `OneToMany_Required_Inverse3Id0`, `l1`.`OneToMany_Required_Self_Inverse3Id` AS `OneToMany_Required_Self_Inverse3Id0`, `l1`.`OneToOne_Optional_PK_Inverse3Id` AS `OneToOne_Optional_PK_Inverse3Id0`, `l1`.`OneToOne_Optional_Self3Id` AS `OneToOne_Optional_Self3Id0` FROM ( - SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` - FROM `LevelTwo` AS `l2` - WHERE (`l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id`) AND ((`l2`.`Name` <> 'Foo') OR `l2`.`Name` IS NULL) - ORDER BY `l2`.`Id` + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` + FROM `LevelTwo` AS `l0` + WHERE (`l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id`) AND ((`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL) + ORDER BY `l0`.`Id` LIMIT 2 - ) AS `t` - LEFT JOIN `LevelThree` AS `l0` ON `t`.`Id` = `l0`.`Level2_Required_Id` - LEFT JOIN `LevelThree` AS `l1` ON `t`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` -) AS `t0` ON TRUE -ORDER BY `l`.`Id`, `t0`.`Id`, `t0`.`Id0`"); + ) AS `l2` + LEFT JOIN `LevelThree` AS `l1` ON `l2`.`Id` = `l1`.`Level2_Required_Id` + LEFT JOIN `LevelThree` AS `l3` ON `l2`.`Id` = `l3`.`OneToMany_Optional_Inverse3Id` +) AS `s` ON TRUE +ORDER BY `l`.`Id`, `s`.`Id`, `s`.`Id0` +"""); } public override async Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async) @@ -1194,21 +1263,23 @@ await base .Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `t0`.`Id0`, `t0`.`Id1`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id`, `t0`.`Level2_Optional_Id0`, `t0`.`Level2_Required_Id0`, `t0`.`Name1`, `t0`.`OneToMany_Optional_Inverse3Id0`, `t0`.`OneToMany_Optional_Self_Inverse3Id0`, `t0`.`OneToMany_Required_Inverse3Id0`, `t0`.`OneToMany_Required_Self_Inverse3Id0`, `t0`.`OneToOne_Optional_PK_Inverse3Id0`, `t0`.`OneToOne_Optional_Self3Id0` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `s`.`Level2_Optional_Id0`, `s`.`Level2_Required_Id0`, `s`.`Name1`, `s`.`OneToMany_Optional_Inverse3Id0`, `s`.`OneToMany_Optional_Self_Inverse3Id0`, `s`.`OneToMany_Required_Inverse3Id0`, `s`.`OneToMany_Required_Self_Inverse3Id0`, `s`.`OneToOne_Optional_PK_Inverse3Id0`, `s`.`OneToOne_Optional_Self3Id0` FROM `LevelOne` AS `l` LEFT JOIN LATERAL ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `l0`.`Id` AS `Id0`, `l1`.`Id` AS `Id1`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l0`.`Level2_Optional_Id` AS `Level2_Optional_Id0`, `l0`.`Level2_Required_Id` AS `Level2_Required_Id0`, `l0`.`Name` AS `Name1`, `l0`.`OneToMany_Optional_Inverse3Id` AS `OneToMany_Optional_Inverse3Id0`, `l0`.`OneToMany_Optional_Self_Inverse3Id` AS `OneToMany_Optional_Self_Inverse3Id0`, `l0`.`OneToMany_Required_Inverse3Id` AS `OneToMany_Required_Inverse3Id0`, `l0`.`OneToMany_Required_Self_Inverse3Id` AS `OneToMany_Required_Self_Inverse3Id0`, `l0`.`OneToOne_Optional_PK_Inverse3Id` AS `OneToOne_Optional_PK_Inverse3Id0`, `l0`.`OneToOne_Optional_Self3Id` AS `OneToOne_Optional_Self3Id0` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l3`.`Id` AS `Id1`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name` AS `Name0`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id`, `l1`.`Level2_Optional_Id` AS `Level2_Optional_Id0`, `l1`.`Level2_Required_Id` AS `Level2_Required_Id0`, `l1`.`Name` AS `Name1`, `l1`.`OneToMany_Optional_Inverse3Id` AS `OneToMany_Optional_Inverse3Id0`, `l1`.`OneToMany_Optional_Self_Inverse3Id` AS `OneToMany_Optional_Self_Inverse3Id0`, `l1`.`OneToMany_Required_Inverse3Id` AS `OneToMany_Required_Inverse3Id0`, `l1`.`OneToMany_Required_Self_Inverse3Id` AS `OneToMany_Required_Self_Inverse3Id0`, `l1`.`OneToOne_Optional_PK_Inverse3Id` AS `OneToOne_Optional_PK_Inverse3Id0`, `l1`.`OneToOne_Optional_Self3Id` AS `OneToOne_Optional_Self3Id0` FROM ( - SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` - FROM `LevelTwo` AS `l2` - WHERE (`l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id`) AND ((`l2`.`Name` <> 'Foo') OR `l2`.`Name` IS NULL) - ORDER BY `l2`.`Id` + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` + FROM `LevelTwo` AS `l0` + WHERE (`l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id`) AND ((`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL) + ORDER BY `l0`.`Id` LIMIT 2 - ) AS `t` - LEFT JOIN `LevelThree` AS `l0` ON `t`.`Id` = `l0`.`Level2_Required_Id` - LEFT JOIN `LevelThree` AS `l1` ON `t`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` -) AS `t0` ON TRUE -ORDER BY `l`.`Id`, `t0`.`Id`, `t0`.`Id0`"); + ) AS `l2` + LEFT JOIN `LevelThree` AS `l1` ON `l2`.`Id` = `l1`.`Level2_Required_Id` + LEFT JOIN `LevelThree` AS `l3` ON `l2`.`Id` = `l3`.`OneToMany_Optional_Inverse3Id` +) AS `s` ON TRUE +ORDER BY `l`.`Id`, `s`.`Id`, `s`.`Id0` +"""); } public override async Task Filtered_include_and_non_filtered_include_on_same_navigation1(bool async) @@ -1216,18 +1287,20 @@ public override async Task Filtered_include_and_non_filtered_include_on_same_nav await base.Filtered_include_and_non_filtered_include_on_same_navigation1(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 3 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Id`"); + ) AS `l1` + WHERE `l1`.`row` <= 3 +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`Id` +"""); } public override async Task Filtered_include_and_non_filtered_include_on_same_navigation2(bool async) @@ -1235,18 +1308,20 @@ public override async Task Filtered_include_and_non_filtered_include_on_same_nav await base.Filtered_include_and_non_filtered_include_on_same_navigation2(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 3 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Id`"); + ) AS `l1` + WHERE `l1`.`row` <= 3 +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`Id` +"""); } public override async Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) @@ -1254,25 +1329,27 @@ public override async Task Filtered_include_and_non_filtered_include_followed_by await base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t1`.`Id`, `t1`.`Date`, `t1`.`Level1_Optional_Id`, `t1`.`Level1_Required_Id`, `t1`.`Name`, `t1`.`OneToMany_Optional_Inverse2Id`, `t1`.`OneToMany_Optional_Self_Inverse2Id`, `t1`.`OneToMany_Required_Inverse2Id`, `t1`.`OneToMany_Required_Self_Inverse2Id`, `t1`.`OneToOne_Optional_PK_Inverse2Id`, `t1`.`OneToOne_Optional_Self2Id`, `t1`.`Id0`, `t1`.`Level2_Optional_Id`, `t1`.`Level2_Required_Id`, `t1`.`Name0`, `t1`.`OneToMany_Optional_Inverse3Id`, `t1`.`OneToMany_Optional_Self_Inverse3Id`, `t1`.`OneToMany_Required_Inverse3Id`, `t1`.`OneToMany_Required_Self_Inverse3Id`, `t1`.`OneToOne_Optional_PK_Inverse3Id`, `t1`.`OneToOne_Optional_Self3Id`, `t1`.`Id1`, `t1`.`Level3_Optional_Id`, `t1`.`Level3_Required_Id`, `t1`.`Name1`, `t1`.`OneToMany_Optional_Inverse4Id`, `t1`.`OneToMany_Optional_Self_Inverse4Id`, `t1`.`OneToMany_Required_Inverse4Id`, `t1`.`OneToMany_Required_Self_Inverse4Id`, `t1`.`OneToOne_Optional_PK_Inverse4Id`, `t1`.`OneToOne_Optional_Self4Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `s`.`Id1`, `s`.`Level3_Optional_Id`, `s`.`Level3_Required_Id`, `s`.`Name1`, `s`.`OneToMany_Optional_Inverse4Id`, `s`.`OneToMany_Optional_Self_Inverse4Id`, `s`.`OneToMany_Required_Inverse4Id`, `s`.`OneToMany_Required_Self_Inverse4Id`, `s`.`OneToOne_Optional_PK_Inverse4Id`, `s`.`OneToOne_Optional_Self4Id` FROM `LevelOne` AS `l` LEFT JOIN LATERAL ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `l0`.`Id` AS `Id0`, `l0`.`Level2_Optional_Id`, `l0`.`Level2_Required_Id`, `l0`.`Name` AS `Name0`, `l0`.`OneToMany_Optional_Inverse3Id`, `l0`.`OneToMany_Optional_Self_Inverse3Id`, `l0`.`OneToMany_Required_Inverse3Id`, `l0`.`OneToMany_Required_Self_Inverse3Id`, `l0`.`OneToOne_Optional_PK_Inverse3Id`, `l0`.`OneToOne_Optional_Self3Id`, `t0`.`Id` AS `Id1`, `t0`.`Level3_Optional_Id`, `t0`.`Level3_Required_Id`, `t0`.`Name` AS `Name1`, `t0`.`OneToMany_Optional_Inverse4Id`, `t0`.`OneToMany_Optional_Self_Inverse4Id`, `t0`.`OneToMany_Required_Inverse4Id`, `t0`.`OneToMany_Required_Self_Inverse4Id`, `t0`.`OneToOne_Optional_PK_Inverse4Id`, `t0`.`OneToOne_Optional_Self4Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l4`.`Id` AS `Id1`, `l4`.`Level3_Optional_Id`, `l4`.`Level3_Required_Id`, `l4`.`Name` AS `Name1`, `l4`.`OneToMany_Optional_Inverse4Id`, `l4`.`OneToMany_Optional_Self_Inverse4Id`, `l4`.`OneToMany_Required_Inverse4Id`, `l4`.`OneToMany_Required_Self_Inverse4Id`, `l4`.`OneToOne_Optional_PK_Inverse4Id`, `l4`.`OneToOne_Optional_Self4Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` - FROM `LevelTwo` AS `l1` - WHERE (`l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id`) AND ((`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL) - ORDER BY `l1`.`Id` + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` + FROM `LevelTwo` AS `l0` + WHERE (`l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id`) AND ((`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL) + ORDER BY `l0`.`Id` LIMIT 1 - ) AS `t` - LEFT JOIN `LevelThree` AS `l0` ON `t`.`Id` = `l0`.`OneToOne_Optional_PK_Inverse3Id` + ) AS `l2` + LEFT JOIN `LevelThree` AS `l1` ON `l2`.`Id` = `l1`.`OneToOne_Optional_PK_Inverse3Id` LEFT JOIN ( - SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id` - FROM `LevelFour` AS `l2` - WHERE `l2`.`Id` > 1 - ) AS `t0` ON `l0`.`Id` = `t0`.`OneToMany_Optional_Inverse4Id` -) AS `t1` ON TRUE -ORDER BY `l`.`Id`, `t1`.`Id`, `t1`.`Id0`"); + SELECT `l3`.`Id`, `l3`.`Level3_Optional_Id`, `l3`.`Level3_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse4Id`, `l3`.`OneToMany_Optional_Self_Inverse4Id`, `l3`.`OneToMany_Required_Inverse4Id`, `l3`.`OneToMany_Required_Self_Inverse4Id`, `l3`.`OneToOne_Optional_PK_Inverse4Id`, `l3`.`OneToOne_Optional_Self4Id` + FROM `LevelFour` AS `l3` + WHERE `l3`.`Id` > 1 + ) AS `l4` ON `l1`.`Id` = `l4`.`OneToMany_Optional_Inverse4Id` +) AS `s` ON TRUE +ORDER BY `l`.`Id`, `s`.`Id`, `s`.`Id0` +"""); } public override async Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) @@ -1280,25 +1357,27 @@ public override async Task Filtered_include_complex_three_level_with_middle_havi await base.Filtered_include_complex_three_level_with_middle_having_filter1(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t1`.`Id`, `t1`.`Date`, `t1`.`Level1_Optional_Id`, `t1`.`Level1_Required_Id`, `t1`.`Name`, `t1`.`OneToMany_Optional_Inverse2Id`, `t1`.`OneToMany_Optional_Self_Inverse2Id`, `t1`.`OneToMany_Required_Inverse2Id`, `t1`.`OneToMany_Required_Self_Inverse2Id`, `t1`.`OneToOne_Optional_PK_Inverse2Id`, `t1`.`OneToOne_Optional_Self2Id`, `t1`.`Id0`, `t1`.`Level2_Optional_Id`, `t1`.`Level2_Required_Id`, `t1`.`Name0`, `t1`.`OneToMany_Optional_Inverse3Id`, `t1`.`OneToMany_Optional_Self_Inverse3Id`, `t1`.`OneToMany_Required_Inverse3Id`, `t1`.`OneToMany_Required_Self_Inverse3Id`, `t1`.`OneToOne_Optional_PK_Inverse3Id`, `t1`.`OneToOne_Optional_Self3Id`, `t1`.`Id00`, `t1`.`Level3_Optional_Id`, `t1`.`Level3_Required_Id`, `t1`.`Name00`, `t1`.`OneToMany_Optional_Inverse4Id`, `t1`.`OneToMany_Optional_Self_Inverse4Id`, `t1`.`OneToMany_Required_Inverse4Id`, `t1`.`OneToMany_Required_Self_Inverse4Id`, `t1`.`OneToOne_Optional_PK_Inverse4Id`, `t1`.`OneToOne_Optional_Self4Id`, `t1`.`Id1`, `t1`.`Level3_Optional_Id0`, `t1`.`Level3_Required_Id0`, `t1`.`Name1`, `t1`.`OneToMany_Optional_Inverse4Id0`, `t1`.`OneToMany_Optional_Self_Inverse4Id0`, `t1`.`OneToMany_Required_Inverse4Id0`, `t1`.`OneToMany_Required_Self_Inverse4Id0`, `t1`.`OneToOne_Optional_PK_Inverse4Id0`, `t1`.`OneToOne_Optional_Self4Id0` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `s0`.`Id`, `s0`.`Date`, `s0`.`Level1_Optional_Id`, `s0`.`Level1_Required_Id`, `s0`.`Name`, `s0`.`OneToMany_Optional_Inverse2Id`, `s0`.`OneToMany_Optional_Self_Inverse2Id`, `s0`.`OneToMany_Required_Inverse2Id`, `s0`.`OneToMany_Required_Self_Inverse2Id`, `s0`.`OneToOne_Optional_PK_Inverse2Id`, `s0`.`OneToOne_Optional_Self2Id`, `s0`.`Id0`, `s0`.`Level2_Optional_Id`, `s0`.`Level2_Required_Id`, `s0`.`Name0`, `s0`.`OneToMany_Optional_Inverse3Id`, `s0`.`OneToMany_Optional_Self_Inverse3Id`, `s0`.`OneToMany_Required_Inverse3Id`, `s0`.`OneToMany_Required_Self_Inverse3Id`, `s0`.`OneToOne_Optional_PK_Inverse3Id`, `s0`.`OneToOne_Optional_Self3Id`, `s0`.`Id00`, `s0`.`Level3_Optional_Id`, `s0`.`Level3_Required_Id`, `s0`.`Name00`, `s0`.`OneToMany_Optional_Inverse4Id`, `s0`.`OneToMany_Optional_Self_Inverse4Id`, `s0`.`OneToMany_Required_Inverse4Id`, `s0`.`OneToMany_Required_Self_Inverse4Id`, `s0`.`OneToOne_Optional_PK_Inverse4Id`, `s0`.`OneToOne_Optional_Self4Id`, `s0`.`Id1`, `s0`.`Level3_Optional_Id0`, `s0`.`Level3_Required_Id0`, `s0`.`Name1`, `s0`.`OneToMany_Optional_Inverse4Id0`, `s0`.`OneToMany_Optional_Self_Inverse4Id0`, `s0`.`OneToMany_Required_Inverse4Id0`, `s0`.`OneToMany_Required_Self_Inverse4Id0`, `s0`.`OneToOne_Optional_PK_Inverse4Id0`, `s0`.`OneToOne_Optional_Self4Id0` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `t0`.`Id` AS `Id0`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name` AS `Name0`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id`, `t0`.`Id0` AS `Id00`, `t0`.`Level3_Optional_Id`, `t0`.`Level3_Required_Id`, `t0`.`Name0` AS `Name00`, `t0`.`OneToMany_Optional_Inverse4Id`, `t0`.`OneToMany_Optional_Self_Inverse4Id`, `t0`.`OneToMany_Required_Inverse4Id`, `t0`.`OneToMany_Required_Self_Inverse4Id`, `t0`.`OneToOne_Optional_PK_Inverse4Id`, `t0`.`OneToOne_Optional_Self4Id`, `t0`.`Id1`, `t0`.`Level3_Optional_Id0`, `t0`.`Level3_Required_Id0`, `t0`.`Name1`, `t0`.`OneToMany_Optional_Inverse4Id0`, `t0`.`OneToMany_Optional_Self_Inverse4Id0`, `t0`.`OneToMany_Required_Inverse4Id0`, `t0`.`OneToMany_Required_Self_Inverse4Id0`, `t0`.`OneToOne_Optional_PK_Inverse4Id0`, `t0`.`OneToOne_Optional_Self4Id0` + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `s`.`Id` AS `Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name` AS `Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `s`.`Id0` AS `Id00`, `s`.`Level3_Optional_Id`, `s`.`Level3_Required_Id`, `s`.`Name0` AS `Name00`, `s`.`OneToMany_Optional_Inverse4Id`, `s`.`OneToMany_Optional_Self_Inverse4Id`, `s`.`OneToMany_Required_Inverse4Id`, `s`.`OneToMany_Required_Self_Inverse4Id`, `s`.`OneToOne_Optional_PK_Inverse4Id`, `s`.`OneToOne_Optional_Self4Id`, `s`.`Id1`, `s`.`Level3_Optional_Id0`, `s`.`Level3_Required_Id0`, `s`.`Name1`, `s`.`OneToMany_Optional_Inverse4Id0`, `s`.`OneToMany_Optional_Self_Inverse4Id0`, `s`.`OneToMany_Required_Inverse4Id0`, `s`.`OneToMany_Required_Self_Inverse4Id0`, `s`.`OneToOne_Optional_PK_Inverse4Id0`, `s`.`OneToOne_Optional_Self4Id0` FROM `LevelTwo` AS `l0` LEFT JOIN LATERAL ( - SELECT `t`.`Id`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id`, `l1`.`Id` AS `Id0`, `l1`.`Level3_Optional_Id`, `l1`.`Level3_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse4Id`, `l1`.`OneToMany_Optional_Self_Inverse4Id`, `l1`.`OneToMany_Required_Inverse4Id`, `l1`.`OneToMany_Required_Self_Inverse4Id`, `l1`.`OneToOne_Optional_PK_Inverse4Id`, `l1`.`OneToOne_Optional_Self4Id`, `l2`.`Id` AS `Id1`, `l2`.`Level3_Optional_Id` AS `Level3_Optional_Id0`, `l2`.`Level3_Required_Id` AS `Level3_Required_Id0`, `l2`.`Name` AS `Name1`, `l2`.`OneToMany_Optional_Inverse4Id` AS `OneToMany_Optional_Inverse4Id0`, `l2`.`OneToMany_Optional_Self_Inverse4Id` AS `OneToMany_Optional_Self_Inverse4Id0`, `l2`.`OneToMany_Required_Inverse4Id` AS `OneToMany_Required_Inverse4Id0`, `l2`.`OneToMany_Required_Self_Inverse4Id` AS `OneToMany_Required_Self_Inverse4Id0`, `l2`.`OneToOne_Optional_PK_Inverse4Id` AS `OneToOne_Optional_PK_Inverse4Id0`, `l2`.`OneToOne_Optional_Self4Id` AS `OneToOne_Optional_Self4Id0` + SELECT `l4`.`Id`, `l4`.`Level2_Optional_Id`, `l4`.`Level2_Required_Id`, `l4`.`Name`, `l4`.`OneToMany_Optional_Inverse3Id`, `l4`.`OneToMany_Optional_Self_Inverse3Id`, `l4`.`OneToMany_Required_Inverse3Id`, `l4`.`OneToMany_Required_Self_Inverse3Id`, `l4`.`OneToOne_Optional_PK_Inverse3Id`, `l4`.`OneToOne_Optional_Self3Id`, `l2`.`Id` AS `Id0`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name` AS `Name0`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l3`.`Id` AS `Id1`, `l3`.`Level3_Optional_Id` AS `Level3_Optional_Id0`, `l3`.`Level3_Required_Id` AS `Level3_Required_Id0`, `l3`.`Name` AS `Name1`, `l3`.`OneToMany_Optional_Inverse4Id` AS `OneToMany_Optional_Inverse4Id0`, `l3`.`OneToMany_Optional_Self_Inverse4Id` AS `OneToMany_Optional_Self_Inverse4Id0`, `l3`.`OneToMany_Required_Inverse4Id` AS `OneToMany_Required_Inverse4Id0`, `l3`.`OneToMany_Required_Self_Inverse4Id` AS `OneToMany_Required_Self_Inverse4Id0`, `l3`.`OneToOne_Optional_PK_Inverse4Id` AS `OneToOne_Optional_PK_Inverse4Id0`, `l3`.`OneToOne_Optional_Self4Id` AS `OneToOne_Optional_Self4Id0` FROM ( - SELECT `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id` - FROM `LevelThree` AS `l3` - WHERE (`l0`.`Id` = `l3`.`OneToMany_Optional_Inverse3Id`) AND ((`l3`.`Name` <> 'Foo') OR `l3`.`Name` IS NULL) - ORDER BY `l3`.`Id` + SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` + FROM `LevelThree` AS `l1` + WHERE (`l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id`) AND ((`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL) + ORDER BY `l1`.`Id` LIMIT 1 - ) AS `t` - LEFT JOIN `LevelFour` AS `l1` ON `t`.`Id` = `l1`.`OneToMany_Optional_Inverse4Id` - LEFT JOIN `LevelFour` AS `l2` ON `t`.`Id` = `l2`.`OneToMany_Required_Inverse4Id` - ) AS `t0` ON TRUE -) AS `t1` ON `l`.`Id` = `t1`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t1`.`Id`, `t1`.`Id0`, `t1`.`Id00`"); + ) AS `l4` + LEFT JOIN `LevelFour` AS `l2` ON `l4`.`Id` = `l2`.`OneToMany_Optional_Inverse4Id` + LEFT JOIN `LevelFour` AS `l3` ON `l4`.`Id` = `l3`.`OneToMany_Required_Inverse4Id` + ) AS `s` ON TRUE +) AS `s0` ON `l`.`Id` = `s0`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `s0`.`Id`, `s0`.`Id0`, `s0`.`Id00` +"""); } public override async Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async) @@ -1306,25 +1385,27 @@ public override async Task Filtered_include_complex_three_level_with_middle_havi await base.Filtered_include_complex_three_level_with_middle_having_filter2(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t1`.`Id`, `t1`.`Date`, `t1`.`Level1_Optional_Id`, `t1`.`Level1_Required_Id`, `t1`.`Name`, `t1`.`OneToMany_Optional_Inverse2Id`, `t1`.`OneToMany_Optional_Self_Inverse2Id`, `t1`.`OneToMany_Required_Inverse2Id`, `t1`.`OneToMany_Required_Self_Inverse2Id`, `t1`.`OneToOne_Optional_PK_Inverse2Id`, `t1`.`OneToOne_Optional_Self2Id`, `t1`.`Id0`, `t1`.`Level2_Optional_Id`, `t1`.`Level2_Required_Id`, `t1`.`Name0`, `t1`.`OneToMany_Optional_Inverse3Id`, `t1`.`OneToMany_Optional_Self_Inverse3Id`, `t1`.`OneToMany_Required_Inverse3Id`, `t1`.`OneToMany_Required_Self_Inverse3Id`, `t1`.`OneToOne_Optional_PK_Inverse3Id`, `t1`.`OneToOne_Optional_Self3Id`, `t1`.`Id00`, `t1`.`Level3_Optional_Id`, `t1`.`Level3_Required_Id`, `t1`.`Name00`, `t1`.`OneToMany_Optional_Inverse4Id`, `t1`.`OneToMany_Optional_Self_Inverse4Id`, `t1`.`OneToMany_Required_Inverse4Id`, `t1`.`OneToMany_Required_Self_Inverse4Id`, `t1`.`OneToOne_Optional_PK_Inverse4Id`, `t1`.`OneToOne_Optional_Self4Id`, `t1`.`Id1`, `t1`.`Level3_Optional_Id0`, `t1`.`Level3_Required_Id0`, `t1`.`Name1`, `t1`.`OneToMany_Optional_Inverse4Id0`, `t1`.`OneToMany_Optional_Self_Inverse4Id0`, `t1`.`OneToMany_Required_Inverse4Id0`, `t1`.`OneToMany_Required_Self_Inverse4Id0`, `t1`.`OneToOne_Optional_PK_Inverse4Id0`, `t1`.`OneToOne_Optional_Self4Id0` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `s0`.`Id`, `s0`.`Date`, `s0`.`Level1_Optional_Id`, `s0`.`Level1_Required_Id`, `s0`.`Name`, `s0`.`OneToMany_Optional_Inverse2Id`, `s0`.`OneToMany_Optional_Self_Inverse2Id`, `s0`.`OneToMany_Required_Inverse2Id`, `s0`.`OneToMany_Required_Self_Inverse2Id`, `s0`.`OneToOne_Optional_PK_Inverse2Id`, `s0`.`OneToOne_Optional_Self2Id`, `s0`.`Id0`, `s0`.`Level2_Optional_Id`, `s0`.`Level2_Required_Id`, `s0`.`Name0`, `s0`.`OneToMany_Optional_Inverse3Id`, `s0`.`OneToMany_Optional_Self_Inverse3Id`, `s0`.`OneToMany_Required_Inverse3Id`, `s0`.`OneToMany_Required_Self_Inverse3Id`, `s0`.`OneToOne_Optional_PK_Inverse3Id`, `s0`.`OneToOne_Optional_Self3Id`, `s0`.`Id00`, `s0`.`Level3_Optional_Id`, `s0`.`Level3_Required_Id`, `s0`.`Name00`, `s0`.`OneToMany_Optional_Inverse4Id`, `s0`.`OneToMany_Optional_Self_Inverse4Id`, `s0`.`OneToMany_Required_Inverse4Id`, `s0`.`OneToMany_Required_Self_Inverse4Id`, `s0`.`OneToOne_Optional_PK_Inverse4Id`, `s0`.`OneToOne_Optional_Self4Id`, `s0`.`Id1`, `s0`.`Level3_Optional_Id0`, `s0`.`Level3_Required_Id0`, `s0`.`Name1`, `s0`.`OneToMany_Optional_Inverse4Id0`, `s0`.`OneToMany_Optional_Self_Inverse4Id0`, `s0`.`OneToMany_Required_Inverse4Id0`, `s0`.`OneToMany_Required_Self_Inverse4Id0`, `s0`.`OneToOne_Optional_PK_Inverse4Id0`, `s0`.`OneToOne_Optional_Self4Id0` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `t0`.`Id` AS `Id0`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name` AS `Name0`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id`, `t0`.`Id0` AS `Id00`, `t0`.`Level3_Optional_Id`, `t0`.`Level3_Required_Id`, `t0`.`Name0` AS `Name00`, `t0`.`OneToMany_Optional_Inverse4Id`, `t0`.`OneToMany_Optional_Self_Inverse4Id`, `t0`.`OneToMany_Required_Inverse4Id`, `t0`.`OneToMany_Required_Self_Inverse4Id`, `t0`.`OneToOne_Optional_PK_Inverse4Id`, `t0`.`OneToOne_Optional_Self4Id`, `t0`.`Id1`, `t0`.`Level3_Optional_Id0`, `t0`.`Level3_Required_Id0`, `t0`.`Name1`, `t0`.`OneToMany_Optional_Inverse4Id0`, `t0`.`OneToMany_Optional_Self_Inverse4Id0`, `t0`.`OneToMany_Required_Inverse4Id0`, `t0`.`OneToMany_Required_Self_Inverse4Id0`, `t0`.`OneToOne_Optional_PK_Inverse4Id0`, `t0`.`OneToOne_Optional_Self4Id0` + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `s`.`Id` AS `Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name` AS `Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `s`.`Id0` AS `Id00`, `s`.`Level3_Optional_Id`, `s`.`Level3_Required_Id`, `s`.`Name0` AS `Name00`, `s`.`OneToMany_Optional_Inverse4Id`, `s`.`OneToMany_Optional_Self_Inverse4Id`, `s`.`OneToMany_Required_Inverse4Id`, `s`.`OneToMany_Required_Self_Inverse4Id`, `s`.`OneToOne_Optional_PK_Inverse4Id`, `s`.`OneToOne_Optional_Self4Id`, `s`.`Id1`, `s`.`Level3_Optional_Id0`, `s`.`Level3_Required_Id0`, `s`.`Name1`, `s`.`OneToMany_Optional_Inverse4Id0`, `s`.`OneToMany_Optional_Self_Inverse4Id0`, `s`.`OneToMany_Required_Inverse4Id0`, `s`.`OneToMany_Required_Self_Inverse4Id0`, `s`.`OneToOne_Optional_PK_Inverse4Id0`, `s`.`OneToOne_Optional_Self4Id0` FROM `LevelTwo` AS `l0` LEFT JOIN LATERAL ( - SELECT `t`.`Id`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id`, `l1`.`Id` AS `Id0`, `l1`.`Level3_Optional_Id`, `l1`.`Level3_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse4Id`, `l1`.`OneToMany_Optional_Self_Inverse4Id`, `l1`.`OneToMany_Required_Inverse4Id`, `l1`.`OneToMany_Required_Self_Inverse4Id`, `l1`.`OneToOne_Optional_PK_Inverse4Id`, `l1`.`OneToOne_Optional_Self4Id`, `l2`.`Id` AS `Id1`, `l2`.`Level3_Optional_Id` AS `Level3_Optional_Id0`, `l2`.`Level3_Required_Id` AS `Level3_Required_Id0`, `l2`.`Name` AS `Name1`, `l2`.`OneToMany_Optional_Inverse4Id` AS `OneToMany_Optional_Inverse4Id0`, `l2`.`OneToMany_Optional_Self_Inverse4Id` AS `OneToMany_Optional_Self_Inverse4Id0`, `l2`.`OneToMany_Required_Inverse4Id` AS `OneToMany_Required_Inverse4Id0`, `l2`.`OneToMany_Required_Self_Inverse4Id` AS `OneToMany_Required_Self_Inverse4Id0`, `l2`.`OneToOne_Optional_PK_Inverse4Id` AS `OneToOne_Optional_PK_Inverse4Id0`, `l2`.`OneToOne_Optional_Self4Id` AS `OneToOne_Optional_Self4Id0` + SELECT `l4`.`Id`, `l4`.`Level2_Optional_Id`, `l4`.`Level2_Required_Id`, `l4`.`Name`, `l4`.`OneToMany_Optional_Inverse3Id`, `l4`.`OneToMany_Optional_Self_Inverse3Id`, `l4`.`OneToMany_Required_Inverse3Id`, `l4`.`OneToMany_Required_Self_Inverse3Id`, `l4`.`OneToOne_Optional_PK_Inverse3Id`, `l4`.`OneToOne_Optional_Self3Id`, `l2`.`Id` AS `Id0`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name` AS `Name0`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l3`.`Id` AS `Id1`, `l3`.`Level3_Optional_Id` AS `Level3_Optional_Id0`, `l3`.`Level3_Required_Id` AS `Level3_Required_Id0`, `l3`.`Name` AS `Name1`, `l3`.`OneToMany_Optional_Inverse4Id` AS `OneToMany_Optional_Inverse4Id0`, `l3`.`OneToMany_Optional_Self_Inverse4Id` AS `OneToMany_Optional_Self_Inverse4Id0`, `l3`.`OneToMany_Required_Inverse4Id` AS `OneToMany_Required_Inverse4Id0`, `l3`.`OneToMany_Required_Self_Inverse4Id` AS `OneToMany_Required_Self_Inverse4Id0`, `l3`.`OneToOne_Optional_PK_Inverse4Id` AS `OneToOne_Optional_PK_Inverse4Id0`, `l3`.`OneToOne_Optional_Self4Id` AS `OneToOne_Optional_Self4Id0` FROM ( - SELECT `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id` - FROM `LevelThree` AS `l3` - WHERE (`l0`.`Id` = `l3`.`OneToMany_Optional_Inverse3Id`) AND ((`l3`.`Name` <> 'Foo') OR `l3`.`Name` IS NULL) - ORDER BY `l3`.`Id` + SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` + FROM `LevelThree` AS `l1` + WHERE (`l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id`) AND ((`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL) + ORDER BY `l1`.`Id` LIMIT 1 - ) AS `t` - LEFT JOIN `LevelFour` AS `l1` ON `t`.`Id` = `l1`.`OneToMany_Optional_Inverse4Id` - LEFT JOIN `LevelFour` AS `l2` ON `t`.`Id` = `l2`.`OneToMany_Required_Inverse4Id` - ) AS `t0` ON TRUE -) AS `t1` ON `l`.`Id` = `t1`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t1`.`Id`, `t1`.`Id0`, `t1`.`Id00`"); + ) AS `l4` + LEFT JOIN `LevelFour` AS `l2` ON `l4`.`Id` = `l2`.`OneToMany_Optional_Inverse4Id` + LEFT JOIN `LevelFour` AS `l3` ON `l4`.`Id` = `l3`.`OneToMany_Required_Inverse4Id` + ) AS `s` ON TRUE +) AS `s0` ON `l`.`Id` = `s0`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `s0`.`Id`, `s0`.`Id0`, `s0`.`Id00` +"""); } public override async Task Filtered_include_variable_used_inside_filter(bool async) @@ -1332,20 +1413,22 @@ public override async Task Filtered_include_variable_used_inside_filter(bool asy await base.Filtered_include_variable_used_inside_filter(async); AssertSql( - @"@__prm_0='Foo' (Size = 4000) +""" +@__prm_0='Foo' (Size = 4000) -SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id` +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` WHERE (`l0`.`Name` <> @__prm_0) OR `l0`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 3 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Id`"); + ) AS `l1` + WHERE `l1`.`row` <= 3 +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`Id` +"""); } public override async Task Filtered_include_context_accessed_inside_filter(bool async) @@ -1353,23 +1436,27 @@ public override async Task Filtered_include_context_accessed_inside_filter(bool await base.Filtered_include_context_accessed_inside_filter(async); AssertSql( - @"SELECT COUNT(*) -FROM `LevelOne` AS `l`", - // - @"@__p_0='True' +""" +SELECT COUNT(*) +FROM `LevelOne` AS `l` +""", +// +""" +@__p_0='True' -SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id` +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` WHERE @__p_0 - ) AS `t` - WHERE `t`.`row` <= 3 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Id`"); + ) AS `l1` + WHERE `l1`.`row` <= 3 +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`Id` +"""); } [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed.")] @@ -1378,10 +1465,11 @@ public override async Task Filtered_include_context_accessed_inside_filter_corre await base.Filtered_include_context_accessed_inside_filter_correlated(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l3`.`Id`, `l3`.`Date`, `l3`.`Level1_Optional_Id`, `l3`.`Level1_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse2Id`, `l3`.`OneToMany_Optional_Self_Inverse2Id`, `l3`.`OneToMany_Required_Inverse2Id`, `l3`.`OneToMany_Required_Self_Inverse2Id`, `l3`.`OneToOne_Optional_PK_Inverse2Id`, `l3`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` @@ -1389,10 +1477,11 @@ LEFT JOIN ( SELECT COUNT(*) FROM `LevelOne` AS `l1` WHERE `l1`.`Id` <> `l0`.`Id`) > 1 - ) AS `t` - WHERE `t`.`row` <= 3 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Id`"); + ) AS `l2` + WHERE `l2`.`row` <= 3 +) AS `l3` ON `l`.`Id` = `l3`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l3`.`OneToMany_Optional_Inverse2Id`, `l3`.`Id` +"""); } public override async Task Filtered_include_outer_parameter_used_inside_filter(bool async) @@ -1400,23 +1489,25 @@ public override async Task Filtered_include_outer_parameter_used_inside_filter(b await base.Filtered_include_outer_parameter_used_inside_filter(async); AssertSql( - @"SELECT `l`.`Id`, `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `t`.`Id0`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `t0`.`Id0`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id` +""" +SELECT `l`.`Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `s0`.`Id`, `s0`.`Date`, `s0`.`Level1_Optional_Id`, `s0`.`Level1_Required_Id`, `s0`.`Name`, `s0`.`OneToMany_Optional_Inverse2Id`, `s0`.`OneToMany_Optional_Self_Inverse2Id`, `s0`.`OneToMany_Required_Inverse2Id`, `s0`.`OneToMany_Required_Self_Inverse2Id`, `s0`.`OneToOne_Optional_PK_Inverse2Id`, `s0`.`OneToOne_Optional_Self2Id`, `s0`.`Id0`, `s0`.`Level2_Optional_Id`, `s0`.`Level2_Required_Id`, `s0`.`Name0`, `s0`.`OneToMany_Optional_Inverse3Id`, `s0`.`OneToMany_Optional_Self_Inverse3Id`, `s0`.`OneToMany_Required_Inverse3Id`, `s0`.`OneToMany_Required_Self_Inverse3Id`, `s0`.`OneToOne_Optional_PK_Inverse3Id`, `s0`.`OneToOne_Optional_Self3Id` FROM `LevelOne` AS `l` LEFT JOIN LATERAL ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` FROM `LevelTwo` AS `l0` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` -) AS `t` ON TRUE +) AS `s` ON TRUE LEFT JOIN LATERAL ( - SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `t1`.`Id` AS `Id0`, `t1`.`Level2_Optional_Id`, `t1`.`Level2_Required_Id`, `t1`.`Name` AS `Name0`, `t1`.`OneToMany_Optional_Inverse3Id`, `t1`.`OneToMany_Optional_Self_Inverse3Id`, `t1`.`OneToMany_Required_Inverse3Id`, `t1`.`OneToMany_Required_Self_Inverse3Id`, `t1`.`OneToOne_Optional_PK_Inverse3Id`, `t1`.`OneToOne_Optional_Self3Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l4`.`Id` AS `Id0`, `l4`.`Level2_Optional_Id`, `l4`.`Level2_Required_Id`, `l4`.`Name` AS `Name0`, `l4`.`OneToMany_Optional_Inverse3Id`, `l4`.`OneToMany_Optional_Self_Inverse3Id`, `l4`.`OneToMany_Required_Inverse3Id`, `l4`.`OneToMany_Required_Self_Inverse3Id`, `l4`.`OneToOne_Optional_PK_Inverse3Id`, `l4`.`OneToOne_Optional_Self3Id` FROM `LevelTwo` AS `l2` LEFT JOIN ( SELECT `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id` FROM `LevelThree` AS `l3` WHERE `l3`.`Id` <> `l`.`Id` - ) AS `t1` ON `l2`.`Id` = `t1`.`OneToMany_Optional_Inverse3Id` -) AS `t0` ON TRUE -ORDER BY `l`.`Id`, `t`.`Id`, `t`.`Id0`, `t0`.`Id`"); + ) AS `l4` ON `l2`.`Id` = `l4`.`OneToMany_Optional_Inverse3Id` +) AS `s0` ON TRUE +ORDER BY `l`.`Id`, `s`.`Id`, `s`.`Id0`, `s0`.`Id` +"""); } public override async Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async) @@ -1424,26 +1515,28 @@ public override async Task Complex_query_with_let_collection_projection_FirstOrD await base.Complex_query_with_let_collection_projection_FirstOrDefault(async); AssertSql( - @"SELECT `l`.`Id`, `t0`.`Id`, `t1`.`Name`, `t1`.`Id`, `t0`.`c` +""" +SELECT `l`.`Id`, `l4`.`Id`, `l5`.`Name`, `l5`.`Id`, `l4`.`c` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`c`, `t`.`Id`, `t`.`OneToMany_Optional_Inverse2Id` + SELECT `l3`.`c`, `l3`.`Id`, `l3`.`OneToMany_Optional_Inverse2Id` FROM ( SELECT 1 AS `c`, `l0`.`Id`, `l0`.`OneToMany_Optional_Inverse2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` + ) AS `l3` + WHERE `l3`.`row` <= 1 +) AS `l4` ON `l`.`Id` = `l4`.`OneToMany_Optional_Inverse2Id` LEFT JOIN LATERAL ( SELECT `l1`.`Name`, `l1`.`Id` FROM `LevelOne` AS `l1` WHERE EXISTS ( SELECT 1 FROM `LevelTwo` AS `l2` - WHERE (`l1`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id`) AND (`l2`.`Id` = `t0`.`Id`)) -) AS `t1` ON TRUE -ORDER BY `l`.`Id`, `t0`.`Id`"); + WHERE (`l1`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id`) AND (`l2`.`Id` = `l4`.`Id`)) +) AS `l5` ON TRUE +ORDER BY `l`.`Id`, `l4`.`Id` +"""); } public override async Task SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(bool async) @@ -1451,7 +1544,8 @@ public override async Task SelectMany_DefaultIfEmpty_multiple_times_with_joins_p await base.SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(async); AssertSql( - @"SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `t`.`Id`, `t`.`Id0`, `t`.`Id1`, `t`.`Id2`, `t0`.`Id`, `t0`.`Id0`, `t0`.`Id1`, `t0`.`Id2`, `l11`.`Id`, `l12`.`Id`, `l13`.`Id`, `l14`.`Id`, `t1`.`Id`, `t1`.`Date`, `t1`.`Level1_Optional_Id`, `t1`.`Level1_Required_Id`, `t1`.`Name`, `t1`.`OneToMany_Optional_Inverse2Id`, `t1`.`OneToMany_Optional_Self_Inverse2Id`, `t1`.`OneToMany_Required_Inverse2Id`, `t1`.`OneToMany_Required_Self_Inverse2Id`, `t1`.`OneToOne_Optional_PK_Inverse2Id`, `t1`.`OneToOne_Optional_Self2Id`, `l14`.`Name` +""" +SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Id2`, `s0`.`Id`, `s0`.`Id0`, `s0`.`Id1`, `s0`.`Id2`, `l11`.`Id`, `l12`.`Id`, `l13`.`Id`, `l14`.`Id`, `l16`.`Id`, `l16`.`Date`, `l16`.`Level1_Optional_Id`, `l16`.`Level1_Required_Id`, `l16`.`Name`, `l16`.`OneToMany_Optional_Inverse2Id`, `l16`.`OneToMany_Optional_Self_Inverse2Id`, `l16`.`OneToMany_Required_Inverse2Id`, `l16`.`OneToMany_Required_Self_Inverse2Id`, `l16`.`OneToOne_Optional_PK_Inverse2Id`, `l16`.`OneToOne_Optional_Self2Id`, `l14`.`Name` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Required_Id` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Level2_Optional_Id` @@ -1462,25 +1556,26 @@ INNER JOIN ( INNER JOIN `LevelThree` AS `l4` ON `l3`.`Level3_Required_Id` = `l4`.`Id` LEFT JOIN `LevelTwo` AS `l5` ON `l4`.`Level2_Optional_Id` = `l5`.`Id` LEFT JOIN `LevelTwo` AS `l6` ON `l5`.`Id` = `l6`.`OneToMany_Required_Self_Inverse2Id` -) AS `t` ON `l2`.`Id` = `t`.`Id2` +) AS `s` ON `l2`.`Id` = `s`.`Id2` LEFT JOIN ( SELECT `l7`.`Id`, `l8`.`Id` AS `Id0`, `l9`.`Id` AS `Id1`, `l10`.`Id` AS `Id2`, `l10`.`Level2_Optional_Id` AS `Level2_Optional_Id0` FROM `LevelFour` AS `l7` INNER JOIN `LevelThree` AS `l8` ON `l7`.`Level3_Required_Id` = `l8`.`Id` INNER JOIN `LevelTwo` AS `l9` ON `l8`.`Level2_Required_Id` = `l9`.`Id` LEFT JOIN `LevelThree` AS `l10` ON `l9`.`Id` = `l10`.`OneToMany_Required_Inverse3Id` -) AS `t0` ON `t`.`Id2` = `t0`.`Id2` +) AS `s0` ON `s`.`Id2` = `s0`.`Id2` LEFT JOIN `LevelThree` AS `l11` ON `l2`.`OneToMany_Optional_Inverse4Id` = `l11`.`Id` -LEFT JOIN `LevelThree` AS `l12` ON `t`.`Id2` = `l12`.`Level2_Optional_Id` -LEFT JOIN `LevelTwo` AS `l13` ON `t0`.`Level2_Optional_Id0` = `l13`.`Id` +LEFT JOIN `LevelThree` AS `l12` ON `s`.`Id2` = `l12`.`Level2_Optional_Id` +LEFT JOIN `LevelTwo` AS `l13` ON `s0`.`Level2_Optional_Id0` = `l13`.`Id` LEFT JOIN `LevelThree` AS `l14` ON `l13`.`Id` = `l14`.`Level2_Required_Id` LEFT JOIN ( SELECT `l15`.`Id`, `l15`.`Date`, `l15`.`Level1_Optional_Id`, `l15`.`Level1_Required_Id`, `l15`.`Name`, `l15`.`OneToMany_Optional_Inverse2Id`, `l15`.`OneToMany_Optional_Self_Inverse2Id`, `l15`.`OneToMany_Required_Inverse2Id`, `l15`.`OneToMany_Required_Self_Inverse2Id`, `l15`.`OneToOne_Optional_PK_Inverse2Id`, `l15`.`OneToOne_Optional_Self2Id` FROM `LevelTwo` AS `l15` WHERE `l15`.`Id` <> 42 -) AS `t1` ON `t`.`Id2` = `t1`.`OneToMany_Optional_Self_Inverse2Id` +) AS `l16` ON `s`.`Id2` = `l16`.`OneToMany_Optional_Self_Inverse2Id` WHERE (`l11`.`Name` <> 'Foo') OR `l11`.`Name` IS NULL -ORDER BY `l12`.`Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `t`.`Id`, `t`.`Id0`, `t`.`Id1`, `t`.`Id2`, `t0`.`Id`, `t0`.`Id0`, `t0`.`Id1`, `t0`.`Id2`, `l11`.`Id`, `l13`.`Id`, `l14`.`Id`"); +ORDER BY `l12`.`Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Id2`, `s0`.`Id`, `s0`.`Id0`, `s0`.`Id1`, `s0`.`Id2`, `l11`.`Id`, `l13`.`Id`, `l14`.`Id` +"""); } public override async Task Take_Select_collection_Take(bool async) @@ -1488,27 +1583,29 @@ public override async Task Take_Select_collection_Take(bool async) await base.Take_Select_collection_Take(async); AssertSql( - @"@__p_0='1' +""" +@__p_0='1' -SELECT `t`.`Id`, `t`.`Name`, `t0`.`Id`, `t0`.`Name`, `t0`.`Level1Id`, `t0`.`Level2Id`, `t0`.`Id0`, `t0`.`Date`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Self_Inverse1Id`, `t0`.`OneToMany_Required_Self_Inverse1Id`, `t0`.`OneToOne_Optional_Self1Id` +SELECT `l3`.`Id`, `l3`.`Name`, `s`.`Id`, `s`.`Name`, `s`.`Level1Id`, `s`.`Level2Id`, `s`.`Id0`, `s`.`Date`, `s`.`Name0`, `s`.`OneToMany_Optional_Self_Inverse1Id`, `s`.`OneToMany_Required_Self_Inverse1Id`, `s`.`OneToOne_Optional_Self1Id` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` LIMIT @__p_0 -) AS `t` +) AS `l3` LEFT JOIN LATERAL ( - SELECT `t1`.`Id`, `t1`.`Name`, `t1`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `t1`.`Level1_Required_Id` AS `Level2Id`, `l0`.`Id` AS `Id0`, `l0`.`Date`, `l0`.`Name` AS `Name0`, `l0`.`OneToMany_Optional_Self_Inverse1Id`, `l0`.`OneToMany_Required_Self_Inverse1Id`, `l0`.`OneToOne_Optional_Self1Id` + SELECT `l2`.`Id`, `l2`.`Name`, `l2`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `l2`.`Level1_Required_Id` AS `Level2Id`, `l1`.`Id` AS `Id0`, `l1`.`Date`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Required_Inverse2Id` - FROM `LevelTwo` AS `l1` - WHERE `t`.`Id` = `l1`.`OneToMany_Required_Inverse2Id` - ORDER BY `l1`.`Id` + SELECT `l0`.`Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Required_Inverse2Id` + FROM `LevelTwo` AS `l0` + WHERE `l3`.`Id` = `l0`.`OneToMany_Required_Inverse2Id` + ORDER BY `l0`.`Id` LIMIT 3 - ) AS `t1` - INNER JOIN `LevelOne` AS `l0` ON `t1`.`Level1_Required_Id` = `l0`.`Id` -) AS `t0` ON TRUE -ORDER BY `t`.`Id`, `t0`.`Id`"); + ) AS `l2` + INNER JOIN `LevelOne` AS `l1` ON `l2`.`Level1_Required_Id` = `l1`.`Id` +) AS `s` ON TRUE +ORDER BY `l3`.`Id`, `s`.`Id` +"""); } public override async Task Skip_Take_Select_collection_Skip_Take(bool async) @@ -1516,27 +1613,29 @@ public override async Task Skip_Take_Select_collection_Skip_Take(bool async) await base.Skip_Take_Select_collection_Skip_Take(async); AssertSql( - @"@__p_0='1' +""" +@__p_0='1' -SELECT `t`.`Id`, `t`.`Name`, `t0`.`Id`, `t0`.`Name`, `t0`.`Level1Id`, `t0`.`Level2Id`, `t0`.`Id0`, `t0`.`Date`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Self_Inverse1Id`, `t0`.`OneToMany_Required_Self_Inverse1Id`, `t0`.`OneToOne_Optional_Self1Id` +SELECT `l3`.`Id`, `l3`.`Name`, `s`.`Id`, `s`.`Name`, `s`.`Level1Id`, `s`.`Level2Id`, `s`.`Id0`, `s`.`Date`, `s`.`Name0`, `s`.`OneToMany_Optional_Self_Inverse1Id`, `s`.`OneToMany_Required_Self_Inverse1Id`, `s`.`OneToOne_Optional_Self1Id` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` LIMIT @__p_0 OFFSET @__p_0 -) AS `t` +) AS `l3` LEFT JOIN LATERAL ( - SELECT `t1`.`Id`, `t1`.`Name`, `t1`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `t1`.`Level1_Required_Id` AS `Level2Id`, `l0`.`Id` AS `Id0`, `l0`.`Date`, `l0`.`Name` AS `Name0`, `l0`.`OneToMany_Optional_Self_Inverse1Id`, `l0`.`OneToMany_Required_Self_Inverse1Id`, `l0`.`OneToOne_Optional_Self1Id` + SELECT `l2`.`Id`, `l2`.`Name`, `l2`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `l2`.`Level1_Required_Id` AS `Level2Id`, `l1`.`Id` AS `Id0`, `l1`.`Date`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Required_Inverse2Id` - FROM `LevelTwo` AS `l1` - WHERE `t`.`Id` = `l1`.`OneToMany_Required_Inverse2Id` - ORDER BY `l1`.`Id` + SELECT `l0`.`Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Required_Inverse2Id` + FROM `LevelTwo` AS `l0` + WHERE `l3`.`Id` = `l0`.`OneToMany_Required_Inverse2Id` + ORDER BY `l0`.`Id` LIMIT 3 OFFSET 1 - ) AS `t1` - INNER JOIN `LevelOne` AS `l0` ON `t1`.`Level1_Required_Id` = `l0`.`Id` -) AS `t0` ON TRUE -ORDER BY `t`.`Id`, `t0`.`Id`"); + ) AS `l2` + INNER JOIN `LevelOne` AS `l1` ON `l2`.`Level1_Required_Id` = `l1`.`Id` +) AS `s` ON TRUE +ORDER BY `l3`.`Id`, `s`.`Id` +"""); } public override async Task Projecting_collection_with_FirstOrDefault(bool async) @@ -1544,15 +1643,17 @@ public override async Task Projecting_collection_with_FirstOrDefault(bool async) await base.Projecting_collection_with_FirstOrDefault(async); AssertSql( - @"SELECT `t`.`Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l1`.`Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` WHERE `l`.`Id` = 1 LIMIT 1 -) AS `t` -LEFT JOIN `LevelTwo` AS `l0` ON `t`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `t`.`Id`"); +) AS `l1` +LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l1`.`Id` +"""); } public override async Task Filtered_include_Take_with_another_Take_on_top_level(bool async) @@ -1560,27 +1661,29 @@ public override async Task Filtered_include_Take_with_another_Take_on_top_level( await base.Filtered_include_Take_with_another_Take_on_top_level(async); AssertSql( - @"@__p_0='5' +""" +@__p_0='5' -SELECT `t`.`Id`, `t`.`Date`, `t`.`Name`, `t`.`OneToMany_Optional_Self_Inverse1Id`, `t`.`OneToMany_Required_Self_Inverse1Id`, `t`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `t0`.`Id0`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id` +SELECT `l3`.`Id`, `l3`.`Date`, `l3`.`Name`, `l3`.`OneToMany_Optional_Self_Inverse1Id`, `l3`.`OneToMany_Required_Self_Inverse1Id`, `l3`.`OneToOne_Optional_Self1Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` LIMIT @__p_0 -) AS `t` +) AS `l3` LEFT JOIN LATERAL ( - SELECT `t1`.`Id`, `t1`.`Date`, `t1`.`Level1_Optional_Id`, `t1`.`Level1_Required_Id`, `t1`.`Name`, `t1`.`OneToMany_Optional_Inverse2Id`, `t1`.`OneToMany_Optional_Self_Inverse2Id`, `t1`.`OneToMany_Required_Inverse2Id`, `t1`.`OneToMany_Required_Self_Inverse2Id`, `t1`.`OneToOne_Optional_PK_Inverse2Id`, `t1`.`OneToOne_Optional_Self2Id`, `l0`.`Id` AS `Id0`, `l0`.`Level2_Optional_Id`, `l0`.`Level2_Required_Id`, `l0`.`Name` AS `Name0`, `l0`.`OneToMany_Optional_Inverse3Id`, `l0`.`OneToMany_Optional_Self_Inverse3Id`, `l0`.`OneToMany_Required_Inverse3Id`, `l0`.`OneToMany_Required_Self_Inverse3Id`, `l0`.`OneToOne_Optional_PK_Inverse3Id`, `l0`.`OneToOne_Optional_Self3Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` - FROM `LevelTwo` AS `l1` - WHERE `t`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` - ORDER BY `l1`.`Name` DESC + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` + FROM `LevelTwo` AS `l0` + WHERE `l3`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` + ORDER BY `l0`.`Name` DESC LIMIT 4 - ) AS `t1` - LEFT JOIN `LevelThree` AS `l0` ON `t1`.`Id` = `l0`.`Level2_Optional_Id` -) AS `t0` ON TRUE -ORDER BY `t`.`Id`, `t0`.`Name` DESC, `t0`.`Id`"); + ) AS `l2` + LEFT JOIN `LevelThree` AS `l1` ON `l2`.`Id` = `l1`.`Level2_Optional_Id` +) AS `s` ON TRUE +ORDER BY `l3`.`Id`, `s`.`Name` DESC, `s`.`Id` +"""); } public override async Task Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(bool async) @@ -1590,27 +1693,27 @@ public override async Task Filtered_include_Skip_Take_with_another_Skip_Take_on_ AssertSql( """ @__p_1='5' -@__p_0='10' +@__p_0='1' -SELECT `t`.`Id`, `t`.`Date`, `t`.`Name`, `t`.`OneToMany_Optional_Self_Inverse1Id`, `t`.`OneToMany_Required_Self_Inverse1Id`, `t`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `t0`.`Id0`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id` +SELECT `l3`.`Id`, `l3`.`Date`, `l3`.`Name`, `l3`.`OneToMany_Optional_Self_Inverse1Id`, `l3`.`OneToMany_Required_Self_Inverse1Id`, `l3`.`OneToOne_Optional_Self1Id`, `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` DESC LIMIT @__p_1 OFFSET @__p_0 -) AS `t` +) AS `l3` LEFT JOIN LATERAL ( - SELECT `t1`.`Id`, `t1`.`Date`, `t1`.`Level1_Optional_Id`, `t1`.`Level1_Required_Id`, `t1`.`Name`, `t1`.`OneToMany_Optional_Inverse2Id`, `t1`.`OneToMany_Optional_Self_Inverse2Id`, `t1`.`OneToMany_Required_Inverse2Id`, `t1`.`OneToMany_Required_Self_Inverse2Id`, `t1`.`OneToOne_Optional_PK_Inverse2Id`, `t1`.`OneToOne_Optional_Self2Id`, `l0`.`Id` AS `Id0`, `l0`.`Level2_Optional_Id`, `l0`.`Level2_Required_Id`, `l0`.`Name` AS `Name0`, `l0`.`OneToMany_Optional_Inverse3Id`, `l0`.`OneToMany_Optional_Self_Inverse3Id`, `l0`.`OneToMany_Required_Inverse3Id`, `l0`.`OneToMany_Required_Self_Inverse3Id`, `l0`.`OneToOne_Optional_PK_Inverse3Id`, `l0`.`OneToOne_Optional_Self3Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` - FROM `LevelTwo` AS `l1` - WHERE `t`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` - ORDER BY `l1`.`Name` DESC + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` + FROM `LevelTwo` AS `l0` + WHERE `l3`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` + ORDER BY `l0`.`Name` DESC LIMIT 4 OFFSET 1 - ) AS `t1` - LEFT JOIN `LevelThree` AS `l0` ON `t1`.`Id` = `l0`.`Level2_Optional_Id` -) AS `t0` ON TRUE -ORDER BY `t`.`Id` DESC, `t0`.`Name` DESC, `t0`.`Id` + ) AS `l2` + LEFT JOIN `LevelThree` AS `l1` ON `l2`.`Id` = `l1`.`Level2_Optional_Id` +) AS `s` ON TRUE +ORDER BY `l3`.`Id` DESC, `s`.`Name` DESC, `s`.`Id` """); } @@ -1620,27 +1723,27 @@ public override async Task Skip_Take_on_grouping_element_inside_collection_proje AssertSql( """ -SELECT `l`.`Id`, `t2`.`Date`, `t2`.`Id`, `t2`.`Date0`, `t2`.`Name`, `t2`.`OneToMany_Optional_Self_Inverse1Id`, `t2`.`OneToMany_Required_Self_Inverse1Id`, `t2`.`OneToOne_Optional_Self1Id` +SELECT `l`.`Id`, `s`.`Date`, `s`.`Id`, `s`.`Date0`, `s`.`Name`, `s`.`OneToMany_Optional_Self_Inverse1Id`, `s`.`OneToMany_Required_Self_Inverse1Id`, `s`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` LEFT JOIN LATERAL ( - SELECT `t`.`Date`, `t0`.`Id`, `t0`.`Date` AS `Date0`, `t0`.`Name`, `t0`.`OneToMany_Optional_Self_Inverse1Id`, `t0`.`OneToMany_Required_Self_Inverse1Id`, `t0`.`OneToOne_Optional_Self1Id` + SELECT `l2`.`Date`, `l4`.`Id`, `l4`.`Date` AS `Date0`, `l4`.`Name`, `l4`.`OneToMany_Optional_Self_Inverse1Id`, `l4`.`OneToMany_Required_Self_Inverse1Id`, `l4`.`OneToOne_Optional_Self1Id` FROM ( SELECT `l0`.`Date` FROM `LevelOne` AS `l0` WHERE (`l0`.`Name` = `l`.`Name`) OR (`l0`.`Name` IS NULL AND (`l`.`Name` IS NULL)) GROUP BY `l0`.`Date` - ) AS `t` + ) AS `l2` LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`Date`, `t1`.`Name`, `t1`.`OneToMany_Optional_Self_Inverse1Id`, `t1`.`OneToMany_Required_Self_Inverse1Id`, `t1`.`OneToOne_Optional_Self1Id` + SELECT `l3`.`Id`, `l3`.`Date`, `l3`.`Name`, `l3`.`OneToMany_Optional_Self_Inverse1Id`, `l3`.`OneToMany_Required_Self_Inverse1Id`, `l3`.`OneToOne_Optional_Self1Id` FROM ( SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`Date` ORDER BY `l1`.`Name`) AS `row` FROM `LevelOne` AS `l1` WHERE (`l1`.`Name` = `l`.`Name`) OR (`l1`.`Name` IS NULL AND (`l`.`Name` IS NULL)) - ) AS `t1` - WHERE (1 < `t1`.`row`) AND (`t1`.`row` <= 6) - ) AS `t0` ON `t`.`Date` = `t0`.`Date` -) AS `t2` ON TRUE -ORDER BY `l`.`Id`, `t2`.`Date`, `t2`.`Date0`, `t2`.`Name` + ) AS `l3` + WHERE (1 < `l3`.`row`) AND (`l3`.`row` <= 6) + ) AS `l4` ON `l2`.`Date` = `l4`.`Date` +) AS `s` ON TRUE +ORDER BY `l`.`Id`, `s`.`Date`, `s`.`Date0`, `s`.`Name` """); } @@ -1649,24 +1752,26 @@ public override async Task Skip_Take_on_grouping_element_with_collection_include await base.Skip_Take_on_grouping_element_with_collection_include(async); AssertSql( - @"SELECT `t`.`Date`, `t0`.`Id`, `t0`.`Date`, `t0`.`Name`, `t0`.`OneToMany_Optional_Self_Inverse1Id`, `t0`.`OneToMany_Required_Self_Inverse1Id`, `t0`.`OneToOne_Optional_Self1Id`, `t0`.`Id0`, `t0`.`Date0`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l2`.`Date`, `s`.`Id`, `s`.`Date`, `s`.`Name`, `s`.`OneToMany_Optional_Self_Inverse1Id`, `s`.`OneToMany_Required_Self_Inverse1Id`, `s`.`OneToOne_Optional_Self1Id`, `s`.`Id0`, `s`.`Date0`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l`.`Date` FROM `LevelOne` AS `l` GROUP BY `l`.`Date` -) AS `t` +) AS `l2` LEFT JOIN LATERAL ( - SELECT `t1`.`Id`, `t1`.`Date`, `t1`.`Name`, `t1`.`OneToMany_Optional_Self_Inverse1Id`, `t1`.`OneToMany_Required_Self_Inverse1Id`, `t1`.`OneToOne_Optional_Self1Id`, `l0`.`Id` AS `Id0`, `l0`.`Date` AS `Date0`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name` AS `Name0`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` + SELECT `l3`.`Id`, `l3`.`Date`, `l3`.`Name`, `l3`.`OneToMany_Optional_Self_Inverse1Id`, `l3`.`OneToMany_Required_Self_Inverse1Id`, `l3`.`OneToOne_Optional_Self1Id`, `l1`.`Id` AS `Id0`, `l1`.`Date` AS `Date0`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id` - FROM `LevelOne` AS `l1` - WHERE `t`.`Date` = `l1`.`Date` - ORDER BY `l1`.`Name` + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Name`, `l0`.`OneToMany_Optional_Self_Inverse1Id`, `l0`.`OneToMany_Required_Self_Inverse1Id`, `l0`.`OneToOne_Optional_Self1Id` + FROM `LevelOne` AS `l0` + WHERE `l2`.`Date` = `l0`.`Date` + ORDER BY `l0`.`Name` LIMIT 5 OFFSET 1 - ) AS `t1` - LEFT JOIN `LevelTwo` AS `l0` ON `t1`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` -) AS `t0` ON TRUE -ORDER BY `t`.`Date`, `t0`.`Name`, `t0`.`Id`"); + ) AS `l3` + LEFT JOIN `LevelTwo` AS `l1` ON `l3`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` +) AS `s` ON TRUE +ORDER BY `l2`.`Date`, `s`.`Name`, `s`.`Id` +"""); } public override async Task Skip_Take_on_grouping_element_with_reference_include(bool async) @@ -1674,24 +1779,26 @@ public override async Task Skip_Take_on_grouping_element_with_reference_include( await base.Skip_Take_on_grouping_element_with_reference_include(async); AssertSql( - @"SELECT `t`.`Date`, `t0`.`Id`, `t0`.`Date`, `t0`.`Name`, `t0`.`OneToMany_Optional_Self_Inverse1Id`, `t0`.`OneToMany_Required_Self_Inverse1Id`, `t0`.`OneToOne_Optional_Self1Id`, `t0`.`Id0`, `t0`.`Date0`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l3`.`Date`, `s`.`Id`, `s`.`Date`, `s`.`Name`, `s`.`OneToMany_Optional_Self_Inverse1Id`, `s`.`OneToMany_Required_Self_Inverse1Id`, `s`.`OneToOne_Optional_Self1Id`, `s`.`Id0`, `s`.`Date0`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l`.`Date` FROM `LevelOne` AS `l` GROUP BY `l`.`Date` -) AS `t` +) AS `l3` LEFT JOIN LATERAL ( - SELECT `t1`.`Id`, `t1`.`Date`, `t1`.`Name`, `t1`.`OneToMany_Optional_Self_Inverse1Id`, `t1`.`OneToMany_Required_Self_Inverse1Id`, `t1`.`OneToOne_Optional_Self1Id`, `l0`.`Id` AS `Id0`, `l0`.`Date` AS `Date0`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name` AS `Name0`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Name`, `l2`.`OneToMany_Optional_Self_Inverse1Id`, `l2`.`OneToMany_Required_Self_Inverse1Id`, `l2`.`OneToOne_Optional_Self1Id`, `l1`.`Id` AS `Id0`, `l1`.`Date` AS `Date0`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id` - FROM `LevelOne` AS `l1` - WHERE `t`.`Date` = `l1`.`Date` - ORDER BY `l1`.`Name` + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Name`, `l0`.`OneToMany_Optional_Self_Inverse1Id`, `l0`.`OneToMany_Required_Self_Inverse1Id`, `l0`.`OneToOne_Optional_Self1Id` + FROM `LevelOne` AS `l0` + WHERE `l3`.`Date` = `l0`.`Date` + ORDER BY `l0`.`Name` LIMIT 5 OFFSET 1 - ) AS `t1` - LEFT JOIN `LevelTwo` AS `l0` ON `t1`.`Id` = `l0`.`Level1_Optional_Id` -) AS `t0` ON TRUE -ORDER BY `t`.`Date`, `t0`.`Name`, `t0`.`Id`"); + ) AS `l2` + LEFT JOIN `LevelTwo` AS `l1` ON `l2`.`Id` = `l1`.`Level1_Optional_Id` +) AS `s` ON TRUE +ORDER BY `l3`.`Date`, `s`.`Name`, `s`.`Id` +"""); } public override async Task Skip_Take_Distinct_on_grouping_element(bool async) @@ -1699,23 +1806,25 @@ public override async Task Skip_Take_Distinct_on_grouping_element(bool async) await base.Skip_Take_Distinct_on_grouping_element(async); AssertSql( - @"SELECT `t`.`Date`, `t0`.`Id`, `t0`.`Date`, `t0`.`Name`, `t0`.`OneToMany_Optional_Self_Inverse1Id`, `t0`.`OneToMany_Required_Self_Inverse1Id`, `t0`.`OneToOne_Optional_Self1Id` +""" +SELECT `l2`.`Date`, `l3`.`Id`, `l3`.`Date`, `l3`.`Name`, `l3`.`OneToMany_Optional_Self_Inverse1Id`, `l3`.`OneToMany_Required_Self_Inverse1Id`, `l3`.`OneToOne_Optional_Self1Id` FROM ( SELECT `l`.`Date` FROM `LevelOne` AS `l` GROUP BY `l`.`Date` -) AS `t` +) AS `l2` LEFT JOIN LATERAL ( - SELECT DISTINCT `t1`.`Id`, `t1`.`Date`, `t1`.`Name`, `t1`.`OneToMany_Optional_Self_Inverse1Id`, `t1`.`OneToMany_Required_Self_Inverse1Id`, `t1`.`OneToOne_Optional_Self1Id` + SELECT DISTINCT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Name`, `l0`.`OneToMany_Optional_Self_Inverse1Id`, `l0`.`OneToMany_Required_Self_Inverse1Id`, `l0`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l0` - WHERE `t`.`Date` = `l0`.`Date` + WHERE `l2`.`Date` = `l0`.`Date` ORDER BY `l0`.`Name` LIMIT 5 OFFSET 1 - ) AS `t1` -) AS `t0` ON TRUE -ORDER BY `t`.`Date`"); + ) AS `l1` +) AS `l3` ON TRUE +ORDER BY `l2`.`Date` +"""); } private void AssertSql(params string[] expected) diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySingleStoreTest.cs index 5654aa7f7..6c2573181 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySingleStoreTest.cs @@ -21,221 +21,237 @@ public override async Task SelectMany_with_Include1(bool async) { await base.SelectMany_with_Include1(async); - AssertSql( - @"SELECT `t`.`Id`, `t`.`OneToOne_Required_PK_Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Level2_Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `l`.`Id`, `t0`.`Id`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Level3_Name`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id` + AssertSql( +""" +SELECT `l1`.`Id`, `l1`.`OneToOne_Required_PK_Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Level2_Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l`.`Id`, `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Level3_Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id` FROM `Level1` AS `l` INNER JOIN ( SELECT `l0`.`Id`, `l0`.`OneToOne_Required_PK_Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Level2_Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id` FROM `Level1` AS `l0` WHERE (`l0`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l0`.`Level1_Required_Id` IS NOT NULL)) AND `l0`.`OneToMany_Required_Inverse2Id` IS NOT NULL -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` +) AS `l1` ON `l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` LEFT JOIN ( - SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Level3_Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id` - FROM `Level1` AS `l1` - WHERE `l1`.`Level2_Required_Id` IS NOT NULL AND (`l1`.`OneToMany_Required_Inverse3Id` IS NOT NULL) -) AS `t0` ON CASE - WHEN (`t`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`t`.`Level1_Required_Id` IS NOT NULL)) AND `t`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `t`.`Id` -END = `t0`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `t`.`Id`"); + SELECT `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Level3_Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id` + FROM `Level1` AS `l2` + WHERE `l2`.`Level2_Required_Id` IS NOT NULL AND (`l2`.`OneToMany_Required_Inverse3Id` IS NOT NULL) +) AS `l3` ON CASE + WHEN (`l1`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l1`.`Level1_Required_Id` IS NOT NULL)) AND `l1`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `l1`.`Id` +END = `l3`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l1`.`Id` +"""); } public override async Task SelectMany_with_navigation_and_Distinct(bool async) { await base.SelectMany_with_navigation_and_Distinct(async); - AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `t`.`Id`, `t0`.`Id`, `t0`.`OneToOne_Required_PK_Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Level2_Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id` + AssertSql( +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l1`.`Id`, `l3`.`Id`, `l3`.`OneToOne_Required_PK_Date`, `l3`.`Level1_Optional_Id`, `l3`.`Level1_Required_Id`, `l3`.`Level2_Name`, `l3`.`OneToMany_Optional_Inverse2Id`, `l3`.`OneToMany_Required_Inverse2Id`, `l3`.`OneToOne_Optional_PK_Inverse2Id` FROM `Level1` AS `l` INNER JOIN ( SELECT DISTINCT `l0`.`Id`, `l0`.`OneToOne_Required_PK_Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Level2_Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id` FROM `Level1` AS `l0` WHERE (`l0`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l0`.`Level1_Required_Id` IS NOT NULL)) AND `l0`.`OneToMany_Required_Inverse2Id` IS NOT NULL -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` +) AS `l1` ON `l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` LEFT JOIN ( - SELECT `l1`.`Id`, `l1`.`OneToOne_Required_PK_Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Level2_Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id` - FROM `Level1` AS `l1` - WHERE (`l1`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l1`.`Level1_Required_Id` IS NOT NULL)) AND `l1`.`OneToMany_Required_Inverse2Id` IS NOT NULL -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -WHERE (`t`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`t`.`Level1_Required_Id` IS NOT NULL)) AND `t`.`OneToMany_Required_Inverse2Id` IS NOT NULL -ORDER BY `l`.`Id`, `t`.`Id`"); + SELECT `l2`.`Id`, `l2`.`OneToOne_Required_PK_Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Level2_Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id` + FROM `Level1` AS `l2` + WHERE (`l2`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l2`.`Level1_Required_Id` IS NOT NULL)) AND `l2`.`OneToMany_Required_Inverse2Id` IS NOT NULL +) AS `l3` ON `l`.`Id` = `l3`.`OneToMany_Optional_Inverse2Id` +WHERE (`l1`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l1`.`Level1_Required_Id` IS NOT NULL)) AND `l1`.`OneToMany_Required_Inverse2Id` IS NOT NULL +ORDER BY `l`.`Id`, `l1`.`Id` +"""); } public override async Task Take_Select_collection_Take(bool async) { await base.Take_Select_collection_Take(async); - AssertSql( - @"@__p_0='1' + AssertSql( +""" +@__p_0='1' -SELECT `t`.`Id`, `t`.`Name`, `t0`.`Id`, `t0`.`Name`, `t0`.`Level1Id`, `t0`.`Level2Id`, `t0`.`Id0`, `t0`.`Date`, `t0`.`Name0`, `t0`.`Id1` +SELECT `l3`.`Id`, `l3`.`Name`, `s`.`Id`, `s`.`Name`, `s`.`Level1Id`, `s`.`Level2Id`, `s`.`Id0`, `s`.`Date`, `s`.`Name0`, `s`.`Id1` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `Level1` AS `l` ORDER BY `l`.`Id` LIMIT @__p_0 -) AS `t` +) AS `l3` LEFT JOIN LATERAL ( SELECT CASE - WHEN (`t1`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`t1`.`Level1_Required_Id` IS NOT NULL)) AND `t1`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `t1`.`Id` - END AS `Id`, `t1`.`Level2_Name` AS `Name`, `t1`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `t1`.`Level1_Required_Id` AS `Level2Id`, `l0`.`Id` AS `Id0`, `l0`.`Date`, `l0`.`Name` AS `Name0`, `t1`.`Id` AS `Id1`, `t1`.`c` + WHEN (`l2`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l2`.`Level1_Required_Id` IS NOT NULL)) AND `l2`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `l2`.`Id` + END AS `Id`, `l2`.`Level2_Name` AS `Name`, `l2`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `l2`.`Level1_Required_Id` AS `Level2Id`, `l1`.`Id` AS `Id0`, `l1`.`Date`, `l1`.`Name` AS `Name0`, `l2`.`Id` AS `Id1`, `l2`.`c` FROM ( - SELECT `l1`.`Id`, `l1`.`OneToOne_Required_PK_Date`, `l1`.`Level1_Required_Id`, `l1`.`Level2_Name`, `l1`.`OneToMany_Required_Inverse2Id`, CASE - WHEN (`l1`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l1`.`Level1_Required_Id` IS NOT NULL)) AND `l1`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `l1`.`Id` + SELECT `l0`.`Id`, `l0`.`OneToOne_Required_PK_Date`, `l0`.`Level1_Required_Id`, `l0`.`Level2_Name`, `l0`.`OneToMany_Required_Inverse2Id`, CASE + WHEN (`l0`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l0`.`Level1_Required_Id` IS NOT NULL)) AND `l0`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `l0`.`Id` END AS `c` - FROM `Level1` AS `l1` - WHERE ((`l1`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l1`.`Level1_Required_Id` IS NOT NULL)) AND `l1`.`OneToMany_Required_Inverse2Id` IS NOT NULL) AND (`t`.`Id` = `l1`.`OneToMany_Required_Inverse2Id`) + FROM `Level1` AS `l0` + WHERE ((`l0`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l0`.`Level1_Required_Id` IS NOT NULL)) AND `l0`.`OneToMany_Required_Inverse2Id` IS NOT NULL) AND (`l3`.`Id` = `l0`.`OneToMany_Required_Inverse2Id`) ORDER BY CASE - WHEN (`l1`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l1`.`Level1_Required_Id` IS NOT NULL)) AND `l1`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `l1`.`Id` + WHEN (`l0`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l0`.`Level1_Required_Id` IS NOT NULL)) AND `l0`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `l0`.`Id` END LIMIT 3 - ) AS `t1` - INNER JOIN `Level1` AS `l0` ON `t1`.`Level1_Required_Id` = `l0`.`Id` -) AS `t0` ON TRUE -ORDER BY `t`.`Id`, `t0`.`c`, `t0`.`Id1`"); + ) AS `l2` + INNER JOIN `Level1` AS `l1` ON `l2`.`Level1_Required_Id` = `l1`.`Id` +) AS `s` ON TRUE +ORDER BY `l3`.`Id`, `s`.`c`, `s`.`Id1` +"""); } public override async Task Skip_Take_Select_collection_Skip_Take(bool async) { await base.Skip_Take_Select_collection_Skip_Take(async); - AssertSql( - @"@__p_0='1' + AssertSql( +""" +@__p_0='1' -SELECT `t`.`Id`, `t`.`Name`, `t0`.`Id`, `t0`.`Name`, `t0`.`Level1Id`, `t0`.`Level2Id`, `t0`.`Id0`, `t0`.`Date`, `t0`.`Name0`, `t0`.`Id1` +SELECT `l3`.`Id`, `l3`.`Name`, `s`.`Id`, `s`.`Name`, `s`.`Level1Id`, `s`.`Level2Id`, `s`.`Id0`, `s`.`Date`, `s`.`Name0`, `s`.`Id1` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `Level1` AS `l` ORDER BY `l`.`Id` LIMIT @__p_0 OFFSET @__p_0 -) AS `t` +) AS `l3` LEFT JOIN LATERAL ( SELECT CASE - WHEN (`t1`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`t1`.`Level1_Required_Id` IS NOT NULL)) AND `t1`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `t1`.`Id` - END AS `Id`, `t1`.`Level2_Name` AS `Name`, `t1`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `t1`.`Level1_Required_Id` AS `Level2Id`, `l0`.`Id` AS `Id0`, `l0`.`Date`, `l0`.`Name` AS `Name0`, `t1`.`Id` AS `Id1`, `t1`.`c` + WHEN (`l2`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l2`.`Level1_Required_Id` IS NOT NULL)) AND `l2`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `l2`.`Id` + END AS `Id`, `l2`.`Level2_Name` AS `Name`, `l2`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `l2`.`Level1_Required_Id` AS `Level2Id`, `l1`.`Id` AS `Id0`, `l1`.`Date`, `l1`.`Name` AS `Name0`, `l2`.`Id` AS `Id1`, `l2`.`c` FROM ( - SELECT `l1`.`Id`, `l1`.`OneToOne_Required_PK_Date`, `l1`.`Level1_Required_Id`, `l1`.`Level2_Name`, `l1`.`OneToMany_Required_Inverse2Id`, CASE - WHEN (`l1`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l1`.`Level1_Required_Id` IS NOT NULL)) AND `l1`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `l1`.`Id` + SELECT `l0`.`Id`, `l0`.`OneToOne_Required_PK_Date`, `l0`.`Level1_Required_Id`, `l0`.`Level2_Name`, `l0`.`OneToMany_Required_Inverse2Id`, CASE + WHEN (`l0`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l0`.`Level1_Required_Id` IS NOT NULL)) AND `l0`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `l0`.`Id` END AS `c` - FROM `Level1` AS `l1` - WHERE ((`l1`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l1`.`Level1_Required_Id` IS NOT NULL)) AND `l1`.`OneToMany_Required_Inverse2Id` IS NOT NULL) AND (`t`.`Id` = `l1`.`OneToMany_Required_Inverse2Id`) + FROM `Level1` AS `l0` + WHERE ((`l0`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l0`.`Level1_Required_Id` IS NOT NULL)) AND `l0`.`OneToMany_Required_Inverse2Id` IS NOT NULL) AND (`l3`.`Id` = `l0`.`OneToMany_Required_Inverse2Id`) ORDER BY CASE - WHEN (`l1`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l1`.`Level1_Required_Id` IS NOT NULL)) AND `l1`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `l1`.`Id` + WHEN (`l0`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l0`.`Level1_Required_Id` IS NOT NULL)) AND `l0`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `l0`.`Id` END LIMIT 3 OFFSET 1 - ) AS `t1` - INNER JOIN `Level1` AS `l0` ON `t1`.`Level1_Required_Id` = `l0`.`Id` -) AS `t0` ON TRUE -ORDER BY `t`.`Id`, `t0`.`c`, `t0`.`Id1`"); + ) AS `l2` + INNER JOIN `Level1` AS `l1` ON `l2`.`Level1_Required_Id` = `l1`.`Id` +) AS `s` ON TRUE +ORDER BY `l3`.`Id`, `s`.`c`, `s`.`Id1` +"""); } public override async Task Skip_Take_on_grouping_element_inside_collection_projection(bool async) { await base.Skip_Take_on_grouping_element_inside_collection_projection(async); - AssertSql( - @"SELECT `l`.`Id`, `t2`.`Date`, `t2`.`Id`, `t2`.`Date0`, `t2`.`Name` + AssertSql( +""" +SELECT `l`.`Id`, `s`.`Date`, `s`.`Id`, `s`.`Date0`, `s`.`Name` FROM `Level1` AS `l` LEFT JOIN LATERAL ( - SELECT `t`.`Date`, `t0`.`Id`, `t0`.`Date` AS `Date0`, `t0`.`Name` + SELECT `l2`.`Date`, `l4`.`Id`, `l4`.`Date` AS `Date0`, `l4`.`Name` FROM ( SELECT `l0`.`Date` FROM `Level1` AS `l0` WHERE (`l0`.`Name` = `l`.`Name`) OR (`l0`.`Name` IS NULL AND (`l`.`Name` IS NULL)) GROUP BY `l0`.`Date` - ) AS `t` + ) AS `l2` LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`Date`, `t1`.`Name` + SELECT `l3`.`Id`, `l3`.`Date`, `l3`.`Name` FROM ( SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, ROW_NUMBER() OVER(PARTITION BY `l1`.`Date` ORDER BY `l1`.`Name`) AS `row` FROM `Level1` AS `l1` WHERE (`l1`.`Name` = `l`.`Name`) OR (`l1`.`Name` IS NULL AND (`l`.`Name` IS NULL)) - ) AS `t1` - WHERE (1 < `t1`.`row`) AND (`t1`.`row` <= 6) - ) AS `t0` ON `t`.`Date` = `t0`.`Date` -) AS `t2` ON TRUE -ORDER BY `l`.`Id`, `t2`.`Date`, `t2`.`Date0`, `t2`.`Name`"); + ) AS `l3` + WHERE (1 < `l3`.`row`) AND (`l3`.`row` <= 6) + ) AS `l4` ON `l2`.`Date` = `l4`.`Date` +) AS `s` ON TRUE +ORDER BY `l`.`Id`, `s`.`Date`, `s`.`Date0`, `s`.`Name` +"""); } public override async Task Skip_Take_Distinct_on_grouping_element(bool async) { await base.Skip_Take_Distinct_on_grouping_element(async); - AssertSql( - @"SELECT `t`.`Date`, `t0`.`Id`, `t0`.`Date`, `t0`.`Name` + AssertSql( +""" +SELECT `l2`.`Date`, `l3`.`Id`, `l3`.`Date`, `l3`.`Name` FROM ( SELECT `l`.`Date` FROM `Level1` AS `l` GROUP BY `l`.`Date` -) AS `t` +) AS `l2` LEFT JOIN LATERAL ( - SELECT DISTINCT `t1`.`Id`, `t1`.`Date`, `t1`.`Name` + SELECT DISTINCT `l1`.`Id`, `l1`.`Date`, `l1`.`Name` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Name` FROM `Level1` AS `l0` - WHERE `t`.`Date` = `l0`.`Date` + WHERE `l2`.`Date` = `l0`.`Date` ORDER BY `l0`.`Name` LIMIT 5 OFFSET 1 - ) AS `t1` -) AS `t0` ON TRUE -ORDER BY `t`.`Date`"); + ) AS `l1` +) AS `l3` ON TRUE +ORDER BY `l2`.`Date` +"""); } public override async Task Skip_Take_on_grouping_element_with_collection_include(bool async) { await base.Skip_Take_on_grouping_element_with_collection_include(async); - AssertSql( - @"SELECT `t`.`Date`, `t1`.`Id`, `t1`.`Date`, `t1`.`Name`, `t1`.`Id0`, `t1`.`OneToOne_Required_PK_Date`, `t1`.`Level1_Optional_Id`, `t1`.`Level1_Required_Id`, `t1`.`Level2_Name`, `t1`.`OneToMany_Optional_Inverse2Id`, `t1`.`OneToMany_Required_Inverse2Id`, `t1`.`OneToOne_Optional_PK_Inverse2Id` + AssertSql( +""" +SELECT `l2`.`Date`, `s`.`Id`, `s`.`Date`, `s`.`Name`, `s`.`Id0`, `s`.`OneToOne_Required_PK_Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Level2_Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id` FROM ( SELECT `l`.`Date` FROM `Level1` AS `l` GROUP BY `l`.`Date` -) AS `t` +) AS `l2` LEFT JOIN LATERAL ( - SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Name`, `t2`.`Id` AS `Id0`, `t2`.`OneToOne_Required_PK_Date`, `t2`.`Level1_Optional_Id`, `t2`.`Level1_Required_Id`, `t2`.`Level2_Name`, `t2`.`OneToMany_Optional_Inverse2Id`, `t2`.`OneToMany_Required_Inverse2Id`, `t2`.`OneToOne_Optional_PK_Inverse2Id` + SELECT `l3`.`Id`, `l3`.`Date`, `l3`.`Name`, `l4`.`Id` AS `Id0`, `l4`.`OneToOne_Required_PK_Date`, `l4`.`Level1_Optional_Id`, `l4`.`Level1_Required_Id`, `l4`.`Level2_Name`, `l4`.`OneToMany_Optional_Inverse2Id`, `l4`.`OneToMany_Required_Inverse2Id`, `l4`.`OneToOne_Optional_PK_Inverse2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Name` FROM `Level1` AS `l0` - WHERE `t`.`Date` = `l0`.`Date` + WHERE `l2`.`Date` = `l0`.`Date` ORDER BY `l0`.`Name` LIMIT 5 OFFSET 1 - ) AS `t0` + ) AS `l3` LEFT JOIN ( SELECT `l1`.`Id`, `l1`.`OneToOne_Required_PK_Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Level2_Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id` FROM `Level1` AS `l1` WHERE (`l1`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l1`.`Level1_Required_Id` IS NOT NULL)) AND `l1`.`OneToMany_Required_Inverse2Id` IS NOT NULL - ) AS `t2` ON `t0`.`Id` = `t2`.`OneToMany_Optional_Inverse2Id` -) AS `t1` ON TRUE -ORDER BY `t`.`Date`, `t1`.`Name`, `t1`.`Id`"); + ) AS `l4` ON `l3`.`Id` = `l4`.`OneToMany_Optional_Inverse2Id` +) AS `s` ON TRUE +ORDER BY `l2`.`Date`, `s`.`Name`, `s`.`Id` +"""); } public override async Task Skip_Take_on_grouping_element_with_reference_include(bool async) { await base.Skip_Take_on_grouping_element_with_reference_include(async); - AssertSql( - @"SELECT `t`.`Date`, `t1`.`Id`, `t1`.`Date`, `t1`.`Name`, `t1`.`Id0`, `t1`.`OneToOne_Required_PK_Date`, `t1`.`Level1_Optional_Id`, `t1`.`Level1_Required_Id`, `t1`.`Level2_Name`, `t1`.`OneToMany_Optional_Inverse2Id`, `t1`.`OneToMany_Required_Inverse2Id`, `t1`.`OneToOne_Optional_PK_Inverse2Id` + AssertSql( +""" +SELECT `l4`.`Date`, `s`.`Id`, `s`.`Date`, `s`.`Name`, `s`.`Id0`, `s`.`OneToOne_Required_PK_Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Level2_Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id` FROM ( SELECT `l`.`Date` FROM `Level1` AS `l` GROUP BY `l`.`Date` -) AS `t` +) AS `l4` LEFT JOIN LATERAL ( - SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Name`, `t2`.`Id` AS `Id0`, `t2`.`OneToOne_Required_PK_Date`, `t2`.`Level1_Optional_Id`, `t2`.`Level1_Required_Id`, `t2`.`Level2_Name`, `t2`.`OneToMany_Optional_Inverse2Id`, `t2`.`OneToMany_Required_Inverse2Id`, `t2`.`OneToOne_Optional_PK_Inverse2Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Name`, `l3`.`Id` AS `Id0`, `l3`.`OneToOne_Required_PK_Date`, `l3`.`Level1_Optional_Id`, `l3`.`Level1_Required_Id`, `l3`.`Level2_Name`, `l3`.`OneToMany_Optional_Inverse2Id`, `l3`.`OneToMany_Required_Inverse2Id`, `l3`.`OneToOne_Optional_PK_Inverse2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Name` FROM `Level1` AS `l0` - WHERE `t`.`Date` = `l0`.`Date` + WHERE `l4`.`Date` = `l0`.`Date` ORDER BY `l0`.`Name` LIMIT 5 OFFSET 1 - ) AS `t0` + ) AS `l2` LEFT JOIN ( SELECT `l1`.`Id`, `l1`.`OneToOne_Required_PK_Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Level2_Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id` FROM `Level1` AS `l1` WHERE (`l1`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l1`.`Level1_Required_Id` IS NOT NULL)) AND `l1`.`OneToMany_Required_Inverse2Id` IS NOT NULL - ) AS `t2` ON `t0`.`Id` = `t2`.`Level1_Optional_Id` -) AS `t1` ON TRUE -ORDER BY `t`.`Date`, `t1`.`Name`, `t1`.`Id`"); + ) AS `l3` ON `l2`.`Id` = `l3`.`Level1_Optional_Id` +) AS `s` ON TRUE +ORDER BY `l4`.`Date`, `s`.`Name`, `s`.`Id` +"""); } [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed.")] diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQuerySingleStoreTest.cs index e2119716c..865150c1a 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQuerySingleStoreTest.cs @@ -23,18 +23,22 @@ public override async Task Filtered_include_basic_Where(bool async) await base.Filtered_include_basic_Where(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` FROM `LevelTwo` AS `l0` WHERE `l0`.`Id` > 5 -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`"); +) AS `l1` ON `l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id` +"""); } public override async Task Filtered_include_OrderBy(bool async) @@ -99,21 +103,25 @@ public override async Task Filtered_include_basic_OrderBy_Take(bool async) await base.Filtered_include_basic_OrderBy_Take(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Name`) AS `row` FROM `LevelTwo` AS `l0` - ) AS `t` - WHERE `t`.`row` <= 3 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Name`"); + ) AS `l1` + WHERE `l1`.`row` <= 3 +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`Name` +"""); } public override async Task Filtered_include_basic_OrderBy_Skip(bool async) @@ -121,21 +129,25 @@ public override async Task Filtered_include_basic_OrderBy_Skip(bool async) await base.Filtered_include_basic_OrderBy_Skip(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Name`) AS `row` FROM `LevelTwo` AS `l0` - ) AS `t` - WHERE 1 < `t`.`row` -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Name`"); + ) AS `l1` + WHERE 1 < `l1`.`row` +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`Name` +"""); } public override async Task Filtered_include_basic_OrderBy_Skip_Take(bool async) @@ -143,21 +155,25 @@ public override async Task Filtered_include_basic_OrderBy_Skip_Take(bool async) await base.Filtered_include_basic_OrderBy_Skip_Take(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Name`) AS `row` FROM `LevelTwo` AS `l0` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 4) -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Name`"); + ) AS `l1` + WHERE (1 < `l1`.`row`) AND (`l1`.`row` <= 4) +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`Name` +"""); } public override async Task Filtered_include_on_ThenInclude(bool async) @@ -165,24 +181,28 @@ public override async Task Filtered_include_on_ThenInclude(bool async) await base.Filtered_include_on_ThenInclude(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id` + SELECT `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Optional_Inverse3Id` ORDER BY `l1`.`Name`) AS `row` FROM `LevelThree` AS `l1` WHERE (`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 4) -) AS `t0` ON `l0`.`Id` = `t0`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`Name`"); + ) AS `l2` + WHERE (1 < `l2`.`row`) AND (`l2`.`row` <= 4) +) AS `l3` ON `l0`.`Id` = `l3`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l0`.`Id`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`Name` +"""); } public override async Task Filtered_include_after_reference_navigation(bool async) @@ -190,24 +210,28 @@ public override async Task Filtered_include_after_reference_navigation(bool asyn await base.Filtered_include_after_reference_navigation(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id` + SELECT `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Optional_Inverse3Id` ORDER BY `l1`.`Name`) AS `row` FROM `LevelThree` AS `l1` WHERE (`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 4) -) AS `t0` ON `l0`.`Id` = `t0`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`Name`"); + ) AS `l2` + WHERE (1 < `l2`.`row`) AND (`l2`.`row` <= 4) +) AS `l3` ON `l0`.`Id` = `l3`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l0`.`Id`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`Name` +"""); } public override async Task Filtered_include_after_different_filtered_include_same_level(bool async) @@ -215,35 +239,41 @@ public override async Task Filtered_include_after_different_filtered_include_sam await base.Filtered_include_after_different_filtered_include_same_level(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l3`.`Id`, `l3`.`Date`, `l3`.`Level1_Optional_Id`, `l3`.`Level1_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse2Id`, `l3`.`OneToMany_Optional_Self_Inverse2Id`, `l3`.`OneToMany_Required_Inverse2Id`, `l3`.`OneToMany_Required_Self_Inverse2Id`, `l3`.`OneToOne_Optional_PK_Inverse2Id`, `l3`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Name`) AS `row` FROM `LevelTwo` AS `l0` WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 3 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Name`", + ) AS `l2` + WHERE `l2`.`row` <= 3 +) AS `l3` ON `l`.`Id` = `l3`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l3`.`OneToMany_Optional_Inverse2Id`, `l3`.`Name` +""", // - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l5`.`Id`, `l5`.`Date`, `l5`.`Level1_Optional_Id`, `l5`.`Level1_Required_Id`, `l5`.`Name`, `l5`.`OneToMany_Optional_Inverse2Id`, `l5`.`OneToMany_Optional_Self_Inverse2Id`, `l5`.`OneToMany_Required_Inverse2Id`, `l5`.`OneToMany_Required_Self_Inverse2Id`, `l5`.`OneToOne_Optional_PK_Inverse2Id`, `l5`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l4`.`Id`, `l4`.`Date`, `l4`.`Level1_Optional_Id`, `l4`.`Level1_Required_Id`, `l4`.`Name`, `l4`.`OneToMany_Optional_Inverse2Id`, `l4`.`OneToMany_Optional_Self_Inverse2Id`, `l4`.`OneToMany_Required_Inverse2Id`, `l4`.`OneToMany_Required_Self_Inverse2Id`, `l4`.`OneToOne_Optional_PK_Inverse2Id`, `l4`.`OneToOne_Optional_Self2Id` FROM ( - SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Required_Inverse2Id` ORDER BY `l0`.`Name` DESC) AS `row` - FROM `LevelTwo` AS `l0` - WHERE (`l0`.`Name` <> 'Bar') OR `l0`.`Name` IS NULL - ) AS `t` - WHERE 1 < `t`.`row` -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Required_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`Name` DESC"); + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Required_Inverse2Id` ORDER BY `l1`.`Name` DESC) AS `row` + FROM `LevelTwo` AS `l1` + WHERE (`l1`.`Name` <> 'Bar') OR `l1`.`Name` IS NULL + ) AS `l4` + WHERE 1 < `l4`.`row` +) AS `l5` ON `l`.`Id` = `l5`.`OneToMany_Required_Inverse2Id` +ORDER BY `l`.`Id`, `l5`.`OneToMany_Required_Inverse2Id`, `l5`.`Name` DESC +"""); } public override async Task Filtered_include_after_different_filtered_include_different_level(bool async) @@ -251,44 +281,50 @@ public override async Task Filtered_include_after_different_filtered_include_dif await base.Filtered_include_after_different_filtered_include_different_level(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l3`.`Id`, `l3`.`Date`, `l3`.`Level1_Optional_Id`, `l3`.`Level1_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse2Id`, `l3`.`OneToMany_Optional_Self_Inverse2Id`, `l3`.`OneToMany_Required_Inverse2Id`, `l3`.`OneToMany_Required_Self_Inverse2Id`, `l3`.`OneToOne_Optional_PK_Inverse2Id`, `l3`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Name`) AS `row` FROM `LevelTwo` AS `l0` WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 3 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Name`, `t0`.`Id`", + ) AS `l2` + WHERE `l2`.`row` <= 3 +) AS `l3` ON `l`.`Id` = `l3`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l3`.`OneToMany_Optional_Inverse2Id`, `l3`.`Name`, `l3`.`Id` +""", // - @"SELECT `t1`.`Id`, `t1`.`Level2_Optional_Id`, `t1`.`Level2_Required_Id`, `t1`.`Name`, `t1`.`OneToMany_Optional_Inverse3Id`, `t1`.`OneToMany_Optional_Self_Inverse3Id`, `t1`.`OneToMany_Required_Inverse3Id`, `t1`.`OneToMany_Required_Self_Inverse3Id`, `t1`.`OneToOne_Optional_PK_Inverse3Id`, `t1`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `t0`.`Id` + """ +SELECT `l5`.`Id`, `l5`.`Level2_Optional_Id`, `l5`.`Level2_Required_Id`, `l5`.`Name`, `l5`.`OneToMany_Optional_Inverse3Id`, `l5`.`OneToMany_Optional_Self_Inverse3Id`, `l5`.`OneToMany_Required_Inverse3Id`, `l5`.`OneToMany_Required_Self_Inverse3Id`, `l5`.`OneToOne_Optional_PK_Inverse3Id`, `l5`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l3`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id` + SELECT `l2`.`Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Name`) AS `row` FROM `LevelTwo` AS `l0` WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 3 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` + ) AS `l2` + WHERE `l2`.`row` <= 3 +) AS `l3` ON `l`.`Id` = `l3`.`OneToMany_Optional_Inverse2Id` INNER JOIN ( - SELECT `t2`.`Id`, `t2`.`Level2_Optional_Id`, `t2`.`Level2_Required_Id`, `t2`.`Name`, `t2`.`OneToMany_Optional_Inverse3Id`, `t2`.`OneToMany_Optional_Self_Inverse3Id`, `t2`.`OneToMany_Required_Inverse3Id`, `t2`.`OneToMany_Required_Self_Inverse3Id`, `t2`.`OneToOne_Optional_PK_Inverse3Id`, `t2`.`OneToOne_Optional_Self3Id` + SELECT `l4`.`Id`, `l4`.`Level2_Optional_Id`, `l4`.`Level2_Required_Id`, `l4`.`Name`, `l4`.`OneToMany_Optional_Inverse3Id`, `l4`.`OneToMany_Optional_Self_Inverse3Id`, `l4`.`OneToMany_Required_Inverse3Id`, `l4`.`OneToMany_Required_Self_Inverse3Id`, `l4`.`OneToOne_Optional_PK_Inverse3Id`, `l4`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Required_Inverse3Id` ORDER BY `l1`.`Name` DESC) AS `row` FROM `LevelThree` AS `l1` WHERE (`l1`.`Name` <> 'Bar') OR `l1`.`Name` IS NULL - ) AS `t2` - WHERE 1 < `t2`.`row` -) AS `t1` ON `t0`.`Id` = `t1`.`OneToMany_Required_Inverse3Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Name`, `t0`.`Id`, `t1`.`OneToMany_Required_Inverse3Id`, `t1`.`Name` DESC"); + ) AS `l4` + WHERE 1 < `l4`.`row` +) AS `l5` ON `l3`.`Id` = `l5`.`OneToMany_Required_Inverse3Id` +ORDER BY `l`.`Id`, `l3`.`OneToMany_Optional_Inverse2Id`, `l3`.`Name`, `l3`.`Id`, `l5`.`OneToMany_Required_Inverse3Id`, `l5`.`Name` DESC +"""); } public override async Task Filtered_include_same_filter_set_on_same_navigation_twice(bool async) @@ -296,22 +332,26 @@ public override async Task Filtered_include_same_filter_set_on_same_navigation_t await base.Filtered_include_same_filter_set_on_same_navigation_twice(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id` DESC) AS `row` FROM `LevelTwo` AS `l0` WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 2 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Id` DESC"); + ) AS `l1` + WHERE `l1`.`row` <= 2 +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`Id` DESC +"""); } public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) @@ -319,40 +359,46 @@ public override async Task Filtered_include_same_filter_set_on_same_navigation_t await base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `t0`.`Id0`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id` + """ +SELECT `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id` FROM `LevelOne` AS `l` JOIN LATERAL ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `l0`.`Id` AS `Id0`, `l0`.`Level2_Optional_Id`, `l0`.`Level2_Required_Id`, `l0`.`Name` AS `Name0`, `l0`.`OneToMany_Optional_Inverse3Id`, `l0`.`OneToMany_Optional_Self_Inverse3Id`, `l0`.`OneToMany_Required_Inverse3Id`, `l0`.`OneToMany_Required_Self_Inverse3Id`, `l0`.`OneToOne_Optional_PK_Inverse3Id`, `l0`.`OneToOne_Optional_Self3Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` - FROM `LevelTwo` AS `l1` - WHERE (`l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id`) AND ((`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL) - ORDER BY `l1`.`Id` + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` + FROM `LevelTwo` AS `l0` + WHERE (`l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id`) AND ((`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL) + ORDER BY `l0`.`Id` LIMIT 2 - ) AS `t` - LEFT JOIN `LevelThree` AS `l0` ON `t`.`Id` = `l0`.`Level2_Required_Id` -) AS `t0` ON TRUE -ORDER BY `l`.`Id`, `t0`.`Id`, `t0`.`Id0`", + ) AS `l2` + LEFT JOIN `LevelThree` AS `l1` ON `l2`.`Id` = `l1`.`Level2_Required_Id` +) AS `s` ON TRUE +ORDER BY `l`.`Id`, `s`.`Id`, `s`.`Id0` +""", // - @"SELECT `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `t0`.`Id`, `t0`.`Id0` + """ +SELECT `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `s`.`Id`, `s`.`Id0` FROM `LevelOne` AS `l` JOIN LATERAL ( - SELECT `t`.`Id`, `l0`.`Id` AS `Id0` + SELECT `l2`.`Id`, `l1`.`Id` AS `Id0` FROM ( - SELECT `l1`.`Id` - FROM `LevelTwo` AS `l1` - WHERE (`l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id`) AND ((`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL) - ORDER BY `l1`.`Id` + SELECT `l0`.`Id` + FROM `LevelTwo` AS `l0` + WHERE (`l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id`) AND ((`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL) + ORDER BY `l0`.`Id` LIMIT 2 - ) AS `t` - LEFT JOIN `LevelThree` AS `l0` ON `t`.`Id` = `l0`.`Level2_Required_Id` -) AS `t0` ON TRUE -INNER JOIN `LevelThree` AS `l2` ON `t0`.`Id` = `l2`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `t0`.`Id`, `t0`.`Id0`"); + ) AS `l2` + LEFT JOIN `LevelThree` AS `l1` ON `l2`.`Id` = `l1`.`Level2_Required_Id` +) AS `s` ON TRUE +INNER JOIN `LevelThree` AS `l3` ON `s`.`Id` = `l3`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `s`.`Id`, `s`.`Id0` +"""); } public override async Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async) @@ -360,40 +406,46 @@ public override async Task Filtered_include_multiple_multi_level_includes_with_f await base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `t0`.`Id0`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id` + """ +SELECT `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id` FROM `LevelOne` AS `l` JOIN LATERAL ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `l0`.`Id` AS `Id0`, `l0`.`Level2_Optional_Id`, `l0`.`Level2_Required_Id`, `l0`.`Name` AS `Name0`, `l0`.`OneToMany_Optional_Inverse3Id`, `l0`.`OneToMany_Optional_Self_Inverse3Id`, `l0`.`OneToMany_Required_Inverse3Id`, `l0`.`OneToMany_Required_Self_Inverse3Id`, `l0`.`OneToOne_Optional_PK_Inverse3Id`, `l0`.`OneToOne_Optional_Self3Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` - FROM `LevelTwo` AS `l1` - WHERE (`l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id`) AND ((`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL) - ORDER BY `l1`.`Id` + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` + FROM `LevelTwo` AS `l0` + WHERE (`l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id`) AND ((`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL) + ORDER BY `l0`.`Id` LIMIT 2 - ) AS `t` - LEFT JOIN `LevelThree` AS `l0` ON `t`.`Id` = `l0`.`Level2_Required_Id` -) AS `t0` ON TRUE -ORDER BY `l`.`Id`, `t0`.`Id`, `t0`.`Id0`", + ) AS `l2` + LEFT JOIN `LevelThree` AS `l1` ON `l2`.`Id` = `l1`.`Level2_Required_Id` +) AS `s` ON TRUE +ORDER BY `l`.`Id`, `s`.`Id`, `s`.`Id0` +""", // - @"SELECT `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `t0`.`Id`, `t0`.`Id0` + """ +SELECT `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `s`.`Id`, `s`.`Id0` FROM `LevelOne` AS `l` JOIN LATERAL ( - SELECT `t`.`Id`, `l0`.`Id` AS `Id0` + SELECT `l2`.`Id`, `l1`.`Id` AS `Id0` FROM ( - SELECT `l1`.`Id` - FROM `LevelTwo` AS `l1` - WHERE (`l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id`) AND ((`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL) - ORDER BY `l1`.`Id` + SELECT `l0`.`Id` + FROM `LevelTwo` AS `l0` + WHERE (`l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id`) AND ((`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL) + ORDER BY `l0`.`Id` LIMIT 2 - ) AS `t` - LEFT JOIN `LevelThree` AS `l0` ON `t`.`Id` = `l0`.`Level2_Required_Id` -) AS `t0` ON TRUE -INNER JOIN `LevelThree` AS `l2` ON `t0`.`Id` = `l2`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `t0`.`Id`, `t0`.`Id0`"); + ) AS `l2` + LEFT JOIN `LevelThree` AS `l1` ON `l2`.`Id` = `l1`.`Level2_Required_Id` +) AS `s` ON TRUE +INNER JOIN `LevelThree` AS `l3` ON `s`.`Id` = `l3`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `s`.`Id`, `s`.`Id0` +"""); } public override async Task Filtered_include_and_non_filtered_include_on_same_navigation1(bool async) @@ -401,22 +453,26 @@ public override async Task Filtered_include_and_non_filtered_include_on_same_nav await base.Filtered_include_and_non_filtered_include_on_same_navigation1(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 3 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Id`"); + ) AS `l1` + WHERE `l1`.`row` <= 3 +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`Id` +"""); } public override async Task Filtered_include_and_non_filtered_include_on_same_navigation2(bool async) @@ -424,22 +480,26 @@ public override async Task Filtered_include_and_non_filtered_include_on_same_nav await base.Filtered_include_and_non_filtered_include_on_same_navigation2(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 3 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Id`"); + ) AS `l1` + WHERE `l1`.`row` <= 3 +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`Id` +"""); } public override async Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) @@ -447,44 +507,50 @@ public override async Task Filtered_include_and_non_filtered_include_followed_by await base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `t0`.`Id0`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id`, `l`.`Id` + """ +SELECT `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `l`.`Id` FROM `LevelOne` AS `l` JOIN LATERAL ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `l0`.`Id` AS `Id0`, `l0`.`Level2_Optional_Id`, `l0`.`Level2_Required_Id`, `l0`.`Name` AS `Name0`, `l0`.`OneToMany_Optional_Inverse3Id`, `l0`.`OneToMany_Optional_Self_Inverse3Id`, `l0`.`OneToMany_Required_Inverse3Id`, `l0`.`OneToMany_Required_Self_Inverse3Id`, `l0`.`OneToOne_Optional_PK_Inverse3Id`, `l0`.`OneToOne_Optional_Self3Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` - FROM `LevelTwo` AS `l1` - WHERE (`l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id`) AND ((`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL) - ORDER BY `l1`.`Id` + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` + FROM `LevelTwo` AS `l0` + WHERE (`l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id`) AND ((`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL) + ORDER BY `l0`.`Id` LIMIT 1 - ) AS `t` - LEFT JOIN `LevelThree` AS `l0` ON `t`.`Id` = `l0`.`OneToOne_Optional_PK_Inverse3Id` -) AS `t0` ON TRUE -ORDER BY `l`.`Id`, `t0`.`Id`, `t0`.`Id0`", + ) AS `l2` + LEFT JOIN `LevelThree` AS `l1` ON `l2`.`Id` = `l1`.`OneToOne_Optional_PK_Inverse3Id` +) AS `s` ON TRUE +ORDER BY `l`.`Id`, `s`.`Id`, `s`.`Id0` +""", // - @"SELECT `t1`.`Id`, `t1`.`Level3_Optional_Id`, `t1`.`Level3_Required_Id`, `t1`.`Name`, `t1`.`OneToMany_Optional_Inverse4Id`, `t1`.`OneToMany_Optional_Self_Inverse4Id`, `t1`.`OneToMany_Required_Inverse4Id`, `t1`.`OneToMany_Required_Self_Inverse4Id`, `t1`.`OneToOne_Optional_PK_Inverse4Id`, `t1`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `t0`.`Id`, `t0`.`Id0` + """ +SELECT `l4`.`Id`, `l4`.`Level3_Optional_Id`, `l4`.`Level3_Required_Id`, `l4`.`Name`, `l4`.`OneToMany_Optional_Inverse4Id`, `l4`.`OneToMany_Optional_Self_Inverse4Id`, `l4`.`OneToMany_Required_Inverse4Id`, `l4`.`OneToMany_Required_Self_Inverse4Id`, `l4`.`OneToOne_Optional_PK_Inverse4Id`, `l4`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `s`.`Id`, `s`.`Id0` FROM `LevelOne` AS `l` JOIN LATERAL ( - SELECT `t`.`Id`, `l0`.`Id` AS `Id0` + SELECT `l2`.`Id`, `l1`.`Id` AS `Id0` FROM ( - SELECT `l1`.`Id` - FROM `LevelTwo` AS `l1` - WHERE (`l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id`) AND ((`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL) - ORDER BY `l1`.`Id` + SELECT `l0`.`Id` + FROM `LevelTwo` AS `l0` + WHERE (`l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id`) AND ((`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL) + ORDER BY `l0`.`Id` LIMIT 1 - ) AS `t` - LEFT JOIN `LevelThree` AS `l0` ON `t`.`Id` = `l0`.`OneToOne_Optional_PK_Inverse3Id` -) AS `t0` ON TRUE + ) AS `l2` + LEFT JOIN `LevelThree` AS `l1` ON `l2`.`Id` = `l1`.`OneToOne_Optional_PK_Inverse3Id` +) AS `s` ON TRUE INNER JOIN ( - SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id` - FROM `LevelFour` AS `l2` - WHERE `l2`.`Id` > 1 -) AS `t1` ON `t0`.`Id0` = `t1`.`OneToMany_Optional_Inverse4Id` -ORDER BY `l`.`Id`, `t0`.`Id`, `t0`.`Id0`"); + SELECT `l3`.`Id`, `l3`.`Level3_Optional_Id`, `l3`.`Level3_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse4Id`, `l3`.`OneToMany_Optional_Self_Inverse4Id`, `l3`.`OneToMany_Required_Inverse4Id`, `l3`.`OneToMany_Required_Self_Inverse4Id`, `l3`.`OneToOne_Optional_PK_Inverse4Id`, `l3`.`OneToOne_Optional_Self4Id` + FROM `LevelFour` AS `l3` + WHERE `l3`.`Id` > 1 +) AS `l4` ON `s`.`Id0` = `l4`.`OneToMany_Optional_Inverse4Id` +ORDER BY `l`.`Id`, `s`.`Id`, `s`.`Id0` +"""); } public override async Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) @@ -492,58 +558,68 @@ public override async Task Filtered_include_complex_three_level_with_middle_havi await base.Filtered_include_complex_three_level_with_middle_having_filter1(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `l5`.`Id`, `l5`.`Level2_Optional_Id`, `l5`.`Level2_Required_Id`, `l5`.`Name`, `l5`.`OneToMany_Optional_Inverse3Id`, `l5`.`OneToMany_Optional_Self_Inverse3Id`, `l5`.`OneToMany_Required_Inverse3Id`, `l5`.`OneToMany_Required_Self_Inverse3Id`, `l5`.`OneToOne_Optional_PK_Inverse3Id`, `l5`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id` + SELECT `l4`.`Id`, `l4`.`Level2_Optional_Id`, `l4`.`Level2_Required_Id`, `l4`.`Name`, `l4`.`OneToMany_Optional_Inverse3Id`, `l4`.`OneToMany_Optional_Self_Inverse3Id`, `l4`.`OneToMany_Required_Inverse3Id`, `l4`.`OneToMany_Required_Self_Inverse3Id`, `l4`.`OneToOne_Optional_PK_Inverse3Id`, `l4`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Optional_Inverse3Id` ORDER BY `l1`.`Id`) AS `row` FROM `LevelThree` AS `l1` WHERE (`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l0`.`Id` = `t0`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`Id`", + ) AS `l4` + WHERE `l4`.`row` <= 1 +) AS `l5` ON `l0`.`Id` = `l5`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l0`.`Id`, `l5`.`OneToMany_Optional_Inverse3Id`, `l5`.`Id` +""", // - @"SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `t0`.`Id` + """ +SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `l5`.`Id` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` INNER JOIN ( - SELECT `t`.`Id`, `t`.`OneToMany_Optional_Inverse3Id` + SELECT `l4`.`Id`, `l4`.`OneToMany_Optional_Inverse3Id` FROM ( SELECT `l1`.`Id`, `l1`.`OneToMany_Optional_Inverse3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Optional_Inverse3Id` ORDER BY `l1`.`Id`) AS `row` FROM `LevelThree` AS `l1` WHERE (`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l0`.`Id` = `t0`.`OneToMany_Optional_Inverse3Id` -INNER JOIN `LevelFour` AS `l2` ON `t0`.`Id` = `l2`.`OneToMany_Optional_Inverse4Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`Id`", + ) AS `l4` + WHERE `l4`.`row` <= 1 +) AS `l5` ON `l0`.`Id` = `l5`.`OneToMany_Optional_Inverse3Id` +INNER JOIN `LevelFour` AS `l2` ON `l5`.`Id` = `l2`.`OneToMany_Optional_Inverse4Id` +ORDER BY `l`.`Id`, `l0`.`Id`, `l5`.`OneToMany_Optional_Inverse3Id`, `l5`.`Id` +""", // - @"SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `t0`.`Id` + """ +SELECT `l3`.`Id`, `l3`.`Level3_Optional_Id`, `l3`.`Level3_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse4Id`, `l3`.`OneToMany_Optional_Self_Inverse4Id`, `l3`.`OneToMany_Required_Inverse4Id`, `l3`.`OneToMany_Required_Self_Inverse4Id`, `l3`.`OneToOne_Optional_PK_Inverse4Id`, `l3`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `l5`.`Id` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` INNER JOIN ( - SELECT `t`.`Id`, `t`.`OneToMany_Optional_Inverse3Id` + SELECT `l4`.`Id`, `l4`.`OneToMany_Optional_Inverse3Id` FROM ( SELECT `l1`.`Id`, `l1`.`OneToMany_Optional_Inverse3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Optional_Inverse3Id` ORDER BY `l1`.`Id`) AS `row` FROM `LevelThree` AS `l1` WHERE (`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l0`.`Id` = `t0`.`OneToMany_Optional_Inverse3Id` -INNER JOIN `LevelFour` AS `l2` ON `t0`.`Id` = `l2`.`OneToMany_Required_Inverse4Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`Id`"); + ) AS `l4` + WHERE `l4`.`row` <= 1 +) AS `l5` ON `l0`.`Id` = `l5`.`OneToMany_Optional_Inverse3Id` +INNER JOIN `LevelFour` AS `l3` ON `l5`.`Id` = `l3`.`OneToMany_Required_Inverse4Id` +ORDER BY `l`.`Id`, `l0`.`Id`, `l5`.`OneToMany_Optional_Inverse3Id`, `l5`.`Id` +"""); } public override async Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async) @@ -551,58 +627,68 @@ public override async Task Filtered_include_complex_three_level_with_middle_havi await base.Filtered_include_complex_three_level_with_middle_having_filter2(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `l5`.`Id`, `l5`.`Level2_Optional_Id`, `l5`.`Level2_Required_Id`, `l5`.`Name`, `l5`.`OneToMany_Optional_Inverse3Id`, `l5`.`OneToMany_Optional_Self_Inverse3Id`, `l5`.`OneToMany_Required_Inverse3Id`, `l5`.`OneToMany_Required_Self_Inverse3Id`, `l5`.`OneToOne_Optional_PK_Inverse3Id`, `l5`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id` + SELECT `l4`.`Id`, `l4`.`Level2_Optional_Id`, `l4`.`Level2_Required_Id`, `l4`.`Name`, `l4`.`OneToMany_Optional_Inverse3Id`, `l4`.`OneToMany_Optional_Self_Inverse3Id`, `l4`.`OneToMany_Required_Inverse3Id`, `l4`.`OneToMany_Required_Self_Inverse3Id`, `l4`.`OneToOne_Optional_PK_Inverse3Id`, `l4`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Optional_Inverse3Id` ORDER BY `l1`.`Id`) AS `row` FROM `LevelThree` AS `l1` WHERE (`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l0`.`Id` = `t0`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`Id`", + ) AS `l4` + WHERE `l4`.`row` <= 1 +) AS `l5` ON `l0`.`Id` = `l5`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l0`.`Id`, `l5`.`OneToMany_Optional_Inverse3Id`, `l5`.`Id` +""", // - @"SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `t0`.`Id` + """ +SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `l5`.`Id` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` INNER JOIN ( - SELECT `t`.`Id`, `t`.`OneToMany_Optional_Inverse3Id` + SELECT `l4`.`Id`, `l4`.`OneToMany_Optional_Inverse3Id` FROM ( SELECT `l1`.`Id`, `l1`.`OneToMany_Optional_Inverse3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Optional_Inverse3Id` ORDER BY `l1`.`Id`) AS `row` FROM `LevelThree` AS `l1` WHERE (`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l0`.`Id` = `t0`.`OneToMany_Optional_Inverse3Id` -INNER JOIN `LevelFour` AS `l2` ON `t0`.`Id` = `l2`.`OneToMany_Optional_Inverse4Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`Id`", + ) AS `l4` + WHERE `l4`.`row` <= 1 +) AS `l5` ON `l0`.`Id` = `l5`.`OneToMany_Optional_Inverse3Id` +INNER JOIN `LevelFour` AS `l2` ON `l5`.`Id` = `l2`.`OneToMany_Optional_Inverse4Id` +ORDER BY `l`.`Id`, `l0`.`Id`, `l5`.`OneToMany_Optional_Inverse3Id`, `l5`.`Id` +""", // - @"SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `t0`.`Id` + """ +SELECT `l3`.`Id`, `l3`.`Level3_Optional_Id`, `l3`.`Level3_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse4Id`, `l3`.`OneToMany_Optional_Self_Inverse4Id`, `l3`.`OneToMany_Required_Inverse4Id`, `l3`.`OneToMany_Required_Self_Inverse4Id`, `l3`.`OneToOne_Optional_PK_Inverse4Id`, `l3`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `l5`.`Id` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` INNER JOIN ( - SELECT `t`.`Id`, `t`.`OneToMany_Optional_Inverse3Id` + SELECT `l4`.`Id`, `l4`.`OneToMany_Optional_Inverse3Id` FROM ( SELECT `l1`.`Id`, `l1`.`OneToMany_Optional_Inverse3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Optional_Inverse3Id` ORDER BY `l1`.`Id`) AS `row` FROM `LevelThree` AS `l1` WHERE (`l1`.`Name` <> 'Foo') OR `l1`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l0`.`Id` = `t0`.`OneToMany_Optional_Inverse3Id` -INNER JOIN `LevelFour` AS `l2` ON `t0`.`Id` = `l2`.`OneToMany_Required_Inverse4Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`Id`"); + ) AS `l4` + WHERE `l4`.`row` <= 1 +) AS `l5` ON `l0`.`Id` = `l5`.`OneToMany_Optional_Inverse3Id` +INNER JOIN `LevelFour` AS `l3` ON `l5`.`Id` = `l3`.`OneToMany_Required_Inverse4Id` +ORDER BY `l`.`Id`, `l0`.`Id`, `l5`.`OneToMany_Optional_Inverse3Id`, `l5`.`Id` +"""); } public override async Task Filtered_include_outer_parameter_used_inside_filter(bool async) @@ -610,31 +696,41 @@ public override async Task Filtered_include_outer_parameter_used_inside_filter(b await base.Filtered_include_outer_parameter_used_inside_filter(async); AssertSql( - @"SELECT `l`.`Id` +""" +SELECT `l`.`Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l4`.`Id`, `l4`.`Date`, `l4`.`Level1_Optional_Id`, `l4`.`Level1_Required_Id`, `l4`.`Name`, `l4`.`OneToMany_Optional_Inverse2Id`, `l4`.`OneToMany_Optional_Self_Inverse2Id`, `l4`.`OneToMany_Required_Inverse2Id`, `l4`.`OneToMany_Required_Self_Inverse2Id`, `l4`.`OneToOne_Optional_PK_Inverse2Id`, `l4`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` -JOIN `LevelTwo` AS `l0` ON TRUE -ORDER BY `l`.`Id`, `l0`.`Id`", +JOIN `LevelTwo` AS `l4` ON TRUE +ORDER BY `l`.`Id`, `l4`.`Id` +""", // - @"SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `l5`.`Id`, `l5`.`Level2_Optional_Id`, `l5`.`Level2_Required_Id`, `l5`.`Name`, `l5`.`OneToMany_Optional_Inverse3Id`, `l5`.`OneToMany_Optional_Self_Inverse3Id`, `l5`.`OneToMany_Required_Inverse3Id`, `l5`.`OneToMany_Required_Self_Inverse3Id`, `l5`.`OneToOne_Optional_PK_Inverse3Id`, `l5`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l4`.`Id` FROM `LevelOne` AS `l` -JOIN `LevelTwo` AS `l0` ON TRUE -INNER JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +JOIN `LevelTwo` AS `l4` ON TRUE +INNER JOIN `LevelThree` AS `l5` ON `l4`.`Id` = `l5`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l4`.`Id` +""", // - @"SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l8`.`Id`, `l8`.`Date`, `l8`.`Level1_Optional_Id`, `l8`.`Level1_Required_Id`, `l8`.`Name`, `l8`.`OneToMany_Optional_Inverse2Id`, `l8`.`OneToMany_Optional_Self_Inverse2Id`, `l8`.`OneToMany_Required_Inverse2Id`, `l8`.`OneToMany_Required_Self_Inverse2Id`, `l8`.`OneToOne_Optional_PK_Inverse2Id`, `l8`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` -JOIN `LevelTwo` AS `l0` ON TRUE -ORDER BY `l`.`Id`, `l0`.`Id`", +JOIN `LevelTwo` AS `l8` ON TRUE +ORDER BY `l`.`Id`, `l8`.`Id` +""", // - @"SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `l9`.`Id`, `l9`.`Level2_Optional_Id`, `l9`.`Level2_Required_Id`, `l9`.`Name`, `l9`.`OneToMany_Optional_Inverse3Id`, `l9`.`OneToMany_Optional_Self_Inverse3Id`, `l9`.`OneToMany_Required_Inverse3Id`, `l9`.`OneToMany_Required_Self_Inverse3Id`, `l9`.`OneToOne_Optional_PK_Inverse3Id`, `l9`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l8`.`Id` FROM `LevelOne` AS `l` -JOIN `LevelTwo` AS `l0` ON TRUE -INNER JOIN `LevelThree` AS `l1` ON (`l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id`) AND (`l`.`Id` <> `l1`.`Id`) -ORDER BY `l`.`Id`, `l0`.`Id`"); +JOIN `LevelTwo` AS `l8` ON TRUE +INNER JOIN `LevelThree` AS `l9` ON (`l8`.`Id` = `l9`.`OneToMany_Optional_Inverse3Id`) AND (`l`.`Id` <> `l9`.`Id`) +ORDER BY `l`.`Id`, `l8`.`Id` +"""); } @@ -643,14 +739,18 @@ public override async Task Select_nav_prop_collection_one_to_many_required(bool await base.Select_nav_prop_collection_one_to_many_required(async); AssertSql( - @"SELECT `l`.`Id` +""" +SELECT `l`.`Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `l0`.`Id`, `l`.`Id` + """ +SELECT `l2`.`Id`, `l`.`Id` FROM `LevelOne` AS `l` -INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Required_Inverse2Id` -ORDER BY `l`.`Id`"); +INNER JOIN `LevelTwo` AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Required_Inverse2Id` +ORDER BY `l`.`Id` +"""); } public override async Task Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(bool async) @@ -658,7 +758,8 @@ public override async Task Complex_SelectMany_with_nested_navigations_and_explic await base.Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(async); AssertSql( - @"SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `t`.`Id`, `t`.`Id0`, `t`.`Id1`, `t`.`Id2`, `t0`.`Id`, `t0`.`Id0`, `t0`.`Id1`, `t0`.`Id2`, `l11`.`Id`, `l12`.`Id`, `l13`.`Id`, `l14`.`Id`, `l14`.`Name` +""" +SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Id2`, `s0`.`Id`, `s0`.`Id0`, `s0`.`Id1`, `s0`.`Id2`, `l11`.`Id`, `l12`.`Id`, `l13`.`Id`, `l14`.`Id`, `l14`.`Name` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Required_Id` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Level2_Optional_Id` @@ -669,22 +770,24 @@ INNER JOIN ( INNER JOIN `LevelThree` AS `l4` ON `l3`.`Level3_Required_Id` = `l4`.`Id` LEFT JOIN `LevelTwo` AS `l5` ON `l4`.`Level2_Optional_Id` = `l5`.`Id` LEFT JOIN `LevelTwo` AS `l6` ON `l5`.`Id` = `l6`.`OneToMany_Required_Self_Inverse2Id` -) AS `t` ON `l2`.`Id` = `t`.`Id2` +) AS `s` ON `l2`.`Id` = `s`.`Id2` LEFT JOIN ( SELECT `l7`.`Id`, `l8`.`Id` AS `Id0`, `l9`.`Id` AS `Id1`, `l10`.`Id` AS `Id2`, `l10`.`Level2_Optional_Id` AS `Level2_Optional_Id0` FROM `LevelFour` AS `l7` INNER JOIN `LevelThree` AS `l8` ON `l7`.`Level3_Required_Id` = `l8`.`Id` INNER JOIN `LevelTwo` AS `l9` ON `l8`.`Level2_Required_Id` = `l9`.`Id` LEFT JOIN `LevelThree` AS `l10` ON `l9`.`Id` = `l10`.`OneToMany_Required_Inverse3Id` -) AS `t0` ON `t`.`Id2` = `t0`.`Id2` +) AS `s0` ON `s`.`Id2` = `s0`.`Id2` LEFT JOIN `LevelThree` AS `l11` ON `l2`.`OneToMany_Optional_Inverse4Id` = `l11`.`Id` -LEFT JOIN `LevelThree` AS `l12` ON `t`.`Id2` = `l12`.`Level2_Optional_Id` -LEFT JOIN `LevelTwo` AS `l13` ON `t0`.`Level2_Optional_Id0` = `l13`.`Id` +LEFT JOIN `LevelThree` AS `l12` ON `s`.`Id2` = `l12`.`Level2_Optional_Id` +LEFT JOIN `LevelTwo` AS `l13` ON `s0`.`Level2_Optional_Id0` = `l13`.`Id` LEFT JOIN `LevelThree` AS `l14` ON `l13`.`Id` = `l14`.`Level2_Required_Id` WHERE (`l11`.`Name` <> 'Foo') OR `l11`.`Name` IS NULL -ORDER BY `l12`.`Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `t`.`Id`, `t`.`Id0`, `t`.`Id1`, `t`.`Id2`, `t0`.`Id`, `t0`.`Id0`, `t0`.`Id1`, `t0`.`Id2`, `l11`.`Id`, `l13`.`Id`, `l14`.`Id`", +ORDER BY `l12`.`Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Id2`, `s0`.`Id`, `s0`.`Id0`, `s0`.`Id1`, `s0`.`Id2`, `l11`.`Id`, `l13`.`Id`, `l14`.`Id` +""", // - @"SELECT `t1`.`Id`, `t1`.`Date`, `t1`.`Level1_Optional_Id`, `t1`.`Level1_Required_Id`, `t1`.`Name`, `t1`.`OneToMany_Optional_Inverse2Id`, `t1`.`OneToMany_Optional_Self_Inverse2Id`, `t1`.`OneToMany_Required_Inverse2Id`, `t1`.`OneToMany_Required_Self_Inverse2Id`, `t1`.`OneToOne_Optional_PK_Inverse2Id`, `t1`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `t`.`Id`, `t`.`Id0`, `t`.`Id1`, `t`.`Id2`, `t0`.`Id`, `t0`.`Id0`, `t0`.`Id1`, `t0`.`Id2`, `l11`.`Id`, `l12`.`Id`, `l13`.`Id`, `l14`.`Id` + """ +SELECT `l18`.`Id`, `l18`.`Date`, `l18`.`Level1_Optional_Id`, `l18`.`Level1_Required_Id`, `l18`.`Name`, `l18`.`OneToMany_Optional_Inverse2Id`, `l18`.`OneToMany_Optional_Self_Inverse2Id`, `l18`.`OneToMany_Required_Inverse2Id`, `l18`.`OneToMany_Required_Self_Inverse2Id`, `l18`.`OneToOne_Optional_PK_Inverse2Id`, `l18`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Id2`, `s0`.`Id`, `s0`.`Id0`, `s0`.`Id1`, `s0`.`Id2`, `l11`.`Id`, `l12`.`Id`, `l13`.`Id`, `l14`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Required_Id` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Level2_Optional_Id` @@ -695,25 +798,26 @@ INNER JOIN ( INNER JOIN `LevelThree` AS `l4` ON `l3`.`Level3_Required_Id` = `l4`.`Id` LEFT JOIN `LevelTwo` AS `l5` ON `l4`.`Level2_Optional_Id` = `l5`.`Id` LEFT JOIN `LevelTwo` AS `l6` ON `l5`.`Id` = `l6`.`OneToMany_Required_Self_Inverse2Id` -) AS `t` ON `l2`.`Id` = `t`.`Id2` +) AS `s` ON `l2`.`Id` = `s`.`Id2` LEFT JOIN ( SELECT `l7`.`Id`, `l8`.`Id` AS `Id0`, `l9`.`Id` AS `Id1`, `l10`.`Id` AS `Id2`, `l10`.`Level2_Optional_Id` AS `Level2_Optional_Id0` FROM `LevelFour` AS `l7` INNER JOIN `LevelThree` AS `l8` ON `l7`.`Level3_Required_Id` = `l8`.`Id` INNER JOIN `LevelTwo` AS `l9` ON `l8`.`Level2_Required_Id` = `l9`.`Id` LEFT JOIN `LevelThree` AS `l10` ON `l9`.`Id` = `l10`.`OneToMany_Required_Inverse3Id` -) AS `t0` ON `t`.`Id2` = `t0`.`Id2` +) AS `s0` ON `s`.`Id2` = `s0`.`Id2` LEFT JOIN `LevelThree` AS `l11` ON `l2`.`OneToMany_Optional_Inverse4Id` = `l11`.`Id` -LEFT JOIN `LevelThree` AS `l12` ON `t`.`Id2` = `l12`.`Level2_Optional_Id` -LEFT JOIN `LevelTwo` AS `l13` ON `t0`.`Level2_Optional_Id0` = `l13`.`Id` +LEFT JOIN `LevelThree` AS `l12` ON `s`.`Id2` = `l12`.`Level2_Optional_Id` +LEFT JOIN `LevelTwo` AS `l13` ON `s0`.`Level2_Optional_Id0` = `l13`.`Id` LEFT JOIN `LevelThree` AS `l14` ON `l13`.`Id` = `l14`.`Level2_Required_Id` INNER JOIN ( - SELECT `l15`.`Id`, `l15`.`Date`, `l15`.`Level1_Optional_Id`, `l15`.`Level1_Required_Id`, `l15`.`Name`, `l15`.`OneToMany_Optional_Inverse2Id`, `l15`.`OneToMany_Optional_Self_Inverse2Id`, `l15`.`OneToMany_Required_Inverse2Id`, `l15`.`OneToMany_Required_Self_Inverse2Id`, `l15`.`OneToOne_Optional_PK_Inverse2Id`, `l15`.`OneToOne_Optional_Self2Id` - FROM `LevelTwo` AS `l15` - WHERE `l15`.`Id` <> 42 -) AS `t1` ON `t`.`Id2` = `t1`.`OneToMany_Optional_Self_Inverse2Id` + SELECT `l17`.`Id`, `l17`.`Date`, `l17`.`Level1_Optional_Id`, `l17`.`Level1_Required_Id`, `l17`.`Name`, `l17`.`OneToMany_Optional_Inverse2Id`, `l17`.`OneToMany_Optional_Self_Inverse2Id`, `l17`.`OneToMany_Required_Inverse2Id`, `l17`.`OneToMany_Required_Self_Inverse2Id`, `l17`.`OneToOne_Optional_PK_Inverse2Id`, `l17`.`OneToOne_Optional_Self2Id` + FROM `LevelTwo` AS `l17` + WHERE `l17`.`Id` <> 42 +) AS `l18` ON `s`.`Id2` = `l18`.`OneToMany_Optional_Self_Inverse2Id` WHERE (`l11`.`Name` <> 'Foo') OR `l11`.`Name` IS NULL -ORDER BY `l12`.`Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `t`.`Id`, `t`.`Id0`, `t`.`Id1`, `t`.`Id2`, `t0`.`Id`, `t0`.`Id0`, `t0`.`Id1`, `t0`.`Id2`, `l11`.`Id`, `l13`.`Id`, `l14`.`Id`"); +ORDER BY `l12`.`Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Id2`, `s0`.`Id`, `s0`.`Id0`, `s0`.`Id1`, `s0`.`Id2`, `l11`.`Id`, `l13`.`Id`, `l14`.`Id` +"""); } public override async Task Project_collection_navigation(bool async) @@ -753,23 +857,27 @@ public override async Task Project_collection_navigation_nested_with_take(bool a await base.Project_collection_navigation_nested_with_take(async); AssertSql( - @"SELECT `l`.`Id`, `l0`.`Id` +""" +SELECT `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `t0`.`Id`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `l5`.`Id`, `l5`.`Level2_Optional_Id`, `l5`.`Level2_Required_Id`, `l5`.`Name`, `l5`.`OneToMany_Optional_Inverse3Id`, `l5`.`OneToMany_Optional_Self_Inverse3Id`, `l5`.`OneToMany_Required_Inverse3Id`, `l5`.`OneToMany_Required_Self_Inverse3Id`, `l5`.`OneToOne_Optional_PK_Inverse3Id`, `l5`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id` + SELECT `l4`.`Id`, `l4`.`Level2_Optional_Id`, `l4`.`Level2_Required_Id`, `l4`.`Name`, `l4`.`OneToMany_Optional_Inverse3Id`, `l4`.`OneToMany_Optional_Self_Inverse3Id`, `l4`.`OneToMany_Required_Inverse3Id`, `l4`.`OneToMany_Required_Self_Inverse3Id`, `l4`.`OneToOne_Optional_PK_Inverse3Id`, `l4`.`OneToOne_Optional_Self3Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Optional_Inverse3Id` ORDER BY `l1`.`Id`) AS `row` - FROM `LevelThree` AS `l1` - ) AS `t` - WHERE `t`.`row` <= 50 -) AS `t0` ON `l0`.`Id` = `t0`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`"); + SELECT `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id`, ROW_NUMBER() OVER(PARTITION BY `l3`.`OneToMany_Optional_Inverse3Id` ORDER BY `l3`.`Id`) AS `row` + FROM `LevelThree` AS `l3` + ) AS `l4` + WHERE `l4`.`row` <= 50 +) AS `l5` ON `l0`.`Id` = `l5`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l0`.`Id` +"""); } public override async Task Project_collection_navigation_using_ef_property(bool async) @@ -811,20 +919,24 @@ public override async Task Project_collection_navigation_composed(bool async) await base.Project_collection_navigation_composed(async); AssertSql( - @"SELECT `l`.`Id` +""" +SELECT `l`.`Id` FROM `LevelOne` AS `l` WHERE `l`.`Id` < 3 -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l3`.`Id`, `l3`.`Date`, `l3`.`Level1_Optional_Id`, `l3`.`Level1_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse2Id`, `l3`.`OneToMany_Optional_Self_Inverse2Id`, `l3`.`OneToMany_Required_Inverse2Id`, `l3`.`OneToMany_Required_Self_Inverse2Id`, `l3`.`OneToOne_Optional_PK_Inverse2Id`, `l3`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( - SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` - FROM `LevelTwo` AS `l0` - WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` + FROM `LevelTwo` AS `l2` + WHERE (`l2`.`Name` <> 'Foo') OR `l2`.`Name` IS NULL +) AS `l3` ON `l`.`Id` = `l3`.`OneToMany_Optional_Inverse2Id` WHERE `l`.`Id` < 3 -ORDER BY `l`.`Id`"); +ORDER BY `l`.`Id` +"""); } public override async Task Project_collection_and_root_entity(bool async) @@ -847,19 +959,25 @@ public override async Task Project_collection_and_include(bool async) await base.Project_collection_and_include(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` -INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`"); +INNER JOIN `LevelTwo` AS `l1` ON `l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id` +"""); } public override async Task Project_navigation_and_collection(bool async) @@ -884,31 +1002,37 @@ public override async Task Include_inside_subquery(bool async) await base.Include_inside_subquery(async); AssertSql( - @"SELECT `l`.`Id` +""" +SELECT `l`.`Id` FROM `LevelOne` AS `l` WHERE `l`.`Id` < 3 -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l6`.`Id`, `l6`.`Date`, `l6`.`Level1_Optional_Id`, `l6`.`Level1_Required_Id`, `l6`.`Name`, `l6`.`OneToMany_Optional_Inverse2Id`, `l6`.`OneToMany_Optional_Self_Inverse2Id`, `l6`.`OneToMany_Required_Inverse2Id`, `l6`.`OneToMany_Required_Self_Inverse2Id`, `l6`.`OneToOne_Optional_PK_Inverse2Id`, `l6`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` JOIN LATERAL ( - SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` - FROM `LevelTwo` AS `l0` - WHERE `l0`.`Id` > 0 -) AS `t` ON TRUE + SELECT `l4`.`Id`, `l4`.`Date`, `l4`.`Level1_Optional_Id`, `l4`.`Level1_Required_Id`, `l4`.`Name`, `l4`.`OneToMany_Optional_Inverse2Id`, `l4`.`OneToMany_Optional_Self_Inverse2Id`, `l4`.`OneToMany_Required_Inverse2Id`, `l4`.`OneToMany_Required_Self_Inverse2Id`, `l4`.`OneToOne_Optional_PK_Inverse2Id`, `l4`.`OneToOne_Optional_Self2Id` + FROM `LevelTwo` AS `l4` + WHERE `l4`.`Id` > 0 +) AS `l6` ON TRUE WHERE `l`.`Id` < 3 -ORDER BY `l`.`Id`, `t`.`Id`", +ORDER BY `l`.`Id`, `l6`.`Id` +""", // - @"SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `t`.`Id` + """ +SELECT `l5`.`Id`, `l5`.`Level2_Optional_Id`, `l5`.`Level2_Required_Id`, `l5`.`Name`, `l5`.`OneToMany_Optional_Inverse3Id`, `l5`.`OneToMany_Optional_Self_Inverse3Id`, `l5`.`OneToMany_Required_Inverse3Id`, `l5`.`OneToMany_Required_Self_Inverse3Id`, `l5`.`OneToOne_Optional_PK_Inverse3Id`, `l5`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l6`.`Id` FROM `LevelOne` AS `l` JOIN LATERAL ( - SELECT `l0`.`Id` - FROM `LevelTwo` AS `l0` - WHERE `l0`.`Id` > 0 -) AS `t` ON TRUE -INNER JOIN `LevelThree` AS `l1` ON `t`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` + SELECT `l4`.`Id` + FROM `LevelTwo` AS `l4` + WHERE `l4`.`Id` > 0 +) AS `l6` ON TRUE +INNER JOIN `LevelThree` AS `l5` ON `l6`.`Id` = `l5`.`OneToMany_Optional_Inverse3Id` WHERE `l`.`Id` < 3 -ORDER BY `l`.`Id`, `t`.`Id`"); +ORDER BY `l`.`Id`, `l6`.`Id` +"""); } public override async Task Null_check_in_anonymous_type_projection_should_not_be_removed(bool async) @@ -916,18 +1040,22 @@ public override async Task Null_check_in_anonymous_type_projection_should_not_be await base.Null_check_in_anonymous_type_projection_should_not_be_removed(async); AssertSql( - @"SELECT `l`.`Id` +""" +SELECT `l`.`Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t`.`c`, `t`.`Name`, `l`.`Id` + """ +SELECT `s`.`c`, `s`.`Name`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( - SELECT `l1`.`Id` IS NULL AS `c`, `l1`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id` - FROM `LevelTwo` AS `l0` - LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Level2_Required_Id` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`"); + SELECT `l5`.`Id` IS NULL AS `c`, `l5`.`Name`, `l4`.`OneToMany_Optional_Inverse2Id` + FROM `LevelTwo` AS `l4` + LEFT JOIN `LevelThree` AS `l5` ON `l4`.`Id` = `l5`.`Level2_Required_Id` +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id` +"""); } public override async Task Null_check_in_Dto_projection_should_not_be_removed(bool async) @@ -935,18 +1063,22 @@ public override async Task Null_check_in_Dto_projection_should_not_be_removed(bo await base.Null_check_in_Dto_projection_should_not_be_removed(async); AssertSql( - @"SELECT `l`.`Id` +""" +SELECT `l`.`Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t`.`c`, `t`.`Name`, `l`.`Id` + """ +SELECT `s`.`c`, `s`.`Name`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( - SELECT `l1`.`Id` IS NULL AS `c`, `l1`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id` - FROM `LevelTwo` AS `l0` - LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Level2_Required_Id` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`"); + SELECT `l5`.`Id` IS NULL AS `c`, `l5`.`Name`, `l4`.`OneToMany_Optional_Inverse2Id` + FROM `LevelTwo` AS `l4` + LEFT JOIN `LevelThree` AS `l5` ON `l4`.`Id` = `l5`.`Level2_Required_Id` +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id` +"""); } public override async Task SelectMany_navigation_property_followed_by_select_collection_navigation(bool async) @@ -990,22 +1122,28 @@ public override async Task SelectMany_navigation_property_with_include_and_follo await base.SelectMany_navigation_property_with_include_and_followed_by_select_collection_navigation(async); AssertSql( - @"SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` +""" +SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` INNER JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Required_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` -INNER JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`"); +INNER JOIN `LevelThree` AS `l2` ON `l0`.`Id` = `l2`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l0`.`Id` +"""); } public override async Task Lift_projection_mapping_when_pushing_down_subquery(bool async) @@ -1013,34 +1151,38 @@ public override async Task Lift_projection_mapping_when_pushing_down_subquery(bo await base.Lift_projection_mapping_when_pushing_down_subquery(async); AssertSql( - @"@__p_0='25' +""" +@__p_0='25' -SELECT `t`.`Id`, `t0`.`Id`, `t0`.`c` +SELECT `l1`.`Id`, `l3`.`Id`, `l3`.`c` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` LIMIT @__p_0 -) AS `t` +) AS `l1` LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`c`, `t1`.`OneToMany_Required_Inverse2Id` + SELECT `l2`.`Id`, `l2`.`c`, `l2`.`OneToMany_Required_Inverse2Id` FROM ( SELECT `l0`.`Id`, 1 AS `c`, `l0`.`OneToMany_Required_Inverse2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Required_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`Id` = `t0`.`OneToMany_Required_Inverse2Id` -ORDER BY `t`.`Id`", + ) AS `l2` + WHERE `l2`.`row` <= 1 +) AS `l3` ON `l1`.`Id` = `l3`.`OneToMany_Required_Inverse2Id` +ORDER BY `l1`.`Id` +""", // - @"@__p_0='25' + """ +@__p_0='25' -SELECT `l0`.`Id`, `t`.`Id` +SELECT `l4`.`Id`, `l5`.`Id` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` LIMIT @__p_0 -) AS `t` -INNER JOIN `LevelTwo` AS `l0` ON `t`.`Id` = `l0`.`OneToMany_Required_Inverse2Id` -ORDER BY `t`.`Id`"); +) AS `l5` +INNER JOIN `LevelTwo` AS `l4` ON `l5`.`Id` = `l4`.`OneToMany_Required_Inverse2Id` +ORDER BY `l5`.`Id` +"""); } public override async Task Select_subquery_single_nested_subquery(bool async) @@ -1048,30 +1190,34 @@ public override async Task Select_subquery_single_nested_subquery(bool async) await base.Select_subquery_single_nested_subquery(async); AssertSql( - @"SELECT `l`.`Id`, `t0`.`Id`, `t0`.`c` +""" +SELECT `l`.`Id`, `l2`.`Id`, `l2`.`c` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`c`, `t`.`Id`, `t`.`OneToMany_Optional_Inverse2Id` + SELECT `l1`.`c`, `l1`.`Id`, `l1`.`OneToMany_Optional_Inverse2Id` FROM ( SELECT 1 AS `c`, `l0`.`Id`, `l0`.`OneToMany_Optional_Inverse2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`Id`", + ) AS `l1` + WHERE `l1`.`row` <= 1 +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`Id` +""", // - @"SELECT `l1`.`Id`, `l`.`Id`, `t0`.`Id` + """ +SELECT `l11`.`Id`, `l`.`Id`, `l13`.`Id` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`OneToMany_Optional_Inverse2Id` + SELECT `l12`.`Id`, `l12`.`OneToMany_Optional_Inverse2Id` FROM ( - SELECT `l0`.`Id`, `l0`.`OneToMany_Optional_Inverse2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` - FROM `LevelTwo` AS `l0` - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -INNER JOIN `LevelThree` AS `l1` ON `t0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `t0`.`Id`, `l1`.`Id`"); + SELECT `l8`.`Id`, `l8`.`OneToMany_Optional_Inverse2Id`, ROW_NUMBER() OVER(PARTITION BY `l8`.`OneToMany_Optional_Inverse2Id` ORDER BY `l8`.`Id`) AS `row` + FROM `LevelTwo` AS `l8` + ) AS `l12` + WHERE `l12`.`row` <= 1 +) AS `l13` ON `l`.`Id` = `l13`.`OneToMany_Optional_Inverse2Id` +INNER JOIN `LevelThree` AS `l11` ON `l13`.`Id` = `l11`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l13`.`Id`, `l11`.`Id` +"""); } public override async Task Select_subquery_single_nested_subquery2(bool async) @@ -1079,36 +1225,42 @@ public override async Task Select_subquery_single_nested_subquery2(bool async) await base.Select_subquery_single_nested_subquery2(async); AssertSql( - @"SELECT `l`.`Id` +""" +SELECT `l`.`Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `l`.`Id`, `l0`.`Id`, `t0`.`Id`, `t0`.`c` + """ +SELECT `l`.`Id`, `l26`.`Id`, `l40`.`Id`, `l40`.`c` FROM `LevelOne` AS `l` -INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` +INNER JOIN `LevelTwo` AS `l26` ON `l`.`Id` = `l26`.`OneToMany_Optional_Inverse2Id` LEFT JOIN ( - SELECT `t`.`c`, `t`.`Id`, `t`.`OneToMany_Optional_Inverse3Id` + SELECT `l39`.`c`, `l39`.`Id`, `l39`.`OneToMany_Optional_Inverse3Id` FROM ( - SELECT 1 AS `c`, `l1`.`Id`, `l1`.`OneToMany_Optional_Inverse3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Optional_Inverse3Id` ORDER BY `l1`.`Id`) AS `row` - FROM `LevelThree` AS `l1` - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l0`.`Id` = `t0`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `t0`.`Id`", + SELECT 1 AS `c`, `l35`.`Id`, `l35`.`OneToMany_Optional_Inverse3Id`, ROW_NUMBER() OVER(PARTITION BY `l35`.`OneToMany_Optional_Inverse3Id` ORDER BY `l35`.`Id`) AS `row` + FROM `LevelThree` AS `l35` + ) AS `l39` + WHERE `l39`.`row` <= 1 +) AS `l40` ON `l26`.`Id` = `l40`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l26`.`Id`, `l40`.`Id` +""", // - @"SELECT `l2`.`Id`, `l`.`Id`, `l0`.`Id`, `t0`.`Id` + """ +SELECT `l38`.`Id`, `l`.`Id`, `l26`.`Id`, `l40`.`Id` FROM `LevelOne` AS `l` -INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` +INNER JOIN `LevelTwo` AS `l26` ON `l`.`Id` = `l26`.`OneToMany_Optional_Inverse2Id` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`OneToMany_Optional_Inverse3Id` + SELECT `l39`.`Id`, `l39`.`OneToMany_Optional_Inverse3Id` FROM ( - SELECT `l1`.`Id`, `l1`.`OneToMany_Optional_Inverse3Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`OneToMany_Optional_Inverse3Id` ORDER BY `l1`.`Id`) AS `row` - FROM `LevelThree` AS `l1` - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l0`.`Id` = `t0`.`OneToMany_Optional_Inverse3Id` -INNER JOIN `LevelFour` AS `l2` ON `t0`.`Id` = `l2`.`OneToMany_Optional_Inverse4Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `t0`.`Id`, `l2`.`Id`"); + SELECT `l35`.`Id`, `l35`.`OneToMany_Optional_Inverse3Id`, ROW_NUMBER() OVER(PARTITION BY `l35`.`OneToMany_Optional_Inverse3Id` ORDER BY `l35`.`Id`) AS `row` + FROM `LevelThree` AS `l35` + ) AS `l39` + WHERE `l39`.`row` <= 1 +) AS `l40` ON `l26`.`Id` = `l40`.`OneToMany_Optional_Inverse3Id` +INNER JOIN `LevelFour` AS `l38` ON `l40`.`Id` = `l38`.`OneToMany_Optional_Inverse4Id` +ORDER BY `l`.`Id`, `l26`.`Id`, `l40`.`Id`, `l38`.`Id` +"""); } public override async Task Queryable_in_subquery_works_when_final_projection_is_List(bool async) @@ -1123,33 +1275,37 @@ public override async Task Complex_query_with_let_collection_projection_FirstOrD await base.Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(async); AssertSql( - @"SELECT `l`.`Id`, `t`.`Id`, `t`.`c` +""" +SELECT `l`.`Id`, `l1`.`Id`, `l1`.`c` FROM `LevelOne` AS `l` LEFT JOIN LATERAL ( SELECT 1 AS `c`, `l0`.`Id` FROM `LevelTwo` AS `l0` WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL LIMIT 1 -) AS `t` ON TRUE -ORDER BY `l`.`Id`, `t`.`Id`", +) AS `l1` ON TRUE +ORDER BY `l`.`Id`, `l1`.`Id` +""", // - @"SELECT `t0`.`Name`, `l`.`Id`, `t`.`Id` + """ +SELECT `l29`.`Name`, `l`.`Id`, `l28`.`Id` FROM `LevelOne` AS `l` LEFT JOIN LATERAL ( - SELECT `l0`.`Id` - FROM `LevelTwo` AS `l0` - WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL + SELECT `l21`.`Id` + FROM `LevelTwo` AS `l21` + WHERE (`l21`.`Name` <> 'Foo') OR `l21`.`Name` IS NULL LIMIT 1 -) AS `t` ON TRUE +) AS `l28` ON TRUE JOIN LATERAL ( - SELECT `l1`.`Name` - FROM `LevelOne` AS `l1` + SELECT `l26`.`Name` + FROM `LevelOne` AS `l26` WHERE EXISTS ( SELECT 1 - FROM `LevelTwo` AS `l2` - WHERE (`l1`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id`) AND (`l2`.`Id` = `t`.`Id`)) -) AS `t0` ON TRUE -ORDER BY `l`.`Id`, `t`.`Id`"); + FROM `LevelTwo` AS `l27` + WHERE (`l26`.`Id` = `l27`.`OneToMany_Optional_Inverse2Id`) AND (`l27`.`Id` = `l28`.`Id`)) +) AS `l29` ON TRUE +ORDER BY `l`.`Id`, `l28`.`Id` +"""); } public override async Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async) @@ -1157,39 +1313,43 @@ public override async Task Complex_query_with_let_collection_projection_FirstOrD await base.Complex_query_with_let_collection_projection_FirstOrDefault(async); AssertSql( - @"SELECT `l`.`Id`, `t0`.`Id`, `t0`.`c` +""" +SELECT `l`.`Id`, `l2`.`Id`, `l2`.`c` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`c`, `t`.`Id`, `t`.`OneToMany_Optional_Inverse2Id` + SELECT `l1`.`c`, `l1`.`Id`, `l1`.`OneToMany_Optional_Inverse2Id` FROM ( SELECT 1 AS `c`, `l0`.`Id`, `l0`.`OneToMany_Optional_Inverse2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`Id`", + ) AS `l1` + WHERE `l1`.`row` <= 1 +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`Id` +""", // - @"SELECT `t1`.`Name`, `l`.`Id`, `t0`.`Id` + """ +SELECT `l23`.`Name`, `l`.`Id`, `l22`.`Id` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`OneToMany_Optional_Inverse2Id` + SELECT `l21`.`Id`, `l21`.`OneToMany_Optional_Inverse2Id` FROM ( - SELECT `l0`.`Id`, `l0`.`OneToMany_Optional_Inverse2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` - FROM `LevelTwo` AS `l0` - WHERE (`l0`.`Name` <> 'Foo') OR `l0`.`Name` IS NULL - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` + SELECT `l14`.`Id`, `l14`.`OneToMany_Optional_Inverse2Id`, ROW_NUMBER() OVER(PARTITION BY `l14`.`OneToMany_Optional_Inverse2Id` ORDER BY `l14`.`Id`) AS `row` + FROM `LevelTwo` AS `l14` + WHERE (`l14`.`Name` <> 'Foo') OR `l14`.`Name` IS NULL + ) AS `l21` + WHERE `l21`.`row` <= 1 +) AS `l22` ON `l`.`Id` = `l22`.`OneToMany_Optional_Inverse2Id` JOIN LATERAL ( - SELECT `l1`.`Name` - FROM `LevelOne` AS `l1` + SELECT `l19`.`Name` + FROM `LevelOne` AS `l19` WHERE EXISTS ( SELECT 1 - FROM `LevelTwo` AS `l2` - WHERE (`l1`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id`) AND (`l2`.`Id` = `t0`.`Id`)) -) AS `t1` ON TRUE -ORDER BY `l`.`Id`, `t0`.`Id`"); + FROM `LevelTwo` AS `l20` + WHERE (`l19`.`Id` = `l20`.`OneToMany_Optional_Inverse2Id`) AND (`l20`.`Id` = `l22`.`Id`)) +) AS `l23` ON TRUE +ORDER BY `l`.`Id`, `l22`.`Id` +"""); } public override async Task SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(bool async) @@ -1197,7 +1357,8 @@ public override async Task SelectMany_DefaultIfEmpty_multiple_times_with_joins_p await base.SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(async); AssertSql( - @"SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `t`.`Id`, `t`.`Id0`, `t`.`Id1`, `t`.`Id2`, `t0`.`Id`, `t0`.`Id0`, `t0`.`Id1`, `t0`.`Id2`, `l11`.`Id`, `l12`.`Id`, `l13`.`Id`, `l14`.`Id`, `l14`.`Name` +""" +SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Id2`, `s0`.`Id`, `s0`.`Id0`, `s0`.`Id1`, `s0`.`Id2`, `l11`.`Id`, `l12`.`Id`, `l13`.`Id`, `l14`.`Id`, `l14`.`Name` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Required_Id` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Level2_Optional_Id` @@ -1208,22 +1369,24 @@ INNER JOIN ( INNER JOIN `LevelThree` AS `l4` ON `l3`.`Level3_Required_Id` = `l4`.`Id` LEFT JOIN `LevelTwo` AS `l5` ON `l4`.`Level2_Optional_Id` = `l5`.`Id` LEFT JOIN `LevelTwo` AS `l6` ON `l5`.`Id` = `l6`.`OneToMany_Required_Self_Inverse2Id` -) AS `t` ON `l2`.`Id` = `t`.`Id2` +) AS `s` ON `l2`.`Id` = `s`.`Id2` LEFT JOIN ( SELECT `l7`.`Id`, `l8`.`Id` AS `Id0`, `l9`.`Id` AS `Id1`, `l10`.`Id` AS `Id2`, `l10`.`Level2_Optional_Id` AS `Level2_Optional_Id0` FROM `LevelFour` AS `l7` INNER JOIN `LevelThree` AS `l8` ON `l7`.`Level3_Required_Id` = `l8`.`Id` INNER JOIN `LevelTwo` AS `l9` ON `l8`.`Level2_Required_Id` = `l9`.`Id` LEFT JOIN `LevelThree` AS `l10` ON `l9`.`Id` = `l10`.`OneToMany_Required_Inverse3Id` -) AS `t0` ON `t`.`Id2` = `t0`.`Id2` +) AS `s0` ON `s`.`Id2` = `s0`.`Id2` LEFT JOIN `LevelThree` AS `l11` ON `l2`.`OneToMany_Optional_Inverse4Id` = `l11`.`Id` -LEFT JOIN `LevelThree` AS `l12` ON `t`.`Id2` = `l12`.`Level2_Optional_Id` -LEFT JOIN `LevelTwo` AS `l13` ON `t0`.`Level2_Optional_Id0` = `l13`.`Id` +LEFT JOIN `LevelThree` AS `l12` ON `s`.`Id2` = `l12`.`Level2_Optional_Id` +LEFT JOIN `LevelTwo` AS `l13` ON `s0`.`Level2_Optional_Id0` = `l13`.`Id` LEFT JOIN `LevelThree` AS `l14` ON `l13`.`Id` = `l14`.`Level2_Required_Id` WHERE (`l11`.`Name` <> 'Foo') OR `l11`.`Name` IS NULL -ORDER BY `l12`.`Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `t`.`Id`, `t`.`Id0`, `t`.`Id1`, `t`.`Id2`, `t0`.`Id`, `t0`.`Id0`, `t0`.`Id1`, `t0`.`Id2`, `l11`.`Id`, `l13`.`Id`, `l14`.`Id`", +ORDER BY `l12`.`Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Id2`, `s0`.`Id`, `s0`.`Id0`, `s0`.`Id1`, `s0`.`Id2`, `l11`.`Id`, `l13`.`Id`, `l14`.`Id` +""", // - @"SELECT `t1`.`Id`, `t1`.`Date`, `t1`.`Level1_Optional_Id`, `t1`.`Level1_Required_Id`, `t1`.`Name`, `t1`.`OneToMany_Optional_Inverse2Id`, `t1`.`OneToMany_Optional_Self_Inverse2Id`, `t1`.`OneToMany_Required_Inverse2Id`, `t1`.`OneToMany_Required_Self_Inverse2Id`, `t1`.`OneToOne_Optional_PK_Inverse2Id`, `t1`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `t`.`Id`, `t`.`Id0`, `t`.`Id1`, `t`.`Id2`, `t0`.`Id`, `t0`.`Id0`, `t0`.`Id1`, `t0`.`Id2`, `l11`.`Id`, `l12`.`Id`, `l13`.`Id`, `l14`.`Id` + """ +SELECT `l18`.`Id`, `l18`.`Date`, `l18`.`Level1_Optional_Id`, `l18`.`Level1_Required_Id`, `l18`.`Name`, `l18`.`OneToMany_Optional_Inverse2Id`, `l18`.`OneToMany_Optional_Self_Inverse2Id`, `l18`.`OneToMany_Required_Inverse2Id`, `l18`.`OneToMany_Required_Self_Inverse2Id`, `l18`.`OneToOne_Optional_PK_Inverse2Id`, `l18`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Id2`, `s0`.`Id`, `s0`.`Id0`, `s0`.`Id1`, `s0`.`Id2`, `l11`.`Id`, `l12`.`Id`, `l13`.`Id`, `l14`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Required_Id` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Level2_Optional_Id` @@ -1234,25 +1397,26 @@ INNER JOIN ( INNER JOIN `LevelThree` AS `l4` ON `l3`.`Level3_Required_Id` = `l4`.`Id` LEFT JOIN `LevelTwo` AS `l5` ON `l4`.`Level2_Optional_Id` = `l5`.`Id` LEFT JOIN `LevelTwo` AS `l6` ON `l5`.`Id` = `l6`.`OneToMany_Required_Self_Inverse2Id` -) AS `t` ON `l2`.`Id` = `t`.`Id2` +) AS `s` ON `l2`.`Id` = `s`.`Id2` LEFT JOIN ( SELECT `l7`.`Id`, `l8`.`Id` AS `Id0`, `l9`.`Id` AS `Id1`, `l10`.`Id` AS `Id2`, `l10`.`Level2_Optional_Id` AS `Level2_Optional_Id0` FROM `LevelFour` AS `l7` INNER JOIN `LevelThree` AS `l8` ON `l7`.`Level3_Required_Id` = `l8`.`Id` INNER JOIN `LevelTwo` AS `l9` ON `l8`.`Level2_Required_Id` = `l9`.`Id` LEFT JOIN `LevelThree` AS `l10` ON `l9`.`Id` = `l10`.`OneToMany_Required_Inverse3Id` -) AS `t0` ON `t`.`Id2` = `t0`.`Id2` +) AS `s0` ON `s`.`Id2` = `s0`.`Id2` LEFT JOIN `LevelThree` AS `l11` ON `l2`.`OneToMany_Optional_Inverse4Id` = `l11`.`Id` -LEFT JOIN `LevelThree` AS `l12` ON `t`.`Id2` = `l12`.`Level2_Optional_Id` -LEFT JOIN `LevelTwo` AS `l13` ON `t0`.`Level2_Optional_Id0` = `l13`.`Id` +LEFT JOIN `LevelThree` AS `l12` ON `s`.`Id2` = `l12`.`Level2_Optional_Id` +LEFT JOIN `LevelTwo` AS `l13` ON `s0`.`Level2_Optional_Id0` = `l13`.`Id` LEFT JOIN `LevelThree` AS `l14` ON `l13`.`Id` = `l14`.`Level2_Required_Id` INNER JOIN ( - SELECT `l15`.`Id`, `l15`.`Date`, `l15`.`Level1_Optional_Id`, `l15`.`Level1_Required_Id`, `l15`.`Name`, `l15`.`OneToMany_Optional_Inverse2Id`, `l15`.`OneToMany_Optional_Self_Inverse2Id`, `l15`.`OneToMany_Required_Inverse2Id`, `l15`.`OneToMany_Required_Self_Inverse2Id`, `l15`.`OneToOne_Optional_PK_Inverse2Id`, `l15`.`OneToOne_Optional_Self2Id` - FROM `LevelTwo` AS `l15` - WHERE `l15`.`Id` <> 42 -) AS `t1` ON `t`.`Id2` = `t1`.`OneToMany_Optional_Self_Inverse2Id` + SELECT `l17`.`Id`, `l17`.`Date`, `l17`.`Level1_Optional_Id`, `l17`.`Level1_Required_Id`, `l17`.`Name`, `l17`.`OneToMany_Optional_Inverse2Id`, `l17`.`OneToMany_Optional_Self_Inverse2Id`, `l17`.`OneToMany_Required_Inverse2Id`, `l17`.`OneToMany_Required_Self_Inverse2Id`, `l17`.`OneToOne_Optional_PK_Inverse2Id`, `l17`.`OneToOne_Optional_Self2Id` + FROM `LevelTwo` AS `l17` + WHERE `l17`.`Id` <> 42 +) AS `l18` ON `s`.`Id2` = `l18`.`OneToMany_Optional_Self_Inverse2Id` WHERE (`l11`.`Name` <> 'Foo') OR `l11`.`Name` IS NULL -ORDER BY `l12`.`Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `t`.`Id`, `t`.`Id0`, `t`.`Id1`, `t`.`Id2`, `t0`.`Id`, `t0`.`Id0`, `t0`.`Id1`, `t0`.`Id2`, `l11`.`Id`, `l13`.`Id`, `l14`.`Id`"); +ORDER BY `l12`.`Id`, `l`.`Id`, `l0`.`Id`, `l1`.`Id`, `l2`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Id2`, `s0`.`Id`, `s0`.`Id0`, `s0`.`Id1`, `s0`.`Id2`, `l11`.`Id`, `l13`.`Id`, `l14`.`Id` +"""); } public override async Task Take_Select_collection_Take(bool async) @@ -1260,34 +1424,38 @@ public override async Task Take_Select_collection_Take(bool async) await base.Take_Select_collection_Take(async); AssertSql( - @"@__p_0='1' +""" +@__p_0='1' SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` -LIMIT @__p_0", +LIMIT @__p_0 +""", // - @"@__p_0='1' + """ +@__p_0='1' -SELECT `t0`.`Id`, `t0`.`Name`, `t0`.`Level1Id`, `t0`.`Level2Id`, `t0`.`Id0`, `t0`.`Date`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Self_Inverse1Id`, `t0`.`OneToMany_Required_Self_Inverse1Id`, `t0`.`OneToOne_Optional_Self1Id`, `t`.`Id` +SELECT `s`.`Id`, `s`.`Name`, `s`.`Level1Id`, `s`.`Level2Id`, `s`.`Id0`, `s`.`Date`, `s`.`Name0`, `s`.`OneToMany_Optional_Self_Inverse1Id`, `s`.`OneToMany_Required_Self_Inverse1Id`, `s`.`OneToOne_Optional_Self1Id`, `l9`.`Id` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` LIMIT @__p_0 -) AS `t` +) AS `l9` JOIN LATERAL ( - SELECT `t1`.`Id`, `t1`.`Name`, `t1`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `t1`.`Level1_Required_Id` AS `Level2Id`, `l0`.`Id` AS `Id0`, `l0`.`Date`, `l0`.`Name` AS `Name0`, `l0`.`OneToMany_Optional_Self_Inverse1Id`, `l0`.`OneToMany_Required_Self_Inverse1Id`, `l0`.`OneToOne_Optional_Self1Id` + SELECT `l8`.`Id`, `l8`.`Name`, `l8`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `l8`.`Level1_Required_Id` AS `Level2Id`, `l7`.`Id` AS `Id0`, `l7`.`Date`, `l7`.`Name` AS `Name0`, `l7`.`OneToMany_Optional_Self_Inverse1Id`, `l7`.`OneToMany_Required_Self_Inverse1Id`, `l7`.`OneToOne_Optional_Self1Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Required_Inverse2Id` - FROM `LevelTwo` AS `l1` - WHERE `t`.`Id` = `l1`.`OneToMany_Required_Inverse2Id` - ORDER BY `l1`.`Id` + SELECT `l6`.`Id`, `l6`.`Level1_Required_Id`, `l6`.`Name`, `l6`.`OneToMany_Required_Inverse2Id` + FROM `LevelTwo` AS `l6` + WHERE `l9`.`Id` = `l6`.`OneToMany_Required_Inverse2Id` + ORDER BY `l6`.`Id` LIMIT 3 - ) AS `t1` - INNER JOIN `LevelOne` AS `l0` ON `t1`.`Level1_Required_Id` = `l0`.`Id` -) AS `t0` ON TRUE -ORDER BY `t`.`Id`, `t0`.`Id`"); + ) AS `l8` + INNER JOIN `LevelOne` AS `l7` ON `l8`.`Level1_Required_Id` = `l7`.`Id` +) AS `s` ON TRUE +ORDER BY `l9`.`Id`, `s`.`Id` +"""); } public override async Task Skip_Take_Select_collection_Skip_Take(bool async) @@ -1295,34 +1463,38 @@ public override async Task Skip_Take_Select_collection_Skip_Take(bool async) await base.Skip_Take_Select_collection_Skip_Take(async); AssertSql( - @"@__p_0='1' +""" +@__p_0='1' SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` -LIMIT @__p_0 OFFSET @__p_0", +LIMIT @__p_0 OFFSET @__p_0 +""", // - @"@__p_0='1' + """ +@__p_0='1' -SELECT `t0`.`Id`, `t0`.`Name`, `t0`.`Level1Id`, `t0`.`Level2Id`, `t0`.`Id0`, `t0`.`Date`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Self_Inverse1Id`, `t0`.`OneToMany_Required_Self_Inverse1Id`, `t0`.`OneToOne_Optional_Self1Id`, `t`.`Id` +SELECT `s`.`Id`, `s`.`Name`, `s`.`Level1Id`, `s`.`Level2Id`, `s`.`Id0`, `s`.`Date`, `s`.`Name0`, `s`.`OneToMany_Optional_Self_Inverse1Id`, `s`.`OneToMany_Required_Self_Inverse1Id`, `s`.`OneToOne_Optional_Self1Id`, `l9`.`Id` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` LIMIT @__p_0 OFFSET @__p_0 -) AS `t` +) AS `l9` JOIN LATERAL ( - SELECT `t1`.`Id`, `t1`.`Name`, `t1`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `t1`.`Level1_Required_Id` AS `Level2Id`, `l0`.`Id` AS `Id0`, `l0`.`Date`, `l0`.`Name` AS `Name0`, `l0`.`OneToMany_Optional_Self_Inverse1Id`, `l0`.`OneToMany_Required_Self_Inverse1Id`, `l0`.`OneToOne_Optional_Self1Id` + SELECT `l8`.`Id`, `l8`.`Name`, `l8`.`OneToMany_Required_Inverse2Id` AS `Level1Id`, `l8`.`Level1_Required_Id` AS `Level2Id`, `l7`.`Id` AS `Id0`, `l7`.`Date`, `l7`.`Name` AS `Name0`, `l7`.`OneToMany_Optional_Self_Inverse1Id`, `l7`.`OneToMany_Required_Self_Inverse1Id`, `l7`.`OneToOne_Optional_Self1Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Required_Inverse2Id` - FROM `LevelTwo` AS `l1` - WHERE `t`.`Id` = `l1`.`OneToMany_Required_Inverse2Id` - ORDER BY `l1`.`Id` + SELECT `l6`.`Id`, `l6`.`Level1_Required_Id`, `l6`.`Name`, `l6`.`OneToMany_Required_Inverse2Id` + FROM `LevelTwo` AS `l6` + WHERE `l9`.`Id` = `l6`.`OneToMany_Required_Inverse2Id` + ORDER BY `l6`.`Id` LIMIT 3 OFFSET 1 - ) AS `t1` - INNER JOIN `LevelOne` AS `l0` ON `t1`.`Level1_Required_Id` = `l0`.`Id` -) AS `t0` ON TRUE -ORDER BY `t`.`Id`, `t0`.`Id`"); + ) AS `l8` + INNER JOIN `LevelOne` AS `l7` ON `l8`.`Level1_Required_Id` = `l7`.`Id` +) AS `s` ON TRUE +ORDER BY `l9`.`Id`, `s`.`Id` +"""); } public override async Task Multi_level_include_one_to_many_optional_and_one_to_many_optional_produces_valid_sql(bool async) @@ -1351,35 +1523,43 @@ public override async Task Multi_level_include_correct_PK_is_chosen_as_the_join_ await base.Multi_level_include_correct_PK_is_chosen_as_the_join_predicate_for_queries_that_join_same_table_multiple_times(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` + """ +SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `t`.`Id`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id`, `t`.`Id0`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `s`.`Id`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `s`.`Id0`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` INNER JOIN ( SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l2`.`Id` AS `Id0`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name` AS `Name0`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelThree` AS `l1` INNER JOIN `LevelTwo` AS `l2` ON `l1`.`OneToMany_Required_Inverse3Id` = `l2`.`Id` -) AS `t` ON `l0`.`Id` = `t`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `t`.`Id`, `t`.`Id0`", +) AS `s` ON `l0`.`Id` = `s`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l0`.`Id`, `s`.`Id`, `s`.`Id0` +""", // - @"SELECT `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id`, `t`.`Id`, `t`.`Id0` + """ +SELECT `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id`, `s`.`Id`, `s`.`Id0` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` INNER JOIN ( SELECT `l1`.`Id`, `l1`.`OneToMany_Optional_Inverse3Id`, `l2`.`Id` AS `Id0` FROM `LevelThree` AS `l1` INNER JOIN `LevelTwo` AS `l2` ON `l1`.`OneToMany_Required_Inverse3Id` = `l2`.`Id` -) AS `t` ON `l0`.`Id` = `t`.`OneToMany_Optional_Inverse3Id` -INNER JOIN `LevelThree` AS `l3` ON `t`.`Id0` = `l3`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`, `t`.`Id`, `t`.`Id0`"); +) AS `s` ON `l0`.`Id` = `s`.`OneToMany_Optional_Inverse3Id` +INNER JOIN `LevelThree` AS `l3` ON `s`.`Id0` = `l3`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l0`.`Id`, `s`.`Id`, `s`.`Id0` +"""); } public override async Task Multiple_complex_includes(bool async) @@ -1387,26 +1567,32 @@ public override async Task Multiple_complex_includes(bool async) await base.Multiple_complex_includes(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` INNER JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `t`.`Id0`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` INNER JOIN ( - SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id`, `l2`.`Id` AS `Id0`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name` AS `Name0`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id` - FROM `LevelTwo` AS `l1` - LEFT JOIN `LevelThree` AS `l2` ON `l1`.`Id` = `l2`.`Level2_Optional_Id` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `l0`.`Id`"); + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l3`.`Id` AS `Id0`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name` AS `Name0`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id` + FROM `LevelTwo` AS `l2` + LEFT JOIN `LevelThree` AS `l3` ON `l2`.`Id` = `l3`.`Level2_Optional_Id` +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l0`.`Id` +"""); } public override async Task Multiple_complex_includes_self_ref(bool async) @@ -1414,26 +1600,32 @@ public override async Task Multiple_complex_includes_self_ref(bool async) await base.Multiple_complex_includes_self_ref(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Name`, `l0`.`OneToMany_Optional_Self_Inverse1Id`, `l0`.`OneToMany_Required_Self_Inverse1Id`, `l0`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Name`, `l0`.`OneToMany_Optional_Self_Inverse1Id`, `l0`.`OneToMany_Required_Self_Inverse1Id`, `l0`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelOne` AS `l0` ON `l`.`OneToOne_Optional_Self1Id` = `l0`.`Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelOne` AS `l0` ON `l`.`OneToOne_Optional_Self1Id` = `l0`.`Id` INNER JOIN `LevelOne` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Optional_Self_Inverse1Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `t`.`Id`, `t`.`Date`, `t`.`Name`, `t`.`OneToMany_Optional_Self_Inverse1Id`, `t`.`OneToMany_Required_Self_Inverse1Id`, `t`.`OneToOne_Optional_Self1Id`, `t`.`Id0`, `t`.`Date0`, `t`.`Name0`, `t`.`OneToMany_Optional_Self_Inverse1Id0`, `t`.`OneToMany_Required_Self_Inverse1Id0`, `t`.`OneToOne_Optional_Self1Id0`, `l`.`Id`, `l0`.`Id` + """ +SELECT `s`.`Id`, `s`.`Date`, `s`.`Name`, `s`.`OneToMany_Optional_Self_Inverse1Id`, `s`.`OneToMany_Required_Self_Inverse1Id`, `s`.`OneToOne_Optional_Self1Id`, `s`.`Id0`, `s`.`Date0`, `s`.`Name0`, `s`.`OneToMany_Optional_Self_Inverse1Id0`, `s`.`OneToMany_Required_Self_Inverse1Id0`, `s`.`OneToOne_Optional_Self1Id0`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelOne` AS `l0` ON `l`.`OneToOne_Optional_Self1Id` = `l0`.`Id` INNER JOIN ( - SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `l2`.`Id` AS `Id0`, `l2`.`Date` AS `Date0`, `l2`.`Name` AS `Name0`, `l2`.`OneToMany_Optional_Self_Inverse1Id` AS `OneToMany_Optional_Self_Inverse1Id0`, `l2`.`OneToMany_Required_Self_Inverse1Id` AS `OneToMany_Required_Self_Inverse1Id0`, `l2`.`OneToOne_Optional_Self1Id` AS `OneToOne_Optional_Self1Id0` - FROM `LevelOne` AS `l1` - LEFT JOIN `LevelOne` AS `l2` ON `l1`.`OneToOne_Optional_Self1Id` = `l2`.`Id` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Self_Inverse1Id` -ORDER BY `l`.`Id`, `l0`.`Id`"); + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Name`, `l2`.`OneToMany_Optional_Self_Inverse1Id`, `l2`.`OneToMany_Required_Self_Inverse1Id`, `l2`.`OneToOne_Optional_Self1Id`, `l3`.`Id` AS `Id0`, `l3`.`Date` AS `Date0`, `l3`.`Name` AS `Name0`, `l3`.`OneToMany_Optional_Self_Inverse1Id` AS `OneToMany_Optional_Self_Inverse1Id0`, `l3`.`OneToMany_Required_Self_Inverse1Id` AS `OneToMany_Required_Self_Inverse1Id0`, `l3`.`OneToOne_Optional_Self1Id` AS `OneToOne_Optional_Self1Id0` + FROM `LevelOne` AS `l2` + LEFT JOIN `LevelOne` AS `l3` ON `l2`.`OneToOne_Optional_Self1Id` = `l3`.`Id` +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Self_Inverse1Id` +ORDER BY `l`.`Id`, `l0`.`Id` +"""); } public override async Task Include_reference_and_collection_order_by(bool async) @@ -1475,18 +1667,22 @@ public override async Task Include_collection_then_reference(bool async) await base.Include_collection_then_reference(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `t`.`Id0`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id`, `l`.`Id` + """ +SELECT `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` FROM `LevelTwo` AS `l0` LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Level2_Optional_Id` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`"); +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id` +"""); } public override async Task Include_collection_with_conditional_order_by(bool async) @@ -1502,8 +1698,8 @@ ORDER BY CASE ELSE 2 END, `l`.`Id` """, -// -""" + // + """ SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` INNER JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` @@ -1519,26 +1715,32 @@ public override async Task Multiple_complex_include_select(bool async) await base.Multiple_complex_include_select(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` INNER JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id`, `t`.`Id0`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` INNER JOIN ( - SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id`, `l2`.`Id` AS `Id0`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name` AS `Name0`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id` - FROM `LevelTwo` AS `l1` - LEFT JOIN `LevelThree` AS `l2` ON `l1`.`Id` = `l2`.`Level2_Optional_Id` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `l0`.`Id`"); + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l3`.`Id` AS `Id0`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name` AS `Name0`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id` + FROM `LevelTwo` AS `l2` + LEFT JOIN `LevelThree` AS `l3` ON `l2`.`Id` = `l3`.`Level2_Optional_Id` +) AS `s` ON `l`.`Id` = `s`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l0`.`Id` +"""); } public override async Task Include_nested_with_optional_navigation(bool async) @@ -1546,22 +1748,26 @@ public override async Task Include_nested_with_optional_navigation(bool async) await base.Include_nested_with_optional_navigation(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` WHERE (`l0`.`Name` <> 'L2 09') OR `l0`.`Name` IS NULL -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `t`.`Id`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id`, `t`.`Id0`, `t`.`Level3_Optional_Id`, `t`.`Level3_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse4Id`, `t`.`OneToMany_Optional_Self_Inverse4Id`, `t`.`OneToMany_Required_Inverse4Id`, `t`.`OneToMany_Required_Self_Inverse4Id`, `t`.`OneToOne_Optional_PK_Inverse4Id`, `t`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `s`.`Id`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `s`.`Id0`, `s`.`Level3_Optional_Id`, `s`.`Level3_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse4Id`, `s`.`OneToMany_Optional_Self_Inverse4Id`, `s`.`OneToMany_Required_Inverse4Id`, `s`.`OneToMany_Required_Self_Inverse4Id`, `s`.`OneToOne_Optional_PK_Inverse4Id`, `s`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` INNER JOIN ( SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l2`.`Id` AS `Id0`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name` AS `Name0`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id` FROM `LevelThree` AS `l1` LEFT JOIN `LevelFour` AS `l2` ON `l1`.`Id` = `l2`.`Level3_Required_Id` -) AS `t` ON `l0`.`Id` = `t`.`OneToMany_Required_Inverse3Id` +) AS `s` ON `l0`.`Id` = `s`.`OneToMany_Required_Inverse3Id` WHERE (`l0`.`Name` <> 'L2 09') OR `l0`.`Name` IS NULL -ORDER BY `l`.`Id`, `l0`.`Id`"); +ORDER BY `l`.`Id`, `l0`.`Id` +"""); } public override async Task Complex_multi_include_with_order_by_and_paging(bool async) @@ -1569,46 +1775,52 @@ public override async Task Complex_multi_include_with_order_by_and_paging(bool a await base.Complex_multi_include_with_order_by_and_paging(async); AssertSql( - @"@__p_1='10' +""" +@__p_1='10' @__p_0='0' -SELECT `t`.`Id`, `t`.`Date`, `t`.`Name`, `t`.`OneToMany_Optional_Self_Inverse1Id`, `t`.`OneToMany_Required_Self_Inverse1Id`, `t`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` +SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` -LEFT JOIN `LevelTwo` AS `l0` ON `t`.`Id` = `l0`.`Level1_Required_Id` -ORDER BY `t`.`Name`, `t`.`Id`, `l0`.`Id`", +) AS `l1` +LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Required_Id` +ORDER BY `l1`.`Name`, `l1`.`Id`, `l0`.`Id` +""", // - @"@__p_1='10' + """ +@__p_1='10' @__p_0='0' -SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `t`.`Id`, `l0`.`Id` +SELECT `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id`, `l1`.`Id`, `l0`.`Id` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` -LEFT JOIN `LevelTwo` AS `l0` ON `t`.`Id` = `l0`.`Level1_Required_Id` -INNER JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Optional_Inverse3Id` -ORDER BY `t`.`Name`, `t`.`Id`, `l0`.`Id`", +) AS `l1` +LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Required_Id` +INNER JOIN `LevelThree` AS `l2` ON `l0`.`Id` = `l2`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l1`.`Name`, `l1`.`Id`, `l0`.`Id` +""", // - @"@__p_1='10' + """ +@__p_1='10' @__p_0='0' -SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `t`.`Id`, `l0`.`Id` +SELECT `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id`, `l1`.`Id`, `l0`.`Id` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` -LEFT JOIN `LevelTwo` AS `l0` ON `t`.`Id` = `l0`.`Level1_Required_Id` -INNER JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`OneToMany_Required_Inverse3Id` -ORDER BY `t`.`Name`, `t`.`Id`, `l0`.`Id`"); +) AS `l1` +LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Required_Id` +INNER JOIN `LevelThree` AS `l3` ON `l0`.`Id` = `l3`.`OneToMany_Required_Inverse3Id` +ORDER BY `l1`.`Name`, `l1`.`Id`, `l0`.`Id` +"""); } public override async Task Complex_multi_include_with_order_by_and_paging_joins_on_correct_key(bool async) @@ -1616,49 +1828,55 @@ public override async Task Complex_multi_include_with_order_by_and_paging_joins_ await base.Complex_multi_include_with_order_by_and_paging_joins_on_correct_key(async); AssertSql( - @"@__p_1='10' +""" +@__p_1='10' @__p_0='0' -SELECT `t`.`Id`, `t`.`Date`, `t`.`Name`, `t`.`OneToMany_Optional_Self_Inverse1Id`, `t`.`OneToMany_Required_Self_Inverse1Id`, `t`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` +SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` -LEFT JOIN `LevelTwo` AS `l0` ON `t`.`Id` = `l0`.`Level1_Optional_Id` -LEFT JOIN `LevelTwo` AS `l1` ON `t`.`Id` = `l1`.`Level1_Required_Id` -ORDER BY `t`.`Name`, `t`.`Id`, `l0`.`Id`, `l1`.`Id`", +) AS `l1` +LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Optional_Id` +LEFT JOIN `LevelTwo` AS `l2` ON `l1`.`Id` = `l2`.`Level1_Required_Id` +ORDER BY `l1`.`Name`, `l1`.`Id`, `l0`.`Id`, `l2`.`Id` +""", // - @"@__p_1='10' + """ +@__p_1='10' @__p_0='0' -SELECT `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id`, `t`.`Id`, `l0`.`Id`, `l1`.`Id` +SELECT `l3`.`Id`, `l3`.`Level2_Optional_Id`, `l3`.`Level2_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse3Id`, `l3`.`OneToMany_Optional_Self_Inverse3Id`, `l3`.`OneToMany_Required_Inverse3Id`, `l3`.`OneToMany_Required_Self_Inverse3Id`, `l3`.`OneToOne_Optional_PK_Inverse3Id`, `l3`.`OneToOne_Optional_Self3Id`, `l1`.`Id`, `l0`.`Id`, `l2`.`Id` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` -LEFT JOIN `LevelTwo` AS `l0` ON `t`.`Id` = `l0`.`Level1_Optional_Id` -LEFT JOIN `LevelTwo` AS `l1` ON `t`.`Id` = `l1`.`Level1_Required_Id` -INNER JOIN `LevelThree` AS `l2` ON `l0`.`Id` = `l2`.`OneToMany_Optional_Inverse3Id` -ORDER BY `t`.`Name`, `t`.`Id`, `l0`.`Id`, `l1`.`Id`", +) AS `l1` +LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Optional_Id` +LEFT JOIN `LevelTwo` AS `l2` ON `l1`.`Id` = `l2`.`Level1_Required_Id` +INNER JOIN `LevelThree` AS `l3` ON `l0`.`Id` = `l3`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l1`.`Name`, `l1`.`Id`, `l0`.`Id`, `l2`.`Id` +""", // - @"@__p_1='10' + """ +@__p_1='10' @__p_0='0' -SELECT `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id`, `t`.`Id`, `l0`.`Id`, `l1`.`Id` +SELECT `l4`.`Id`, `l4`.`Level2_Optional_Id`, `l4`.`Level2_Required_Id`, `l4`.`Name`, `l4`.`OneToMany_Optional_Inverse3Id`, `l4`.`OneToMany_Optional_Self_Inverse3Id`, `l4`.`OneToMany_Required_Inverse3Id`, `l4`.`OneToMany_Required_Self_Inverse3Id`, `l4`.`OneToOne_Optional_PK_Inverse3Id`, `l4`.`OneToOne_Optional_Self3Id`, `l1`.`Id`, `l0`.`Id`, `l2`.`Id` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` -LEFT JOIN `LevelTwo` AS `l0` ON `t`.`Id` = `l0`.`Level1_Optional_Id` -LEFT JOIN `LevelTwo` AS `l1` ON `t`.`Id` = `l1`.`Level1_Required_Id` -INNER JOIN `LevelThree` AS `l2` ON `l1`.`Id` = `l2`.`OneToMany_Required_Inverse3Id` -ORDER BY `t`.`Name`, `t`.`Id`, `l0`.`Id`, `l1`.`Id`"); +) AS `l1` +LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Optional_Id` +LEFT JOIN `LevelTwo` AS `l2` ON `l1`.`Id` = `l2`.`Level1_Required_Id` +INNER JOIN `LevelThree` AS `l4` ON `l2`.`Id` = `l4`.`OneToMany_Required_Inverse3Id` +ORDER BY `l1`.`Name`, `l1`.`Id`, `l0`.`Id`, `l2`.`Id` +"""); } public override async Task Complex_multi_include_with_order_by_and_paging_joins_on_correct_key2(bool async) @@ -1666,34 +1884,38 @@ public override async Task Complex_multi_include_with_order_by_and_paging_joins_ await base.Complex_multi_include_with_order_by_and_paging_joins_on_correct_key2(async); AssertSql( - @"@__p_1='10' +""" +@__p_1='10' @__p_0='0' -SELECT `t`.`Id`, `t`.`Date`, `t`.`Name`, `t`.`OneToMany_Optional_Self_Inverse1Id`, `t`.`OneToMany_Required_Self_Inverse1Id`, `t`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` +SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l2`.`Id`, `l2`.`Level2_Optional_Id`, `l2`.`Level2_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse3Id`, `l2`.`OneToMany_Optional_Self_Inverse3Id`, `l2`.`OneToMany_Required_Inverse3Id`, `l2`.`OneToMany_Required_Self_Inverse3Id`, `l2`.`OneToOne_Optional_PK_Inverse3Id`, `l2`.`OneToOne_Optional_Self3Id` FROM ( SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` -LEFT JOIN `LevelTwo` AS `l0` ON `t`.`Id` = `l0`.`Level1_Optional_Id` -LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Level2_Required_Id` -ORDER BY `t`.`Name`, `t`.`Id`, `l0`.`Id`, `l1`.`Id`", +) AS `l1` +LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Optional_Id` +LEFT JOIN `LevelThree` AS `l2` ON `l0`.`Id` = `l2`.`Level2_Required_Id` +ORDER BY `l1`.`Name`, `l1`.`Id`, `l0`.`Id`, `l2`.`Id` +""", // - @"@__p_1='10' + """ +@__p_1='10' @__p_0='0' -SELECT `l2`.`Id`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id`, `t`.`Id`, `l0`.`Id`, `l1`.`Id` +SELECT `l3`.`Id`, `l3`.`Level3_Optional_Id`, `l3`.`Level3_Required_Id`, `l3`.`Name`, `l3`.`OneToMany_Optional_Inverse4Id`, `l3`.`OneToMany_Optional_Self_Inverse4Id`, `l3`.`OneToMany_Required_Inverse4Id`, `l3`.`OneToMany_Required_Self_Inverse4Id`, `l3`.`OneToOne_Optional_PK_Inverse4Id`, `l3`.`OneToOne_Optional_Self4Id`, `l1`.`Id`, `l0`.`Id`, `l2`.`Id` FROM ( SELECT `l`.`Id`, `l`.`Name` FROM `LevelOne` AS `l` ORDER BY `l`.`Name` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` -LEFT JOIN `LevelTwo` AS `l0` ON `t`.`Id` = `l0`.`Level1_Optional_Id` -LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Level2_Required_Id` -INNER JOIN `LevelFour` AS `l2` ON `l1`.`Id` = `l2`.`OneToMany_Optional_Inverse4Id` -ORDER BY `t`.`Name`, `t`.`Id`, `l0`.`Id`, `l1`.`Id`"); +) AS `l1` +LEFT JOIN `LevelTwo` AS `l0` ON `l1`.`Id` = `l0`.`Level1_Optional_Id` +LEFT JOIN `LevelThree` AS `l2` ON `l0`.`Id` = `l2`.`Level2_Required_Id` +INNER JOIN `LevelFour` AS `l3` ON `l2`.`Id` = `l3`.`OneToMany_Optional_Inverse4Id` +ORDER BY `l1`.`Name`, `l1`.`Id`, `l0`.`Id`, `l2`.`Id` +"""); } public override async Task Multiple_include_with_multiple_optional_navigations(bool async) @@ -1836,20 +2058,24 @@ public override async Task Optional_navigation_with_Include_ThenInclude(bool asy await base.Optional_navigation_with_Include_ThenInclude(async); AssertSql( - @"SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` +""" +SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `l`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` -ORDER BY `l`.`Id`, `l0`.`Id`", +ORDER BY `l`.`Id`, `l0`.`Id` +""", // - @"SELECT `t`.`Id`, `t`.`Level2_Optional_Id`, `t`.`Level2_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse3Id`, `t`.`OneToMany_Optional_Self_Inverse3Id`, `t`.`OneToMany_Required_Inverse3Id`, `t`.`OneToMany_Required_Self_Inverse3Id`, `t`.`OneToOne_Optional_PK_Inverse3Id`, `t`.`OneToOne_Optional_Self3Id`, `t`.`Id0`, `t`.`Level3_Optional_Id`, `t`.`Level3_Required_Id`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse4Id`, `t`.`OneToMany_Optional_Self_Inverse4Id`, `t`.`OneToMany_Required_Inverse4Id`, `t`.`OneToMany_Required_Self_Inverse4Id`, `t`.`OneToOne_Optional_PK_Inverse4Id`, `t`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id` + """ +SELECT `s`.`Id`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `s`.`Id0`, `s`.`Level3_Optional_Id`, `s`.`Level3_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse4Id`, `s`.`OneToMany_Optional_Self_Inverse4Id`, `s`.`OneToMany_Required_Inverse4Id`, `s`.`OneToMany_Required_Self_Inverse4Id`, `s`.`OneToOne_Optional_PK_Inverse4Id`, `s`.`OneToOne_Optional_Self4Id`, `l`.`Id`, `l0`.`Id` FROM `LevelOne` AS `l` LEFT JOIN `LevelTwo` AS `l0` ON `l`.`Id` = `l0`.`Level1_Optional_Id` INNER JOIN ( SELECT `l1`.`Id`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id`, `l2`.`Id` AS `Id0`, `l2`.`Level3_Optional_Id`, `l2`.`Level3_Required_Id`, `l2`.`Name` AS `Name0`, `l2`.`OneToMany_Optional_Inverse4Id`, `l2`.`OneToMany_Optional_Self_Inverse4Id`, `l2`.`OneToMany_Required_Inverse4Id`, `l2`.`OneToMany_Required_Self_Inverse4Id`, `l2`.`OneToOne_Optional_PK_Inverse4Id`, `l2`.`OneToOne_Optional_Self4Id` FROM `LevelThree` AS `l1` LEFT JOIN `LevelFour` AS `l2` ON `l1`.`Id` = `l2`.`Level3_Optional_Id` -) AS `t` ON `l0`.`Id` = `t`.`OneToMany_Optional_Inverse3Id` -ORDER BY `l`.`Id`, `l0`.`Id`"); +) AS `s` ON `l0`.`Id` = `s`.`OneToMany_Optional_Inverse3Id` +ORDER BY `l`.`Id`, `l0`.`Id` +"""); } public override async Task Multiple_optional_navigation_with_Include(bool async) @@ -1963,22 +2189,26 @@ public override async Task SelectMany_with_navigation_and_Distinct(bool async) await base.SelectMany_with_navigation_and_Distinct(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t`.`Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l1`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( SELECT DISTINCT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` FROM `LevelTwo` AS `l0` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t`.`Id`", +) AS `l1` ON `l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l1`.`Id` +""", // - @"SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `t`.`Id` + """ +SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `l1`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( SELECT DISTINCT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` FROM `LevelTwo` AS `l0` -) AS `t` ON `l`.`Id` = `t`.`OneToMany_Optional_Inverse2Id` -INNER JOIN `LevelTwo` AS `l1` ON `l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t`.`Id`"); +) AS `l1` ON `l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` +INNER JOIN `LevelTwo` AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l1`.`Id` +"""); } public override async Task SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(bool async) @@ -1986,22 +2216,26 @@ public override async Task SelectMany_with_navigation_and_Distinct_projecting_co await base.SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t`.`Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l1`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( SELECT DISTINCT `l0`.`Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id` AS `FK` FROM `LevelTwo` AS `l0` -) AS `t` ON `l`.`Id` = `t`.`FK` -ORDER BY `l`.`Id`, `t`.`Id`", +) AS `l1` ON `l`.`Id` = `l1`.`FK` +ORDER BY `l`.`Id`, `l1`.`Id` +""", // - @"SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `t`.`Id` + """ +SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l`.`Id`, `l1`.`Id` FROM `LevelOne` AS `l` INNER JOIN ( SELECT DISTINCT `l0`.`Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id` AS `FK` FROM `LevelTwo` AS `l0` -) AS `t` ON `l`.`Id` = `t`.`FK` -INNER JOIN `LevelTwo` AS `l1` ON `l`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t`.`Id`"); +) AS `l1` ON `l`.`Id` = `l1`.`FK` +INNER JOIN `LevelTwo` AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l1`.`Id` +"""); } public override async Task Include_collection_with_multiple_orderbys_member(bool async) @@ -2099,38 +2333,42 @@ public override async Task Include_collection_with_groupby_in_subquery(bool asyn await base.Include_collection_with_groupby_in_subquery(async); AssertSql( - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Name`, `t0`.`OneToMany_Optional_Self_Inverse1Id`, `t0`.`OneToMany_Required_Self_Inverse1Id`, `t0`.`OneToOne_Optional_Self1Id`, `t`.`Name` +""" +SELECT `l3`.`Id`, `l3`.`Date`, `l3`.`Name`, `l3`.`OneToMany_Optional_Self_Inverse1Id`, `l3`.`OneToMany_Required_Self_Inverse1Id`, `l3`.`OneToOne_Optional_Self1Id`, `l1`.`Name` FROM ( SELECT `l`.`Name` FROM `LevelOne` AS `l` GROUP BY `l`.`Name` -) AS `t` +) AS `l1` LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`Date`, `t1`.`Name`, `t1`.`OneToMany_Optional_Self_Inverse1Id`, `t1`.`OneToMany_Required_Self_Inverse1Id`, `t1`.`OneToOne_Optional_Self1Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Name`, `l2`.`OneToMany_Optional_Self_Inverse1Id`, `l2`.`OneToMany_Required_Self_Inverse1Id`, `l2`.`OneToOne_Optional_Self1Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Name`, `l0`.`OneToMany_Optional_Self_Inverse1Id`, `l0`.`OneToMany_Required_Self_Inverse1Id`, `l0`.`OneToOne_Optional_Self1Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`Name` ORDER BY `l0`.`Id`) AS `row` FROM `LevelOne` AS `l0` - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`Name` = `t0`.`Name` -ORDER BY `t`.`Name`, `t0`.`Id`", + ) AS `l2` + WHERE `l2`.`row` <= 1 +) AS `l3` ON `l1`.`Name` = `l3`.`Name` +ORDER BY `l1`.`Name`, `l3`.`Id` +""", // - @"SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id`, `t`.`Name`, `t0`.`Id` + """ +SELECT `l6`.`Id`, `l6`.`Date`, `l6`.`Level1_Optional_Id`, `l6`.`Level1_Required_Id`, `l6`.`Name`, `l6`.`OneToMany_Optional_Inverse2Id`, `l6`.`OneToMany_Optional_Self_Inverse2Id`, `l6`.`OneToMany_Required_Inverse2Id`, `l6`.`OneToMany_Required_Self_Inverse2Id`, `l6`.`OneToOne_Optional_PK_Inverse2Id`, `l6`.`OneToOne_Optional_Self2Id`, `l7`.`Name`, `l9`.`Id` FROM ( SELECT `l`.`Name` FROM `LevelOne` AS `l` GROUP BY `l`.`Name` -) AS `t` +) AS `l7` LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`Name` + SELECT `l8`.`Id`, `l8`.`Name` FROM ( - SELECT `l0`.`Id`, `l0`.`Name`, ROW_NUMBER() OVER(PARTITION BY `l0`.`Name` ORDER BY `l0`.`Id`) AS `row` - FROM `LevelOne` AS `l0` - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`Name` = `t0`.`Name` -INNER JOIN `LevelTwo` AS `l1` ON `t0`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` -ORDER BY `t`.`Name`, `t0`.`Id`"); + SELECT `l5`.`Id`, `l5`.`Name`, ROW_NUMBER() OVER(PARTITION BY `l5`.`Name` ORDER BY `l5`.`Id`) AS `row` + FROM `LevelOne` AS `l5` + ) AS `l8` + WHERE `l8`.`row` <= 1 +) AS `l9` ON `l7`.`Name` = `l9`.`Name` +INNER JOIN `LevelTwo` AS `l6` ON `l9`.`Id` = `l6`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l7`.`Name`, `l9`.`Id` +"""); } public override async Task Include_collection_with_groupby_in_subquery_and_filter_before_groupby(bool async) @@ -2138,42 +2376,46 @@ public override async Task Include_collection_with_groupby_in_subquery_and_filte await base.Include_collection_with_groupby_in_subquery_and_filter_before_groupby(async); AssertSql( - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Name`, `t0`.`OneToMany_Optional_Self_Inverse1Id`, `t0`.`OneToMany_Required_Self_Inverse1Id`, `t0`.`OneToOne_Optional_Self1Id`, `t`.`Name` +""" +SELECT `l3`.`Id`, `l3`.`Date`, `l3`.`Name`, `l3`.`OneToMany_Optional_Self_Inverse1Id`, `l3`.`OneToMany_Required_Self_Inverse1Id`, `l3`.`OneToOne_Optional_Self1Id`, `l1`.`Name` FROM ( SELECT `l`.`Name` FROM `LevelOne` AS `l` WHERE `l`.`Id` > 3 GROUP BY `l`.`Name` -) AS `t` +) AS `l1` LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`Date`, `t1`.`Name`, `t1`.`OneToMany_Optional_Self_Inverse1Id`, `t1`.`OneToMany_Required_Self_Inverse1Id`, `t1`.`OneToOne_Optional_Self1Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Name`, `l2`.`OneToMany_Optional_Self_Inverse1Id`, `l2`.`OneToMany_Required_Self_Inverse1Id`, `l2`.`OneToOne_Optional_Self1Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Name`, `l0`.`OneToMany_Optional_Self_Inverse1Id`, `l0`.`OneToMany_Required_Self_Inverse1Id`, `l0`.`OneToOne_Optional_Self1Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`Name` ORDER BY `l0`.`Id`) AS `row` FROM `LevelOne` AS `l0` WHERE `l0`.`Id` > 3 - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`Name` = `t0`.`Name` -ORDER BY `t`.`Name`, `t0`.`Id`", + ) AS `l2` + WHERE `l2`.`row` <= 1 +) AS `l3` ON `l1`.`Name` = `l3`.`Name` +ORDER BY `l1`.`Name`, `l3`.`Id` +""", // - @"SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id`, `t`.`Name`, `t0`.`Id` + """ +SELECT `l6`.`Id`, `l6`.`Date`, `l6`.`Level1_Optional_Id`, `l6`.`Level1_Required_Id`, `l6`.`Name`, `l6`.`OneToMany_Optional_Inverse2Id`, `l6`.`OneToMany_Optional_Self_Inverse2Id`, `l6`.`OneToMany_Required_Inverse2Id`, `l6`.`OneToMany_Required_Self_Inverse2Id`, `l6`.`OneToOne_Optional_PK_Inverse2Id`, `l6`.`OneToOne_Optional_Self2Id`, `l7`.`Name`, `l9`.`Id` FROM ( SELECT `l`.`Name` FROM `LevelOne` AS `l` WHERE `l`.`Id` > 3 GROUP BY `l`.`Name` -) AS `t` +) AS `l7` LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`Name` + SELECT `l8`.`Id`, `l8`.`Name` FROM ( - SELECT `l0`.`Id`, `l0`.`Name`, ROW_NUMBER() OVER(PARTITION BY `l0`.`Name` ORDER BY `l0`.`Id`) AS `row` - FROM `LevelOne` AS `l0` - WHERE `l0`.`Id` > 3 - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`Name` = `t0`.`Name` -INNER JOIN `LevelTwo` AS `l1` ON `t0`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` -ORDER BY `t`.`Name`, `t0`.`Id`"); + SELECT `l5`.`Id`, `l5`.`Name`, ROW_NUMBER() OVER(PARTITION BY `l5`.`Name` ORDER BY `l5`.`Id`) AS `row` + FROM `LevelOne` AS `l5` + WHERE `l5`.`Id` > 3 + ) AS `l8` + WHERE `l8`.`row` <= 1 +) AS `l9` ON `l7`.`Name` = `l9`.`Name` +INNER JOIN `LevelTwo` AS `l6` ON `l9`.`Id` = `l6`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l7`.`Name`, `l9`.`Id` +"""); } public override async Task Include_collection_with_groupby_in_subquery_and_filter_after_groupby(bool async) @@ -2181,46 +2423,44 @@ public override async Task Include_collection_with_groupby_in_subquery_and_filte await base.Include_collection_with_groupby_in_subquery_and_filter_after_groupby(async); AssertSql( - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Name`, `t0`.`OneToMany_Optional_Self_Inverse1Id`, `t0`.`OneToMany_Required_Self_Inverse1Id`, `t0`.`OneToOne_Optional_Self1Id`, `t`.`Name` +""" +SELECT `l3`.`Id`, `l3`.`Date`, `l3`.`Name`, `l3`.`OneToMany_Optional_Self_Inverse1Id`, `l3`.`OneToMany_Required_Self_Inverse1Id`, `l3`.`OneToOne_Optional_Self1Id`, `l1`.`Name` FROM ( - SELECT `t`.`Name` - FROM ( - SELECT `l`.`Name`, (`l`.`Name` <> 'Foo') OR `l`.`Name` IS NULL AS `c` - FROM `LevelOne` AS `l` - GROUP BY `l`.`Name`, `c` - HAVING `c` - ) AS `t` -) AS `t` + SELECT `l`.`Name`, (`l`.`Name` <> 'Foo') OR `l`.`Name` IS NULL AS `c` + FROM `LevelOne` AS `l` + GROUP BY `l`.`Name`, `c` + HAVING `c` +) AS `l1` LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`Date`, `t1`.`Name`, `t1`.`OneToMany_Optional_Self_Inverse1Id`, `t1`.`OneToMany_Required_Self_Inverse1Id`, `t1`.`OneToOne_Optional_Self1Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Name`, `l2`.`OneToMany_Optional_Self_Inverse1Id`, `l2`.`OneToMany_Required_Self_Inverse1Id`, `l2`.`OneToOne_Optional_Self1Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Name`, `l0`.`OneToMany_Optional_Self_Inverse1Id`, `l0`.`OneToMany_Required_Self_Inverse1Id`, `l0`.`OneToOne_Optional_Self1Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`Name` ORDER BY `l0`.`Id`) AS `row` FROM `LevelOne` AS `l0` - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`Name` = `t0`.`Name` -ORDER BY `t`.`Name`, `t0`.`Id`", + ) AS `l2` + WHERE `l2`.`row` <= 1 +) AS `l3` ON `l1`.`Name` = `l3`.`Name` +ORDER BY `l1`.`Name`, `l3`.`Id` +""", // - @"SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id`, `t`.`Name`, `t0`.`Id` + """ +SELECT `l6`.`Id`, `l6`.`Date`, `l6`.`Level1_Optional_Id`, `l6`.`Level1_Required_Id`, `l6`.`Name`, `l6`.`OneToMany_Optional_Inverse2Id`, `l6`.`OneToMany_Optional_Self_Inverse2Id`, `l6`.`OneToMany_Required_Inverse2Id`, `l6`.`OneToMany_Required_Self_Inverse2Id`, `l6`.`OneToOne_Optional_PK_Inverse2Id`, `l6`.`OneToOne_Optional_Self2Id`, `l7`.`Name`, `l9`.`Id` FROM ( - SELECT `t`.`Name` - FROM ( - SELECT `l`.`Name`, (`l`.`Name` <> 'Foo') OR `l`.`Name` IS NULL AS `c` - FROM `LevelOne` AS `l` - GROUP BY `l`.`Name`, `c` - HAVING `c` - ) AS `t` -) AS `t` + SELECT `l`.`Name`, (`l`.`Name` <> 'Foo') OR `l`.`Name` IS NULL AS `c` + FROM `LevelOne` AS `l` + GROUP BY `l`.`Name`, `c` + HAVING `c` +) AS `l7` LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`Name` + SELECT `l8`.`Id`, `l8`.`Name` FROM ( - SELECT `l0`.`Id`, `l0`.`Name`, ROW_NUMBER() OVER(PARTITION BY `l0`.`Name` ORDER BY `l0`.`Id`) AS `row` - FROM `LevelOne` AS `l0` - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`Name` = `t0`.`Name` -INNER JOIN `LevelTwo` AS `l1` ON `t0`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` -ORDER BY `t`.`Name`, `t0`.`Id`"); + SELECT `l5`.`Id`, `l5`.`Name`, ROW_NUMBER() OVER(PARTITION BY `l5`.`Name` ORDER BY `l5`.`Id`) AS `row` + FROM `LevelOne` AS `l5` + ) AS `l8` + WHERE `l8`.`row` <= 1 +) AS `l9` ON `l7`.`Name` = `l9`.`Name` +INNER JOIN `LevelTwo` AS `l6` ON `l9`.`Id` = `l6`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l7`.`Name`, `l9`.`Id` +"""); } public override async Task Include_reference_collection_order_by_reference_navigation(bool async) @@ -2369,24 +2609,21 @@ public override async Task Filtered_include_different_filter_set_on_same_navigat { await base.Filtered_include_different_filter_set_on_same_navigation_twice(async); - AssertSql( - ); + AssertSql(); } public override async Task Filtered_include_different_filter_set_on_same_navigation_twice_multi_level(bool async) { await base.Filtered_include_different_filter_set_on_same_navigation_twice_multi_level(async); - AssertSql( - ); + AssertSql(); } public override async Task Filtered_include_include_parameter_used_inside_filter_throws(bool async) { await base.Filtered_include_include_parameter_used_inside_filter_throws(async); - AssertSql( - ); + AssertSql(); } public override async Task Filtered_include_is_considered_loaded(bool async) @@ -2394,33 +2631,33 @@ public override async Task Filtered_include_is_considered_loaded(bool async) await base.Filtered_include_is_considered_loaded(async); AssertSql( - @"SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id` +""" +SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id`, `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id` FROM `LevelOne` AS `l` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Date`, `t`.`Level1_Optional_Id`, `t`.`Level1_Required_Id`, `t`.`Name`, `t`.`OneToMany_Optional_Inverse2Id`, `t`.`OneToMany_Optional_Self_Inverse2Id`, `t`.`OneToMany_Required_Inverse2Id`, `t`.`OneToMany_Required_Self_Inverse2Id`, `t`.`OneToOne_Optional_PK_Inverse2Id`, `t`.`OneToOne_Optional_Self2Id` + SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` FROM ( SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, ROW_NUMBER() OVER(PARTITION BY `l0`.`OneToMany_Optional_Inverse2Id` ORDER BY `l0`.`Id`) AS `row` FROM `LevelTwo` AS `l0` - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `l`.`Id` = `t0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `l`.`Id`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`Id`"); + ) AS `l1` + WHERE `l1`.`row` <= 1 +) AS `l2` ON `l`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l`.`Id`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`Id` +"""); } public override async Task Filtered_include_with_Distinct_throws(bool async) { await base.Filtered_include_with_Distinct_throws(async); - AssertSql( - ); + AssertSql(); } public override async Task Filtered_include_calling_methods_directly_on_parameter_throws(bool async) { await base.Filtered_include_calling_methods_directly_on_parameter_throws(async); - AssertSql( - ); + AssertSql(); } public override async Task Filtered_include_Take_with_another_Take_on_top_level(bool async) @@ -2428,34 +2665,38 @@ public override async Task Filtered_include_Take_with_another_Take_on_top_level( await base.Filtered_include_Take_with_another_Take_on_top_level(async); AssertSql( - @"@__p_0='5' +""" +@__p_0='5' SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` -LIMIT @__p_0", +LIMIT @__p_0 +""", // - @"@__p_0='5' + """ +@__p_0='5' -SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `t0`.`Id0`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id`, `t`.`Id` +SELECT `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `l3`.`Id` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` LIMIT @__p_0 -) AS `t` +) AS `l3` JOIN LATERAL ( - SELECT `t1`.`Id`, `t1`.`Date`, `t1`.`Level1_Optional_Id`, `t1`.`Level1_Required_Id`, `t1`.`Name`, `t1`.`OneToMany_Optional_Inverse2Id`, `t1`.`OneToMany_Optional_Self_Inverse2Id`, `t1`.`OneToMany_Required_Inverse2Id`, `t1`.`OneToMany_Required_Self_Inverse2Id`, `t1`.`OneToOne_Optional_PK_Inverse2Id`, `t1`.`OneToOne_Optional_Self2Id`, `l0`.`Id` AS `Id0`, `l0`.`Level2_Optional_Id`, `l0`.`Level2_Required_Id`, `l0`.`Name` AS `Name0`, `l0`.`OneToMany_Optional_Inverse3Id`, `l0`.`OneToMany_Optional_Self_Inverse3Id`, `l0`.`OneToMany_Required_Inverse3Id`, `l0`.`OneToMany_Required_Self_Inverse3Id`, `l0`.`OneToOne_Optional_PK_Inverse3Id`, `l0`.`OneToOne_Optional_Self3Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` - FROM `LevelTwo` AS `l1` - WHERE `t`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` - ORDER BY `l1`.`Name` DESC + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` + FROM `LevelTwo` AS `l0` + WHERE `l3`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` + ORDER BY `l0`.`Name` DESC LIMIT 4 - ) AS `t1` - LEFT JOIN `LevelThree` AS `l0` ON `t1`.`Id` = `l0`.`Level2_Optional_Id` -) AS `t0` ON TRUE -ORDER BY `t`.`Id`, `t0`.`Name` DESC"); + ) AS `l2` + LEFT JOIN `LevelThree` AS `l1` ON `l2`.`Id` = `l1`.`Level2_Optional_Id` +) AS `s` ON TRUE +ORDER BY `l3`.`Id`, `s`.`Name` DESC +"""); } public override async Task Filtered_include_Skip_Take_with_another_Skip_Take_on_top_level(bool async) @@ -2465,7 +2706,7 @@ public override async Task Filtered_include_Skip_Take_with_another_Skip_Take_on_ AssertSql( """ @__p_1='5' -@__p_0='10' +@__p_0='1' SELECT `l`.`Id`, `l`.`Date`, `l`.`Name`, `l`.`OneToMany_Optional_Self_Inverse1Id`, `l`.`OneToMany_Required_Self_Inverse1Id`, `l`.`OneToOne_Optional_Self1Id` FROM `LevelOne` AS `l` @@ -2473,29 +2714,29 @@ ORDER BY `l`.`Id` DESC LIMIT @__p_1 OFFSET @__p_0 """, // -""" + """ @__p_1='5' -@__p_0='10' +@__p_0='1' -SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `t0`.`Id0`, `t0`.`Level2_Optional_Id`, `t0`.`Level2_Required_Id`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Inverse3Id`, `t0`.`OneToMany_Optional_Self_Inverse3Id`, `t0`.`OneToMany_Required_Inverse3Id`, `t0`.`OneToMany_Required_Self_Inverse3Id`, `t0`.`OneToOne_Optional_PK_Inverse3Id`, `t0`.`OneToOne_Optional_Self3Id`, `t`.`Id` +SELECT `s`.`Id`, `s`.`Date`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `s`.`Id0`, `s`.`Level2_Optional_Id`, `s`.`Level2_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id`, `s`.`OneToMany_Optional_Self_Inverse3Id`, `s`.`OneToMany_Required_Inverse3Id`, `s`.`OneToMany_Required_Self_Inverse3Id`, `s`.`OneToOne_Optional_PK_Inverse3Id`, `s`.`OneToOne_Optional_Self3Id`, `l3`.`Id` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` ORDER BY `l`.`Id` DESC LIMIT @__p_1 OFFSET @__p_0 -) AS `t` +) AS `l3` JOIN LATERAL ( - SELECT `t1`.`Id`, `t1`.`Date`, `t1`.`Level1_Optional_Id`, `t1`.`Level1_Required_Id`, `t1`.`Name`, `t1`.`OneToMany_Optional_Inverse2Id`, `t1`.`OneToMany_Optional_Self_Inverse2Id`, `t1`.`OneToMany_Required_Inverse2Id`, `t1`.`OneToMany_Required_Self_Inverse2Id`, `t1`.`OneToOne_Optional_PK_Inverse2Id`, `t1`.`OneToOne_Optional_Self2Id`, `l0`.`Id` AS `Id0`, `l0`.`Level2_Optional_Id`, `l0`.`Level2_Required_Id`, `l0`.`Name` AS `Name0`, `l0`.`OneToMany_Optional_Inverse3Id`, `l0`.`OneToMany_Optional_Self_Inverse3Id`, `l0`.`OneToMany_Required_Inverse3Id`, `l0`.`OneToMany_Required_Self_Inverse3Id`, `l0`.`OneToOne_Optional_PK_Inverse3Id`, `l0`.`OneToOne_Optional_Self3Id` + SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l1`.`Id` AS `Id0`, `l1`.`Level2_Optional_Id`, `l1`.`Level2_Required_Id`, `l1`.`Name` AS `Name0`, `l1`.`OneToMany_Optional_Inverse3Id`, `l1`.`OneToMany_Optional_Self_Inverse3Id`, `l1`.`OneToMany_Required_Inverse3Id`, `l1`.`OneToMany_Required_Self_Inverse3Id`, `l1`.`OneToOne_Optional_PK_Inverse3Id`, `l1`.`OneToOne_Optional_Self3Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Level1_Optional_Id`, `l1`.`Level1_Required_Id`, `l1`.`Name`, `l1`.`OneToMany_Optional_Inverse2Id`, `l1`.`OneToMany_Optional_Self_Inverse2Id`, `l1`.`OneToMany_Required_Inverse2Id`, `l1`.`OneToMany_Required_Self_Inverse2Id`, `l1`.`OneToOne_Optional_PK_Inverse2Id`, `l1`.`OneToOne_Optional_Self2Id` - FROM `LevelTwo` AS `l1` - WHERE `t`.`Id` = `l1`.`OneToMany_Optional_Inverse2Id` - ORDER BY `l1`.`Name` DESC + SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` + FROM `LevelTwo` AS `l0` + WHERE `l3`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` + ORDER BY `l0`.`Name` DESC LIMIT 4 OFFSET 1 - ) AS `t1` - LEFT JOIN `LevelThree` AS `l0` ON `t1`.`Id` = `l0`.`Level2_Optional_Id` -) AS `t0` ON TRUE -ORDER BY `t`.`Id` DESC, `t0`.`Name` DESC + ) AS `l2` + LEFT JOIN `LevelThree` AS `l1` ON `l2`.`Id` = `l1`.`Level2_Optional_Id` +) AS `s` ON TRUE +ORDER BY `l3`.`Id` DESC, `s`.`Name` DESC """); } @@ -2504,28 +2745,32 @@ public override async Task Skip_Take_Distinct_on_grouping_element(bool async) await base.Skip_Take_Distinct_on_grouping_element(async); AssertSql( - @"SELECT `l`.`Date` +""" +SELECT `l`.`Date` FROM `LevelOne` AS `l` GROUP BY `l`.`Date` -ORDER BY `l`.`Date`", +ORDER BY `l`.`Date` +""", // - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Name`, `t0`.`OneToMany_Optional_Self_Inverse1Id`, `t0`.`OneToMany_Required_Self_Inverse1Id`, `t0`.`OneToOne_Optional_Self1Id`, `t`.`Date` + """ +SELECT `l8`.`Id`, `l8`.`Date`, `l8`.`Name`, `l8`.`OneToMany_Optional_Self_Inverse1Id`, `l8`.`OneToMany_Required_Self_Inverse1Id`, `l8`.`OneToOne_Optional_Self1Id`, `l7`.`Date` FROM ( SELECT `l`.`Date` FROM `LevelOne` AS `l` GROUP BY `l`.`Date` -) AS `t` +) AS `l7` JOIN LATERAL ( - SELECT DISTINCT `t1`.`Id`, `t1`.`Date`, `t1`.`Name`, `t1`.`OneToMany_Optional_Self_Inverse1Id`, `t1`.`OneToMany_Required_Self_Inverse1Id`, `t1`.`OneToOne_Optional_Self1Id` + SELECT DISTINCT `l6`.`Id`, `l6`.`Date`, `l6`.`Name`, `l6`.`OneToMany_Optional_Self_Inverse1Id`, `l6`.`OneToMany_Required_Self_Inverse1Id`, `l6`.`OneToOne_Optional_Self1Id` FROM ( - SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Name`, `l0`.`OneToMany_Optional_Self_Inverse1Id`, `l0`.`OneToMany_Required_Self_Inverse1Id`, `l0`.`OneToOne_Optional_Self1Id` - FROM `LevelOne` AS `l0` - WHERE `t`.`Date` = `l0`.`Date` - ORDER BY `l0`.`Name` + SELECT `l5`.`Id`, `l5`.`Date`, `l5`.`Name`, `l5`.`OneToMany_Optional_Self_Inverse1Id`, `l5`.`OneToMany_Required_Self_Inverse1Id`, `l5`.`OneToOne_Optional_Self1Id` + FROM `LevelOne` AS `l5` + WHERE `l7`.`Date` = `l5`.`Date` + ORDER BY `l5`.`Name` LIMIT 5 OFFSET 1 - ) AS `t1` -) AS `t0` ON TRUE -ORDER BY `t`.`Date`"); + ) AS `l6` +) AS `l8` ON TRUE +ORDER BY `l7`.`Date` +"""); } public override async Task Skip_Take_on_grouping_element_inside_collection_projection(bool async) @@ -2533,37 +2778,43 @@ public override async Task Skip_Take_on_grouping_element_inside_collection_proje await base.Skip_Take_on_grouping_element_inside_collection_projection(async); AssertSql( - @"SELECT `l`.`Id` +""" +SELECT `l`.`Id` FROM `LevelOne` AS `l` -ORDER BY `l`.`Id`", +ORDER BY `l`.`Id` +""", // - @"SELECT `t`.`Date`, `l`.`Id` + """ +SELECT `l15`.`Date`, `l`.`Id` FROM `LevelOne` AS `l` JOIN LATERAL ( - SELECT `l0`.`Date` - FROM `LevelOne` AS `l0` - WHERE (`l0`.`Name` = `l`.`Name`) OR (`l0`.`Name` IS NULL AND (`l`.`Name` IS NULL)) - GROUP BY `l0`.`Date` -) AS `t` ON TRUE -ORDER BY `l`.`Id`, `t`.`Date`", + SELECT `l10`.`Date` + FROM `LevelOne` AS `l10` + WHERE (`l10`.`Name` = `l`.`Name`) OR (`l10`.`Name` IS NULL AND (`l`.`Name` IS NULL)) + GROUP BY `l10`.`Date` +) AS `l15` ON TRUE +ORDER BY `l`.`Id`, `l15`.`Date` +""", // - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Name`, `t0`.`OneToMany_Optional_Self_Inverse1Id`, `t0`.`OneToMany_Required_Self_Inverse1Id`, `t0`.`OneToOne_Optional_Self1Id`, `l`.`Id`, `t`.`Date` + """ +SELECT `l17`.`Id`, `l17`.`Date`, `l17`.`Name`, `l17`.`OneToMany_Optional_Self_Inverse1Id`, `l17`.`OneToMany_Required_Self_Inverse1Id`, `l17`.`OneToOne_Optional_Self1Id`, `l`.`Id`, `l15`.`Date` FROM `LevelOne` AS `l` JOIN LATERAL ( - SELECT `l0`.`Date` - FROM `LevelOne` AS `l0` - WHERE (`l0`.`Name` = `l`.`Name`) OR (`l0`.`Name` IS NULL AND (`l`.`Name` IS NULL)) - GROUP BY `l0`.`Date` -) AS `t` ON TRUE + SELECT `l10`.`Date` + FROM `LevelOne` AS `l10` + WHERE (`l10`.`Name` = `l`.`Name`) OR (`l10`.`Name` IS NULL AND (`l`.`Name` IS NULL)) + GROUP BY `l10`.`Date` +) AS `l15` ON TRUE INNER JOIN ( - SELECT `t1`.`Id`, `t1`.`Date`, `t1`.`Name`, `t1`.`OneToMany_Optional_Self_Inverse1Id`, `t1`.`OneToMany_Required_Self_Inverse1Id`, `t1`.`OneToOne_Optional_Self1Id` + SELECT `l16`.`Id`, `l16`.`Date`, `l16`.`Name`, `l16`.`OneToMany_Optional_Self_Inverse1Id`, `l16`.`OneToMany_Required_Self_Inverse1Id`, `l16`.`OneToOne_Optional_Self1Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id`, ROW_NUMBER() OVER(PARTITION BY `l1`.`Name`, `l1`.`Date` ORDER BY `l1`.`Name`) AS `row` - FROM `LevelOne` AS `l1` - ) AS `t1` - WHERE (1 < `t1`.`row`) AND (`t1`.`row` <= 6) -) AS `t0` ON ((`l`.`Name` = `t0`.`Name`) OR (`l`.`Name` IS NULL AND (`t0`.`Name` IS NULL))) AND (`t`.`Date` = `t0`.`Date`) -ORDER BY `l`.`Id`, `t`.`Date`, `t0`.`Name`, `t0`.`Date`"); + SELECT `l14`.`Id`, `l14`.`Date`, `l14`.`Name`, `l14`.`OneToMany_Optional_Self_Inverse1Id`, `l14`.`OneToMany_Required_Self_Inverse1Id`, `l14`.`OneToOne_Optional_Self1Id`, ROW_NUMBER() OVER(PARTITION BY `l14`.`Name`, `l14`.`Date` ORDER BY `l14`.`Name`) AS `row` + FROM `LevelOne` AS `l14` + ) AS `l16` + WHERE (1 < `l16`.`row`) AND (`l16`.`row` <= 6) +) AS `l17` ON ((`l`.`Name` = `l17`.`Name`) OR (`l`.`Name` IS NULL AND (`l17`.`Name` IS NULL))) AND (`l15`.`Date` = `l17`.`Date`) +ORDER BY `l`.`Id`, `l15`.`Date`, `l17`.`Name`, `l17`.`Date` +"""); } public override async Task Skip_Take_on_grouping_element_with_reference_include(bool async) @@ -2571,29 +2822,33 @@ public override async Task Skip_Take_on_grouping_element_with_reference_include( await base.Skip_Take_on_grouping_element_with_reference_include(async); AssertSql( - @"SELECT `l`.`Date` +""" +SELECT `l`.`Date` FROM `LevelOne` AS `l` GROUP BY `l`.`Date` -ORDER BY `l`.`Date`", +ORDER BY `l`.`Date` +""", // - @"SELECT `t0`.`Id`, `t0`.`Date`, `t0`.`Name`, `t0`.`OneToMany_Optional_Self_Inverse1Id`, `t0`.`OneToMany_Required_Self_Inverse1Id`, `t0`.`OneToOne_Optional_Self1Id`, `t0`.`Id0`, `t0`.`Date0`, `t0`.`Level1_Optional_Id`, `t0`.`Level1_Required_Id`, `t0`.`Name0`, `t0`.`OneToMany_Optional_Inverse2Id`, `t0`.`OneToMany_Optional_Self_Inverse2Id`, `t0`.`OneToMany_Required_Inverse2Id`, `t0`.`OneToMany_Required_Self_Inverse2Id`, `t0`.`OneToOne_Optional_PK_Inverse2Id`, `t0`.`OneToOne_Optional_Self2Id`, `t`.`Date` + """ +SELECT `s`.`Id`, `s`.`Date`, `s`.`Name`, `s`.`OneToMany_Optional_Self_Inverse1Id`, `s`.`OneToMany_Required_Self_Inverse1Id`, `s`.`OneToOne_Optional_Self1Id`, `s`.`Id0`, `s`.`Date0`, `s`.`Level1_Optional_Id`, `s`.`Level1_Required_Id`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse2Id`, `s`.`OneToMany_Optional_Self_Inverse2Id`, `s`.`OneToMany_Required_Inverse2Id`, `s`.`OneToMany_Required_Self_Inverse2Id`, `s`.`OneToOne_Optional_PK_Inverse2Id`, `s`.`OneToOne_Optional_Self2Id`, `l10`.`Date` FROM ( SELECT `l`.`Date` FROM `LevelOne` AS `l` GROUP BY `l`.`Date` -) AS `t` +) AS `l10` JOIN LATERAL ( - SELECT `t1`.`Id`, `t1`.`Date`, `t1`.`Name`, `t1`.`OneToMany_Optional_Self_Inverse1Id`, `t1`.`OneToMany_Required_Self_Inverse1Id`, `t1`.`OneToOne_Optional_Self1Id`, `l0`.`Id` AS `Id0`, `l0`.`Date` AS `Date0`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name` AS `Name0`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id` + SELECT `l9`.`Id`, `l9`.`Date`, `l9`.`Name`, `l9`.`OneToMany_Optional_Self_Inverse1Id`, `l9`.`OneToMany_Required_Self_Inverse1Id`, `l9`.`OneToOne_Optional_Self1Id`, `l8`.`Id` AS `Id0`, `l8`.`Date` AS `Date0`, `l8`.`Level1_Optional_Id`, `l8`.`Level1_Required_Id`, `l8`.`Name` AS `Name0`, `l8`.`OneToMany_Optional_Inverse2Id`, `l8`.`OneToMany_Optional_Self_Inverse2Id`, `l8`.`OneToMany_Required_Inverse2Id`, `l8`.`OneToMany_Required_Self_Inverse2Id`, `l8`.`OneToOne_Optional_PK_Inverse2Id`, `l8`.`OneToOne_Optional_Self2Id` FROM ( - SELECT `l1`.`Id`, `l1`.`Date`, `l1`.`Name`, `l1`.`OneToMany_Optional_Self_Inverse1Id`, `l1`.`OneToMany_Required_Self_Inverse1Id`, `l1`.`OneToOne_Optional_Self1Id` - FROM `LevelOne` AS `l1` - WHERE `t`.`Date` = `l1`.`Date` - ORDER BY `l1`.`Name` + SELECT `l7`.`Id`, `l7`.`Date`, `l7`.`Name`, `l7`.`OneToMany_Optional_Self_Inverse1Id`, `l7`.`OneToMany_Required_Self_Inverse1Id`, `l7`.`OneToOne_Optional_Self1Id` + FROM `LevelOne` AS `l7` + WHERE `l10`.`Date` = `l7`.`Date` + ORDER BY `l7`.`Name` LIMIT 5 OFFSET 1 - ) AS `t1` - LEFT JOIN `LevelTwo` AS `l0` ON `t1`.`Id` = `l0`.`Level1_Optional_Id` -) AS `t0` ON TRUE -ORDER BY `t`.`Date`, `t0`.`Name`"); + ) AS `l9` + LEFT JOIN `LevelTwo` AS `l8` ON `l9`.`Id` = `l8`.`Level1_Optional_Id` +) AS `s` ON TRUE +ORDER BY `l10`.`Date`, `s`.`Name` +"""); } public override async Task Projecting_collection_with_FirstOrDefault(bool async) @@ -2601,21 +2856,25 @@ public override async Task Projecting_collection_with_FirstOrDefault(bool async) await base.Projecting_collection_with_FirstOrDefault(async); AssertSql( - @"SELECT `l`.`Id` +""" +SELECT `l`.`Id` FROM `LevelOne` AS `l` WHERE `l`.`Id` = 1 ORDER BY `l`.`Id` -LIMIT 1", +LIMIT 1 +""", // - @"SELECT `l0`.`Id`, `l0`.`Date`, `l0`.`Level1_Optional_Id`, `l0`.`Level1_Required_Id`, `l0`.`Name`, `l0`.`OneToMany_Optional_Inverse2Id`, `l0`.`OneToMany_Optional_Self_Inverse2Id`, `l0`.`OneToMany_Required_Inverse2Id`, `l0`.`OneToMany_Required_Self_Inverse2Id`, `l0`.`OneToOne_Optional_PK_Inverse2Id`, `l0`.`OneToOne_Optional_Self2Id`, `t`.`Id` + """ +SELECT `l2`.`Id`, `l2`.`Date`, `l2`.`Level1_Optional_Id`, `l2`.`Level1_Required_Id`, `l2`.`Name`, `l2`.`OneToMany_Optional_Inverse2Id`, `l2`.`OneToMany_Optional_Self_Inverse2Id`, `l2`.`OneToMany_Required_Inverse2Id`, `l2`.`OneToMany_Required_Self_Inverse2Id`, `l2`.`OneToOne_Optional_PK_Inverse2Id`, `l2`.`OneToOne_Optional_Self2Id`, `l3`.`Id` FROM ( SELECT `l`.`Id` FROM `LevelOne` AS `l` WHERE `l`.`Id` = 1 LIMIT 1 -) AS `t` -INNER JOIN `LevelTwo` AS `l0` ON `t`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` -ORDER BY `t`.`Id`"); +) AS `l3` +INNER JOIN `LevelTwo` AS `l2` ON `l3`.`Id` = `l2`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l3`.`Id` +"""); } [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed.")] diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsQuerySingleStoreTest.cs index 95e97479f..6dee747ff 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsQuerySingleStoreTest.cs @@ -21,9 +21,6 @@ public ComplexNavigationsQuerySingleStoreTest(ComplexNavigationsQuerySingleStore //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed")] public override Task Collection_FirstOrDefault_property_accesses_in_projection(bool async) { @@ -42,18 +39,6 @@ public override Task Contains_over_optional_navigation_with_null_entity_referenc return base.Contains_over_optional_navigation_with_null_entity_reference(async); } - [ConditionalTheory(Skip = "SingleStore has no implicit ordering of results by primary key")] - public override Task Distinct_skip_without_orderby(bool async) - { - return base.Distinct_skip_without_orderby(async); - } - - [ConditionalTheory(Skip = "SingleStore has no implicit ordering of results by primary key")] - public override Task Distinct_take_without_orderby(bool async) - { - return base.Distinct_take_without_orderby(async); - } - [ConditionalTheory(Skip = "SingleStore does not support this type of query: correlated subselect inside HAVING")] public override Task Element_selector_with_coalesce_repeated_in_aggregate(bool async) { @@ -160,20 +145,22 @@ await Assert.ThrowsAsync( async () => await base.Nested_SelectMany_correlated_with_join_table_correctly_translated_to_apply(async)); AssertSql( - @"SELECT `t0`.`l1Name`, `t0`.`l2Name`, `t0`.`l3Name` -FROM `LevelOne` AS `l` -LEFT JOIN LATERAL ( - SELECT `t`.`l1Name`, `t`.`l2Name`, `t`.`l3Name` - FROM `LevelTwo` AS `l0` - LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Id` - JOIN LATERAL ( - SELECT `l`.`Name` AS `l1Name`, `l1`.`Name` AS `l2Name`, `l3`.`Name` AS `l3Name` - FROM `LevelFour` AS `l2` - LEFT JOIN `LevelThree` AS `l3` ON `l2`.`OneToOne_Optional_PK_Inverse4Id` = `l3`.`Id` - WHERE `l1`.`Id` IS NOT NULL AND (`l1`.`Id` = `l2`.`OneToMany_Optional_Inverse4Id`) - ) AS `t` ON TRUE - WHERE `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` -) AS `t0` ON TRUE"); + """ + SELECT `s0`.`l1Name`, `s0`.`l2Name`, `s0`.`l3Name` + FROM `LevelOne` AS `l` + LEFT JOIN LATERAL ( + SELECT `s`.`l1Name`, `s`.`l2Name`, `s`.`l3Name` + FROM `LevelTwo` AS `l0` + LEFT JOIN `LevelThree` AS `l1` ON `l0`.`Id` = `l1`.`Id` + JOIN LATERAL ( + SELECT `l`.`Name` AS `l1Name`, `l1`.`Name` AS `l2Name`, `l3`.`Name` AS `l3Name` + FROM `LevelFour` AS `l2` + LEFT JOIN `LevelThree` AS `l3` ON `l2`.`OneToOne_Optional_PK_Inverse4Id` = `l3`.`Id` + WHERE `l1`.`Id` IS NOT NULL AND (`l1`.`Id` = `l2`.`OneToMany_Optional_Inverse4Id`) + ) AS `s` ON TRUE + WHERE `l`.`Id` = `l0`.`OneToMany_Optional_Inverse2Id` + ) AS `s0` ON TRUE + """); } public override async Task Method_call_on_optional_navigation_translates_to_null_conditional_properly_for_arguments(bool async) diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySingleStoreTest.cs index 482421771..cf0b1167d 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySingleStoreTest.cs @@ -39,26 +39,6 @@ public override Task Contains_with_subquery_optional_navigation_and_constant_ite return base.Contains_with_subquery_optional_navigation_and_constant_item(async); } - public override Task Distinct_take_without_orderby(bool async) - { - return AssertQuery( - async, - ss => from l1 in ss.Set() - where l1.Id < 3 - select (from l3 in ss.Set() - select l3).Distinct().OrderBy(e => e.Id).Take(1).FirstOrDefault().Name); // Apply OrderBy before Skip - } - - public override Task Distinct_skip_without_orderby(bool async) - { - return AssertQuery( - async, - ss => from l1 in ss.Set() - where l1.Id < 3 - select (from l3 in ss.Set() - select l3).Distinct().OrderBy(e => e.Id).Skip(1).FirstOrDefault().Name); // Apply OrderBy before Skip - } - [ConditionalTheory(Skip = "SingleStore does not support this type of query: correlated subselect inside HAVING")] public override Task Element_selector_with_coalesce_repeated_in_aggregate(bool async) { @@ -184,6 +164,97 @@ await Assert.ThrowsAsync( AssertSql(); } + public override async Task Max_in_multi_level_nested_subquery(bool async) + { + await AssertQuery( + async, + ss => ss.Set() + .OrderBy(l1 => l1.Id) // <-- ensure order is deterministic + .Take(2).Select(x => new + { + x.Id, + LevelTwos = x.OneToMany_Optional1.AsQueryable().Select(xx => new + { + xx.Id, + LevelThree = new + { + xx.OneToOne_Required_FK2.Id, + LevelFour = new + { + xx.OneToOne_Required_FK2.OneToOne_Required_FK3.Id, + Result = (xx.OneToOne_Required_FK2.OneToMany_Optional3.Max(xxx => (int?)xxx.Id) ?? 0) > 1 + } + } + }).ToList() + }), + elementSorter: e => e.Id, + elementAsserter: (e, a) => + { + AssertEqual(e.Id, a.Id); + AssertCollection( + e.LevelTwos, + a.LevelTwos, + elementSorter: ee => ee.Id, + elementAsserter: (ee, aa) => + { + AssertEqual(ee.Id, aa.Id); + AssertEqual(ee.LevelThree.Id, aa.LevelThree.Id); + AssertEqual(ee.LevelThree.LevelFour.Id, aa.LevelThree.LevelFour.Id); + AssertEqual(ee.LevelThree.LevelFour.Result, aa.LevelThree.LevelFour.Result); + }); + }); + + AssertSql( +""" +@__p_0='2' + +SELECT `l6`.`Id`, `s`.`Id`, `s`.`Id0`, `s`.`Id1`, `s`.`Result`, `s`.`Id2`, `s`.`Id3`, `s`.`Id4` +FROM ( + SELECT `l`.`Id` + FROM `Level1` AS `l` + ORDER BY `l`.`Id` + LIMIT @__p_0 +) AS `l6` +LEFT JOIN ( + SELECT CASE + WHEN (`l0`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l0`.`Level1_Required_Id` IS NOT NULL)) AND `l0`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `l0`.`Id` + END AS `Id`, CASE + WHEN `l2`.`Level2_Required_Id` IS NOT NULL AND (`l2`.`OneToMany_Required_Inverse3Id` IS NOT NULL) THEN `l2`.`Id` + END AS `Id0`, CASE + WHEN `l4`.`Level3_Required_Id` IS NOT NULL AND (`l4`.`OneToMany_Required_Inverse4Id` IS NOT NULL) THEN `l4`.`Id` + END AS `Id1`, COALESCE(( + SELECT MAX(CASE + WHEN `l5`.`Level3_Required_Id` IS NOT NULL AND (`l5`.`OneToMany_Required_Inverse4Id` IS NOT NULL) THEN `l5`.`Id` + END) + FROM `Level1` AS `l5` + WHERE (`l5`.`Level3_Required_Id` IS NOT NULL AND (`l5`.`OneToMany_Required_Inverse4Id` IS NOT NULL)) AND (CASE + WHEN `l2`.`Level2_Required_Id` IS NOT NULL AND (`l2`.`OneToMany_Required_Inverse3Id` IS NOT NULL) THEN `l2`.`Id` + END IS NOT NULL AND ((CASE + WHEN `l2`.`Level2_Required_Id` IS NOT NULL AND (`l2`.`OneToMany_Required_Inverse3Id` IS NOT NULL) THEN `l2`.`Id` + END = `l5`.`OneToMany_Optional_Inverse4Id`) OR (CASE + WHEN `l2`.`Level2_Required_Id` IS NOT NULL AND (`l2`.`OneToMany_Required_Inverse3Id` IS NOT NULL) THEN `l2`.`Id` + END IS NULL AND (`l5`.`OneToMany_Optional_Inverse4Id` IS NULL))))), 0) > 1 AS `Result`, `l0`.`Id` AS `Id2`, `l2`.`Id` AS `Id3`, `l4`.`Id` AS `Id4`, `l0`.`OneToMany_Optional_Inverse2Id` + FROM `Level1` AS `l0` + LEFT JOIN ( + SELECT `l1`.`Id`, `l1`.`Level2_Required_Id`, `l1`.`OneToMany_Required_Inverse3Id` + FROM `Level1` AS `l1` + WHERE `l1`.`Level2_Required_Id` IS NOT NULL AND (`l1`.`OneToMany_Required_Inverse3Id` IS NOT NULL) + ) AS `l2` ON CASE + WHEN (`l0`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l0`.`Level1_Required_Id` IS NOT NULL)) AND `l0`.`OneToMany_Required_Inverse2Id` IS NOT NULL THEN `l0`.`Id` + END = `l2`.`Level2_Required_Id` + LEFT JOIN ( + SELECT `l3`.`Id`, `l3`.`Level3_Required_Id`, `l3`.`OneToMany_Required_Inverse4Id` + FROM `Level1` AS `l3` + WHERE `l3`.`Level3_Required_Id` IS NOT NULL AND (`l3`.`OneToMany_Required_Inverse4Id` IS NOT NULL) + ) AS `l4` ON CASE + WHEN `l2`.`Level2_Required_Id` IS NOT NULL AND (`l2`.`OneToMany_Required_Inverse3Id` IS NOT NULL) THEN `l2`.`Id` + END = `l4`.`Level3_Required_Id` + WHERE (`l0`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l0`.`Level1_Required_Id` IS NOT NULL)) AND `l0`.`OneToMany_Required_Inverse2Id` IS NOT NULL +) AS `s` ON `l6`.`Id` = `s`.`OneToMany_Optional_Inverse2Id` +ORDER BY `l6`.`Id`, `s`.`Id2`, `s`.`Id3` +"""); + } + public override async Task Method_call_on_optional_navigation_translates_to_null_conditional_properly_for_arguments(bool async) { await base.Method_call_on_optional_navigation_translates_to_null_conditional_properly_for_arguments(async); @@ -196,8 +267,8 @@ LEFT JOIN ( SELECT `l0`.`Level1_Optional_Id`, `l0`.`Level2_Name` FROM `Level1` AS `l0` WHERE (`l0`.`OneToOne_Required_PK_Date` IS NOT NULL AND (`l0`.`Level1_Required_Id` IS NOT NULL)) AND `l0`.`OneToMany_Required_Inverse2Id` IS NOT NULL - ) AS `t` ON `l`.`Id` = `t`.`Level1_Optional_Id` - WHERE `t`.`Level2_Name` IS NOT NULL AND (LEFT(`t`.`Level2_Name`, CHAR_LENGTH(`t`.`Level2_Name`)) = `t`.`Level2_Name`) + ) AS `l1` ON `l`.`Id` = `l1`.`Level1_Optional_Id` + WHERE `l1`.`Level2_Name` IS NOT NULL AND (LEFT(`l1`.`Level2_Name`, CHAR_LENGTH(`l1`.`Level2_Name`)) = `l1`.`Level2_Name`) """); } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/ComplexTypeQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/ComplexTypeQuerySingleStoreTest.cs index d47c423f5..d3075cdbd 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/ComplexTypeQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/ComplexTypeQuerySingleStoreTest.cs @@ -25,7 +25,7 @@ public override async Task Filter_on_property_inside_complex_type(bool async) AssertSql( """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` WHERE `c`.`ShippingAddress_ZipCode` = 7728 """); @@ -37,7 +37,7 @@ public override async Task Filter_on_property_inside_nested_complex_type(bool as AssertSql( """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` WHERE `c`.`ShippingAddress_Country_Code` = 'DE' """); @@ -51,14 +51,14 @@ public override async Task Filter_on_property_inside_complex_type_after_subquery """ @__p_0='1' -SELECT DISTINCT `t`.`Id`, `t`.`Name`, `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`ShippingAddress_AddressLine1`, `t`.`ShippingAddress_AddressLine2`, `t`.`ShippingAddress_ZipCode`, `t`.`ShippingAddress_Country_Code`, `t`.`ShippingAddress_Country_FullName` +SELECT DISTINCT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM ( - SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` + SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` ORDER BY `c`.`Id` LIMIT 18446744073709551610 OFFSET @__p_0 -) AS `t` -WHERE `t`.`ShippingAddress_ZipCode` = 7728 +) AS `c0` +WHERE `c0`.`ShippingAddress_ZipCode` = 7728 """); } @@ -70,14 +70,14 @@ public override async Task Filter_on_property_inside_nested_complex_type_after_s """ @__p_0='1' -SELECT DISTINCT `t`.`Id`, `t`.`Name`, `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`ShippingAddress_AddressLine1`, `t`.`ShippingAddress_AddressLine2`, `t`.`ShippingAddress_ZipCode`, `t`.`ShippingAddress_Country_Code`, `t`.`ShippingAddress_Country_FullName` +SELECT DISTINCT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM ( - SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` + SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` ORDER BY `c`.`Id` LIMIT 18446744073709551610 OFFSET @__p_0 -) AS `t` -WHERE `t`.`ShippingAddress_Country_Code` = 'DE' +) AS `c0` +WHERE `c0`.`ShippingAddress_Country_Code` = 'DE' """); } @@ -87,7 +87,7 @@ public override async Task Filter_on_required_property_inside_required_complex_t AssertSql( """ -SELECT `c`.`Id`, `c`.`OptionalCustomerId`, `c`.`RequiredCustomerId`, `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName`, `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`OptionalCustomerId`, `c`.`RequiredCustomerId`, `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName`, `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_Tags`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName` FROM `CustomerGroup` AS `c` LEFT JOIN `Customer` AS `c0` ON `c`.`OptionalCustomerId` = `c0`.`Id` INNER JOIN `Customer` AS `c1` ON `c`.`RequiredCustomerId` = `c1`.`Id` @@ -101,7 +101,7 @@ public override async Task Filter_on_required_property_inside_required_complex_t AssertSql( """ -SELECT `c`.`Id`, `c`.`OptionalCustomerId`, `c`.`RequiredCustomerId`, `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName`, `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`OptionalCustomerId`, `c`.`RequiredCustomerId`, `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_Tags`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName`, `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM `CustomerGroup` AS `c` INNER JOIN `Customer` AS `c0` ON `c`.`RequiredCustomerId` = `c0`.`Id` LEFT JOIN `Customer` AS `c1` ON `c`.`OptionalCustomerId` = `c1`.`Id` @@ -125,7 +125,7 @@ public override async Task Project_complex_type_via_required_navigation(bool asy AssertSql( """ -SELECT `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` +SELECT `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM `CustomerGroup` AS `c` INNER JOIN `Customer` AS `c0` ON `c`.`RequiredCustomerId` = `c0`.`Id` """); @@ -139,13 +139,13 @@ public override async Task Load_complex_type_after_subquery_on_entity_type(bool """ @__p_0='1' -SELECT DISTINCT `t`.`Id`, `t`.`Name`, `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`ShippingAddress_AddressLine1`, `t`.`ShippingAddress_AddressLine2`, `t`.`ShippingAddress_ZipCode`, `t`.`ShippingAddress_Country_Code`, `t`.`ShippingAddress_Country_FullName` +SELECT DISTINCT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM ( - SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` + SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` ORDER BY `c`.`Id` LIMIT 18446744073709551610 OFFSET @__p_0 -) AS `t` +) AS `c0` """); } @@ -155,7 +155,7 @@ public override async Task Select_complex_type(bool async) AssertSql( """ -SELECT `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` """); } @@ -188,7 +188,7 @@ public override async Task Select_complex_type_Where(bool async) AssertSql( """ -SELECT `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` WHERE `c`.`ShippingAddress_ZipCode` = 7728 """); @@ -200,7 +200,7 @@ public override async Task Select_complex_type_Distinct(bool async) AssertSql( """ -SELECT DISTINCT `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT DISTINCT `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` """); } @@ -211,9 +211,9 @@ public override async Task Complex_type_equals_complex_type(bool async) AssertSql( """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` -WHERE ((`c`.`ShippingAddress_AddressLine1` = `c`.`BillingAddress_AddressLine1`) AND ((`c`.`ShippingAddress_AddressLine2` = `c`.`BillingAddress_AddressLine2`) OR (`c`.`ShippingAddress_AddressLine2` IS NULL AND (`c`.`BillingAddress_AddressLine2` IS NULL)))) AND (`c`.`ShippingAddress_ZipCode` = `c`.`BillingAddress_ZipCode`) +WHERE (((`c`.`ShippingAddress_AddressLine1` = `c`.`BillingAddress_AddressLine1`) AND ((`c`.`ShippingAddress_AddressLine2` = `c`.`BillingAddress_AddressLine2`) OR (`c`.`ShippingAddress_AddressLine2` IS NULL AND (`c`.`BillingAddress_AddressLine2` IS NULL)))) AND (`c`.`ShippingAddress_Tags` = `c`.`BillingAddress_Tags`)) AND (`c`.`ShippingAddress_ZipCode` = `c`.`BillingAddress_ZipCode`) """); } @@ -223,9 +223,9 @@ public override async Task Complex_type_equals_constant(bool async) AssertSql( """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` -WHERE ((((`c`.`ShippingAddress_AddressLine1` = '804 S. Lakeshore Road') AND `c`.`ShippingAddress_AddressLine2` IS NULL) AND (`c`.`ShippingAddress_ZipCode` = 38654)) AND (`c`.`ShippingAddress_Country_Code` = 'US')) AND (`c`.`ShippingAddress_Country_FullName` = 'United States') +WHERE (((((`c`.`ShippingAddress_AddressLine1` = '804 S. Lakeshore Road') AND `c`.`ShippingAddress_AddressLine2` IS NULL) AND (`c`.`ShippingAddress_Tags` = '["foo","bar"]')) AND (`c`.`ShippingAddress_ZipCode` = 38654)) AND (`c`.`ShippingAddress_Country_Code` = 'US')) AND (`c`.`ShippingAddress_Country_FullName` = 'United States') """); } @@ -236,13 +236,14 @@ public override async Task Complex_type_equals_parameter(bool async) AssertSql( """ @__entity_equality_address_0_AddressLine1='804 S. Lakeshore Road' (Size = 4000) +@__entity_equality_address_0_Tags='["foo","bar"]' (Size = 4000) @__entity_equality_address_0_ZipCode='38654' (Nullable = true) @__entity_equality_address_0_Country_Code='US' (Size = 4000) @__entity_equality_address_0_Country_FullName='United States' (Size = 4000) -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` -WHERE ((((`c`.`ShippingAddress_AddressLine1` = @__entity_equality_address_0_AddressLine1) AND `c`.`ShippingAddress_AddressLine2` IS NULL) AND (`c`.`ShippingAddress_ZipCode` = @__entity_equality_address_0_ZipCode)) AND (`c`.`ShippingAddress_Country_Code` = @__entity_equality_address_0_Country_Code)) AND (`c`.`ShippingAddress_Country_FullName` = @__entity_equality_address_0_Country_FullName) +WHERE (((((`c`.`ShippingAddress_AddressLine1` = @__entity_equality_address_0_AddressLine1) AND `c`.`ShippingAddress_AddressLine2` IS NULL) AND (`c`.`ShippingAddress_Tags` = @__entity_equality_address_0_Tags)) AND (`c`.`ShippingAddress_ZipCode` = @__entity_equality_address_0_ZipCode)) AND (`c`.`ShippingAddress_Country_Code` = @__entity_equality_address_0_Country_Code)) AND (`c`.`ShippingAddress_Country_FullName` = @__entity_equality_address_0_Country_FullName) """); } @@ -250,8 +251,7 @@ public override async Task Subquery_over_complex_type(bool async) { await base.Subquery_over_complex_type(async); - AssertSql( -); + AssertSql(); } public override async Task Contains_over_complex_type(bool async) @@ -261,29 +261,31 @@ public override async Task Contains_over_complex_type(bool async) AssertSql( """ @__entity_equality_address_0_AddressLine1='804 S. Lakeshore Road' (Size = 4000) +@__entity_equality_address_0_Tags='["foo","bar"]' (Size = 4000) @__entity_equality_address_0_ZipCode='38654' (Nullable = true) @__entity_equality_address_0_Country_Code='US' (Size = 4000) @__entity_equality_address_0_Country_FullName='United States' (Size = 4000) -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` WHERE EXISTS ( SELECT 1 FROM `Customer` AS `c0` - WHERE ((((`c0`.`ShippingAddress_AddressLine1` = @__entity_equality_address_0_AddressLine1) AND `c0`.`ShippingAddress_AddressLine2` IS NULL) AND (`c0`.`ShippingAddress_ZipCode` = @__entity_equality_address_0_ZipCode)) AND (`c0`.`ShippingAddress_Country_Code` = @__entity_equality_address_0_Country_Code)) AND (`c0`.`ShippingAddress_Country_FullName` = @__entity_equality_address_0_Country_FullName)) + WHERE (((((`c0`.`ShippingAddress_AddressLine1` = @__entity_equality_address_0_AddressLine1) AND `c0`.`ShippingAddress_AddressLine2` IS NULL) AND (`c0`.`ShippingAddress_Tags` = @__entity_equality_address_0_Tags)) AND (`c0`.`ShippingAddress_ZipCode` = @__entity_equality_address_0_ZipCode)) AND (`c0`.`ShippingAddress_Country_Code` = @__entity_equality_address_0_Country_Code)) AND (`c0`.`ShippingAddress_Country_FullName` = @__entity_equality_address_0_Country_FullName)) """); } public override async Task Concat_complex_type(bool async) { await base.Concat_complex_type(async); + AssertSql( """ -SELECT `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` WHERE `c`.`Id` = 1 UNION ALL -SELECT `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` +SELECT `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c0` WHERE `c0`.`Id` = 2 """); @@ -295,11 +297,11 @@ public override async Task Concat_entity_type_containing_complex_property(bool a AssertSql( """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` WHERE `c`.`Id` = 1 UNION ALL -SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` +SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c0` WHERE `c0`.`Id` = 2 """); @@ -311,11 +313,11 @@ public override async Task Union_entity_type_containing_complex_property(bool as AssertSql( """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` WHERE `c`.`Id` = 1 UNION -SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` +SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c0` WHERE `c0`.`Id` = 2 """); @@ -327,11 +329,11 @@ public override async Task Union_complex_type(bool async) AssertSql( """ -SELECT `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +SELECT `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` WHERE `c`.`Id` = 1 UNION -SELECT `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` +SELECT `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c0` WHERE `c0`.`Id` = 2 """); @@ -369,8 +371,7 @@ public override async Task Concat_two_different_complex_type(bool async) { await base.Concat_two_different_complex_type(async); - AssertSql( -); + AssertSql(); } public override async Task Union_two_different_complex_type(bool async) @@ -385,32 +386,28 @@ public override async Task Complex_type_equals_null(bool async) { await base.Complex_type_equals_null(async); - AssertSql( -); + AssertSql(); } public override async Task Subquery_over_struct_complex_type(bool async) { await base.Subquery_over_struct_complex_type(async); - AssertSql( -); + AssertSql(); } public override async Task Concat_two_different_struct_complex_type(bool async) { await base.Concat_two_different_struct_complex_type(async); - AssertSql( -); + AssertSql(); } public override async Task Union_two_different_struct_complex_type(bool async) { await base.Union_two_different_struct_complex_type(async); - AssertSql( -); + AssertSql(); } public override async Task Filter_on_property_inside_struct_complex_type(bool async) @@ -445,14 +442,14 @@ public override async Task Filter_on_property_inside_struct_complex_type_after_s """ @__p_0='1' -SELECT DISTINCT `t`.`Id`, `t`.`Name`, `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`ShippingAddress_AddressLine1`, `t`.`ShippingAddress_AddressLine2`, `t`.`ShippingAddress_ZipCode`, `t`.`ShippingAddress_Country_Code`, `t`.`ShippingAddress_Country_FullName` +SELECT DISTINCT `v0`.`Id`, `v0`.`Name`, `v0`.`BillingAddress_AddressLine1`, `v0`.`BillingAddress_AddressLine2`, `v0`.`BillingAddress_ZipCode`, `v0`.`BillingAddress_Country_Code`, `v0`.`BillingAddress_Country_FullName`, `v0`.`ShippingAddress_AddressLine1`, `v0`.`ShippingAddress_AddressLine2`, `v0`.`ShippingAddress_ZipCode`, `v0`.`ShippingAddress_Country_Code`, `v0`.`ShippingAddress_Country_FullName` FROM ( SELECT `v`.`Id`, `v`.`Name`, `v`.`BillingAddress_AddressLine1`, `v`.`BillingAddress_AddressLine2`, `v`.`BillingAddress_ZipCode`, `v`.`BillingAddress_Country_Code`, `v`.`BillingAddress_Country_FullName`, `v`.`ShippingAddress_AddressLine1`, `v`.`ShippingAddress_AddressLine2`, `v`.`ShippingAddress_ZipCode`, `v`.`ShippingAddress_Country_Code`, `v`.`ShippingAddress_Country_FullName` FROM `ValuedCustomer` AS `v` ORDER BY `v`.`Id` LIMIT 18446744073709551610 OFFSET @__p_0 -) AS `t` -WHERE `t`.`ShippingAddress_ZipCode` = 7728 +) AS `v0` +WHERE `v0`.`ShippingAddress_ZipCode` = 7728 """); } @@ -464,14 +461,14 @@ public override async Task Filter_on_property_inside_nested_struct_complex_type_ """ @__p_0='1' -SELECT DISTINCT `t`.`Id`, `t`.`Name`, `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`ShippingAddress_AddressLine1`, `t`.`ShippingAddress_AddressLine2`, `t`.`ShippingAddress_ZipCode`, `t`.`ShippingAddress_Country_Code`, `t`.`ShippingAddress_Country_FullName` +SELECT DISTINCT `v0`.`Id`, `v0`.`Name`, `v0`.`BillingAddress_AddressLine1`, `v0`.`BillingAddress_AddressLine2`, `v0`.`BillingAddress_ZipCode`, `v0`.`BillingAddress_Country_Code`, `v0`.`BillingAddress_Country_FullName`, `v0`.`ShippingAddress_AddressLine1`, `v0`.`ShippingAddress_AddressLine2`, `v0`.`ShippingAddress_ZipCode`, `v0`.`ShippingAddress_Country_Code`, `v0`.`ShippingAddress_Country_FullName` FROM ( SELECT `v`.`Id`, `v`.`Name`, `v`.`BillingAddress_AddressLine1`, `v`.`BillingAddress_AddressLine2`, `v`.`BillingAddress_ZipCode`, `v`.`BillingAddress_Country_Code`, `v`.`BillingAddress_Country_FullName`, `v`.`ShippingAddress_AddressLine1`, `v`.`ShippingAddress_AddressLine2`, `v`.`ShippingAddress_ZipCode`, `v`.`ShippingAddress_Country_Code`, `v`.`ShippingAddress_Country_FullName` FROM `ValuedCustomer` AS `v` ORDER BY `v`.`Id` LIMIT 18446744073709551610 OFFSET @__p_0 -) AS `t` -WHERE `t`.`ShippingAddress_Country_Code` = 'DE' +) AS `v0` +WHERE `v0`.`ShippingAddress_Country_Code` = 'DE' """); } @@ -516,7 +513,8 @@ public override async Task Project_struct_complex_type_via_optional_navigation(b public override async Task Project_struct_complex_type_via_required_navigation(bool async) { await base.Project_struct_complex_type_via_required_navigation(async); -AssertSql( + + AssertSql( """ SELECT `v0`.`ShippingAddress_AddressLine1`, `v0`.`ShippingAddress_AddressLine2`, `v0`.`ShippingAddress_ZipCode`, `v0`.`ShippingAddress_Country_Code`, `v0`.`ShippingAddress_Country_FullName` FROM `ValuedCustomerGroup` AS `v` @@ -532,20 +530,21 @@ public override async Task Load_struct_complex_type_after_subquery_on_entity_typ """ @__p_0='1' -SELECT DISTINCT `t`.`Id`, `t`.`Name`, `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`ShippingAddress_AddressLine1`, `t`.`ShippingAddress_AddressLine2`, `t`.`ShippingAddress_ZipCode`, `t`.`ShippingAddress_Country_Code`, `t`.`ShippingAddress_Country_FullName` +SELECT DISTINCT `v0`.`Id`, `v0`.`Name`, `v0`.`BillingAddress_AddressLine1`, `v0`.`BillingAddress_AddressLine2`, `v0`.`BillingAddress_ZipCode`, `v0`.`BillingAddress_Country_Code`, `v0`.`BillingAddress_Country_FullName`, `v0`.`ShippingAddress_AddressLine1`, `v0`.`ShippingAddress_AddressLine2`, `v0`.`ShippingAddress_ZipCode`, `v0`.`ShippingAddress_Country_Code`, `v0`.`ShippingAddress_Country_FullName` FROM ( SELECT `v`.`Id`, `v`.`Name`, `v`.`BillingAddress_AddressLine1`, `v`.`BillingAddress_AddressLine2`, `v`.`BillingAddress_ZipCode`, `v`.`BillingAddress_Country_Code`, `v`.`BillingAddress_Country_FullName`, `v`.`ShippingAddress_AddressLine1`, `v`.`ShippingAddress_AddressLine2`, `v`.`ShippingAddress_ZipCode`, `v`.`ShippingAddress_Country_Code`, `v`.`ShippingAddress_Country_FullName` FROM `ValuedCustomer` AS `v` ORDER BY `v`.`Id` LIMIT 18446744073709551610 OFFSET @__p_0 -) AS `t` +) AS `v0` """); } public override async Task Select_struct_complex_type(bool async) { await base.Select_struct_complex_type(async); -AssertSql( + + AssertSql( """ SELECT `v`.`ShippingAddress_AddressLine1`, `v`.`ShippingAddress_AddressLine2`, `v`.`ShippingAddress_ZipCode`, `v`.`ShippingAddress_Country_Code`, `v`.`ShippingAddress_Country_FullName` FROM `ValuedCustomer` AS `v` @@ -752,12 +751,12 @@ public override async Task Project_same_nested_complex_type_twice_with_pushdown( AssertSql( """ -SELECT `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`BillingAddress_AddressLine10`, `t`.`BillingAddress_AddressLine20`, `t`.`BillingAddress_ZipCode0`, `t`.`BillingAddress_Country_Code0`, `t`.`BillingAddress_Country_FullName0` +SELECT `s`.`BillingAddress_AddressLine1`, `s`.`BillingAddress_AddressLine2`, `s`.`BillingAddress_Tags`, `s`.`BillingAddress_ZipCode`, `s`.`BillingAddress_Country_Code`, `s`.`BillingAddress_Country_FullName`, `s`.`BillingAddress_AddressLine10`, `s`.`BillingAddress_AddressLine20`, `s`.`BillingAddress_Tags0`, `s`.`BillingAddress_ZipCode0`, `s`.`BillingAddress_Country_Code0`, `s`.`BillingAddress_Country_FullName0` FROM ( - SELECT DISTINCT `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0` + SELECT DISTINCT `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0` FROM `Customer` AS `c` CROSS JOIN `Customer` AS `c0` -) AS `t` +) AS `s` """); } @@ -767,12 +766,12 @@ public override async Task Project_same_entity_with_nested_complex_type_twice_wi AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`ShippingAddress_AddressLine1`, `t`.`ShippingAddress_AddressLine2`, `t`.`ShippingAddress_ZipCode`, `t`.`ShippingAddress_Country_Code`, `t`.`ShippingAddress_Country_FullName`, `t`.`Id0`, `t`.`Name0`, `t`.`BillingAddress_AddressLine10`, `t`.`BillingAddress_AddressLine20`, `t`.`BillingAddress_ZipCode0`, `t`.`BillingAddress_Country_Code0`, `t`.`BillingAddress_Country_FullName0`, `t`.`ShippingAddress_AddressLine10`, `t`.`ShippingAddress_AddressLine20`, `t`.`ShippingAddress_ZipCode0`, `t`.`ShippingAddress_Country_Code0`, `t`.`ShippingAddress_Country_FullName0` +SELECT `s`.`Id`, `s`.`Name`, `s`.`BillingAddress_AddressLine1`, `s`.`BillingAddress_AddressLine2`, `s`.`BillingAddress_Tags`, `s`.`BillingAddress_ZipCode`, `s`.`BillingAddress_Country_Code`, `s`.`BillingAddress_Country_FullName`, `s`.`ShippingAddress_AddressLine1`, `s`.`ShippingAddress_AddressLine2`, `s`.`ShippingAddress_Tags`, `s`.`ShippingAddress_ZipCode`, `s`.`ShippingAddress_Country_Code`, `s`.`ShippingAddress_Country_FullName`, `s`.`Id0`, `s`.`Name0`, `s`.`BillingAddress_AddressLine10`, `s`.`BillingAddress_AddressLine20`, `s`.`BillingAddress_Tags0`, `s`.`BillingAddress_ZipCode0`, `s`.`BillingAddress_Country_Code0`, `s`.`BillingAddress_Country_FullName0`, `s`.`ShippingAddress_AddressLine10`, `s`.`ShippingAddress_AddressLine20`, `s`.`ShippingAddress_Tags0`, `s`.`ShippingAddress_ZipCode0`, `s`.`ShippingAddress_Country_Code0`, `s`.`ShippingAddress_Country_FullName0` FROM ( - SELECT DISTINCT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` + SELECT DISTINCT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` FROM `Customer` AS `c` CROSS JOIN `Customer` AS `c0` -) AS `t` +) AS `s` """); } @@ -784,17 +783,17 @@ public override async Task Project_same_nested_complex_type_twice_with_double_pu """ @__p_0='50' -SELECT `t0`.`BillingAddress_AddressLine1`, `t0`.`BillingAddress_AddressLine2`, `t0`.`BillingAddress_ZipCode`, `t0`.`BillingAddress_Country_Code`, `t0`.`BillingAddress_Country_FullName`, `t0`.`BillingAddress_AddressLine10`, `t0`.`BillingAddress_AddressLine20`, `t0`.`BillingAddress_ZipCode0`, `t0`.`BillingAddress_Country_Code0`, `t0`.`BillingAddress_Country_FullName0` +SELECT `s0`.`BillingAddress_AddressLine1`, `s0`.`BillingAddress_AddressLine2`, `s0`.`BillingAddress_Tags`, `s0`.`BillingAddress_ZipCode`, `s0`.`BillingAddress_Country_Code`, `s0`.`BillingAddress_Country_FullName`, `s0`.`BillingAddress_AddressLine10`, `s0`.`BillingAddress_AddressLine20`, `s0`.`BillingAddress_Tags0`, `s0`.`BillingAddress_ZipCode0`, `s0`.`BillingAddress_Country_Code0`, `s0`.`BillingAddress_Country_FullName0` FROM ( - SELECT DISTINCT `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`BillingAddress_AddressLine10`, `t`.`BillingAddress_AddressLine20`, `t`.`BillingAddress_ZipCode0`, `t`.`BillingAddress_Country_Code0`, `t`.`BillingAddress_Country_FullName0` + SELECT DISTINCT `s`.`BillingAddress_AddressLine1`, `s`.`BillingAddress_AddressLine2`, `s`.`BillingAddress_Tags`, `s`.`BillingAddress_ZipCode`, `s`.`BillingAddress_Country_Code`, `s`.`BillingAddress_Country_FullName`, `s`.`BillingAddress_AddressLine10`, `s`.`BillingAddress_AddressLine20`, `s`.`BillingAddress_Tags0`, `s`.`BillingAddress_ZipCode0`, `s`.`BillingAddress_Country_Code0`, `s`.`BillingAddress_Country_FullName0` FROM ( - SELECT `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0` + SELECT `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0` FROM `Customer` AS `c` CROSS JOIN `Customer` AS `c0` ORDER BY `c`.`Id`, `c0`.`Id` LIMIT @__p_0 - ) AS `t` -) AS `t0` + ) AS `s` +) AS `s0` """); } @@ -806,17 +805,17 @@ public override async Task Project_same_entity_with_nested_complex_type_twice_wi """ @__p_0='50' -SELECT `t0`.`Id`, `t0`.`Name`, `t0`.`BillingAddress_AddressLine1`, `t0`.`BillingAddress_AddressLine2`, `t0`.`BillingAddress_ZipCode`, `t0`.`BillingAddress_Country_Code`, `t0`.`BillingAddress_Country_FullName`, `t0`.`ShippingAddress_AddressLine1`, `t0`.`ShippingAddress_AddressLine2`, `t0`.`ShippingAddress_ZipCode`, `t0`.`ShippingAddress_Country_Code`, `t0`.`ShippingAddress_Country_FullName`, `t0`.`Id0`, `t0`.`Name0`, `t0`.`BillingAddress_AddressLine10`, `t0`.`BillingAddress_AddressLine20`, `t0`.`BillingAddress_ZipCode0`, `t0`.`BillingAddress_Country_Code0`, `t0`.`BillingAddress_Country_FullName0`, `t0`.`ShippingAddress_AddressLine10`, `t0`.`ShippingAddress_AddressLine20`, `t0`.`ShippingAddress_ZipCode0`, `t0`.`ShippingAddress_Country_Code0`, `t0`.`ShippingAddress_Country_FullName0` +SELECT `s0`.`Id`, `s0`.`Name`, `s0`.`BillingAddress_AddressLine1`, `s0`.`BillingAddress_AddressLine2`, `s0`.`BillingAddress_Tags`, `s0`.`BillingAddress_ZipCode`, `s0`.`BillingAddress_Country_Code`, `s0`.`BillingAddress_Country_FullName`, `s0`.`ShippingAddress_AddressLine1`, `s0`.`ShippingAddress_AddressLine2`, `s0`.`ShippingAddress_Tags`, `s0`.`ShippingAddress_ZipCode`, `s0`.`ShippingAddress_Country_Code`, `s0`.`ShippingAddress_Country_FullName`, `s0`.`Id0`, `s0`.`Name0`, `s0`.`BillingAddress_AddressLine10`, `s0`.`BillingAddress_AddressLine20`, `s0`.`BillingAddress_Tags0`, `s0`.`BillingAddress_ZipCode0`, `s0`.`BillingAddress_Country_Code0`, `s0`.`BillingAddress_Country_FullName0`, `s0`.`ShippingAddress_AddressLine10`, `s0`.`ShippingAddress_AddressLine20`, `s0`.`ShippingAddress_Tags0`, `s0`.`ShippingAddress_ZipCode0`, `s0`.`ShippingAddress_Country_Code0`, `s0`.`ShippingAddress_Country_FullName0` FROM ( - SELECT DISTINCT `t`.`Id`, `t`.`Name`, `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`ShippingAddress_AddressLine1`, `t`.`ShippingAddress_AddressLine2`, `t`.`ShippingAddress_ZipCode`, `t`.`ShippingAddress_Country_Code`, `t`.`ShippingAddress_Country_FullName`, `t`.`Id0`, `t`.`Name0`, `t`.`BillingAddress_AddressLine10`, `t`.`BillingAddress_AddressLine20`, `t`.`BillingAddress_ZipCode0`, `t`.`BillingAddress_Country_Code0`, `t`.`BillingAddress_Country_FullName0`, `t`.`ShippingAddress_AddressLine10`, `t`.`ShippingAddress_AddressLine20`, `t`.`ShippingAddress_ZipCode0`, `t`.`ShippingAddress_Country_Code0`, `t`.`ShippingAddress_Country_FullName0` + SELECT DISTINCT `s`.`Id`, `s`.`Name`, `s`.`BillingAddress_AddressLine1`, `s`.`BillingAddress_AddressLine2`, `s`.`BillingAddress_Tags`, `s`.`BillingAddress_ZipCode`, `s`.`BillingAddress_Country_Code`, `s`.`BillingAddress_Country_FullName`, `s`.`ShippingAddress_AddressLine1`, `s`.`ShippingAddress_AddressLine2`, `s`.`ShippingAddress_Tags`, `s`.`ShippingAddress_ZipCode`, `s`.`ShippingAddress_Country_Code`, `s`.`ShippingAddress_Country_FullName`, `s`.`Id0`, `s`.`Name0`, `s`.`BillingAddress_AddressLine10`, `s`.`BillingAddress_AddressLine20`, `s`.`BillingAddress_Tags0`, `s`.`BillingAddress_ZipCode0`, `s`.`BillingAddress_Country_Code0`, `s`.`BillingAddress_Country_FullName0`, `s`.`ShippingAddress_AddressLine10`, `s`.`ShippingAddress_AddressLine20`, `s`.`ShippingAddress_Tags0`, `s`.`ShippingAddress_ZipCode0`, `s`.`ShippingAddress_Country_Code0`, `s`.`ShippingAddress_Country_FullName0` FROM ( - SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` + SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` FROM `Customer` AS `c` CROSS JOIN `Customer` AS `c0` ORDER BY `c`.`Id`, `c0`.`Id` LIMIT @__p_0 - ) AS `t` -) AS `t0` + ) AS `s` +) AS `s0` """); } @@ -826,12 +825,12 @@ public override async Task Project_same_struct_nested_complex_type_twice_with_pu AssertSql( """ -SELECT `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`BillingAddress_AddressLine10`, `t`.`BillingAddress_AddressLine20`, `t`.`BillingAddress_ZipCode0`, `t`.`BillingAddress_Country_Code0`, `t`.`BillingAddress_Country_FullName0` +SELECT `s`.`BillingAddress_AddressLine1`, `s`.`BillingAddress_AddressLine2`, `s`.`BillingAddress_ZipCode`, `s`.`BillingAddress_Country_Code`, `s`.`BillingAddress_Country_FullName`, `s`.`BillingAddress_AddressLine10`, `s`.`BillingAddress_AddressLine20`, `s`.`BillingAddress_ZipCode0`, `s`.`BillingAddress_Country_Code0`, `s`.`BillingAddress_Country_FullName0` FROM ( SELECT DISTINCT `v`.`BillingAddress_AddressLine1`, `v`.`BillingAddress_AddressLine2`, `v`.`BillingAddress_ZipCode`, `v`.`BillingAddress_Country_Code`, `v`.`BillingAddress_Country_FullName`, `v0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `v0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `v0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `v0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `v0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0` FROM `ValuedCustomer` AS `v` CROSS JOIN `ValuedCustomer` AS `v0` -) AS `t` +) AS `s` """); } @@ -841,12 +840,12 @@ public override async Task Project_same_entity_with_struct_nested_complex_type_t AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`ShippingAddress_AddressLine1`, `t`.`ShippingAddress_AddressLine2`, `t`.`ShippingAddress_ZipCode`, `t`.`ShippingAddress_Country_Code`, `t`.`ShippingAddress_Country_FullName`, `t`.`Id0`, `t`.`Name0`, `t`.`BillingAddress_AddressLine10`, `t`.`BillingAddress_AddressLine20`, `t`.`BillingAddress_ZipCode0`, `t`.`BillingAddress_Country_Code0`, `t`.`BillingAddress_Country_FullName0`, `t`.`ShippingAddress_AddressLine10`, `t`.`ShippingAddress_AddressLine20`, `t`.`ShippingAddress_ZipCode0`, `t`.`ShippingAddress_Country_Code0`, `t`.`ShippingAddress_Country_FullName0` +SELECT `s`.`Id`, `s`.`Name`, `s`.`BillingAddress_AddressLine1`, `s`.`BillingAddress_AddressLine2`, `s`.`BillingAddress_ZipCode`, `s`.`BillingAddress_Country_Code`, `s`.`BillingAddress_Country_FullName`, `s`.`ShippingAddress_AddressLine1`, `s`.`ShippingAddress_AddressLine2`, `s`.`ShippingAddress_ZipCode`, `s`.`ShippingAddress_Country_Code`, `s`.`ShippingAddress_Country_FullName`, `s`.`Id0`, `s`.`Name0`, `s`.`BillingAddress_AddressLine10`, `s`.`BillingAddress_AddressLine20`, `s`.`BillingAddress_ZipCode0`, `s`.`BillingAddress_Country_Code0`, `s`.`BillingAddress_Country_FullName0`, `s`.`ShippingAddress_AddressLine10`, `s`.`ShippingAddress_AddressLine20`, `s`.`ShippingAddress_ZipCode0`, `s`.`ShippingAddress_Country_Code0`, `s`.`ShippingAddress_Country_FullName0` FROM ( SELECT DISTINCT `v`.`Id`, `v`.`Name`, `v`.`BillingAddress_AddressLine1`, `v`.`BillingAddress_AddressLine2`, `v`.`BillingAddress_ZipCode`, `v`.`BillingAddress_Country_Code`, `v`.`BillingAddress_Country_FullName`, `v`.`ShippingAddress_AddressLine1`, `v`.`ShippingAddress_AddressLine2`, `v`.`ShippingAddress_ZipCode`, `v`.`ShippingAddress_Country_Code`, `v`.`ShippingAddress_Country_FullName`, `v0`.`Id` AS `Id0`, `v0`.`Name` AS `Name0`, `v0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `v0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `v0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `v0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `v0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `v0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `v0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `v0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `v0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `v0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` FROM `ValuedCustomer` AS `v` CROSS JOIN `ValuedCustomer` AS `v0` -) AS `t` +) AS `s` """); } @@ -858,17 +857,17 @@ public override async Task Project_same_struct_nested_complex_type_twice_with_do """ @__p_0='50' -SELECT `t0`.`BillingAddress_AddressLine1`, `t0`.`BillingAddress_AddressLine2`, `t0`.`BillingAddress_ZipCode`, `t0`.`BillingAddress_Country_Code`, `t0`.`BillingAddress_Country_FullName`, `t0`.`BillingAddress_AddressLine10`, `t0`.`BillingAddress_AddressLine20`, `t0`.`BillingAddress_ZipCode0`, `t0`.`BillingAddress_Country_Code0`, `t0`.`BillingAddress_Country_FullName0` +SELECT `s0`.`BillingAddress_AddressLine1`, `s0`.`BillingAddress_AddressLine2`, `s0`.`BillingAddress_ZipCode`, `s0`.`BillingAddress_Country_Code`, `s0`.`BillingAddress_Country_FullName`, `s0`.`BillingAddress_AddressLine10`, `s0`.`BillingAddress_AddressLine20`, `s0`.`BillingAddress_ZipCode0`, `s0`.`BillingAddress_Country_Code0`, `s0`.`BillingAddress_Country_FullName0` FROM ( - SELECT DISTINCT `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`BillingAddress_AddressLine10`, `t`.`BillingAddress_AddressLine20`, `t`.`BillingAddress_ZipCode0`, `t`.`BillingAddress_Country_Code0`, `t`.`BillingAddress_Country_FullName0` + SELECT DISTINCT `s`.`BillingAddress_AddressLine1`, `s`.`BillingAddress_AddressLine2`, `s`.`BillingAddress_ZipCode`, `s`.`BillingAddress_Country_Code`, `s`.`BillingAddress_Country_FullName`, `s`.`BillingAddress_AddressLine10`, `s`.`BillingAddress_AddressLine20`, `s`.`BillingAddress_ZipCode0`, `s`.`BillingAddress_Country_Code0`, `s`.`BillingAddress_Country_FullName0` FROM ( SELECT `v`.`BillingAddress_AddressLine1`, `v`.`BillingAddress_AddressLine2`, `v`.`BillingAddress_ZipCode`, `v`.`BillingAddress_Country_Code`, `v`.`BillingAddress_Country_FullName`, `v0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `v0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `v0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `v0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `v0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0` FROM `ValuedCustomer` AS `v` CROSS JOIN `ValuedCustomer` AS `v0` ORDER BY `v`.`Id`, `v0`.`Id` LIMIT @__p_0 - ) AS `t` -) AS `t0` + ) AS `s` +) AS `s0` """); } @@ -880,17 +879,17 @@ public override async Task Project_same_entity_with_struct_nested_complex_type_t """ @__p_0='50' -SELECT `t0`.`Id`, `t0`.`Name`, `t0`.`BillingAddress_AddressLine1`, `t0`.`BillingAddress_AddressLine2`, `t0`.`BillingAddress_ZipCode`, `t0`.`BillingAddress_Country_Code`, `t0`.`BillingAddress_Country_FullName`, `t0`.`ShippingAddress_AddressLine1`, `t0`.`ShippingAddress_AddressLine2`, `t0`.`ShippingAddress_ZipCode`, `t0`.`ShippingAddress_Country_Code`, `t0`.`ShippingAddress_Country_FullName`, `t0`.`Id0`, `t0`.`Name0`, `t0`.`BillingAddress_AddressLine10`, `t0`.`BillingAddress_AddressLine20`, `t0`.`BillingAddress_ZipCode0`, `t0`.`BillingAddress_Country_Code0`, `t0`.`BillingAddress_Country_FullName0`, `t0`.`ShippingAddress_AddressLine10`, `t0`.`ShippingAddress_AddressLine20`, `t0`.`ShippingAddress_ZipCode0`, `t0`.`ShippingAddress_Country_Code0`, `t0`.`ShippingAddress_Country_FullName0` +SELECT `s0`.`Id`, `s0`.`Name`, `s0`.`BillingAddress_AddressLine1`, `s0`.`BillingAddress_AddressLine2`, `s0`.`BillingAddress_ZipCode`, `s0`.`BillingAddress_Country_Code`, `s0`.`BillingAddress_Country_FullName`, `s0`.`ShippingAddress_AddressLine1`, `s0`.`ShippingAddress_AddressLine2`, `s0`.`ShippingAddress_ZipCode`, `s0`.`ShippingAddress_Country_Code`, `s0`.`ShippingAddress_Country_FullName`, `s0`.`Id0`, `s0`.`Name0`, `s0`.`BillingAddress_AddressLine10`, `s0`.`BillingAddress_AddressLine20`, `s0`.`BillingAddress_ZipCode0`, `s0`.`BillingAddress_Country_Code0`, `s0`.`BillingAddress_Country_FullName0`, `s0`.`ShippingAddress_AddressLine10`, `s0`.`ShippingAddress_AddressLine20`, `s0`.`ShippingAddress_ZipCode0`, `s0`.`ShippingAddress_Country_Code0`, `s0`.`ShippingAddress_Country_FullName0` FROM ( - SELECT DISTINCT `t`.`Id`, `t`.`Name`, `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`ShippingAddress_AddressLine1`, `t`.`ShippingAddress_AddressLine2`, `t`.`ShippingAddress_ZipCode`, `t`.`ShippingAddress_Country_Code`, `t`.`ShippingAddress_Country_FullName`, `t`.`Id0`, `t`.`Name0`, `t`.`BillingAddress_AddressLine10`, `t`.`BillingAddress_AddressLine20`, `t`.`BillingAddress_ZipCode0`, `t`.`BillingAddress_Country_Code0`, `t`.`BillingAddress_Country_FullName0`, `t`.`ShippingAddress_AddressLine10`, `t`.`ShippingAddress_AddressLine20`, `t`.`ShippingAddress_ZipCode0`, `t`.`ShippingAddress_Country_Code0`, `t`.`ShippingAddress_Country_FullName0` + SELECT DISTINCT `s`.`Id`, `s`.`Name`, `s`.`BillingAddress_AddressLine1`, `s`.`BillingAddress_AddressLine2`, `s`.`BillingAddress_ZipCode`, `s`.`BillingAddress_Country_Code`, `s`.`BillingAddress_Country_FullName`, `s`.`ShippingAddress_AddressLine1`, `s`.`ShippingAddress_AddressLine2`, `s`.`ShippingAddress_ZipCode`, `s`.`ShippingAddress_Country_Code`, `s`.`ShippingAddress_Country_FullName`, `s`.`Id0`, `s`.`Name0`, `s`.`BillingAddress_AddressLine10`, `s`.`BillingAddress_AddressLine20`, `s`.`BillingAddress_ZipCode0`, `s`.`BillingAddress_Country_Code0`, `s`.`BillingAddress_Country_FullName0`, `s`.`ShippingAddress_AddressLine10`, `s`.`ShippingAddress_AddressLine20`, `s`.`ShippingAddress_ZipCode0`, `s`.`ShippingAddress_Country_Code0`, `s`.`ShippingAddress_Country_FullName0` FROM ( SELECT `v`.`Id`, `v`.`Name`, `v`.`BillingAddress_AddressLine1`, `v`.`BillingAddress_AddressLine2`, `v`.`BillingAddress_ZipCode`, `v`.`BillingAddress_Country_Code`, `v`.`BillingAddress_Country_FullName`, `v`.`ShippingAddress_AddressLine1`, `v`.`ShippingAddress_AddressLine2`, `v`.`ShippingAddress_ZipCode`, `v`.`ShippingAddress_Country_Code`, `v`.`ShippingAddress_Country_FullName`, `v0`.`Id` AS `Id0`, `v0`.`Name` AS `Name0`, `v0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `v0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `v0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `v0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `v0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `v0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `v0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `v0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `v0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `v0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` FROM `ValuedCustomer` AS `v` CROSS JOIN `ValuedCustomer` AS `v0` ORDER BY `v`.`Id`, `v0`.`Id` LIMIT @__p_0 - ) AS `t` -) AS `t0` + ) AS `s` +) AS `s0` """); } @@ -902,17 +901,17 @@ public override async Task Union_of_same_entity_with_nested_complex_type_project """ @__p_0='50' -SELECT `t`.`Id`, `t`.`Name`, `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`ShippingAddress_AddressLine1`, `t`.`ShippingAddress_AddressLine2`, `t`.`ShippingAddress_ZipCode`, `t`.`ShippingAddress_Country_Code`, `t`.`ShippingAddress_Country_FullName`, `t`.`Id0`, `t`.`Name0`, `t`.`BillingAddress_AddressLine10`, `t`.`BillingAddress_AddressLine20`, `t`.`BillingAddress_ZipCode0`, `t`.`BillingAddress_Country_Code0`, `t`.`BillingAddress_Country_FullName0`, `t`.`ShippingAddress_AddressLine10`, `t`.`ShippingAddress_AddressLine20`, `t`.`ShippingAddress_ZipCode0`, `t`.`ShippingAddress_Country_Code0`, `t`.`ShippingAddress_Country_FullName0` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BillingAddress_AddressLine1`, `u`.`BillingAddress_AddressLine2`, `u`.`BillingAddress_Tags`, `u`.`BillingAddress_ZipCode`, `u`.`BillingAddress_Country_Code`, `u`.`BillingAddress_Country_FullName`, `u`.`ShippingAddress_AddressLine1`, `u`.`ShippingAddress_AddressLine2`, `u`.`ShippingAddress_Tags`, `u`.`ShippingAddress_ZipCode`, `u`.`ShippingAddress_Country_Code`, `u`.`ShippingAddress_Country_FullName`, `u`.`Id0`, `u`.`Name0`, `u`.`BillingAddress_AddressLine10`, `u`.`BillingAddress_AddressLine20`, `u`.`BillingAddress_Tags0`, `u`.`BillingAddress_ZipCode0`, `u`.`BillingAddress_Country_Code0`, `u`.`BillingAddress_Country_FullName0`, `u`.`ShippingAddress_AddressLine10`, `u`.`ShippingAddress_AddressLine20`, `u`.`ShippingAddress_Tags0`, `u`.`ShippingAddress_ZipCode0`, `u`.`ShippingAddress_Country_Code0`, `u`.`ShippingAddress_Country_FullName0` FROM ( - SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` + SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` FROM `Customer` AS `c` CROSS JOIN `Customer` AS `c0` UNION - SELECT `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName`, `c2`.`Id` AS `Id0`, `c2`.`Name` AS `Name0`, `c2`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c2`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c2`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c2`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c2`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c2`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c2`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c2`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c2`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c2`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` + SELECT `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_Tags`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName`, `c2`.`Id` AS `Id0`, `c2`.`Name` AS `Name0`, `c2`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c2`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c2`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c2`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c2`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c2`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c2`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c2`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c2`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c2`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c2`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c2`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` FROM `Customer` AS `c1` CROSS JOIN `Customer` AS `c2` -) AS `t` -ORDER BY `t`.`Id`, `t`.`Id0` +) AS `u` +ORDER BY `u`.`Id`, `u`.`Id0` LIMIT @__p_0 """); } @@ -925,25 +924,25 @@ public override async Task Union_of_same_entity_with_nested_complex_type_project """ @__p_0='50' -SELECT `t1`.`Id`, `t1`.`Name`, `t1`.`BillingAddress_AddressLine1`, `t1`.`BillingAddress_AddressLine2`, `t1`.`BillingAddress_ZipCode`, `t1`.`BillingAddress_Country_Code`, `t1`.`BillingAddress_Country_FullName`, `t1`.`ShippingAddress_AddressLine1`, `t1`.`ShippingAddress_AddressLine2`, `t1`.`ShippingAddress_ZipCode`, `t1`.`ShippingAddress_Country_Code`, `t1`.`ShippingAddress_Country_FullName`, `t1`.`Id0`, `t1`.`Name0`, `t1`.`BillingAddress_AddressLine10`, `t1`.`BillingAddress_AddressLine20`, `t1`.`BillingAddress_ZipCode0`, `t1`.`BillingAddress_Country_Code0`, `t1`.`BillingAddress_Country_FullName0`, `t1`.`ShippingAddress_AddressLine10`, `t1`.`ShippingAddress_AddressLine20`, `t1`.`ShippingAddress_ZipCode0`, `t1`.`ShippingAddress_Country_Code0`, `t1`.`ShippingAddress_Country_FullName0` +SELECT `u1`.`Id`, `u1`.`Name`, `u1`.`BillingAddress_AddressLine1`, `u1`.`BillingAddress_AddressLine2`, `u1`.`BillingAddress_Tags`, `u1`.`BillingAddress_ZipCode`, `u1`.`BillingAddress_Country_Code`, `u1`.`BillingAddress_Country_FullName`, `u1`.`ShippingAddress_AddressLine1`, `u1`.`ShippingAddress_AddressLine2`, `u1`.`ShippingAddress_Tags`, `u1`.`ShippingAddress_ZipCode`, `u1`.`ShippingAddress_Country_Code`, `u1`.`ShippingAddress_Country_FullName`, `u1`.`Id0`, `u1`.`Name0`, `u1`.`BillingAddress_AddressLine10`, `u1`.`BillingAddress_AddressLine20`, `u1`.`BillingAddress_Tags0`, `u1`.`BillingAddress_ZipCode0`, `u1`.`BillingAddress_Country_Code0`, `u1`.`BillingAddress_Country_FullName0`, `u1`.`ShippingAddress_AddressLine10`, `u1`.`ShippingAddress_AddressLine20`, `u1`.`ShippingAddress_Tags0`, `u1`.`ShippingAddress_ZipCode0`, `u1`.`ShippingAddress_Country_Code0`, `u1`.`ShippingAddress_Country_FullName0` FROM ( - SELECT DISTINCT `t0`.`Id`, `t0`.`Name`, `t0`.`BillingAddress_AddressLine1`, `t0`.`BillingAddress_AddressLine2`, `t0`.`BillingAddress_ZipCode`, `t0`.`BillingAddress_Country_Code`, `t0`.`BillingAddress_Country_FullName`, `t0`.`ShippingAddress_AddressLine1`, `t0`.`ShippingAddress_AddressLine2`, `t0`.`ShippingAddress_ZipCode`, `t0`.`ShippingAddress_Country_Code`, `t0`.`ShippingAddress_Country_FullName`, `t0`.`Id0`, `t0`.`Name0`, `t0`.`BillingAddress_AddressLine10`, `t0`.`BillingAddress_AddressLine20`, `t0`.`BillingAddress_ZipCode0`, `t0`.`BillingAddress_Country_Code0`, `t0`.`BillingAddress_Country_FullName0`, `t0`.`ShippingAddress_AddressLine10`, `t0`.`ShippingAddress_AddressLine20`, `t0`.`ShippingAddress_ZipCode0`, `t0`.`ShippingAddress_Country_Code0`, `t0`.`ShippingAddress_Country_FullName0` + SELECT DISTINCT `u0`.`Id`, `u0`.`Name`, `u0`.`BillingAddress_AddressLine1`, `u0`.`BillingAddress_AddressLine2`, `u0`.`BillingAddress_Tags`, `u0`.`BillingAddress_ZipCode`, `u0`.`BillingAddress_Country_Code`, `u0`.`BillingAddress_Country_FullName`, `u0`.`ShippingAddress_AddressLine1`, `u0`.`ShippingAddress_AddressLine2`, `u0`.`ShippingAddress_Tags`, `u0`.`ShippingAddress_ZipCode`, `u0`.`ShippingAddress_Country_Code`, `u0`.`ShippingAddress_Country_FullName`, `u0`.`Id0`, `u0`.`Name0`, `u0`.`BillingAddress_AddressLine10`, `u0`.`BillingAddress_AddressLine20`, `u0`.`BillingAddress_Tags0`, `u0`.`BillingAddress_ZipCode0`, `u0`.`BillingAddress_Country_Code0`, `u0`.`BillingAddress_Country_FullName0`, `u0`.`ShippingAddress_AddressLine10`, `u0`.`ShippingAddress_AddressLine20`, `u0`.`ShippingAddress_Tags0`, `u0`.`ShippingAddress_ZipCode0`, `u0`.`ShippingAddress_Country_Code0`, `u0`.`ShippingAddress_Country_FullName0` FROM ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`ShippingAddress_AddressLine1`, `t`.`ShippingAddress_AddressLine2`, `t`.`ShippingAddress_ZipCode`, `t`.`ShippingAddress_Country_Code`, `t`.`ShippingAddress_Country_FullName`, `t`.`Id0`, `t`.`Name0`, `t`.`BillingAddress_AddressLine10`, `t`.`BillingAddress_AddressLine20`, `t`.`BillingAddress_ZipCode0`, `t`.`BillingAddress_Country_Code0`, `t`.`BillingAddress_Country_FullName0`, `t`.`ShippingAddress_AddressLine10`, `t`.`ShippingAddress_AddressLine20`, `t`.`ShippingAddress_ZipCode0`, `t`.`ShippingAddress_Country_Code0`, `t`.`ShippingAddress_Country_FullName0` + SELECT `u`.`Id`, `u`.`Name`, `u`.`BillingAddress_AddressLine1`, `u`.`BillingAddress_AddressLine2`, `u`.`BillingAddress_Tags`, `u`.`BillingAddress_ZipCode`, `u`.`BillingAddress_Country_Code`, `u`.`BillingAddress_Country_FullName`, `u`.`ShippingAddress_AddressLine1`, `u`.`ShippingAddress_AddressLine2`, `u`.`ShippingAddress_Tags`, `u`.`ShippingAddress_ZipCode`, `u`.`ShippingAddress_Country_Code`, `u`.`ShippingAddress_Country_FullName`, `u`.`Id0`, `u`.`Name0`, `u`.`BillingAddress_AddressLine10`, `u`.`BillingAddress_AddressLine20`, `u`.`BillingAddress_Tags0`, `u`.`BillingAddress_ZipCode0`, `u`.`BillingAddress_Country_Code0`, `u`.`BillingAddress_Country_FullName0`, `u`.`ShippingAddress_AddressLine10`, `u`.`ShippingAddress_AddressLine20`, `u`.`ShippingAddress_Tags0`, `u`.`ShippingAddress_ZipCode0`, `u`.`ShippingAddress_Country_Code0`, `u`.`ShippingAddress_Country_FullName0` FROM ( - SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` + SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, `c0`.`Id` AS `Id0`, `c0`.`Name` AS `Name0`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c0`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c0`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c0`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c0`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c0`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c0`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` FROM `Customer` AS `c` CROSS JOIN `Customer` AS `c0` UNION - SELECT `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName`, `c2`.`Id` AS `Id0`, `c2`.`Name` AS `Name0`, `c2`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c2`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c2`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c2`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c2`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c2`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c2`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c2`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c2`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c2`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` + SELECT `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_Tags`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName`, `c2`.`Id` AS `Id0`, `c2`.`Name` AS `Name0`, `c2`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c2`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c2`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c2`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c2`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c2`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c2`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c2`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c2`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c2`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c2`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c2`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0` FROM `Customer` AS `c1` CROSS JOIN `Customer` AS `c2` - ) AS `t` - ORDER BY `t`.`Id`, `t`.`Id0` + ) AS `u` + ORDER BY `u`.`Id`, `u`.`Id0` LIMIT @__p_0 - ) AS `t0` -) AS `t1` -ORDER BY `t1`.`Id`, `t1`.`Id0` + ) AS `u0` +) AS `u1` +ORDER BY `u1`.`Id`, `u1`.`Id0` LIMIT @__p_0 """); } @@ -956,17 +955,17 @@ public override async Task Union_of_same_nested_complex_type_projected_twice_wit """ @__p_0='50' -SELECT `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`BillingAddress_AddressLine10`, `t`.`BillingAddress_AddressLine20`, `t`.`BillingAddress_ZipCode0`, `t`.`BillingAddress_Country_Code0`, `t`.`BillingAddress_Country_FullName0` +SELECT `u`.`BillingAddress_AddressLine1`, `u`.`BillingAddress_AddressLine2`, `u`.`BillingAddress_Tags`, `u`.`BillingAddress_ZipCode`, `u`.`BillingAddress_Country_Code`, `u`.`BillingAddress_Country_FullName`, `u`.`BillingAddress_AddressLine10`, `u`.`BillingAddress_AddressLine20`, `u`.`BillingAddress_Tags0`, `u`.`BillingAddress_ZipCode0`, `u`.`BillingAddress_Country_Code0`, `u`.`BillingAddress_Country_FullName0` FROM ( - SELECT `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0` + SELECT `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0` FROM `Customer` AS `c` CROSS JOIN `Customer` AS `c0` UNION - SELECT `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c2`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c2`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c2`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c2`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c2`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0` + SELECT `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c2`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c2`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c2`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c2`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c2`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c2`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0` FROM `Customer` AS `c1` CROSS JOIN `Customer` AS `c2` -) AS `t` -ORDER BY `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_ZipCode0` +) AS `u` +ORDER BY `u`.`BillingAddress_ZipCode`, `u`.`BillingAddress_ZipCode0` LIMIT @__p_0 """); } @@ -979,25 +978,25 @@ public override async Task Union_of_same_nested_complex_type_projected_twice_wit """ @__p_0='50' -SELECT `t1`.`BillingAddress_AddressLine1`, `t1`.`BillingAddress_AddressLine2`, `t1`.`BillingAddress_ZipCode`, `t1`.`BillingAddress_Country_Code`, `t1`.`BillingAddress_Country_FullName`, `t1`.`BillingAddress_AddressLine10`, `t1`.`BillingAddress_AddressLine20`, `t1`.`BillingAddress_ZipCode0`, `t1`.`BillingAddress_Country_Code0`, `t1`.`BillingAddress_Country_FullName0` +SELECT `u1`.`BillingAddress_AddressLine1`, `u1`.`BillingAddress_AddressLine2`, `u1`.`BillingAddress_Tags`, `u1`.`BillingAddress_ZipCode`, `u1`.`BillingAddress_Country_Code`, `u1`.`BillingAddress_Country_FullName`, `u1`.`BillingAddress_AddressLine10`, `u1`.`BillingAddress_AddressLine20`, `u1`.`BillingAddress_Tags0`, `u1`.`BillingAddress_ZipCode0`, `u1`.`BillingAddress_Country_Code0`, `u1`.`BillingAddress_Country_FullName0` FROM ( - SELECT DISTINCT `t0`.`BillingAddress_AddressLine1`, `t0`.`BillingAddress_AddressLine2`, `t0`.`BillingAddress_ZipCode`, `t0`.`BillingAddress_Country_Code`, `t0`.`BillingAddress_Country_FullName`, `t0`.`BillingAddress_AddressLine10`, `t0`.`BillingAddress_AddressLine20`, `t0`.`BillingAddress_ZipCode0`, `t0`.`BillingAddress_Country_Code0`, `t0`.`BillingAddress_Country_FullName0` + SELECT DISTINCT `u0`.`BillingAddress_AddressLine1`, `u0`.`BillingAddress_AddressLine2`, `u0`.`BillingAddress_Tags`, `u0`.`BillingAddress_ZipCode`, `u0`.`BillingAddress_Country_Code`, `u0`.`BillingAddress_Country_FullName`, `u0`.`BillingAddress_AddressLine10`, `u0`.`BillingAddress_AddressLine20`, `u0`.`BillingAddress_Tags0`, `u0`.`BillingAddress_ZipCode0`, `u0`.`BillingAddress_Country_Code0`, `u0`.`BillingAddress_Country_FullName0` FROM ( - SELECT `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`BillingAddress_AddressLine10`, `t`.`BillingAddress_AddressLine20`, `t`.`BillingAddress_ZipCode0`, `t`.`BillingAddress_Country_Code0`, `t`.`BillingAddress_Country_FullName0` + SELECT `u`.`BillingAddress_AddressLine1`, `u`.`BillingAddress_AddressLine2`, `u`.`BillingAddress_Tags`, `u`.`BillingAddress_ZipCode`, `u`.`BillingAddress_Country_Code`, `u`.`BillingAddress_Country_FullName`, `u`.`BillingAddress_AddressLine10`, `u`.`BillingAddress_AddressLine20`, `u`.`BillingAddress_Tags0`, `u`.`BillingAddress_ZipCode0`, `u`.`BillingAddress_Country_Code0`, `u`.`BillingAddress_Country_FullName0` FROM ( - SELECT `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0` + SELECT `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c0`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c0`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c0`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c0`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c0`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c0`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0` FROM `Customer` AS `c` CROSS JOIN `Customer` AS `c0` UNION - SELECT `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c2`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c2`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c2`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c2`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c2`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0` + SELECT `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c2`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c2`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c2`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c2`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c2`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c2`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0` FROM `Customer` AS `c1` CROSS JOIN `Customer` AS `c2` - ) AS `t` - ORDER BY `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_ZipCode0` + ) AS `u` + ORDER BY `u`.`BillingAddress_ZipCode`, `u`.`BillingAddress_ZipCode0` LIMIT @__p_0 - ) AS `t0` -) AS `t1` -ORDER BY `t1`.`BillingAddress_ZipCode`, `t1`.`BillingAddress_ZipCode0` + ) AS `u0` +) AS `u1` +ORDER BY `u1`.`BillingAddress_ZipCode`, `u1`.`BillingAddress_ZipCode0` LIMIT @__p_0 """); } @@ -1008,15 +1007,15 @@ public override async Task Same_entity_with_complex_type_projected_twice_with_pu AssertSql( """ -SELECT `c`.`Id`, `t`.`Id`, `t`.`Name`, `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`ShippingAddress_AddressLine1`, `t`.`ShippingAddress_AddressLine2`, `t`.`ShippingAddress_ZipCode`, `t`.`ShippingAddress_Country_Code`, `t`.`ShippingAddress_Country_FullName`, `t`.`Id0`, `t`.`Name0`, `t`.`BillingAddress_AddressLine10`, `t`.`BillingAddress_AddressLine20`, `t`.`BillingAddress_ZipCode0`, `t`.`BillingAddress_Country_Code0`, `t`.`BillingAddress_Country_FullName0`, `t`.`ShippingAddress_AddressLine10`, `t`.`ShippingAddress_AddressLine20`, `t`.`ShippingAddress_ZipCode0`, `t`.`ShippingAddress_Country_Code0`, `t`.`ShippingAddress_Country_FullName0`, `t`.`c` +SELECT `c`.`Id`, `s`.`Id`, `s`.`Name`, `s`.`BillingAddress_AddressLine1`, `s`.`BillingAddress_AddressLine2`, `s`.`BillingAddress_Tags`, `s`.`BillingAddress_ZipCode`, `s`.`BillingAddress_Country_Code`, `s`.`BillingAddress_Country_FullName`, `s`.`ShippingAddress_AddressLine1`, `s`.`ShippingAddress_AddressLine2`, `s`.`ShippingAddress_Tags`, `s`.`ShippingAddress_ZipCode`, `s`.`ShippingAddress_Country_Code`, `s`.`ShippingAddress_Country_FullName`, `s`.`Id0`, `s`.`Name0`, `s`.`BillingAddress_AddressLine10`, `s`.`BillingAddress_AddressLine20`, `s`.`BillingAddress_Tags0`, `s`.`BillingAddress_ZipCode0`, `s`.`BillingAddress_Country_Code0`, `s`.`BillingAddress_Country_FullName0`, `s`.`ShippingAddress_AddressLine10`, `s`.`ShippingAddress_AddressLine20`, `s`.`ShippingAddress_Tags0`, `s`.`ShippingAddress_ZipCode0`, `s`.`ShippingAddress_Country_Code0`, `s`.`ShippingAddress_Country_FullName0`, `s`.`c` FROM `Customer` AS `c` LEFT JOIN LATERAL ( - SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName`, `c1`.`Id` AS `Id0`, `c1`.`Name` AS `Name0`, `c1`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c1`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c1`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c1`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c1`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c1`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c1`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c1`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c1`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c1`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0`, 1 AS `c` + SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName`, `c1`.`Id` AS `Id0`, `c1`.`Name` AS `Name0`, `c1`.`BillingAddress_AddressLine1` AS `BillingAddress_AddressLine10`, `c1`.`BillingAddress_AddressLine2` AS `BillingAddress_AddressLine20`, `c1`.`BillingAddress_Tags` AS `BillingAddress_Tags0`, `c1`.`BillingAddress_ZipCode` AS `BillingAddress_ZipCode0`, `c1`.`BillingAddress_Country_Code` AS `BillingAddress_Country_Code0`, `c1`.`BillingAddress_Country_FullName` AS `BillingAddress_Country_FullName0`, `c1`.`ShippingAddress_AddressLine1` AS `ShippingAddress_AddressLine10`, `c1`.`ShippingAddress_AddressLine2` AS `ShippingAddress_AddressLine20`, `c1`.`ShippingAddress_Tags` AS `ShippingAddress_Tags0`, `c1`.`ShippingAddress_ZipCode` AS `ShippingAddress_ZipCode0`, `c1`.`ShippingAddress_Country_Code` AS `ShippingAddress_Country_Code0`, `c1`.`ShippingAddress_Country_FullName` AS `ShippingAddress_Country_FullName0`, 1 AS `c` FROM `Customer` AS `c0` CROSS JOIN `Customer` AS `c1` ORDER BY `c0`.`Id`, `c1`.`Id` DESC LIMIT 1 -) AS `t` ON TRUE +) AS `s` ON TRUE """); } @@ -1024,7 +1023,66 @@ public override async Task Same_complex_type_projected_twice_with_pushdown_as_pa { await base.Same_complex_type_projected_twice_with_pushdown_as_part_of_another_projection(async); - AssertSql(""); + AssertSql(); + } + + public override async Task GroupBy_over_property_in_nested_complex_type(bool async) + { + await base.GroupBy_over_property_in_nested_complex_type(async); + + AssertSql( +""" +SELECT `c`.`ShippingAddress_Country_Code` AS `Code`, COUNT(*) AS `Count` +FROM `Customer` AS `c` +GROUP BY `c`.`ShippingAddress_Country_Code` +"""); + } + + public override async Task GroupBy_over_complex_type(bool async) + { + await base.GroupBy_over_complex_type(async); + + AssertSql( +""" +SELECT `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, COUNT(*) AS `Count` +FROM `Customer` AS `c` +GROUP BY `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +"""); + } + + public override async Task GroupBy_over_nested_complex_type(bool async) + { + await base.GroupBy_over_nested_complex_type(async); + + AssertSql( +""" +SELECT `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName`, COUNT(*) AS `Count` +FROM `Customer` AS `c` +GROUP BY `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` +"""); + } + + public override async Task Entity_with_complex_type_with_group_by_and_first(bool async) + { + await base.Entity_with_complex_type_with_group_by_and_first(async); + + AssertSql( +""" +SELECT `c3`.`Id`, `c3`.`Name`, `c3`.`BillingAddress_AddressLine1`, `c3`.`BillingAddress_AddressLine2`, `c3`.`BillingAddress_Tags`, `c3`.`BillingAddress_ZipCode`, `c3`.`BillingAddress_Country_Code`, `c3`.`BillingAddress_Country_FullName`, `c3`.`ShippingAddress_AddressLine1`, `c3`.`ShippingAddress_AddressLine2`, `c3`.`ShippingAddress_Tags`, `c3`.`ShippingAddress_ZipCode`, `c3`.`ShippingAddress_Country_Code`, `c3`.`ShippingAddress_Country_FullName` +FROM ( + SELECT `c`.`Id` + FROM `Customer` AS `c` + GROUP BY `c`.`Id` +) AS `c1` +LEFT JOIN ( + SELECT `c2`.`Id`, `c2`.`Name`, `c2`.`BillingAddress_AddressLine1`, `c2`.`BillingAddress_AddressLine2`, `c2`.`BillingAddress_Tags`, `c2`.`BillingAddress_ZipCode`, `c2`.`BillingAddress_Country_Code`, `c2`.`BillingAddress_Country_FullName`, `c2`.`ShippingAddress_AddressLine1`, `c2`.`ShippingAddress_AddressLine2`, `c2`.`ShippingAddress_Tags`, `c2`.`ShippingAddress_ZipCode`, `c2`.`ShippingAddress_Country_Code`, `c2`.`ShippingAddress_Country_FullName` + FROM ( + SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName`, ROW_NUMBER() OVER(PARTITION BY `c0`.`Id` ORDER BY `c0`.`Id`) AS `row` + FROM `Customer` AS `c0` + ) AS `c2` + WHERE `c2`.`row` <= 1 +) AS `c3` ON `c1`.`Id` = `c3`.`Id` +"""); } public override async Task Projecting_property_of_complex_type_using_left_join_with_pushdown(bool async) @@ -1033,13 +1091,13 @@ public override async Task Projecting_property_of_complex_type_using_left_join_w AssertSql( """ -SELECT `t`.`BillingAddress_ZipCode` +SELECT `c1`.`BillingAddress_ZipCode` FROM `CustomerGroup` AS `c` LEFT JOIN ( SELECT `c0`.`Id`, `c0`.`BillingAddress_ZipCode` FROM `Customer` AS `c0` WHERE `c0`.`Id` > 5 -) AS `t` ON `c`.`Id` = `t`.`Id` +) AS `c1` ON `c`.`Id` = `c1`.`Id` """); } @@ -1051,17 +1109,17 @@ public override async Task Projecting_complex_from_optional_navigation_using_con """ @__p_0='20' -SELECT `t0`.`ShippingAddress_ZipCode` +SELECT `s0`.`ShippingAddress_ZipCode` FROM ( - SELECT DISTINCT `t`.`ShippingAddress_AddressLine1`, `t`.`ShippingAddress_AddressLine2`, `t`.`ShippingAddress_ZipCode`, `t`.`ShippingAddress_Country_Code`, `t`.`ShippingAddress_Country_FullName` + SELECT DISTINCT `s`.`ShippingAddress_AddressLine1`, `s`.`ShippingAddress_AddressLine2`, `s`.`ShippingAddress_Tags`, `s`.`ShippingAddress_ZipCode`, `s`.`ShippingAddress_Country_Code`, `s`.`ShippingAddress_Country_FullName` FROM ( - SELECT `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` + SELECT `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM `CustomerGroup` AS `c` LEFT JOIN `Customer` AS `c0` ON `c`.`OptionalCustomerId` = `c0`.`Id` ORDER BY `c0`.`ShippingAddress_ZipCode` LIMIT @__p_0 - ) AS `t` -) AS `t0` + ) AS `s` +) AS `s0` """); } @@ -1074,25 +1132,25 @@ public override async Task Project_entity_with_complex_type_pushdown_and_then_le @__p_0='20' @__p_1='30' -SELECT `t0`.`BillingAddress_ZipCode` AS `Zip1`, `t1`.`ShippingAddress_ZipCode` AS `Zip2` +SELECT `c3`.`BillingAddress_ZipCode` AS `Zip1`, `c4`.`ShippingAddress_ZipCode` AS `Zip2` FROM ( - SELECT DISTINCT `t`.`Id`, `t`.`Name`, `t`.`BillingAddress_AddressLine1`, `t`.`BillingAddress_AddressLine2`, `t`.`BillingAddress_ZipCode`, `t`.`BillingAddress_Country_Code`, `t`.`BillingAddress_Country_FullName`, `t`.`ShippingAddress_AddressLine1`, `t`.`ShippingAddress_AddressLine2`, `t`.`ShippingAddress_ZipCode`, `t`.`ShippingAddress_Country_Code`, `t`.`ShippingAddress_Country_FullName` + SELECT DISTINCT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_Tags`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_Tags`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` FROM ( - SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` + SELECT `c`.`Id`, `c`.`Name`, `c`.`BillingAddress_AddressLine1`, `c`.`BillingAddress_AddressLine2`, `c`.`BillingAddress_Tags`, `c`.`BillingAddress_ZipCode`, `c`.`BillingAddress_Country_Code`, `c`.`BillingAddress_Country_FullName`, `c`.`ShippingAddress_AddressLine1`, `c`.`ShippingAddress_AddressLine2`, `c`.`ShippingAddress_Tags`, `c`.`ShippingAddress_ZipCode`, `c`.`ShippingAddress_Country_Code`, `c`.`ShippingAddress_Country_FullName` FROM `Customer` AS `c` ORDER BY `c`.`Id` LIMIT @__p_0 - ) AS `t` -) AS `t0` + ) AS `c0` +) AS `c3` LEFT JOIN ( - SELECT DISTINCT `t2`.`Id`, `t2`.`Name`, `t2`.`BillingAddress_AddressLine1`, `t2`.`BillingAddress_AddressLine2`, `t2`.`BillingAddress_ZipCode`, `t2`.`BillingAddress_Country_Code`, `t2`.`BillingAddress_Country_FullName`, `t2`.`ShippingAddress_AddressLine1`, `t2`.`ShippingAddress_AddressLine2`, `t2`.`ShippingAddress_ZipCode`, `t2`.`ShippingAddress_Country_Code`, `t2`.`ShippingAddress_Country_FullName` + SELECT DISTINCT `c2`.`Id`, `c2`.`Name`, `c2`.`BillingAddress_AddressLine1`, `c2`.`BillingAddress_AddressLine2`, `c2`.`BillingAddress_Tags`, `c2`.`BillingAddress_ZipCode`, `c2`.`BillingAddress_Country_Code`, `c2`.`BillingAddress_Country_FullName`, `c2`.`ShippingAddress_AddressLine1`, `c2`.`ShippingAddress_AddressLine2`, `c2`.`ShippingAddress_Tags`, `c2`.`ShippingAddress_ZipCode`, `c2`.`ShippingAddress_Country_Code`, `c2`.`ShippingAddress_Country_FullName` FROM ( - SELECT `c0`.`Id`, `c0`.`Name`, `c0`.`BillingAddress_AddressLine1`, `c0`.`BillingAddress_AddressLine2`, `c0`.`BillingAddress_ZipCode`, `c0`.`BillingAddress_Country_Code`, `c0`.`BillingAddress_Country_FullName`, `c0`.`ShippingAddress_AddressLine1`, `c0`.`ShippingAddress_AddressLine2`, `c0`.`ShippingAddress_ZipCode`, `c0`.`ShippingAddress_Country_Code`, `c0`.`ShippingAddress_Country_FullName` - FROM `Customer` AS `c0` - ORDER BY `c0`.`Id` DESC + SELECT `c1`.`Id`, `c1`.`Name`, `c1`.`BillingAddress_AddressLine1`, `c1`.`BillingAddress_AddressLine2`, `c1`.`BillingAddress_Tags`, `c1`.`BillingAddress_ZipCode`, `c1`.`BillingAddress_Country_Code`, `c1`.`BillingAddress_Country_FullName`, `c1`.`ShippingAddress_AddressLine1`, `c1`.`ShippingAddress_AddressLine2`, `c1`.`ShippingAddress_Tags`, `c1`.`ShippingAddress_ZipCode`, `c1`.`ShippingAddress_Country_Code`, `c1`.`ShippingAddress_Country_FullName` + FROM `Customer` AS `c1` + ORDER BY `c1`.`Id` DESC LIMIT @__p_1 - ) AS `t2` -) AS `t1` ON `t0`.`Id` = `t1`.`Id` + ) AS `c2` +) AS `c4` ON `c3`.`Id` = `c4`.`Id` """); } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/CompositeKeysQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/CompositeKeysQuerySingleStoreTest.cs index 6676a1b06..2920fae7c 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/CompositeKeysQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/CompositeKeysQuerySingleStoreTest.cs @@ -15,9 +15,6 @@ public CompositeKeysQuerySingleStoreTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - public override async Task Projecting_multiple_collections_same_level_top_level_ordering(bool async) { await base.Projecting_multiple_collections_same_level_top_level_ordering(async); @@ -71,14 +68,16 @@ public override async Task Projecting_collections_multi_level(bool async) await base.Projecting_collections_multi_level(async); AssertSql( - @"SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `t`.`Name`, `t`.`Id1`, `t`.`Id2`, `t`.`Id10`, `t`.`Id20`, `t`.`Level2_Optional_Id1`, `t`.`Level2_Optional_Id2`, `t`.`Level2_Required_Id1`, `t`.`Level2_Required_Id2`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse3Id1`, `t`.`OneToMany_Optional_Inverse3Id2`, `t`.`OneToMany_Optional_Self_Inverse3Id1`, `t`.`OneToMany_Optional_Self_Inverse3Id2`, `t`.`OneToMany_Required_Inverse3Id1`, `t`.`OneToMany_Required_Inverse3Id2`, `t`.`OneToMany_Required_Self_Inverse3Id1`, `t`.`OneToMany_Required_Self_Inverse3Id2`, `t`.`OneToOne_Optional_PK_Inverse3Id1`, `t`.`OneToOne_Optional_PK_Inverse3Id2`, `t`.`OneToOne_Optional_Self3Id1`, `t`.`OneToOne_Optional_Self3Id2` +""" +SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `s`.`Name`, `s`.`Id1`, `s`.`Id2`, `s`.`Id10`, `s`.`Id20`, `s`.`Level2_Optional_Id1`, `s`.`Level2_Optional_Id2`, `s`.`Level2_Required_Id1`, `s`.`Level2_Required_Id2`, `s`.`Name0`, `s`.`OneToMany_Optional_Inverse3Id1`, `s`.`OneToMany_Optional_Inverse3Id2`, `s`.`OneToMany_Optional_Self_Inverse3Id1`, `s`.`OneToMany_Optional_Self_Inverse3Id2`, `s`.`OneToMany_Required_Inverse3Id1`, `s`.`OneToMany_Required_Inverse3Id2`, `s`.`OneToMany_Required_Self_Inverse3Id1`, `s`.`OneToMany_Required_Self_Inverse3Id2`, `s`.`OneToOne_Optional_PK_Inverse3Id1`, `s`.`OneToOne_Optional_PK_Inverse3Id2`, `s`.`OneToOne_Optional_Self3Id1`, `s`.`OneToOne_Optional_Self3Id2` FROM `CompositeOnes` AS `c` LEFT JOIN ( SELECT `c0`.`Name`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1` AS `Id10`, `c1`.`Id2` AS `Id20`, `c1`.`Level2_Optional_Id1`, `c1`.`Level2_Optional_Id2`, `c1`.`Level2_Required_Id1`, `c1`.`Level2_Required_Id2`, `c1`.`Name` AS `Name0`, `c1`.`OneToMany_Optional_Inverse3Id1`, `c1`.`OneToMany_Optional_Inverse3Id2`, `c1`.`OneToMany_Optional_Self_Inverse3Id1`, `c1`.`OneToMany_Optional_Self_Inverse3Id2`, `c1`.`OneToMany_Required_Inverse3Id1`, `c1`.`OneToMany_Required_Inverse3Id2`, `c1`.`OneToMany_Required_Self_Inverse3Id1`, `c1`.`OneToMany_Required_Self_Inverse3Id2`, `c1`.`OneToOne_Optional_PK_Inverse3Id1`, `c1`.`OneToOne_Optional_PK_Inverse3Id2`, `c1`.`OneToOne_Optional_Self3Id1`, `c1`.`OneToOne_Optional_Self3Id2`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2` FROM `CompositeTwos` AS `c0` LEFT JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Required_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Required_Inverse3Id2`) -) AS `t` ON (`c`.`Id1` = `t`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `t`.`OneToMany_Optional_Inverse2Id2`) -ORDER BY `c`.`Id2`, `c`.`Id1`, `t`.`Id2`, `t`.`Id1`, `t`.`Id20` DESC"); +) AS `s` ON (`c`.`Id1` = `s`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `s`.`OneToMany_Optional_Inverse2Id2`) +ORDER BY `c`.`Id2`, `c`.`Id1`, `s`.`Id2`, `s`.`Id1`, `s`.`Id20` DESC +"""); } public override async Task Projecting_multiple_collections_on_multiple_levels_no_explicit_ordering(bool async) @@ -86,41 +85,43 @@ public override async Task Projecting_multiple_collections_on_multiple_levels_no await base.Projecting_multiple_collections_on_multiple_levels_no_explicit_ordering(async); AssertSql( - @"SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `t1`.`Name`, `t1`.`Id1`, `t1`.`Id2`, `t1`.`Name0`, `t1`.`Id10`, `t1`.`Id20`, `t1`.`Id100`, `t1`.`Id200`, `t1`.`Level3_Optional_Id1`, `t1`.`Level3_Optional_Id2`, `t1`.`Level3_Required_Id1`, `t1`.`Level3_Required_Id2`, `t1`.`Name00`, `t1`.`OneToMany_Optional_Inverse4Id1`, `t1`.`OneToMany_Optional_Inverse4Id2`, `t1`.`OneToMany_Optional_Self_Inverse4Id1`, `t1`.`OneToMany_Optional_Self_Inverse4Id2`, `t1`.`OneToMany_Required_Inverse4Id1`, `t1`.`OneToMany_Required_Inverse4Id2`, `t1`.`OneToMany_Required_Self_Inverse4Id1`, `t1`.`OneToMany_Required_Self_Inverse4Id2`, `t1`.`OneToOne_Optional_PK_Inverse4Id1`, `t1`.`OneToOne_Optional_PK_Inverse4Id2`, `t1`.`OneToOne_Optional_Self4Id1`, `t1`.`OneToOne_Optional_Self4Id2`, `t1`.`Id11`, `t1`.`Id21`, `t1`.`Level3_Optional_Id10`, `t1`.`Level3_Optional_Id20`, `t1`.`Level3_Required_Id10`, `t1`.`Level3_Required_Id20`, `t1`.`Name1`, `t1`.`OneToMany_Optional_Inverse4Id10`, `t1`.`OneToMany_Optional_Inverse4Id20`, `t1`.`OneToMany_Optional_Self_Inverse4Id10`, `t1`.`OneToMany_Optional_Self_Inverse4Id20`, `t1`.`OneToMany_Required_Inverse4Id10`, `t1`.`OneToMany_Required_Inverse4Id20`, `t1`.`OneToMany_Required_Self_Inverse4Id10`, `t1`.`OneToMany_Required_Self_Inverse4Id20`, `t1`.`OneToOne_Optional_PK_Inverse4Id10`, `t1`.`OneToOne_Optional_PK_Inverse4Id20`, `t1`.`OneToOne_Optional_Self4Id10`, `t1`.`OneToOne_Optional_Self4Id20`, `t1`.`Name2`, `t1`.`Id12`, `t1`.`Id22`, `t1`.`Id101`, `t1`.`Id201`, `t1`.`Level3_Optional_Id11`, `t1`.`Level3_Optional_Id21`, `t1`.`Level3_Required_Id11`, `t1`.`Level3_Required_Id21`, `t1`.`Name01`, `t1`.`OneToMany_Optional_Inverse4Id11`, `t1`.`OneToMany_Optional_Inverse4Id21`, `t1`.`OneToMany_Optional_Self_Inverse4Id11`, `t1`.`OneToMany_Optional_Self_Inverse4Id21`, `t1`.`OneToMany_Required_Inverse4Id11`, `t1`.`OneToMany_Required_Inverse4Id21`, `t1`.`OneToMany_Required_Self_Inverse4Id11`, `t1`.`OneToMany_Required_Self_Inverse4Id21`, `t1`.`OneToOne_Optional_PK_Inverse4Id11`, `t1`.`OneToOne_Optional_PK_Inverse4Id21`, `t1`.`OneToOne_Optional_Self4Id11`, `t1`.`OneToOne_Optional_Self4Id21`, `t1`.`Id110`, `t1`.`Id210`, `t1`.`Level3_Optional_Id100`, `t1`.`Level3_Optional_Id200`, `t1`.`Level3_Required_Id100`, `t1`.`Level3_Required_Id200`, `t1`.`Name10`, `t1`.`OneToMany_Optional_Inverse4Id100`, `t1`.`OneToMany_Optional_Inverse4Id200`, `t1`.`OneToMany_Optional_Self_Inverse4Id100`, `t1`.`OneToMany_Optional_Self_Inverse4Id200`, `t1`.`OneToMany_Required_Inverse4Id100`, `t1`.`OneToMany_Required_Inverse4Id200`, `t1`.`OneToMany_Required_Self_Inverse4Id100`, `t1`.`OneToMany_Required_Self_Inverse4Id200`, `t1`.`OneToOne_Optional_PK_Inverse4Id100`, `t1`.`OneToOne_Optional_PK_Inverse4Id200`, `t1`.`OneToOne_Optional_Self4Id100`, `t1`.`OneToOne_Optional_Self4Id200`, `t2`.`Name`, `t2`.`Id1`, `t2`.`Id2`, `t2`.`Name0`, `t2`.`Id10`, `t2`.`Id20`, `t2`.`Id100`, `t2`.`Id200`, `t2`.`Level3_Optional_Id1`, `t2`.`Level3_Optional_Id2`, `t2`.`Level3_Required_Id1`, `t2`.`Level3_Required_Id2`, `t2`.`Name00`, `t2`.`OneToMany_Optional_Inverse4Id1`, `t2`.`OneToMany_Optional_Inverse4Id2`, `t2`.`OneToMany_Optional_Self_Inverse4Id1`, `t2`.`OneToMany_Optional_Self_Inverse4Id2`, `t2`.`OneToMany_Required_Inverse4Id1`, `t2`.`OneToMany_Required_Inverse4Id2`, `t2`.`OneToMany_Required_Self_Inverse4Id1`, `t2`.`OneToMany_Required_Self_Inverse4Id2`, `t2`.`OneToOne_Optional_PK_Inverse4Id1`, `t2`.`OneToOne_Optional_PK_Inverse4Id2`, `t2`.`OneToOne_Optional_Self4Id1`, `t2`.`OneToOne_Optional_Self4Id2`, `t2`.`Id11`, `t2`.`Id21`, `t2`.`Level3_Optional_Id10`, `t2`.`Level3_Optional_Id20`, `t2`.`Level3_Required_Id10`, `t2`.`Level3_Required_Id20`, `t2`.`Name1`, `t2`.`OneToMany_Optional_Inverse4Id10`, `t2`.`OneToMany_Optional_Inverse4Id20`, `t2`.`OneToMany_Optional_Self_Inverse4Id10`, `t2`.`OneToMany_Optional_Self_Inverse4Id20`, `t2`.`OneToMany_Required_Inverse4Id10`, `t2`.`OneToMany_Required_Inverse4Id20`, `t2`.`OneToMany_Required_Self_Inverse4Id10`, `t2`.`OneToMany_Required_Self_Inverse4Id20`, `t2`.`OneToOne_Optional_PK_Inverse4Id10`, `t2`.`OneToOne_Optional_PK_Inverse4Id20`, `t2`.`OneToOne_Optional_Self4Id10`, `t2`.`OneToOne_Optional_Self4Id20`, `t2`.`Name2`, `t2`.`Id12`, `t2`.`Id22`, `t2`.`Id101`, `t2`.`Id201`, `t2`.`Level3_Optional_Id11`, `t2`.`Level3_Optional_Id21`, `t2`.`Level3_Required_Id11`, `t2`.`Level3_Required_Id21`, `t2`.`Name01`, `t2`.`OneToMany_Optional_Inverse4Id11`, `t2`.`OneToMany_Optional_Inverse4Id21`, `t2`.`OneToMany_Optional_Self_Inverse4Id11`, `t2`.`OneToMany_Optional_Self_Inverse4Id21`, `t2`.`OneToMany_Required_Inverse4Id11`, `t2`.`OneToMany_Required_Inverse4Id21`, `t2`.`OneToMany_Required_Self_Inverse4Id11`, `t2`.`OneToMany_Required_Self_Inverse4Id21`, `t2`.`OneToOne_Optional_PK_Inverse4Id11`, `t2`.`OneToOne_Optional_PK_Inverse4Id21`, `t2`.`OneToOne_Optional_Self4Id11`, `t2`.`OneToOne_Optional_Self4Id21`, `t2`.`Id110`, `t2`.`Id210`, `t2`.`Level3_Optional_Id100`, `t2`.`Level3_Optional_Id200`, `t2`.`Level3_Required_Id100`, `t2`.`Level3_Required_Id200`, `t2`.`Name10`, `t2`.`OneToMany_Optional_Inverse4Id100`, `t2`.`OneToMany_Optional_Inverse4Id200`, `t2`.`OneToMany_Optional_Self_Inverse4Id100`, `t2`.`OneToMany_Optional_Self_Inverse4Id200`, `t2`.`OneToMany_Required_Inverse4Id100`, `t2`.`OneToMany_Required_Inverse4Id200`, `t2`.`OneToMany_Required_Self_Inverse4Id100`, `t2`.`OneToMany_Required_Self_Inverse4Id200`, `t2`.`OneToOne_Optional_PK_Inverse4Id100`, `t2`.`OneToOne_Optional_PK_Inverse4Id200`, `t2`.`OneToOne_Optional_Self4Id100`, `t2`.`OneToOne_Optional_Self4Id200` +""" +SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `s1`.`Name`, `s1`.`Id1`, `s1`.`Id2`, `s1`.`Name0`, `s1`.`Id10`, `s1`.`Id20`, `s1`.`Id100`, `s1`.`Id200`, `s1`.`Level3_Optional_Id1`, `s1`.`Level3_Optional_Id2`, `s1`.`Level3_Required_Id1`, `s1`.`Level3_Required_Id2`, `s1`.`Name00`, `s1`.`OneToMany_Optional_Inverse4Id1`, `s1`.`OneToMany_Optional_Inverse4Id2`, `s1`.`OneToMany_Optional_Self_Inverse4Id1`, `s1`.`OneToMany_Optional_Self_Inverse4Id2`, `s1`.`OneToMany_Required_Inverse4Id1`, `s1`.`OneToMany_Required_Inverse4Id2`, `s1`.`OneToMany_Required_Self_Inverse4Id1`, `s1`.`OneToMany_Required_Self_Inverse4Id2`, `s1`.`OneToOne_Optional_PK_Inverse4Id1`, `s1`.`OneToOne_Optional_PK_Inverse4Id2`, `s1`.`OneToOne_Optional_Self4Id1`, `s1`.`OneToOne_Optional_Self4Id2`, `s1`.`Id11`, `s1`.`Id21`, `s1`.`Level3_Optional_Id10`, `s1`.`Level3_Optional_Id20`, `s1`.`Level3_Required_Id10`, `s1`.`Level3_Required_Id20`, `s1`.`Name1`, `s1`.`OneToMany_Optional_Inverse4Id10`, `s1`.`OneToMany_Optional_Inverse4Id20`, `s1`.`OneToMany_Optional_Self_Inverse4Id10`, `s1`.`OneToMany_Optional_Self_Inverse4Id20`, `s1`.`OneToMany_Required_Inverse4Id10`, `s1`.`OneToMany_Required_Inverse4Id20`, `s1`.`OneToMany_Required_Self_Inverse4Id10`, `s1`.`OneToMany_Required_Self_Inverse4Id20`, `s1`.`OneToOne_Optional_PK_Inverse4Id10`, `s1`.`OneToOne_Optional_PK_Inverse4Id20`, `s1`.`OneToOne_Optional_Self4Id10`, `s1`.`OneToOne_Optional_Self4Id20`, `s1`.`Name2`, `s1`.`Id12`, `s1`.`Id22`, `s1`.`Id101`, `s1`.`Id201`, `s1`.`Level3_Optional_Id11`, `s1`.`Level3_Optional_Id21`, `s1`.`Level3_Required_Id11`, `s1`.`Level3_Required_Id21`, `s1`.`Name01`, `s1`.`OneToMany_Optional_Inverse4Id11`, `s1`.`OneToMany_Optional_Inverse4Id21`, `s1`.`OneToMany_Optional_Self_Inverse4Id11`, `s1`.`OneToMany_Optional_Self_Inverse4Id21`, `s1`.`OneToMany_Required_Inverse4Id11`, `s1`.`OneToMany_Required_Inverse4Id21`, `s1`.`OneToMany_Required_Self_Inverse4Id11`, `s1`.`OneToMany_Required_Self_Inverse4Id21`, `s1`.`OneToOne_Optional_PK_Inverse4Id11`, `s1`.`OneToOne_Optional_PK_Inverse4Id21`, `s1`.`OneToOne_Optional_Self4Id11`, `s1`.`OneToOne_Optional_Self4Id21`, `s1`.`Id110`, `s1`.`Id210`, `s1`.`Level3_Optional_Id100`, `s1`.`Level3_Optional_Id200`, `s1`.`Level3_Required_Id100`, `s1`.`Level3_Required_Id200`, `s1`.`Name10`, `s1`.`OneToMany_Optional_Inverse4Id100`, `s1`.`OneToMany_Optional_Inverse4Id200`, `s1`.`OneToMany_Optional_Self_Inverse4Id100`, `s1`.`OneToMany_Optional_Self_Inverse4Id200`, `s1`.`OneToMany_Required_Inverse4Id100`, `s1`.`OneToMany_Required_Inverse4Id200`, `s1`.`OneToMany_Required_Self_Inverse4Id100`, `s1`.`OneToMany_Required_Self_Inverse4Id200`, `s1`.`OneToOne_Optional_PK_Inverse4Id100`, `s1`.`OneToOne_Optional_PK_Inverse4Id200`, `s1`.`OneToOne_Optional_Self4Id100`, `s1`.`OneToOne_Optional_Self4Id200`, `s4`.`Name`, `s4`.`Id1`, `s4`.`Id2`, `s4`.`Name0`, `s4`.`Id10`, `s4`.`Id20`, `s4`.`Id100`, `s4`.`Id200`, `s4`.`Level3_Optional_Id1`, `s4`.`Level3_Optional_Id2`, `s4`.`Level3_Required_Id1`, `s4`.`Level3_Required_Id2`, `s4`.`Name00`, `s4`.`OneToMany_Optional_Inverse4Id1`, `s4`.`OneToMany_Optional_Inverse4Id2`, `s4`.`OneToMany_Optional_Self_Inverse4Id1`, `s4`.`OneToMany_Optional_Self_Inverse4Id2`, `s4`.`OneToMany_Required_Inverse4Id1`, `s4`.`OneToMany_Required_Inverse4Id2`, `s4`.`OneToMany_Required_Self_Inverse4Id1`, `s4`.`OneToMany_Required_Self_Inverse4Id2`, `s4`.`OneToOne_Optional_PK_Inverse4Id1`, `s4`.`OneToOne_Optional_PK_Inverse4Id2`, `s4`.`OneToOne_Optional_Self4Id1`, `s4`.`OneToOne_Optional_Self4Id2`, `s4`.`Id11`, `s4`.`Id21`, `s4`.`Level3_Optional_Id10`, `s4`.`Level3_Optional_Id20`, `s4`.`Level3_Required_Id10`, `s4`.`Level3_Required_Id20`, `s4`.`Name1`, `s4`.`OneToMany_Optional_Inverse4Id10`, `s4`.`OneToMany_Optional_Inverse4Id20`, `s4`.`OneToMany_Optional_Self_Inverse4Id10`, `s4`.`OneToMany_Optional_Self_Inverse4Id20`, `s4`.`OneToMany_Required_Inverse4Id10`, `s4`.`OneToMany_Required_Inverse4Id20`, `s4`.`OneToMany_Required_Self_Inverse4Id10`, `s4`.`OneToMany_Required_Self_Inverse4Id20`, `s4`.`OneToOne_Optional_PK_Inverse4Id10`, `s4`.`OneToOne_Optional_PK_Inverse4Id20`, `s4`.`OneToOne_Optional_Self4Id10`, `s4`.`OneToOne_Optional_Self4Id20`, `s4`.`Name2`, `s4`.`Id12`, `s4`.`Id22`, `s4`.`Id101`, `s4`.`Id201`, `s4`.`Level3_Optional_Id11`, `s4`.`Level3_Optional_Id21`, `s4`.`Level3_Required_Id11`, `s4`.`Level3_Required_Id21`, `s4`.`Name01`, `s4`.`OneToMany_Optional_Inverse4Id11`, `s4`.`OneToMany_Optional_Inverse4Id21`, `s4`.`OneToMany_Optional_Self_Inverse4Id11`, `s4`.`OneToMany_Optional_Self_Inverse4Id21`, `s4`.`OneToMany_Required_Inverse4Id11`, `s4`.`OneToMany_Required_Inverse4Id21`, `s4`.`OneToMany_Required_Self_Inverse4Id11`, `s4`.`OneToMany_Required_Self_Inverse4Id21`, `s4`.`OneToOne_Optional_PK_Inverse4Id11`, `s4`.`OneToOne_Optional_PK_Inverse4Id21`, `s4`.`OneToOne_Optional_Self4Id11`, `s4`.`OneToOne_Optional_Self4Id21`, `s4`.`Id110`, `s4`.`Id210`, `s4`.`Level3_Optional_Id100`, `s4`.`Level3_Optional_Id200`, `s4`.`Level3_Required_Id100`, `s4`.`Level3_Required_Id200`, `s4`.`Name10`, `s4`.`OneToMany_Optional_Inverse4Id100`, `s4`.`OneToMany_Optional_Inverse4Id200`, `s4`.`OneToMany_Optional_Self_Inverse4Id100`, `s4`.`OneToMany_Optional_Self_Inverse4Id200`, `s4`.`OneToMany_Required_Inverse4Id100`, `s4`.`OneToMany_Required_Inverse4Id200`, `s4`.`OneToMany_Required_Self_Inverse4Id100`, `s4`.`OneToMany_Required_Self_Inverse4Id200`, `s4`.`OneToOne_Optional_PK_Inverse4Id100`, `s4`.`OneToOne_Optional_PK_Inverse4Id200`, `s4`.`OneToOne_Optional_Self4Id100`, `s4`.`OneToOne_Optional_Self4Id200` FROM `CompositeOnes` AS `c` LEFT JOIN ( - SELECT `c0`.`Name`, `c0`.`Id1`, `c0`.`Id2`, `t`.`Name` AS `Name0`, `t`.`Id1` AS `Id10`, `t`.`Id2` AS `Id20`, `t`.`Id10` AS `Id100`, `t`.`Id20` AS `Id200`, `t`.`Level3_Optional_Id1`, `t`.`Level3_Optional_Id2`, `t`.`Level3_Required_Id1`, `t`.`Level3_Required_Id2`, `t`.`Name0` AS `Name00`, `t`.`OneToMany_Optional_Inverse4Id1`, `t`.`OneToMany_Optional_Inverse4Id2`, `t`.`OneToMany_Optional_Self_Inverse4Id1`, `t`.`OneToMany_Optional_Self_Inverse4Id2`, `t`.`OneToMany_Required_Inverse4Id1`, `t`.`OneToMany_Required_Inverse4Id2`, `t`.`OneToMany_Required_Self_Inverse4Id1`, `t`.`OneToMany_Required_Self_Inverse4Id2`, `t`.`OneToOne_Optional_PK_Inverse4Id1`, `t`.`OneToOne_Optional_PK_Inverse4Id2`, `t`.`OneToOne_Optional_Self4Id1`, `t`.`OneToOne_Optional_Self4Id2`, `t`.`Id11`, `t`.`Id21`, `t`.`Level3_Optional_Id10`, `t`.`Level3_Optional_Id20`, `t`.`Level3_Required_Id10`, `t`.`Level3_Required_Id20`, `t`.`Name1`, `t`.`OneToMany_Optional_Inverse4Id10`, `t`.`OneToMany_Optional_Inverse4Id20`, `t`.`OneToMany_Optional_Self_Inverse4Id10`, `t`.`OneToMany_Optional_Self_Inverse4Id20`, `t`.`OneToMany_Required_Inverse4Id10`, `t`.`OneToMany_Required_Inverse4Id20`, `t`.`OneToMany_Required_Self_Inverse4Id10`, `t`.`OneToMany_Required_Self_Inverse4Id20`, `t`.`OneToOne_Optional_PK_Inverse4Id10`, `t`.`OneToOne_Optional_PK_Inverse4Id20`, `t`.`OneToOne_Optional_Self4Id10`, `t`.`OneToOne_Optional_Self4Id20`, `t0`.`Name` AS `Name2`, `t0`.`Id1` AS `Id12`, `t0`.`Id2` AS `Id22`, `t0`.`Id10` AS `Id101`, `t0`.`Id20` AS `Id201`, `t0`.`Level3_Optional_Id1` AS `Level3_Optional_Id11`, `t0`.`Level3_Optional_Id2` AS `Level3_Optional_Id21`, `t0`.`Level3_Required_Id1` AS `Level3_Required_Id11`, `t0`.`Level3_Required_Id2` AS `Level3_Required_Id21`, `t0`.`Name0` AS `Name01`, `t0`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id11`, `t0`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id21`, `t0`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id11`, `t0`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id21`, `t0`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id11`, `t0`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id21`, `t0`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id11`, `t0`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id21`, `t0`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id11`, `t0`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id21`, `t0`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id11`, `t0`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id21`, `t0`.`Id11` AS `Id110`, `t0`.`Id21` AS `Id210`, `t0`.`Level3_Optional_Id10` AS `Level3_Optional_Id100`, `t0`.`Level3_Optional_Id20` AS `Level3_Optional_Id200`, `t0`.`Level3_Required_Id10` AS `Level3_Required_Id100`, `t0`.`Level3_Required_Id20` AS `Level3_Required_Id200`, `t0`.`Name1` AS `Name10`, `t0`.`OneToMany_Optional_Inverse4Id10` AS `OneToMany_Optional_Inverse4Id100`, `t0`.`OneToMany_Optional_Inverse4Id20` AS `OneToMany_Optional_Inverse4Id200`, `t0`.`OneToMany_Optional_Self_Inverse4Id10` AS `OneToMany_Optional_Self_Inverse4Id100`, `t0`.`OneToMany_Optional_Self_Inverse4Id20` AS `OneToMany_Optional_Self_Inverse4Id200`, `t0`.`OneToMany_Required_Inverse4Id10` AS `OneToMany_Required_Inverse4Id100`, `t0`.`OneToMany_Required_Inverse4Id20` AS `OneToMany_Required_Inverse4Id200`, `t0`.`OneToMany_Required_Self_Inverse4Id10` AS `OneToMany_Required_Self_Inverse4Id100`, `t0`.`OneToMany_Required_Self_Inverse4Id20` AS `OneToMany_Required_Self_Inverse4Id200`, `t0`.`OneToOne_Optional_PK_Inverse4Id10` AS `OneToOne_Optional_PK_Inverse4Id100`, `t0`.`OneToOne_Optional_PK_Inverse4Id20` AS `OneToOne_Optional_PK_Inverse4Id200`, `t0`.`OneToOne_Optional_Self4Id10` AS `OneToOne_Optional_Self4Id100`, `t0`.`OneToOne_Optional_Self4Id20` AS `OneToOne_Optional_Self4Id200`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2` + SELECT `c0`.`Name`, `c0`.`Id1`, `c0`.`Id2`, `s`.`Name` AS `Name0`, `s`.`Id1` AS `Id10`, `s`.`Id2` AS `Id20`, `s`.`Id10` AS `Id100`, `s`.`Id20` AS `Id200`, `s`.`Level3_Optional_Id1`, `s`.`Level3_Optional_Id2`, `s`.`Level3_Required_Id1`, `s`.`Level3_Required_Id2`, `s`.`Name0` AS `Name00`, `s`.`OneToMany_Optional_Inverse4Id1`, `s`.`OneToMany_Optional_Inverse4Id2`, `s`.`OneToMany_Optional_Self_Inverse4Id1`, `s`.`OneToMany_Optional_Self_Inverse4Id2`, `s`.`OneToMany_Required_Inverse4Id1`, `s`.`OneToMany_Required_Inverse4Id2`, `s`.`OneToMany_Required_Self_Inverse4Id1`, `s`.`OneToMany_Required_Self_Inverse4Id2`, `s`.`OneToOne_Optional_PK_Inverse4Id1`, `s`.`OneToOne_Optional_PK_Inverse4Id2`, `s`.`OneToOne_Optional_Self4Id1`, `s`.`OneToOne_Optional_Self4Id2`, `s`.`Id11`, `s`.`Id21`, `s`.`Level3_Optional_Id10`, `s`.`Level3_Optional_Id20`, `s`.`Level3_Required_Id10`, `s`.`Level3_Required_Id20`, `s`.`Name1`, `s`.`OneToMany_Optional_Inverse4Id10`, `s`.`OneToMany_Optional_Inverse4Id20`, `s`.`OneToMany_Optional_Self_Inverse4Id10`, `s`.`OneToMany_Optional_Self_Inverse4Id20`, `s`.`OneToMany_Required_Inverse4Id10`, `s`.`OneToMany_Required_Inverse4Id20`, `s`.`OneToMany_Required_Self_Inverse4Id10`, `s`.`OneToMany_Required_Self_Inverse4Id20`, `s`.`OneToOne_Optional_PK_Inverse4Id10`, `s`.`OneToOne_Optional_PK_Inverse4Id20`, `s`.`OneToOne_Optional_Self4Id10`, `s`.`OneToOne_Optional_Self4Id20`, `s0`.`Name` AS `Name2`, `s0`.`Id1` AS `Id12`, `s0`.`Id2` AS `Id22`, `s0`.`Id10` AS `Id101`, `s0`.`Id20` AS `Id201`, `s0`.`Level3_Optional_Id1` AS `Level3_Optional_Id11`, `s0`.`Level3_Optional_Id2` AS `Level3_Optional_Id21`, `s0`.`Level3_Required_Id1` AS `Level3_Required_Id11`, `s0`.`Level3_Required_Id2` AS `Level3_Required_Id21`, `s0`.`Name0` AS `Name01`, `s0`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id11`, `s0`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id21`, `s0`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id11`, `s0`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id21`, `s0`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id11`, `s0`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id21`, `s0`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id11`, `s0`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id21`, `s0`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id11`, `s0`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id21`, `s0`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id11`, `s0`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id21`, `s0`.`Id11` AS `Id110`, `s0`.`Id21` AS `Id210`, `s0`.`Level3_Optional_Id10` AS `Level3_Optional_Id100`, `s0`.`Level3_Optional_Id20` AS `Level3_Optional_Id200`, `s0`.`Level3_Required_Id10` AS `Level3_Required_Id100`, `s0`.`Level3_Required_Id20` AS `Level3_Required_Id200`, `s0`.`Name1` AS `Name10`, `s0`.`OneToMany_Optional_Inverse4Id10` AS `OneToMany_Optional_Inverse4Id100`, `s0`.`OneToMany_Optional_Inverse4Id20` AS `OneToMany_Optional_Inverse4Id200`, `s0`.`OneToMany_Optional_Self_Inverse4Id10` AS `OneToMany_Optional_Self_Inverse4Id100`, `s0`.`OneToMany_Optional_Self_Inverse4Id20` AS `OneToMany_Optional_Self_Inverse4Id200`, `s0`.`OneToMany_Required_Inverse4Id10` AS `OneToMany_Required_Inverse4Id100`, `s0`.`OneToMany_Required_Inverse4Id20` AS `OneToMany_Required_Inverse4Id200`, `s0`.`OneToMany_Required_Self_Inverse4Id10` AS `OneToMany_Required_Self_Inverse4Id100`, `s0`.`OneToMany_Required_Self_Inverse4Id20` AS `OneToMany_Required_Self_Inverse4Id200`, `s0`.`OneToOne_Optional_PK_Inverse4Id10` AS `OneToOne_Optional_PK_Inverse4Id100`, `s0`.`OneToOne_Optional_PK_Inverse4Id20` AS `OneToOne_Optional_PK_Inverse4Id200`, `s0`.`OneToOne_Optional_Self4Id10` AS `OneToOne_Optional_Self4Id100`, `s0`.`OneToOne_Optional_Self4Id20` AS `OneToOne_Optional_Self4Id200`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2` FROM `CompositeTwos` AS `c0` LEFT JOIN ( SELECT `c1`.`Name`, `c1`.`Id1`, `c1`.`Id2`, `c2`.`Id1` AS `Id10`, `c2`.`Id2` AS `Id20`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name` AS `Name0`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c3`.`Id1` AS `Id11`, `c3`.`Id2` AS `Id21`, `c3`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c3`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c3`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c3`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c3`.`Name` AS `Name1`, `c3`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c3`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c3`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c3`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c3`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c3`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c3`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c3`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c3`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c3`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c3`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c3`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, `c1`.`OneToMany_Required_Inverse3Id1`, `c1`.`OneToMany_Required_Inverse3Id2` FROM `CompositeThrees` AS `c1` LEFT JOIN `CompositeFours` AS `c2` ON (`c1`.`Id1` = `c2`.`OneToMany_Optional_Inverse4Id1`) AND (`c1`.`Id2` = `c2`.`OneToMany_Optional_Inverse4Id2`) LEFT JOIN `CompositeFours` AS `c3` ON (`c1`.`Id1` = `c3`.`OneToMany_Required_Inverse4Id1`) AND (`c1`.`Id2` = `c3`.`OneToMany_Required_Inverse4Id2`) - ) AS `t` ON (`c0`.`Id1` = `t`.`OneToMany_Required_Inverse3Id1`) AND (`c0`.`Id2` = `t`.`OneToMany_Required_Inverse3Id2`) + ) AS `s` ON (`c0`.`Id1` = `s`.`OneToMany_Required_Inverse3Id1`) AND (`c0`.`Id2` = `s`.`OneToMany_Required_Inverse3Id2`) LEFT JOIN ( SELECT `c4`.`Name`, `c4`.`Id1`, `c4`.`Id2`, `c5`.`Id1` AS `Id10`, `c5`.`Id2` AS `Id20`, `c5`.`Level3_Optional_Id1`, `c5`.`Level3_Optional_Id2`, `c5`.`Level3_Required_Id1`, `c5`.`Level3_Required_Id2`, `c5`.`Name` AS `Name0`, `c5`.`OneToMany_Optional_Inverse4Id1`, `c5`.`OneToMany_Optional_Inverse4Id2`, `c5`.`OneToMany_Optional_Self_Inverse4Id1`, `c5`.`OneToMany_Optional_Self_Inverse4Id2`, `c5`.`OneToMany_Required_Inverse4Id1`, `c5`.`OneToMany_Required_Inverse4Id2`, `c5`.`OneToMany_Required_Self_Inverse4Id1`, `c5`.`OneToMany_Required_Self_Inverse4Id2`, `c5`.`OneToOne_Optional_PK_Inverse4Id1`, `c5`.`OneToOne_Optional_PK_Inverse4Id2`, `c5`.`OneToOne_Optional_Self4Id1`, `c5`.`OneToOne_Optional_Self4Id2`, `c6`.`Id1` AS `Id11`, `c6`.`Id2` AS `Id21`, `c6`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c6`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c6`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c6`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c6`.`Name` AS `Name1`, `c6`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c6`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c6`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c6`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c6`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c6`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c6`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c6`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c6`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c6`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c6`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c6`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, `c4`.`OneToMany_Optional_Inverse3Id1`, `c4`.`OneToMany_Optional_Inverse3Id2` FROM `CompositeThrees` AS `c4` LEFT JOIN `CompositeFours` AS `c5` ON (`c4`.`Id1` = `c5`.`OneToMany_Required_Inverse4Id1`) AND (`c4`.`Id2` = `c5`.`OneToMany_Required_Inverse4Id2`) LEFT JOIN `CompositeFours` AS `c6` ON (`c4`.`Id1` = `c6`.`OneToMany_Optional_Inverse4Id1`) AND (`c4`.`Id2` = `c6`.`OneToMany_Optional_Inverse4Id2`) - ) AS `t0` ON (`c0`.`Id1` = `t0`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `t0`.`OneToMany_Optional_Inverse3Id2`) -) AS `t1` ON (`c`.`Id1` = `t1`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `t1`.`OneToMany_Optional_Inverse2Id2`) + ) AS `s0` ON (`c0`.`Id1` = `s0`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `s0`.`OneToMany_Optional_Inverse3Id2`) +) AS `s1` ON (`c`.`Id1` = `s1`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `s1`.`OneToMany_Optional_Inverse2Id2`) LEFT JOIN ( - SELECT `c7`.`Name`, `c7`.`Id1`, `c7`.`Id2`, `t3`.`Name` AS `Name0`, `t3`.`Id1` AS `Id10`, `t3`.`Id2` AS `Id20`, `t3`.`Id10` AS `Id100`, `t3`.`Id20` AS `Id200`, `t3`.`Level3_Optional_Id1`, `t3`.`Level3_Optional_Id2`, `t3`.`Level3_Required_Id1`, `t3`.`Level3_Required_Id2`, `t3`.`Name0` AS `Name00`, `t3`.`OneToMany_Optional_Inverse4Id1`, `t3`.`OneToMany_Optional_Inverse4Id2`, `t3`.`OneToMany_Optional_Self_Inverse4Id1`, `t3`.`OneToMany_Optional_Self_Inverse4Id2`, `t3`.`OneToMany_Required_Inverse4Id1`, `t3`.`OneToMany_Required_Inverse4Id2`, `t3`.`OneToMany_Required_Self_Inverse4Id1`, `t3`.`OneToMany_Required_Self_Inverse4Id2`, `t3`.`OneToOne_Optional_PK_Inverse4Id1`, `t3`.`OneToOne_Optional_PK_Inverse4Id2`, `t3`.`OneToOne_Optional_Self4Id1`, `t3`.`OneToOne_Optional_Self4Id2`, `t3`.`Id11`, `t3`.`Id21`, `t3`.`Level3_Optional_Id10`, `t3`.`Level3_Optional_Id20`, `t3`.`Level3_Required_Id10`, `t3`.`Level3_Required_Id20`, `t3`.`Name1`, `t3`.`OneToMany_Optional_Inverse4Id10`, `t3`.`OneToMany_Optional_Inverse4Id20`, `t3`.`OneToMany_Optional_Self_Inverse4Id10`, `t3`.`OneToMany_Optional_Self_Inverse4Id20`, `t3`.`OneToMany_Required_Inverse4Id10`, `t3`.`OneToMany_Required_Inverse4Id20`, `t3`.`OneToMany_Required_Self_Inverse4Id10`, `t3`.`OneToMany_Required_Self_Inverse4Id20`, `t3`.`OneToOne_Optional_PK_Inverse4Id10`, `t3`.`OneToOne_Optional_PK_Inverse4Id20`, `t3`.`OneToOne_Optional_Self4Id10`, `t3`.`OneToOne_Optional_Self4Id20`, `t4`.`Name` AS `Name2`, `t4`.`Id1` AS `Id12`, `t4`.`Id2` AS `Id22`, `t4`.`Id10` AS `Id101`, `t4`.`Id20` AS `Id201`, `t4`.`Level3_Optional_Id1` AS `Level3_Optional_Id11`, `t4`.`Level3_Optional_Id2` AS `Level3_Optional_Id21`, `t4`.`Level3_Required_Id1` AS `Level3_Required_Id11`, `t4`.`Level3_Required_Id2` AS `Level3_Required_Id21`, `t4`.`Name0` AS `Name01`, `t4`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id11`, `t4`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id21`, `t4`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id11`, `t4`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id21`, `t4`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id11`, `t4`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id21`, `t4`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id11`, `t4`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id21`, `t4`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id11`, `t4`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id21`, `t4`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id11`, `t4`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id21`, `t4`.`Id11` AS `Id110`, `t4`.`Id21` AS `Id210`, `t4`.`Level3_Optional_Id10` AS `Level3_Optional_Id100`, `t4`.`Level3_Optional_Id20` AS `Level3_Optional_Id200`, `t4`.`Level3_Required_Id10` AS `Level3_Required_Id100`, `t4`.`Level3_Required_Id20` AS `Level3_Required_Id200`, `t4`.`Name1` AS `Name10`, `t4`.`OneToMany_Optional_Inverse4Id10` AS `OneToMany_Optional_Inverse4Id100`, `t4`.`OneToMany_Optional_Inverse4Id20` AS `OneToMany_Optional_Inverse4Id200`, `t4`.`OneToMany_Optional_Self_Inverse4Id10` AS `OneToMany_Optional_Self_Inverse4Id100`, `t4`.`OneToMany_Optional_Self_Inverse4Id20` AS `OneToMany_Optional_Self_Inverse4Id200`, `t4`.`OneToMany_Required_Inverse4Id10` AS `OneToMany_Required_Inverse4Id100`, `t4`.`OneToMany_Required_Inverse4Id20` AS `OneToMany_Required_Inverse4Id200`, `t4`.`OneToMany_Required_Self_Inverse4Id10` AS `OneToMany_Required_Self_Inverse4Id100`, `t4`.`OneToMany_Required_Self_Inverse4Id20` AS `OneToMany_Required_Self_Inverse4Id200`, `t4`.`OneToOne_Optional_PK_Inverse4Id10` AS `OneToOne_Optional_PK_Inverse4Id100`, `t4`.`OneToOne_Optional_PK_Inverse4Id20` AS `OneToOne_Optional_PK_Inverse4Id200`, `t4`.`OneToOne_Optional_Self4Id10` AS `OneToOne_Optional_Self4Id100`, `t4`.`OneToOne_Optional_Self4Id20` AS `OneToOne_Optional_Self4Id200`, `c7`.`OneToMany_Required_Inverse2Id1`, `c7`.`OneToMany_Required_Inverse2Id2` + SELECT `c7`.`Name`, `c7`.`Id1`, `c7`.`Id2`, `s2`.`Name` AS `Name0`, `s2`.`Id1` AS `Id10`, `s2`.`Id2` AS `Id20`, `s2`.`Id10` AS `Id100`, `s2`.`Id20` AS `Id200`, `s2`.`Level3_Optional_Id1`, `s2`.`Level3_Optional_Id2`, `s2`.`Level3_Required_Id1`, `s2`.`Level3_Required_Id2`, `s2`.`Name0` AS `Name00`, `s2`.`OneToMany_Optional_Inverse4Id1`, `s2`.`OneToMany_Optional_Inverse4Id2`, `s2`.`OneToMany_Optional_Self_Inverse4Id1`, `s2`.`OneToMany_Optional_Self_Inverse4Id2`, `s2`.`OneToMany_Required_Inverse4Id1`, `s2`.`OneToMany_Required_Inverse4Id2`, `s2`.`OneToMany_Required_Self_Inverse4Id1`, `s2`.`OneToMany_Required_Self_Inverse4Id2`, `s2`.`OneToOne_Optional_PK_Inverse4Id1`, `s2`.`OneToOne_Optional_PK_Inverse4Id2`, `s2`.`OneToOne_Optional_Self4Id1`, `s2`.`OneToOne_Optional_Self4Id2`, `s2`.`Id11`, `s2`.`Id21`, `s2`.`Level3_Optional_Id10`, `s2`.`Level3_Optional_Id20`, `s2`.`Level3_Required_Id10`, `s2`.`Level3_Required_Id20`, `s2`.`Name1`, `s2`.`OneToMany_Optional_Inverse4Id10`, `s2`.`OneToMany_Optional_Inverse4Id20`, `s2`.`OneToMany_Optional_Self_Inverse4Id10`, `s2`.`OneToMany_Optional_Self_Inverse4Id20`, `s2`.`OneToMany_Required_Inverse4Id10`, `s2`.`OneToMany_Required_Inverse4Id20`, `s2`.`OneToMany_Required_Self_Inverse4Id10`, `s2`.`OneToMany_Required_Self_Inverse4Id20`, `s2`.`OneToOne_Optional_PK_Inverse4Id10`, `s2`.`OneToOne_Optional_PK_Inverse4Id20`, `s2`.`OneToOne_Optional_Self4Id10`, `s2`.`OneToOne_Optional_Self4Id20`, `s3`.`Name` AS `Name2`, `s3`.`Id1` AS `Id12`, `s3`.`Id2` AS `Id22`, `s3`.`Id10` AS `Id101`, `s3`.`Id20` AS `Id201`, `s3`.`Level3_Optional_Id1` AS `Level3_Optional_Id11`, `s3`.`Level3_Optional_Id2` AS `Level3_Optional_Id21`, `s3`.`Level3_Required_Id1` AS `Level3_Required_Id11`, `s3`.`Level3_Required_Id2` AS `Level3_Required_Id21`, `s3`.`Name0` AS `Name01`, `s3`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id11`, `s3`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id21`, `s3`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id11`, `s3`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id21`, `s3`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id11`, `s3`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id21`, `s3`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id11`, `s3`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id21`, `s3`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id11`, `s3`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id21`, `s3`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id11`, `s3`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id21`, `s3`.`Id11` AS `Id110`, `s3`.`Id21` AS `Id210`, `s3`.`Level3_Optional_Id10` AS `Level3_Optional_Id100`, `s3`.`Level3_Optional_Id20` AS `Level3_Optional_Id200`, `s3`.`Level3_Required_Id10` AS `Level3_Required_Id100`, `s3`.`Level3_Required_Id20` AS `Level3_Required_Id200`, `s3`.`Name1` AS `Name10`, `s3`.`OneToMany_Optional_Inverse4Id10` AS `OneToMany_Optional_Inverse4Id100`, `s3`.`OneToMany_Optional_Inverse4Id20` AS `OneToMany_Optional_Inverse4Id200`, `s3`.`OneToMany_Optional_Self_Inverse4Id10` AS `OneToMany_Optional_Self_Inverse4Id100`, `s3`.`OneToMany_Optional_Self_Inverse4Id20` AS `OneToMany_Optional_Self_Inverse4Id200`, `s3`.`OneToMany_Required_Inverse4Id10` AS `OneToMany_Required_Inverse4Id100`, `s3`.`OneToMany_Required_Inverse4Id20` AS `OneToMany_Required_Inverse4Id200`, `s3`.`OneToMany_Required_Self_Inverse4Id10` AS `OneToMany_Required_Self_Inverse4Id100`, `s3`.`OneToMany_Required_Self_Inverse4Id20` AS `OneToMany_Required_Self_Inverse4Id200`, `s3`.`OneToOne_Optional_PK_Inverse4Id10` AS `OneToOne_Optional_PK_Inverse4Id100`, `s3`.`OneToOne_Optional_PK_Inverse4Id20` AS `OneToOne_Optional_PK_Inverse4Id200`, `s3`.`OneToOne_Optional_Self4Id10` AS `OneToOne_Optional_Self4Id100`, `s3`.`OneToOne_Optional_Self4Id20` AS `OneToOne_Optional_Self4Id200`, `c7`.`OneToMany_Required_Inverse2Id1`, `c7`.`OneToMany_Required_Inverse2Id2` FROM `CompositeTwos` AS `c7` LEFT JOIN ( SELECT `c8`.`Name`, `c8`.`Id1`, `c8`.`Id2`, `c9`.`Id1` AS `Id10`, `c9`.`Id2` AS `Id20`, `c9`.`Level3_Optional_Id1`, `c9`.`Level3_Optional_Id2`, `c9`.`Level3_Required_Id1`, `c9`.`Level3_Required_Id2`, `c9`.`Name` AS `Name0`, `c9`.`OneToMany_Optional_Inverse4Id1`, `c9`.`OneToMany_Optional_Inverse4Id2`, `c9`.`OneToMany_Optional_Self_Inverse4Id1`, `c9`.`OneToMany_Optional_Self_Inverse4Id2`, `c9`.`OneToMany_Required_Inverse4Id1`, `c9`.`OneToMany_Required_Inverse4Id2`, `c9`.`OneToMany_Required_Self_Inverse4Id1`, `c9`.`OneToMany_Required_Self_Inverse4Id2`, `c9`.`OneToOne_Optional_PK_Inverse4Id1`, `c9`.`OneToOne_Optional_PK_Inverse4Id2`, `c9`.`OneToOne_Optional_Self4Id1`, `c9`.`OneToOne_Optional_Self4Id2`, `c10`.`Id1` AS `Id11`, `c10`.`Id2` AS `Id21`, `c10`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c10`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c10`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c10`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c10`.`Name` AS `Name1`, `c10`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c10`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c10`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c10`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c10`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c10`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c10`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c10`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c10`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c10`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c10`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c10`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, `c8`.`OneToMany_Optional_Inverse3Id1`, `c8`.`OneToMany_Optional_Inverse3Id2` FROM `CompositeThrees` AS `c8` LEFT JOIN `CompositeFours` AS `c9` ON (`c8`.`Id1` = `c9`.`OneToMany_Required_Inverse4Id1`) AND (`c8`.`Id2` = `c9`.`OneToMany_Required_Inverse4Id2`) LEFT JOIN `CompositeFours` AS `c10` ON (`c8`.`Id1` = `c10`.`OneToMany_Optional_Inverse4Id1`) AND (`c8`.`Id2` = `c10`.`OneToMany_Optional_Inverse4Id2`) - ) AS `t3` ON (`c7`.`Id1` = `t3`.`OneToMany_Optional_Inverse3Id1`) AND (`c7`.`Id2` = `t3`.`OneToMany_Optional_Inverse3Id2`) + ) AS `s2` ON (`c7`.`Id1` = `s2`.`OneToMany_Optional_Inverse3Id1`) AND (`c7`.`Id2` = `s2`.`OneToMany_Optional_Inverse3Id2`) LEFT JOIN ( SELECT `c11`.`Name`, `c11`.`Id1`, `c11`.`Id2`, `c12`.`Id1` AS `Id10`, `c12`.`Id2` AS `Id20`, `c12`.`Level3_Optional_Id1`, `c12`.`Level3_Optional_Id2`, `c12`.`Level3_Required_Id1`, `c12`.`Level3_Required_Id2`, `c12`.`Name` AS `Name0`, `c12`.`OneToMany_Optional_Inverse4Id1`, `c12`.`OneToMany_Optional_Inverse4Id2`, `c12`.`OneToMany_Optional_Self_Inverse4Id1`, `c12`.`OneToMany_Optional_Self_Inverse4Id2`, `c12`.`OneToMany_Required_Inverse4Id1`, `c12`.`OneToMany_Required_Inverse4Id2`, `c12`.`OneToMany_Required_Self_Inverse4Id1`, `c12`.`OneToMany_Required_Self_Inverse4Id2`, `c12`.`OneToOne_Optional_PK_Inverse4Id1`, `c12`.`OneToOne_Optional_PK_Inverse4Id2`, `c12`.`OneToOne_Optional_Self4Id1`, `c12`.`OneToOne_Optional_Self4Id2`, `c13`.`Id1` AS `Id11`, `c13`.`Id2` AS `Id21`, `c13`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c13`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c13`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c13`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c13`.`Name` AS `Name1`, `c13`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c13`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c13`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c13`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c13`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c13`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c13`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c13`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c13`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c13`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c13`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c13`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, `c11`.`OneToMany_Optional_Inverse3Id1`, `c11`.`OneToMany_Optional_Inverse3Id2` FROM `CompositeThrees` AS `c11` LEFT JOIN `CompositeFours` AS `c12` ON (`c11`.`Id1` = `c12`.`OneToMany_Optional_Inverse4Id1`) AND (`c11`.`Id2` = `c12`.`OneToMany_Optional_Inverse4Id2`) LEFT JOIN `CompositeFours` AS `c13` ON (`c11`.`Id1` = `c13`.`OneToMany_Required_Inverse4Id1`) AND (`c11`.`Id2` = `c13`.`OneToMany_Required_Inverse4Id2`) - ) AS `t4` ON (`c7`.`Id1` = `t4`.`OneToMany_Optional_Inverse3Id1`) AND (`c7`.`Id2` = `t4`.`OneToMany_Optional_Inverse3Id2`) -) AS `t2` ON (`c`.`Id1` = `t2`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `t2`.`OneToMany_Required_Inverse2Id2`) -ORDER BY `c`.`Id1`, `c`.`Id2`, `t1`.`Id1`, `t1`.`Id2`, `t1`.`Id10`, `t1`.`Id20`, `t1`.`Id100`, `t1`.`Id200`, `t1`.`Id11`, `t1`.`Id21`, `t1`.`Id12`, `t1`.`Id22`, `t1`.`Id101`, `t1`.`Id201`, `t1`.`Id110`, `t1`.`Id210`, `t2`.`Id1`, `t2`.`Id2`, `t2`.`Id10`, `t2`.`Id20`, `t2`.`Id100`, `t2`.`Id200`, `t2`.`Id11`, `t2`.`Id21`, `t2`.`Id12`, `t2`.`Id22`, `t2`.`Id101`, `t2`.`Id201`, `t2`.`Id110`"); + ) AS `s3` ON (`c7`.`Id1` = `s3`.`OneToMany_Optional_Inverse3Id1`) AND (`c7`.`Id2` = `s3`.`OneToMany_Optional_Inverse3Id2`) +) AS `s4` ON (`c`.`Id1` = `s4`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `s4`.`OneToMany_Required_Inverse2Id2`) +ORDER BY `c`.`Id1`, `c`.`Id2`, `s1`.`Id1`, `s1`.`Id2`, `s1`.`Id10`, `s1`.`Id20`, `s1`.`Id100`, `s1`.`Id200`, `s1`.`Id11`, `s1`.`Id21`, `s1`.`Id12`, `s1`.`Id22`, `s1`.`Id101`, `s1`.`Id201`, `s1`.`Id110`, `s1`.`Id210`, `s4`.`Id1`, `s4`.`Id2`, `s4`.`Id10`, `s4`.`Id20`, `s4`.`Id100`, `s4`.`Id200`, `s4`.`Id11`, `s4`.`Id21`, `s4`.`Id12`, `s4`.`Id22`, `s4`.`Id101`, `s4`.`Id201`, `s4`.`Id110` +"""); } public override async Task Projecting_multiple_collections_on_multiple_levels_some_explicit_ordering(bool async) @@ -128,41 +129,43 @@ public override async Task Projecting_multiple_collections_on_multiple_levels_so await base.Projecting_multiple_collections_on_multiple_levels_some_explicit_ordering(async); AssertSql( - @"SELECT `c`.`Id1`, `c`.`Id2`, `t1`.`Name`, `t1`.`Id1`, `t1`.`Id2`, `t1`.`Id10`, `t1`.`Id20`, `t1`.`Id100`, `t1`.`Id200`, `t1`.`Level3_Optional_Id1`, `t1`.`Level3_Optional_Id2`, `t1`.`Level3_Required_Id1`, `t1`.`Level3_Required_Id2`, `t1`.`Name0`, `t1`.`OneToMany_Optional_Inverse4Id1`, `t1`.`OneToMany_Optional_Inverse4Id2`, `t1`.`OneToMany_Optional_Self_Inverse4Id1`, `t1`.`OneToMany_Optional_Self_Inverse4Id2`, `t1`.`OneToMany_Required_Inverse4Id1`, `t1`.`OneToMany_Required_Inverse4Id2`, `t1`.`OneToMany_Required_Self_Inverse4Id1`, `t1`.`OneToMany_Required_Self_Inverse4Id2`, `t1`.`OneToOne_Optional_PK_Inverse4Id1`, `t1`.`OneToOne_Optional_PK_Inverse4Id2`, `t1`.`OneToOne_Optional_Self4Id1`, `t1`.`OneToOne_Optional_Self4Id2`, `t1`.`Id11`, `t1`.`Id21`, `t1`.`Level3_Optional_Id10`, `t1`.`Level3_Optional_Id20`, `t1`.`Level3_Required_Id10`, `t1`.`Level3_Required_Id20`, `t1`.`Name00`, `t1`.`OneToMany_Optional_Inverse4Id10`, `t1`.`OneToMany_Optional_Inverse4Id20`, `t1`.`OneToMany_Optional_Self_Inverse4Id10`, `t1`.`OneToMany_Optional_Self_Inverse4Id20`, `t1`.`OneToMany_Required_Inverse4Id10`, `t1`.`OneToMany_Required_Inverse4Id20`, `t1`.`OneToMany_Required_Self_Inverse4Id10`, `t1`.`OneToMany_Required_Self_Inverse4Id20`, `t1`.`OneToOne_Optional_PK_Inverse4Id10`, `t1`.`OneToOne_Optional_PK_Inverse4Id20`, `t1`.`OneToOne_Optional_Self4Id10`, `t1`.`OneToOne_Optional_Self4Id20`, `t1`.`Name1`, `t1`.`Id12`, `t1`.`Id22`, `t1`.`Id101`, `t1`.`Id201`, `t1`.`Level3_Optional_Id11`, `t1`.`Level3_Optional_Id21`, `t1`.`Level3_Required_Id11`, `t1`.`Level3_Required_Id21`, `t1`.`Name01`, `t1`.`OneToMany_Optional_Inverse4Id11`, `t1`.`OneToMany_Optional_Inverse4Id21`, `t1`.`OneToMany_Optional_Self_Inverse4Id11`, `t1`.`OneToMany_Optional_Self_Inverse4Id21`, `t1`.`OneToMany_Required_Inverse4Id11`, `t1`.`OneToMany_Required_Inverse4Id21`, `t1`.`OneToMany_Required_Self_Inverse4Id11`, `t1`.`OneToMany_Required_Self_Inverse4Id21`, `t1`.`OneToOne_Optional_PK_Inverse4Id11`, `t1`.`OneToOne_Optional_PK_Inverse4Id21`, `t1`.`OneToOne_Optional_Self4Id11`, `t1`.`OneToOne_Optional_Self4Id21`, `t1`.`Id110`, `t1`.`Id210`, `t1`.`Level3_Optional_Id100`, `t1`.`Level3_Optional_Id200`, `t1`.`Level3_Required_Id100`, `t1`.`Level3_Required_Id200`, `t1`.`Name10`, `t1`.`OneToMany_Optional_Inverse4Id100`, `t1`.`OneToMany_Optional_Inverse4Id200`, `t1`.`OneToMany_Optional_Self_Inverse4Id100`, `t1`.`OneToMany_Optional_Self_Inverse4Id200`, `t1`.`OneToMany_Required_Inverse4Id100`, `t1`.`OneToMany_Required_Inverse4Id200`, `t1`.`OneToMany_Required_Self_Inverse4Id100`, `t1`.`OneToMany_Required_Self_Inverse4Id200`, `t1`.`OneToOne_Optional_PK_Inverse4Id100`, `t1`.`OneToOne_Optional_PK_Inverse4Id200`, `t1`.`OneToOne_Optional_Self4Id100`, `t1`.`OneToOne_Optional_Self4Id200`, `t2`.`Name`, `t2`.`Id1`, `t2`.`Id2`, `t2`.`Name0`, `t2`.`Id10`, `t2`.`Id20`, `t2`.`Id100`, `t2`.`Id200`, `t2`.`Level3_Optional_Id1`, `t2`.`Level3_Optional_Id2`, `t2`.`Level3_Required_Id1`, `t2`.`Level3_Required_Id2`, `t2`.`Name00`, `t2`.`OneToMany_Optional_Inverse4Id1`, `t2`.`OneToMany_Optional_Inverse4Id2`, `t2`.`OneToMany_Optional_Self_Inverse4Id1`, `t2`.`OneToMany_Optional_Self_Inverse4Id2`, `t2`.`OneToMany_Required_Inverse4Id1`, `t2`.`OneToMany_Required_Inverse4Id2`, `t2`.`OneToMany_Required_Self_Inverse4Id1`, `t2`.`OneToMany_Required_Self_Inverse4Id2`, `t2`.`OneToOne_Optional_PK_Inverse4Id1`, `t2`.`OneToOne_Optional_PK_Inverse4Id2`, `t2`.`OneToOne_Optional_Self4Id1`, `t2`.`OneToOne_Optional_Self4Id2`, `t2`.`Id11`, `t2`.`Id21`, `t2`.`Level3_Optional_Id10`, `t2`.`Level3_Optional_Id20`, `t2`.`Level3_Required_Id10`, `t2`.`Level3_Required_Id20`, `t2`.`Name1`, `t2`.`OneToMany_Optional_Inverse4Id10`, `t2`.`OneToMany_Optional_Inverse4Id20`, `t2`.`OneToMany_Optional_Self_Inverse4Id10`, `t2`.`OneToMany_Optional_Self_Inverse4Id20`, `t2`.`OneToMany_Required_Inverse4Id10`, `t2`.`OneToMany_Required_Inverse4Id20`, `t2`.`OneToMany_Required_Self_Inverse4Id10`, `t2`.`OneToMany_Required_Self_Inverse4Id20`, `t2`.`OneToOne_Optional_PK_Inverse4Id10`, `t2`.`OneToOne_Optional_PK_Inverse4Id20`, `t2`.`OneToOne_Optional_Self4Id10`, `t2`.`OneToOne_Optional_Self4Id20`, `t2`.`Name2`, `t2`.`Id12`, `t2`.`Id22`, `t2`.`Id101`, `t2`.`Id201`, `t2`.`Level3_Optional_Id11`, `t2`.`Level3_Optional_Id21`, `t2`.`Level3_Required_Id11`, `t2`.`Level3_Required_Id21`, `t2`.`Name01`, `t2`.`OneToMany_Optional_Inverse4Id11`, `t2`.`OneToMany_Optional_Inverse4Id21`, `t2`.`OneToMany_Optional_Self_Inverse4Id11`, `t2`.`OneToMany_Optional_Self_Inverse4Id21`, `t2`.`OneToMany_Required_Inverse4Id11`, `t2`.`OneToMany_Required_Inverse4Id21`, `t2`.`OneToMany_Required_Self_Inverse4Id11`, `t2`.`OneToMany_Required_Self_Inverse4Id21`, `t2`.`OneToOne_Optional_PK_Inverse4Id11`, `t2`.`OneToOne_Optional_PK_Inverse4Id21`, `t2`.`OneToOne_Optional_Self4Id11`, `t2`.`OneToOne_Optional_Self4Id21`, `t2`.`Id110`, `t2`.`Id210`, `t2`.`Level3_Optional_Id100`, `t2`.`Level3_Optional_Id200`, `t2`.`Level3_Required_Id100`, `t2`.`Level3_Required_Id200`, `t2`.`Name10`, `t2`.`OneToMany_Optional_Inverse4Id100`, `t2`.`OneToMany_Optional_Inverse4Id200`, `t2`.`OneToMany_Optional_Self_Inverse4Id100`, `t2`.`OneToMany_Optional_Self_Inverse4Id200`, `t2`.`OneToMany_Required_Inverse4Id100`, `t2`.`OneToMany_Required_Inverse4Id200`, `t2`.`OneToMany_Required_Self_Inverse4Id100`, `t2`.`OneToMany_Required_Self_Inverse4Id200`, `t2`.`OneToOne_Optional_PK_Inverse4Id100`, `t2`.`OneToOne_Optional_PK_Inverse4Id200`, `t2`.`OneToOne_Optional_Self4Id100`, `t2`.`OneToOne_Optional_Self4Id200` +""" +SELECT `c`.`Id1`, `c`.`Id2`, `s1`.`Name`, `s1`.`Id1`, `s1`.`Id2`, `s1`.`Id10`, `s1`.`Id20`, `s1`.`Id100`, `s1`.`Id200`, `s1`.`Level3_Optional_Id1`, `s1`.`Level3_Optional_Id2`, `s1`.`Level3_Required_Id1`, `s1`.`Level3_Required_Id2`, `s1`.`Name0`, `s1`.`OneToMany_Optional_Inverse4Id1`, `s1`.`OneToMany_Optional_Inverse4Id2`, `s1`.`OneToMany_Optional_Self_Inverse4Id1`, `s1`.`OneToMany_Optional_Self_Inverse4Id2`, `s1`.`OneToMany_Required_Inverse4Id1`, `s1`.`OneToMany_Required_Inverse4Id2`, `s1`.`OneToMany_Required_Self_Inverse4Id1`, `s1`.`OneToMany_Required_Self_Inverse4Id2`, `s1`.`OneToOne_Optional_PK_Inverse4Id1`, `s1`.`OneToOne_Optional_PK_Inverse4Id2`, `s1`.`OneToOne_Optional_Self4Id1`, `s1`.`OneToOne_Optional_Self4Id2`, `s1`.`Id11`, `s1`.`Id21`, `s1`.`Level3_Optional_Id10`, `s1`.`Level3_Optional_Id20`, `s1`.`Level3_Required_Id10`, `s1`.`Level3_Required_Id20`, `s1`.`Name00`, `s1`.`OneToMany_Optional_Inverse4Id10`, `s1`.`OneToMany_Optional_Inverse4Id20`, `s1`.`OneToMany_Optional_Self_Inverse4Id10`, `s1`.`OneToMany_Optional_Self_Inverse4Id20`, `s1`.`OneToMany_Required_Inverse4Id10`, `s1`.`OneToMany_Required_Inverse4Id20`, `s1`.`OneToMany_Required_Self_Inverse4Id10`, `s1`.`OneToMany_Required_Self_Inverse4Id20`, `s1`.`OneToOne_Optional_PK_Inverse4Id10`, `s1`.`OneToOne_Optional_PK_Inverse4Id20`, `s1`.`OneToOne_Optional_Self4Id10`, `s1`.`OneToOne_Optional_Self4Id20`, `s1`.`Name1`, `s1`.`Id12`, `s1`.`Id22`, `s1`.`Id101`, `s1`.`Id201`, `s1`.`Level3_Optional_Id11`, `s1`.`Level3_Optional_Id21`, `s1`.`Level3_Required_Id11`, `s1`.`Level3_Required_Id21`, `s1`.`Name01`, `s1`.`OneToMany_Optional_Inverse4Id11`, `s1`.`OneToMany_Optional_Inverse4Id21`, `s1`.`OneToMany_Optional_Self_Inverse4Id11`, `s1`.`OneToMany_Optional_Self_Inverse4Id21`, `s1`.`OneToMany_Required_Inverse4Id11`, `s1`.`OneToMany_Required_Inverse4Id21`, `s1`.`OneToMany_Required_Self_Inverse4Id11`, `s1`.`OneToMany_Required_Self_Inverse4Id21`, `s1`.`OneToOne_Optional_PK_Inverse4Id11`, `s1`.`OneToOne_Optional_PK_Inverse4Id21`, `s1`.`OneToOne_Optional_Self4Id11`, `s1`.`OneToOne_Optional_Self4Id21`, `s1`.`Id110`, `s1`.`Id210`, `s1`.`Level3_Optional_Id100`, `s1`.`Level3_Optional_Id200`, `s1`.`Level3_Required_Id100`, `s1`.`Level3_Required_Id200`, `s1`.`Name10`, `s1`.`OneToMany_Optional_Inverse4Id100`, `s1`.`OneToMany_Optional_Inverse4Id200`, `s1`.`OneToMany_Optional_Self_Inverse4Id100`, `s1`.`OneToMany_Optional_Self_Inverse4Id200`, `s1`.`OneToMany_Required_Inverse4Id100`, `s1`.`OneToMany_Required_Inverse4Id200`, `s1`.`OneToMany_Required_Self_Inverse4Id100`, `s1`.`OneToMany_Required_Self_Inverse4Id200`, `s1`.`OneToOne_Optional_PK_Inverse4Id100`, `s1`.`OneToOne_Optional_PK_Inverse4Id200`, `s1`.`OneToOne_Optional_Self4Id100`, `s1`.`OneToOne_Optional_Self4Id200`, `s4`.`Name`, `s4`.`Id1`, `s4`.`Id2`, `s4`.`Name0`, `s4`.`Id10`, `s4`.`Id20`, `s4`.`Id100`, `s4`.`Id200`, `s4`.`Level3_Optional_Id1`, `s4`.`Level3_Optional_Id2`, `s4`.`Level3_Required_Id1`, `s4`.`Level3_Required_Id2`, `s4`.`Name00`, `s4`.`OneToMany_Optional_Inverse4Id1`, `s4`.`OneToMany_Optional_Inverse4Id2`, `s4`.`OneToMany_Optional_Self_Inverse4Id1`, `s4`.`OneToMany_Optional_Self_Inverse4Id2`, `s4`.`OneToMany_Required_Inverse4Id1`, `s4`.`OneToMany_Required_Inverse4Id2`, `s4`.`OneToMany_Required_Self_Inverse4Id1`, `s4`.`OneToMany_Required_Self_Inverse4Id2`, `s4`.`OneToOne_Optional_PK_Inverse4Id1`, `s4`.`OneToOne_Optional_PK_Inverse4Id2`, `s4`.`OneToOne_Optional_Self4Id1`, `s4`.`OneToOne_Optional_Self4Id2`, `s4`.`Id11`, `s4`.`Id21`, `s4`.`Level3_Optional_Id10`, `s4`.`Level3_Optional_Id20`, `s4`.`Level3_Required_Id10`, `s4`.`Level3_Required_Id20`, `s4`.`Name1`, `s4`.`OneToMany_Optional_Inverse4Id10`, `s4`.`OneToMany_Optional_Inverse4Id20`, `s4`.`OneToMany_Optional_Self_Inverse4Id10`, `s4`.`OneToMany_Optional_Self_Inverse4Id20`, `s4`.`OneToMany_Required_Inverse4Id10`, `s4`.`OneToMany_Required_Inverse4Id20`, `s4`.`OneToMany_Required_Self_Inverse4Id10`, `s4`.`OneToMany_Required_Self_Inverse4Id20`, `s4`.`OneToOne_Optional_PK_Inverse4Id10`, `s4`.`OneToOne_Optional_PK_Inverse4Id20`, `s4`.`OneToOne_Optional_Self4Id10`, `s4`.`OneToOne_Optional_Self4Id20`, `s4`.`Name2`, `s4`.`Id12`, `s4`.`Id22`, `s4`.`Id101`, `s4`.`Id201`, `s4`.`Level3_Optional_Id11`, `s4`.`Level3_Optional_Id21`, `s4`.`Level3_Required_Id11`, `s4`.`Level3_Required_Id21`, `s4`.`Name01`, `s4`.`OneToMany_Optional_Inverse4Id11`, `s4`.`OneToMany_Optional_Inverse4Id21`, `s4`.`OneToMany_Optional_Self_Inverse4Id11`, `s4`.`OneToMany_Optional_Self_Inverse4Id21`, `s4`.`OneToMany_Required_Inverse4Id11`, `s4`.`OneToMany_Required_Inverse4Id21`, `s4`.`OneToMany_Required_Self_Inverse4Id11`, `s4`.`OneToMany_Required_Self_Inverse4Id21`, `s4`.`OneToOne_Optional_PK_Inverse4Id11`, `s4`.`OneToOne_Optional_PK_Inverse4Id21`, `s4`.`OneToOne_Optional_Self4Id11`, `s4`.`OneToOne_Optional_Self4Id21`, `s4`.`Id110`, `s4`.`Id210`, `s4`.`Level3_Optional_Id100`, `s4`.`Level3_Optional_Id200`, `s4`.`Level3_Required_Id100`, `s4`.`Level3_Required_Id200`, `s4`.`Name10`, `s4`.`OneToMany_Optional_Inverse4Id100`, `s4`.`OneToMany_Optional_Inverse4Id200`, `s4`.`OneToMany_Optional_Self_Inverse4Id100`, `s4`.`OneToMany_Optional_Self_Inverse4Id200`, `s4`.`OneToMany_Required_Inverse4Id100`, `s4`.`OneToMany_Required_Inverse4Id200`, `s4`.`OneToMany_Required_Self_Inverse4Id100`, `s4`.`OneToMany_Required_Self_Inverse4Id200`, `s4`.`OneToOne_Optional_PK_Inverse4Id100`, `s4`.`OneToOne_Optional_PK_Inverse4Id200`, `s4`.`OneToOne_Optional_Self4Id100`, `s4`.`OneToOne_Optional_Self4Id200` FROM `CompositeOnes` AS `c` LEFT JOIN ( - SELECT `c0`.`Name`, `c0`.`Id1`, `c0`.`Id2`, `t`.`Id1` AS `Id10`, `t`.`Id2` AS `Id20`, `t`.`Id10` AS `Id100`, `t`.`Id20` AS `Id200`, `t`.`Level3_Optional_Id1`, `t`.`Level3_Optional_Id2`, `t`.`Level3_Required_Id1`, `t`.`Level3_Required_Id2`, `t`.`Name` AS `Name0`, `t`.`OneToMany_Optional_Inverse4Id1`, `t`.`OneToMany_Optional_Inverse4Id2`, `t`.`OneToMany_Optional_Self_Inverse4Id1`, `t`.`OneToMany_Optional_Self_Inverse4Id2`, `t`.`OneToMany_Required_Inverse4Id1`, `t`.`OneToMany_Required_Inverse4Id2`, `t`.`OneToMany_Required_Self_Inverse4Id1`, `t`.`OneToMany_Required_Self_Inverse4Id2`, `t`.`OneToOne_Optional_PK_Inverse4Id1`, `t`.`OneToOne_Optional_PK_Inverse4Id2`, `t`.`OneToOne_Optional_Self4Id1`, `t`.`OneToOne_Optional_Self4Id2`, `t`.`Id11`, `t`.`Id21`, `t`.`Level3_Optional_Id10`, `t`.`Level3_Optional_Id20`, `t`.`Level3_Required_Id10`, `t`.`Level3_Required_Id20`, `t`.`Name0` AS `Name00`, `t`.`OneToMany_Optional_Inverse4Id10`, `t`.`OneToMany_Optional_Inverse4Id20`, `t`.`OneToMany_Optional_Self_Inverse4Id10`, `t`.`OneToMany_Optional_Self_Inverse4Id20`, `t`.`OneToMany_Required_Inverse4Id10`, `t`.`OneToMany_Required_Inverse4Id20`, `t`.`OneToMany_Required_Self_Inverse4Id10`, `t`.`OneToMany_Required_Self_Inverse4Id20`, `t`.`OneToOne_Optional_PK_Inverse4Id10`, `t`.`OneToOne_Optional_PK_Inverse4Id20`, `t`.`OneToOne_Optional_Self4Id10`, `t`.`OneToOne_Optional_Self4Id20`, `t0`.`Name` AS `Name1`, `t0`.`Id1` AS `Id12`, `t0`.`Id2` AS `Id22`, `t0`.`Id10` AS `Id101`, `t0`.`Id20` AS `Id201`, `t0`.`Level3_Optional_Id1` AS `Level3_Optional_Id11`, `t0`.`Level3_Optional_Id2` AS `Level3_Optional_Id21`, `t0`.`Level3_Required_Id1` AS `Level3_Required_Id11`, `t0`.`Level3_Required_Id2` AS `Level3_Required_Id21`, `t0`.`Name0` AS `Name01`, `t0`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id11`, `t0`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id21`, `t0`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id11`, `t0`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id21`, `t0`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id11`, `t0`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id21`, `t0`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id11`, `t0`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id21`, `t0`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id11`, `t0`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id21`, `t0`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id11`, `t0`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id21`, `t0`.`Id11` AS `Id110`, `t0`.`Id21` AS `Id210`, `t0`.`Level3_Optional_Id10` AS `Level3_Optional_Id100`, `t0`.`Level3_Optional_Id20` AS `Level3_Optional_Id200`, `t0`.`Level3_Required_Id10` AS `Level3_Required_Id100`, `t0`.`Level3_Required_Id20` AS `Level3_Required_Id200`, `t0`.`Name1` AS `Name10`, `t0`.`OneToMany_Optional_Inverse4Id10` AS `OneToMany_Optional_Inverse4Id100`, `t0`.`OneToMany_Optional_Inverse4Id20` AS `OneToMany_Optional_Inverse4Id200`, `t0`.`OneToMany_Optional_Self_Inverse4Id10` AS `OneToMany_Optional_Self_Inverse4Id100`, `t0`.`OneToMany_Optional_Self_Inverse4Id20` AS `OneToMany_Optional_Self_Inverse4Id200`, `t0`.`OneToMany_Required_Inverse4Id10` AS `OneToMany_Required_Inverse4Id100`, `t0`.`OneToMany_Required_Inverse4Id20` AS `OneToMany_Required_Inverse4Id200`, `t0`.`OneToMany_Required_Self_Inverse4Id10` AS `OneToMany_Required_Self_Inverse4Id100`, `t0`.`OneToMany_Required_Self_Inverse4Id20` AS `OneToMany_Required_Self_Inverse4Id200`, `t0`.`OneToOne_Optional_PK_Inverse4Id10` AS `OneToOne_Optional_PK_Inverse4Id100`, `t0`.`OneToOne_Optional_PK_Inverse4Id20` AS `OneToOne_Optional_PK_Inverse4Id200`, `t0`.`OneToOne_Optional_Self4Id10` AS `OneToOne_Optional_Self4Id100`, `t0`.`OneToOne_Optional_Self4Id20` AS `OneToOne_Optional_Self4Id200`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2` + SELECT `c0`.`Name`, `c0`.`Id1`, `c0`.`Id2`, `s`.`Id1` AS `Id10`, `s`.`Id2` AS `Id20`, `s`.`Id10` AS `Id100`, `s`.`Id20` AS `Id200`, `s`.`Level3_Optional_Id1`, `s`.`Level3_Optional_Id2`, `s`.`Level3_Required_Id1`, `s`.`Level3_Required_Id2`, `s`.`Name` AS `Name0`, `s`.`OneToMany_Optional_Inverse4Id1`, `s`.`OneToMany_Optional_Inverse4Id2`, `s`.`OneToMany_Optional_Self_Inverse4Id1`, `s`.`OneToMany_Optional_Self_Inverse4Id2`, `s`.`OneToMany_Required_Inverse4Id1`, `s`.`OneToMany_Required_Inverse4Id2`, `s`.`OneToMany_Required_Self_Inverse4Id1`, `s`.`OneToMany_Required_Self_Inverse4Id2`, `s`.`OneToOne_Optional_PK_Inverse4Id1`, `s`.`OneToOne_Optional_PK_Inverse4Id2`, `s`.`OneToOne_Optional_Self4Id1`, `s`.`OneToOne_Optional_Self4Id2`, `s`.`Id11`, `s`.`Id21`, `s`.`Level3_Optional_Id10`, `s`.`Level3_Optional_Id20`, `s`.`Level3_Required_Id10`, `s`.`Level3_Required_Id20`, `s`.`Name0` AS `Name00`, `s`.`OneToMany_Optional_Inverse4Id10`, `s`.`OneToMany_Optional_Inverse4Id20`, `s`.`OneToMany_Optional_Self_Inverse4Id10`, `s`.`OneToMany_Optional_Self_Inverse4Id20`, `s`.`OneToMany_Required_Inverse4Id10`, `s`.`OneToMany_Required_Inverse4Id20`, `s`.`OneToMany_Required_Self_Inverse4Id10`, `s`.`OneToMany_Required_Self_Inverse4Id20`, `s`.`OneToOne_Optional_PK_Inverse4Id10`, `s`.`OneToOne_Optional_PK_Inverse4Id20`, `s`.`OneToOne_Optional_Self4Id10`, `s`.`OneToOne_Optional_Self4Id20`, `s0`.`Name` AS `Name1`, `s0`.`Id1` AS `Id12`, `s0`.`Id2` AS `Id22`, `s0`.`Id10` AS `Id101`, `s0`.`Id20` AS `Id201`, `s0`.`Level3_Optional_Id1` AS `Level3_Optional_Id11`, `s0`.`Level3_Optional_Id2` AS `Level3_Optional_Id21`, `s0`.`Level3_Required_Id1` AS `Level3_Required_Id11`, `s0`.`Level3_Required_Id2` AS `Level3_Required_Id21`, `s0`.`Name0` AS `Name01`, `s0`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id11`, `s0`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id21`, `s0`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id11`, `s0`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id21`, `s0`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id11`, `s0`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id21`, `s0`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id11`, `s0`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id21`, `s0`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id11`, `s0`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id21`, `s0`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id11`, `s0`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id21`, `s0`.`Id11` AS `Id110`, `s0`.`Id21` AS `Id210`, `s0`.`Level3_Optional_Id10` AS `Level3_Optional_Id100`, `s0`.`Level3_Optional_Id20` AS `Level3_Optional_Id200`, `s0`.`Level3_Required_Id10` AS `Level3_Required_Id100`, `s0`.`Level3_Required_Id20` AS `Level3_Required_Id200`, `s0`.`Name1` AS `Name10`, `s0`.`OneToMany_Optional_Inverse4Id10` AS `OneToMany_Optional_Inverse4Id100`, `s0`.`OneToMany_Optional_Inverse4Id20` AS `OneToMany_Optional_Inverse4Id200`, `s0`.`OneToMany_Optional_Self_Inverse4Id10` AS `OneToMany_Optional_Self_Inverse4Id100`, `s0`.`OneToMany_Optional_Self_Inverse4Id20` AS `OneToMany_Optional_Self_Inverse4Id200`, `s0`.`OneToMany_Required_Inverse4Id10` AS `OneToMany_Required_Inverse4Id100`, `s0`.`OneToMany_Required_Inverse4Id20` AS `OneToMany_Required_Inverse4Id200`, `s0`.`OneToMany_Required_Self_Inverse4Id10` AS `OneToMany_Required_Self_Inverse4Id100`, `s0`.`OneToMany_Required_Self_Inverse4Id20` AS `OneToMany_Required_Self_Inverse4Id200`, `s0`.`OneToOne_Optional_PK_Inverse4Id10` AS `OneToOne_Optional_PK_Inverse4Id100`, `s0`.`OneToOne_Optional_PK_Inverse4Id20` AS `OneToOne_Optional_PK_Inverse4Id200`, `s0`.`OneToOne_Optional_Self4Id10` AS `OneToOne_Optional_Self4Id100`, `s0`.`OneToOne_Optional_Self4Id20` AS `OneToOne_Optional_Self4Id200`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2` FROM `CompositeTwos` AS `c0` LEFT JOIN ( SELECT `c1`.`Id1`, `c1`.`Id2`, `c2`.`Id1` AS `Id10`, `c2`.`Id2` AS `Id20`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c3`.`Id1` AS `Id11`, `c3`.`Id2` AS `Id21`, `c3`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c3`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c3`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c3`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c3`.`Name` AS `Name0`, `c3`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c3`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c3`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c3`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c3`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c3`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c3`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c3`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c3`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c3`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c3`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c3`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, `c1`.`OneToMany_Required_Inverse3Id1`, `c1`.`OneToMany_Required_Inverse3Id2` FROM `CompositeThrees` AS `c1` LEFT JOIN `CompositeFours` AS `c2` ON (`c1`.`Id1` = `c2`.`OneToMany_Optional_Inverse4Id1`) AND (`c1`.`Id2` = `c2`.`OneToMany_Optional_Inverse4Id2`) LEFT JOIN `CompositeFours` AS `c3` ON (`c1`.`Id1` = `c3`.`OneToMany_Required_Inverse4Id1`) AND (`c1`.`Id2` = `c3`.`OneToMany_Required_Inverse4Id2`) - ) AS `t` ON (`c0`.`Id1` = `t`.`OneToMany_Required_Inverse3Id1`) AND (`c0`.`Id2` = `t`.`OneToMany_Required_Inverse3Id2`) + ) AS `s` ON (`c0`.`Id1` = `s`.`OneToMany_Required_Inverse3Id1`) AND (`c0`.`Id2` = `s`.`OneToMany_Required_Inverse3Id2`) LEFT JOIN ( SELECT `c4`.`Name`, `c4`.`Id1`, `c4`.`Id2`, `c5`.`Id1` AS `Id10`, `c5`.`Id2` AS `Id20`, `c5`.`Level3_Optional_Id1`, `c5`.`Level3_Optional_Id2`, `c5`.`Level3_Required_Id1`, `c5`.`Level3_Required_Id2`, `c5`.`Name` AS `Name0`, `c5`.`OneToMany_Optional_Inverse4Id1`, `c5`.`OneToMany_Optional_Inverse4Id2`, `c5`.`OneToMany_Optional_Self_Inverse4Id1`, `c5`.`OneToMany_Optional_Self_Inverse4Id2`, `c5`.`OneToMany_Required_Inverse4Id1`, `c5`.`OneToMany_Required_Inverse4Id2`, `c5`.`OneToMany_Required_Self_Inverse4Id1`, `c5`.`OneToMany_Required_Self_Inverse4Id2`, `c5`.`OneToOne_Optional_PK_Inverse4Id1`, `c5`.`OneToOne_Optional_PK_Inverse4Id2`, `c5`.`OneToOne_Optional_Self4Id1`, `c5`.`OneToOne_Optional_Self4Id2`, `c6`.`Id1` AS `Id11`, `c6`.`Id2` AS `Id21`, `c6`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c6`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c6`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c6`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c6`.`Name` AS `Name1`, `c6`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c6`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c6`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c6`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c6`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c6`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c6`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c6`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c6`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c6`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c6`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c6`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, `c4`.`OneToMany_Optional_Inverse3Id1`, `c4`.`OneToMany_Optional_Inverse3Id2` FROM `CompositeThrees` AS `c4` LEFT JOIN `CompositeFours` AS `c5` ON (`c4`.`Id1` = `c5`.`OneToMany_Required_Inverse4Id1`) AND (`c4`.`Id2` = `c5`.`OneToMany_Required_Inverse4Id2`) LEFT JOIN `CompositeFours` AS `c6` ON (`c4`.`Id1` = `c6`.`OneToMany_Optional_Inverse4Id1`) AND (`c4`.`Id2` = `c6`.`OneToMany_Optional_Inverse4Id2`) - ) AS `t0` ON (`c0`.`Id1` = `t0`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `t0`.`OneToMany_Optional_Inverse3Id2`) -) AS `t1` ON (`c`.`Id1` = `t1`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `t1`.`OneToMany_Optional_Inverse2Id2`) + ) AS `s0` ON (`c0`.`Id1` = `s0`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `s0`.`OneToMany_Optional_Inverse3Id2`) +) AS `s1` ON (`c`.`Id1` = `s1`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `s1`.`OneToMany_Optional_Inverse2Id2`) LEFT JOIN ( - SELECT `c7`.`Name`, `c7`.`Id1`, `c7`.`Id2`, `t3`.`Name` AS `Name0`, `t3`.`Id1` AS `Id10`, `t3`.`Id2` AS `Id20`, `t3`.`Id10` AS `Id100`, `t3`.`Id20` AS `Id200`, `t3`.`Level3_Optional_Id1`, `t3`.`Level3_Optional_Id2`, `t3`.`Level3_Required_Id1`, `t3`.`Level3_Required_Id2`, `t3`.`Name0` AS `Name00`, `t3`.`OneToMany_Optional_Inverse4Id1`, `t3`.`OneToMany_Optional_Inverse4Id2`, `t3`.`OneToMany_Optional_Self_Inverse4Id1`, `t3`.`OneToMany_Optional_Self_Inverse4Id2`, `t3`.`OneToMany_Required_Inverse4Id1`, `t3`.`OneToMany_Required_Inverse4Id2`, `t3`.`OneToMany_Required_Self_Inverse4Id1`, `t3`.`OneToMany_Required_Self_Inverse4Id2`, `t3`.`OneToOne_Optional_PK_Inverse4Id1`, `t3`.`OneToOne_Optional_PK_Inverse4Id2`, `t3`.`OneToOne_Optional_Self4Id1`, `t3`.`OneToOne_Optional_Self4Id2`, `t3`.`Id11`, `t3`.`Id21`, `t3`.`Level3_Optional_Id10`, `t3`.`Level3_Optional_Id20`, `t3`.`Level3_Required_Id10`, `t3`.`Level3_Required_Id20`, `t3`.`Name1`, `t3`.`OneToMany_Optional_Inverse4Id10`, `t3`.`OneToMany_Optional_Inverse4Id20`, `t3`.`OneToMany_Optional_Self_Inverse4Id10`, `t3`.`OneToMany_Optional_Self_Inverse4Id20`, `t3`.`OneToMany_Required_Inverse4Id10`, `t3`.`OneToMany_Required_Inverse4Id20`, `t3`.`OneToMany_Required_Self_Inverse4Id10`, `t3`.`OneToMany_Required_Self_Inverse4Id20`, `t3`.`OneToOne_Optional_PK_Inverse4Id10`, `t3`.`OneToOne_Optional_PK_Inverse4Id20`, `t3`.`OneToOne_Optional_Self4Id10`, `t3`.`OneToOne_Optional_Self4Id20`, `t4`.`Name` AS `Name2`, `t4`.`Id1` AS `Id12`, `t4`.`Id2` AS `Id22`, `t4`.`Id10` AS `Id101`, `t4`.`Id20` AS `Id201`, `t4`.`Level3_Optional_Id1` AS `Level3_Optional_Id11`, `t4`.`Level3_Optional_Id2` AS `Level3_Optional_Id21`, `t4`.`Level3_Required_Id1` AS `Level3_Required_Id11`, `t4`.`Level3_Required_Id2` AS `Level3_Required_Id21`, `t4`.`Name0` AS `Name01`, `t4`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id11`, `t4`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id21`, `t4`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id11`, `t4`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id21`, `t4`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id11`, `t4`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id21`, `t4`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id11`, `t4`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id21`, `t4`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id11`, `t4`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id21`, `t4`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id11`, `t4`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id21`, `t4`.`Id11` AS `Id110`, `t4`.`Id21` AS `Id210`, `t4`.`Level3_Optional_Id10` AS `Level3_Optional_Id100`, `t4`.`Level3_Optional_Id20` AS `Level3_Optional_Id200`, `t4`.`Level3_Required_Id10` AS `Level3_Required_Id100`, `t4`.`Level3_Required_Id20` AS `Level3_Required_Id200`, `t4`.`Name1` AS `Name10`, `t4`.`OneToMany_Optional_Inverse4Id10` AS `OneToMany_Optional_Inverse4Id100`, `t4`.`OneToMany_Optional_Inverse4Id20` AS `OneToMany_Optional_Inverse4Id200`, `t4`.`OneToMany_Optional_Self_Inverse4Id10` AS `OneToMany_Optional_Self_Inverse4Id100`, `t4`.`OneToMany_Optional_Self_Inverse4Id20` AS `OneToMany_Optional_Self_Inverse4Id200`, `t4`.`OneToMany_Required_Inverse4Id10` AS `OneToMany_Required_Inverse4Id100`, `t4`.`OneToMany_Required_Inverse4Id20` AS `OneToMany_Required_Inverse4Id200`, `t4`.`OneToMany_Required_Self_Inverse4Id10` AS `OneToMany_Required_Self_Inverse4Id100`, `t4`.`OneToMany_Required_Self_Inverse4Id20` AS `OneToMany_Required_Self_Inverse4Id200`, `t4`.`OneToOne_Optional_PK_Inverse4Id10` AS `OneToOne_Optional_PK_Inverse4Id100`, `t4`.`OneToOne_Optional_PK_Inverse4Id20` AS `OneToOne_Optional_PK_Inverse4Id200`, `t4`.`OneToOne_Optional_Self4Id10` AS `OneToOne_Optional_Self4Id100`, `t4`.`OneToOne_Optional_Self4Id20` AS `OneToOne_Optional_Self4Id200`, CHAR_LENGTH(`c7`.`Name`) AS `c`, `t4`.`c` AS `c0`, `c7`.`OneToMany_Required_Inverse2Id1`, `c7`.`OneToMany_Required_Inverse2Id2` + SELECT `c7`.`Name`, `c7`.`Id1`, `c7`.`Id2`, `s2`.`Name` AS `Name0`, `s2`.`Id1` AS `Id10`, `s2`.`Id2` AS `Id20`, `s2`.`Id10` AS `Id100`, `s2`.`Id20` AS `Id200`, `s2`.`Level3_Optional_Id1`, `s2`.`Level3_Optional_Id2`, `s2`.`Level3_Required_Id1`, `s2`.`Level3_Required_Id2`, `s2`.`Name0` AS `Name00`, `s2`.`OneToMany_Optional_Inverse4Id1`, `s2`.`OneToMany_Optional_Inverse4Id2`, `s2`.`OneToMany_Optional_Self_Inverse4Id1`, `s2`.`OneToMany_Optional_Self_Inverse4Id2`, `s2`.`OneToMany_Required_Inverse4Id1`, `s2`.`OneToMany_Required_Inverse4Id2`, `s2`.`OneToMany_Required_Self_Inverse4Id1`, `s2`.`OneToMany_Required_Self_Inverse4Id2`, `s2`.`OneToOne_Optional_PK_Inverse4Id1`, `s2`.`OneToOne_Optional_PK_Inverse4Id2`, `s2`.`OneToOne_Optional_Self4Id1`, `s2`.`OneToOne_Optional_Self4Id2`, `s2`.`Id11`, `s2`.`Id21`, `s2`.`Level3_Optional_Id10`, `s2`.`Level3_Optional_Id20`, `s2`.`Level3_Required_Id10`, `s2`.`Level3_Required_Id20`, `s2`.`Name1`, `s2`.`OneToMany_Optional_Inverse4Id10`, `s2`.`OneToMany_Optional_Inverse4Id20`, `s2`.`OneToMany_Optional_Self_Inverse4Id10`, `s2`.`OneToMany_Optional_Self_Inverse4Id20`, `s2`.`OneToMany_Required_Inverse4Id10`, `s2`.`OneToMany_Required_Inverse4Id20`, `s2`.`OneToMany_Required_Self_Inverse4Id10`, `s2`.`OneToMany_Required_Self_Inverse4Id20`, `s2`.`OneToOne_Optional_PK_Inverse4Id10`, `s2`.`OneToOne_Optional_PK_Inverse4Id20`, `s2`.`OneToOne_Optional_Self4Id10`, `s2`.`OneToOne_Optional_Self4Id20`, `s3`.`Name` AS `Name2`, `s3`.`Id1` AS `Id12`, `s3`.`Id2` AS `Id22`, `s3`.`Id10` AS `Id101`, `s3`.`Id20` AS `Id201`, `s3`.`Level3_Optional_Id1` AS `Level3_Optional_Id11`, `s3`.`Level3_Optional_Id2` AS `Level3_Optional_Id21`, `s3`.`Level3_Required_Id1` AS `Level3_Required_Id11`, `s3`.`Level3_Required_Id2` AS `Level3_Required_Id21`, `s3`.`Name0` AS `Name01`, `s3`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id11`, `s3`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id21`, `s3`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id11`, `s3`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id21`, `s3`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id11`, `s3`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id21`, `s3`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id11`, `s3`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id21`, `s3`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id11`, `s3`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id21`, `s3`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id11`, `s3`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id21`, `s3`.`Id11` AS `Id110`, `s3`.`Id21` AS `Id210`, `s3`.`Level3_Optional_Id10` AS `Level3_Optional_Id100`, `s3`.`Level3_Optional_Id20` AS `Level3_Optional_Id200`, `s3`.`Level3_Required_Id10` AS `Level3_Required_Id100`, `s3`.`Level3_Required_Id20` AS `Level3_Required_Id200`, `s3`.`Name1` AS `Name10`, `s3`.`OneToMany_Optional_Inverse4Id10` AS `OneToMany_Optional_Inverse4Id100`, `s3`.`OneToMany_Optional_Inverse4Id20` AS `OneToMany_Optional_Inverse4Id200`, `s3`.`OneToMany_Optional_Self_Inverse4Id10` AS `OneToMany_Optional_Self_Inverse4Id100`, `s3`.`OneToMany_Optional_Self_Inverse4Id20` AS `OneToMany_Optional_Self_Inverse4Id200`, `s3`.`OneToMany_Required_Inverse4Id10` AS `OneToMany_Required_Inverse4Id100`, `s3`.`OneToMany_Required_Inverse4Id20` AS `OneToMany_Required_Inverse4Id200`, `s3`.`OneToMany_Required_Self_Inverse4Id10` AS `OneToMany_Required_Self_Inverse4Id100`, `s3`.`OneToMany_Required_Self_Inverse4Id20` AS `OneToMany_Required_Self_Inverse4Id200`, `s3`.`OneToOne_Optional_PK_Inverse4Id10` AS `OneToOne_Optional_PK_Inverse4Id100`, `s3`.`OneToOne_Optional_PK_Inverse4Id20` AS `OneToOne_Optional_PK_Inverse4Id200`, `s3`.`OneToOne_Optional_Self4Id10` AS `OneToOne_Optional_Self4Id100`, `s3`.`OneToOne_Optional_Self4Id20` AS `OneToOne_Optional_Self4Id200`, CHAR_LENGTH(`c7`.`Name`) AS `c`, `s3`.`c` AS `c0`, `c7`.`OneToMany_Required_Inverse2Id1`, `c7`.`OneToMany_Required_Inverse2Id2` FROM `CompositeTwos` AS `c7` LEFT JOIN ( SELECT `c8`.`Name`, `c8`.`Id1`, `c8`.`Id2`, `c9`.`Id1` AS `Id10`, `c9`.`Id2` AS `Id20`, `c9`.`Level3_Optional_Id1`, `c9`.`Level3_Optional_Id2`, `c9`.`Level3_Required_Id1`, `c9`.`Level3_Required_Id2`, `c9`.`Name` AS `Name0`, `c9`.`OneToMany_Optional_Inverse4Id1`, `c9`.`OneToMany_Optional_Inverse4Id2`, `c9`.`OneToMany_Optional_Self_Inverse4Id1`, `c9`.`OneToMany_Optional_Self_Inverse4Id2`, `c9`.`OneToMany_Required_Inverse4Id1`, `c9`.`OneToMany_Required_Inverse4Id2`, `c9`.`OneToMany_Required_Self_Inverse4Id1`, `c9`.`OneToMany_Required_Self_Inverse4Id2`, `c9`.`OneToOne_Optional_PK_Inverse4Id1`, `c9`.`OneToOne_Optional_PK_Inverse4Id2`, `c9`.`OneToOne_Optional_Self4Id1`, `c9`.`OneToOne_Optional_Self4Id2`, `c10`.`Id1` AS `Id11`, `c10`.`Id2` AS `Id21`, `c10`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c10`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c10`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c10`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c10`.`Name` AS `Name1`, `c10`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c10`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c10`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c10`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c10`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c10`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c10`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c10`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c10`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c10`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c10`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c10`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, `c8`.`OneToMany_Optional_Inverse3Id1`, `c8`.`OneToMany_Optional_Inverse3Id2` FROM `CompositeThrees` AS `c8` LEFT JOIN `CompositeFours` AS `c9` ON (`c8`.`Id1` = `c9`.`OneToMany_Required_Inverse4Id1`) AND (`c8`.`Id2` = `c9`.`OneToMany_Required_Inverse4Id2`) LEFT JOIN `CompositeFours` AS `c10` ON (`c8`.`Id1` = `c10`.`OneToMany_Optional_Inverse4Id1`) AND (`c8`.`Id2` = `c10`.`OneToMany_Optional_Inverse4Id2`) - ) AS `t3` ON (`c7`.`Id1` = `t3`.`OneToMany_Optional_Inverse3Id1`) AND (`c7`.`Id2` = `t3`.`OneToMany_Optional_Inverse3Id2`) + ) AS `s2` ON (`c7`.`Id1` = `s2`.`OneToMany_Optional_Inverse3Id1`) AND (`c7`.`Id2` = `s2`.`OneToMany_Optional_Inverse3Id2`) LEFT JOIN ( SELECT `c11`.`Name`, `c11`.`Id1`, `c11`.`Id2`, `c12`.`Id1` AS `Id10`, `c12`.`Id2` AS `Id20`, `c12`.`Level3_Optional_Id1`, `c12`.`Level3_Optional_Id2`, `c12`.`Level3_Required_Id1`, `c12`.`Level3_Required_Id2`, `c12`.`Name` AS `Name0`, `c12`.`OneToMany_Optional_Inverse4Id1`, `c12`.`OneToMany_Optional_Inverse4Id2`, `c12`.`OneToMany_Optional_Self_Inverse4Id1`, `c12`.`OneToMany_Optional_Self_Inverse4Id2`, `c12`.`OneToMany_Required_Inverse4Id1`, `c12`.`OneToMany_Required_Inverse4Id2`, `c12`.`OneToMany_Required_Self_Inverse4Id1`, `c12`.`OneToMany_Required_Self_Inverse4Id2`, `c12`.`OneToOne_Optional_PK_Inverse4Id1`, `c12`.`OneToOne_Optional_PK_Inverse4Id2`, `c12`.`OneToOne_Optional_Self4Id1`, `c12`.`OneToOne_Optional_Self4Id2`, `c13`.`Id1` AS `Id11`, `c13`.`Id2` AS `Id21`, `c13`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c13`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c13`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c13`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c13`.`Name` AS `Name1`, `c13`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c13`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c13`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c13`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c13`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c13`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c13`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c13`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c13`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c13`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c13`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c13`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, CONCAT(`c13`.`Id1`, CAST(`c13`.`Id2` AS char)) AS `c`, `c11`.`OneToMany_Optional_Inverse3Id1`, `c11`.`OneToMany_Optional_Inverse3Id2` FROM `CompositeThrees` AS `c11` LEFT JOIN `CompositeFours` AS `c12` ON (`c11`.`Id1` = `c12`.`OneToMany_Optional_Inverse4Id1`) AND (`c11`.`Id2` = `c12`.`OneToMany_Optional_Inverse4Id2`) LEFT JOIN `CompositeFours` AS `c13` ON (`c11`.`Id1` = `c13`.`OneToMany_Required_Inverse4Id1`) AND (`c11`.`Id2` = `c13`.`OneToMany_Required_Inverse4Id2`) - ) AS `t4` ON (`c7`.`Id1` = `t4`.`OneToMany_Optional_Inverse3Id1`) AND (`c7`.`Id2` = `t4`.`OneToMany_Optional_Inverse3Id2`) -) AS `t2` ON (`c`.`Id1` = `t2`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `t2`.`OneToMany_Required_Inverse2Id2`) -ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `t1`.`Id1`, `t1`.`Id2`, `t1`.`Id20` DESC, `t1`.`Id10` DESC, `t1`.`Id100`, `t1`.`Id200`, `t1`.`Id11`, `t1`.`Id21`, `t1`.`Id12`, `t1`.`Id22`, `t1`.`Id101`, `t1`.`Id201`, `t1`.`Id110`, `t1`.`Id210`, `t2`.`c`, `t2`.`Id1`, `t2`.`Id2`, `t2`.`Id10`, `t2`.`Id20`, `t2`.`Id100`, `t2`.`Id200`, `t2`.`Id11`, `t2`.`Id21`, `t2`.`Id12`, `t2`.`Id22`, `t2`.`Id101`, `t2`.`Id201`, `t2`.`c0` DESC, `t2`.`Id110`"); + ) AS `s3` ON (`c7`.`Id1` = `s3`.`OneToMany_Optional_Inverse3Id1`) AND (`c7`.`Id2` = `s3`.`OneToMany_Optional_Inverse3Id2`) +) AS `s4` ON (`c`.`Id1` = `s4`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `s4`.`OneToMany_Required_Inverse2Id2`) +ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `s1`.`Id1`, `s1`.`Id2`, `s1`.`Id20` DESC, `s1`.`Id10` DESC, `s1`.`Id100`, `s1`.`Id200`, `s1`.`Id11`, `s1`.`Id21`, `s1`.`Id12`, `s1`.`Id22`, `s1`.`Id101`, `s1`.`Id201`, `s1`.`Id110`, `s1`.`Id210`, `s4`.`c`, `s4`.`Id1`, `s4`.`Id2`, `s4`.`Id10`, `s4`.`Id20`, `s4`.`Id100`, `s4`.`Id200`, `s4`.`Id11`, `s4`.`Id21`, `s4`.`Id12`, `s4`.`Id22`, `s4`.`Id101`, `s4`.`Id201`, `s4`.`c0` DESC, `s4`.`Id110` +"""); } private void AssertSql(params string[] expected) diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/CompositeKeysSplitQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/CompositeKeysSplitQuerySingleStoreTest.cs index d9bc3a594..f0fe2ac8e 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/CompositeKeysSplitQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/CompositeKeysSplitQuerySingleStoreTest.cs @@ -15,28 +15,31 @@ public CompositeKeysSplitQuerySingleStoreTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - public override async Task Projecting_collections_multi_level(bool async) { await base.Projecting_collections_multi_level(async); AssertSql( - @"SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2` +""" +SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2` FROM `CompositeOnes` AS `c` -ORDER BY `c`.`Id2`, `c`.`Id1`", +ORDER BY `c`.`Id2`, `c`.`Id1` +""", // - @"SELECT `c0`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2` + """ +SELECT `c8`.`Name`, `c`.`Id1`, `c`.`Id2`, `c8`.`Id1`, `c8`.`Id2` FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -ORDER BY `c`.`Id2`, `c`.`Id1`, `c0`.`Id2`, `c0`.`Id1`", +INNER JOIN `CompositeTwos` AS `c8` ON (`c`.`Id1` = `c8`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c8`.`OneToMany_Optional_Inverse2Id2`) +ORDER BY `c`.`Id2`, `c`.`Id1`, `c8`.`Id2`, `c8`.`Id1` +""", // - @"SELECT `c1`.`Id1`, `c1`.`Id2`, `c1`.`Level2_Optional_Id1`, `c1`.`Level2_Optional_Id2`, `c1`.`Level2_Required_Id1`, `c1`.`Level2_Required_Id2`, `c1`.`Name`, `c1`.`OneToMany_Optional_Inverse3Id1`, `c1`.`OneToMany_Optional_Inverse3Id2`, `c1`.`OneToMany_Optional_Self_Inverse3Id1`, `c1`.`OneToMany_Optional_Self_Inverse3Id2`, `c1`.`OneToMany_Required_Inverse3Id1`, `c1`.`OneToMany_Required_Inverse3Id2`, `c1`.`OneToMany_Required_Self_Inverse3Id1`, `c1`.`OneToMany_Required_Self_Inverse3Id2`, `c1`.`OneToOne_Optional_PK_Inverse3Id1`, `c1`.`OneToOne_Optional_PK_Inverse3Id2`, `c1`.`OneToOne_Optional_Self3Id1`, `c1`.`OneToOne_Optional_Self3Id2`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2` + """ +SELECT `c11`.`Id1`, `c11`.`Id2`, `c11`.`Level2_Optional_Id1`, `c11`.`Level2_Optional_Id2`, `c11`.`Level2_Required_Id1`, `c11`.`Level2_Required_Id2`, `c11`.`Name`, `c11`.`OneToMany_Optional_Inverse3Id1`, `c11`.`OneToMany_Optional_Inverse3Id2`, `c11`.`OneToMany_Optional_Self_Inverse3Id1`, `c11`.`OneToMany_Optional_Self_Inverse3Id2`, `c11`.`OneToMany_Required_Inverse3Id1`, `c11`.`OneToMany_Required_Inverse3Id2`, `c11`.`OneToMany_Required_Self_Inverse3Id1`, `c11`.`OneToMany_Required_Self_Inverse3Id2`, `c11`.`OneToOne_Optional_PK_Inverse3Id1`, `c11`.`OneToOne_Optional_PK_Inverse3Id2`, `c11`.`OneToOne_Optional_Self3Id1`, `c11`.`OneToOne_Optional_Self3Id2`, `c`.`Id1`, `c`.`Id2`, `c8`.`Id1`, `c8`.`Id2` FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Required_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Required_Inverse3Id2`) -ORDER BY `c`.`Id2`, `c`.`Id1`, `c0`.`Id2`, `c0`.`Id1`, `c1`.`Id2` DESC"); +INNER JOIN `CompositeTwos` AS `c8` ON (`c`.`Id1` = `c8`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c8`.`OneToMany_Optional_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c11` ON (`c8`.`Id1` = `c11`.`OneToMany_Required_Inverse3Id1`) AND (`c8`.`Id2` = `c11`.`OneToMany_Required_Inverse3Id2`) +ORDER BY `c`.`Id2`, `c`.`Id1`, `c8`.`Id2`, `c8`.`Id1`, `c11`.`Id2` DESC +"""); } public override async Task Projecting_multiple_collections_on_multiple_levels_no_explicit_ordering(bool async) @@ -44,171 +47,223 @@ public override async Task Projecting_multiple_collections_on_multiple_levels_no await base.Projecting_multiple_collections_on_multiple_levels_no_explicit_ordering(async); AssertSql( - @"SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2` -FROM `CompositeOnes` AS `c` -ORDER BY `c`.`Id1`, `c`.`Id2`", - // - @"SELECT `c0`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -ORDER BY `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`", - // - @"SELECT `c1`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Required_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Required_Inverse3Id2`) -ORDER BY `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c1`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -ORDER BY `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -INNER JOIN `CompositeFours` AS `c2` ON (`c1`.`Id1` = `c2`.`OneToMany_Required_Inverse4Id1`) AND (`c1`.`Id2` = `c2`.`OneToMany_Required_Inverse4Id2`) -ORDER BY `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -INNER JOIN `CompositeFours` AS `c2` ON (`c1`.`Id1` = `c2`.`OneToMany_Optional_Inverse4Id1`) AND (`c1`.`Id2` = `c2`.`OneToMany_Optional_Inverse4Id2`) -ORDER BY `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c0`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -ORDER BY `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`", - // - @"SELECT `c1`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -ORDER BY `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -INNER JOIN `CompositeFours` AS `c2` ON (`c1`.`Id1` = `c2`.`OneToMany_Required_Inverse4Id1`) AND (`c1`.`Id2` = `c2`.`OneToMany_Required_Inverse4Id2`) -ORDER BY `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -INNER JOIN `CompositeFours` AS `c2` ON (`c1`.`Id1` = `c2`.`OneToMany_Optional_Inverse4Id1`) AND (`c1`.`Id2` = `c2`.`OneToMany_Optional_Inverse4Id2`) -ORDER BY `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c1`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -ORDER BY `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -INNER JOIN `CompositeFours` AS `c2` ON (`c1`.`Id1` = `c2`.`OneToMany_Optional_Inverse4Id1`) AND (`c1`.`Id2` = `c2`.`OneToMany_Optional_Inverse4Id2`) -ORDER BY `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` +""" +SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2` FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -INNER JOIN `CompositeFours` AS `c2` ON (`c1`.`Id1` = `c2`.`OneToMany_Required_Inverse4Id1`) AND (`c1`.`Id2` = `c2`.`OneToMany_Required_Inverse4Id2`) -ORDER BY `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`"); +ORDER BY `c`.`Id1`, `c`.`Id2` +""", + // + """ +SELECT `c62`.`Name`, `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c62` ON (`c`.`Id1` = `c62`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c62`.`OneToMany_Optional_Inverse2Id2`) +ORDER BY `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2` +""", + // + """ +SELECT `c75`.`Name`, `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c75`.`Id1`, `c75`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c62` ON (`c`.`Id1` = `c62`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c62`.`OneToMany_Optional_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c75` ON (`c62`.`Id1` = `c75`.`OneToMany_Required_Inverse3Id1`) AND (`c62`.`Id2` = `c75`.`OneToMany_Required_Inverse3Id2`) +ORDER BY `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c75`.`Id1`, `c75`.`Id2` +""", + // + """ +SELECT `c87`.`Name`, `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c87`.`Id1`, `c87`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c62` ON (`c`.`Id1` = `c62`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c62`.`OneToMany_Optional_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c87` ON (`c62`.`Id1` = `c87`.`OneToMany_Optional_Inverse3Id1`) AND (`c62`.`Id2` = `c87`.`OneToMany_Optional_Inverse3Id2`) +ORDER BY `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c87`.`Id1`, `c87`.`Id2` +""", + // + """ +SELECT `c90`.`Id1`, `c90`.`Id2`, `c90`.`Level3_Optional_Id1`, `c90`.`Level3_Optional_Id2`, `c90`.`Level3_Required_Id1`, `c90`.`Level3_Required_Id2`, `c90`.`Name`, `c90`.`OneToMany_Optional_Inverse4Id1`, `c90`.`OneToMany_Optional_Inverse4Id2`, `c90`.`OneToMany_Optional_Self_Inverse4Id1`, `c90`.`OneToMany_Optional_Self_Inverse4Id2`, `c90`.`OneToMany_Required_Inverse4Id1`, `c90`.`OneToMany_Required_Inverse4Id2`, `c90`.`OneToMany_Required_Self_Inverse4Id1`, `c90`.`OneToMany_Required_Self_Inverse4Id2`, `c90`.`OneToOne_Optional_PK_Inverse4Id1`, `c90`.`OneToOne_Optional_PK_Inverse4Id2`, `c90`.`OneToOne_Optional_Self4Id1`, `c90`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c87`.`Id1`, `c87`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c62` ON (`c`.`Id1` = `c62`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c62`.`OneToMany_Optional_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c87` ON (`c62`.`Id1` = `c87`.`OneToMany_Optional_Inverse3Id1`) AND (`c62`.`Id2` = `c87`.`OneToMany_Optional_Inverse3Id2`) +INNER JOIN `CompositeFours` AS `c90` ON (`c87`.`Id1` = `c90`.`OneToMany_Required_Inverse4Id1`) AND (`c87`.`Id2` = `c90`.`OneToMany_Required_Inverse4Id2`) +ORDER BY `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c87`.`Id1`, `c87`.`Id2` +""", + // + """ +SELECT `c92`.`Id1`, `c92`.`Id2`, `c92`.`Level3_Optional_Id1`, `c92`.`Level3_Optional_Id2`, `c92`.`Level3_Required_Id1`, `c92`.`Level3_Required_Id2`, `c92`.`Name`, `c92`.`OneToMany_Optional_Inverse4Id1`, `c92`.`OneToMany_Optional_Inverse4Id2`, `c92`.`OneToMany_Optional_Self_Inverse4Id1`, `c92`.`OneToMany_Optional_Self_Inverse4Id2`, `c92`.`OneToMany_Required_Inverse4Id1`, `c92`.`OneToMany_Required_Inverse4Id2`, `c92`.`OneToMany_Required_Self_Inverse4Id1`, `c92`.`OneToMany_Required_Self_Inverse4Id2`, `c92`.`OneToOne_Optional_PK_Inverse4Id1`, `c92`.`OneToOne_Optional_PK_Inverse4Id2`, `c92`.`OneToOne_Optional_Self4Id1`, `c92`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c87`.`Id1`, `c87`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c62` ON (`c`.`Id1` = `c62`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c62`.`OneToMany_Optional_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c87` ON (`c62`.`Id1` = `c87`.`OneToMany_Optional_Inverse3Id1`) AND (`c62`.`Id2` = `c87`.`OneToMany_Optional_Inverse3Id2`) +INNER JOIN `CompositeFours` AS `c92` ON (`c87`.`Id1` = `c92`.`OneToMany_Optional_Inverse4Id1`) AND (`c87`.`Id2` = `c92`.`OneToMany_Optional_Inverse4Id2`) +ORDER BY `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c87`.`Id1`, `c87`.`Id2` +""", + // + """ +SELECT `c124`.`Name`, `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c124` ON (`c`.`Id1` = `c124`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c124`.`OneToMany_Required_Inverse2Id2`) +ORDER BY `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2` +""", + // + """ +SELECT `c137`.`Name`, `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c137`.`Id1`, `c137`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c124` ON (`c`.`Id1` = `c124`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c124`.`OneToMany_Required_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c137` ON (`c124`.`Id1` = `c137`.`OneToMany_Optional_Inverse3Id1`) AND (`c124`.`Id2` = `c137`.`OneToMany_Optional_Inverse3Id2`) +ORDER BY `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c137`.`Id1`, `c137`.`Id2` +""", + // + """ +SELECT `c140`.`Id1`, `c140`.`Id2`, `c140`.`Level3_Optional_Id1`, `c140`.`Level3_Optional_Id2`, `c140`.`Level3_Required_Id1`, `c140`.`Level3_Required_Id2`, `c140`.`Name`, `c140`.`OneToMany_Optional_Inverse4Id1`, `c140`.`OneToMany_Optional_Inverse4Id2`, `c140`.`OneToMany_Optional_Self_Inverse4Id1`, `c140`.`OneToMany_Optional_Self_Inverse4Id2`, `c140`.`OneToMany_Required_Inverse4Id1`, `c140`.`OneToMany_Required_Inverse4Id2`, `c140`.`OneToMany_Required_Self_Inverse4Id1`, `c140`.`OneToMany_Required_Self_Inverse4Id2`, `c140`.`OneToOne_Optional_PK_Inverse4Id1`, `c140`.`OneToOne_Optional_PK_Inverse4Id2`, `c140`.`OneToOne_Optional_Self4Id1`, `c140`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c137`.`Id1`, `c137`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c124` ON (`c`.`Id1` = `c124`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c124`.`OneToMany_Required_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c137` ON (`c124`.`Id1` = `c137`.`OneToMany_Optional_Inverse3Id1`) AND (`c124`.`Id2` = `c137`.`OneToMany_Optional_Inverse3Id2`) +INNER JOIN `CompositeFours` AS `c140` ON (`c137`.`Id1` = `c140`.`OneToMany_Required_Inverse4Id1`) AND (`c137`.`Id2` = `c140`.`OneToMany_Required_Inverse4Id2`) +ORDER BY `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c137`.`Id1`, `c137`.`Id2` +""", + // + """ +SELECT `c142`.`Id1`, `c142`.`Id2`, `c142`.`Level3_Optional_Id1`, `c142`.`Level3_Optional_Id2`, `c142`.`Level3_Required_Id1`, `c142`.`Level3_Required_Id2`, `c142`.`Name`, `c142`.`OneToMany_Optional_Inverse4Id1`, `c142`.`OneToMany_Optional_Inverse4Id2`, `c142`.`OneToMany_Optional_Self_Inverse4Id1`, `c142`.`OneToMany_Optional_Self_Inverse4Id2`, `c142`.`OneToMany_Required_Inverse4Id1`, `c142`.`OneToMany_Required_Inverse4Id2`, `c142`.`OneToMany_Required_Self_Inverse4Id1`, `c142`.`OneToMany_Required_Self_Inverse4Id2`, `c142`.`OneToOne_Optional_PK_Inverse4Id1`, `c142`.`OneToOne_Optional_PK_Inverse4Id2`, `c142`.`OneToOne_Optional_Self4Id1`, `c142`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c137`.`Id1`, `c137`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c124` ON (`c`.`Id1` = `c124`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c124`.`OneToMany_Required_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c137` ON (`c124`.`Id1` = `c137`.`OneToMany_Optional_Inverse3Id1`) AND (`c124`.`Id2` = `c137`.`OneToMany_Optional_Inverse3Id2`) +INNER JOIN `CompositeFours` AS `c142` ON (`c137`.`Id1` = `c142`.`OneToMany_Optional_Inverse4Id1`) AND (`c137`.`Id2` = `c142`.`OneToMany_Optional_Inverse4Id2`) +ORDER BY `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c137`.`Id1`, `c137`.`Id2` +""", + // + """ +SELECT `c149`.`Name`, `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c149`.`Id1`, `c149`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c124` ON (`c`.`Id1` = `c124`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c124`.`OneToMany_Required_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c149` ON (`c124`.`Id1` = `c149`.`OneToMany_Optional_Inverse3Id1`) AND (`c124`.`Id2` = `c149`.`OneToMany_Optional_Inverse3Id2`) +ORDER BY `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c149`.`Id1`, `c149`.`Id2` +""", + // + """ +SELECT `c152`.`Id1`, `c152`.`Id2`, `c152`.`Level3_Optional_Id1`, `c152`.`Level3_Optional_Id2`, `c152`.`Level3_Required_Id1`, `c152`.`Level3_Required_Id2`, `c152`.`Name`, `c152`.`OneToMany_Optional_Inverse4Id1`, `c152`.`OneToMany_Optional_Inverse4Id2`, `c152`.`OneToMany_Optional_Self_Inverse4Id1`, `c152`.`OneToMany_Optional_Self_Inverse4Id2`, `c152`.`OneToMany_Required_Inverse4Id1`, `c152`.`OneToMany_Required_Inverse4Id2`, `c152`.`OneToMany_Required_Self_Inverse4Id1`, `c152`.`OneToMany_Required_Self_Inverse4Id2`, `c152`.`OneToOne_Optional_PK_Inverse4Id1`, `c152`.`OneToOne_Optional_PK_Inverse4Id2`, `c152`.`OneToOne_Optional_Self4Id1`, `c152`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c149`.`Id1`, `c149`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c124` ON (`c`.`Id1` = `c124`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c124`.`OneToMany_Required_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c149` ON (`c124`.`Id1` = `c149`.`OneToMany_Optional_Inverse3Id1`) AND (`c124`.`Id2` = `c149`.`OneToMany_Optional_Inverse3Id2`) +INNER JOIN `CompositeFours` AS `c152` ON (`c149`.`Id1` = `c152`.`OneToMany_Optional_Inverse4Id1`) AND (`c149`.`Id2` = `c152`.`OneToMany_Optional_Inverse4Id2`) +ORDER BY `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c149`.`Id1`, `c149`.`Id2` +""", + // + """ +SELECT `c154`.`Id1`, `c154`.`Id2`, `c154`.`Level3_Optional_Id1`, `c154`.`Level3_Optional_Id2`, `c154`.`Level3_Required_Id1`, `c154`.`Level3_Required_Id2`, `c154`.`Name`, `c154`.`OneToMany_Optional_Inverse4Id1`, `c154`.`OneToMany_Optional_Inverse4Id2`, `c154`.`OneToMany_Optional_Self_Inverse4Id1`, `c154`.`OneToMany_Optional_Self_Inverse4Id2`, `c154`.`OneToMany_Required_Inverse4Id1`, `c154`.`OneToMany_Required_Inverse4Id2`, `c154`.`OneToMany_Required_Self_Inverse4Id1`, `c154`.`OneToMany_Required_Self_Inverse4Id2`, `c154`.`OneToOne_Optional_PK_Inverse4Id1`, `c154`.`OneToOne_Optional_PK_Inverse4Id2`, `c154`.`OneToOne_Optional_Self4Id1`, `c154`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c149`.`Id1`, `c149`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c124` ON (`c`.`Id1` = `c124`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c124`.`OneToMany_Required_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c149` ON (`c124`.`Id1` = `c149`.`OneToMany_Optional_Inverse3Id1`) AND (`c124`.`Id2` = `c149`.`OneToMany_Optional_Inverse3Id2`) +INNER JOIN `CompositeFours` AS `c154` ON (`c149`.`Id1` = `c154`.`OneToMany_Required_Inverse4Id1`) AND (`c149`.`Id2` = `c154`.`OneToMany_Required_Inverse4Id2`) +ORDER BY `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c149`.`Id1`, `c149`.`Id2` +"""); } public override async Task Projecting_multiple_collections_on_multiple_levels_some_explicit_ordering(bool async) { await base.Projecting_multiple_collections_on_multiple_levels_some_explicit_ordering(async); - AssertSql( - @"SELECT `c`.`Id1`, `c`.`Id2` -FROM `CompositeOnes` AS `c` -ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`", - // - @"SELECT `c0`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`", - // - @"SELECT `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Required_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Required_Inverse3Id2`) -ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id2` DESC, `c1`.`Id1` DESC", - // - @"SELECT `c1`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -INNER JOIN `CompositeFours` AS `c2` ON (`c1`.`Id1` = `c2`.`OneToMany_Required_Inverse4Id1`) AND (`c1`.`Id2` = `c2`.`OneToMany_Required_Inverse4Id2`) -ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -INNER JOIN `CompositeFours` AS `c2` ON (`c1`.`Id1` = `c2`.`OneToMany_Optional_Inverse4Id1`) AND (`c1`.`Id2` = `c2`.`OneToMany_Optional_Inverse4Id2`) -ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c0`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, CHAR_LENGTH(`c0`.`Name`), `c0`.`Id1`, `c0`.`Id2`", - // - @"SELECT `c1`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, CHAR_LENGTH(`c0`.`Name`), `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -INNER JOIN `CompositeFours` AS `c2` ON (`c1`.`Id1` = `c2`.`OneToMany_Required_Inverse4Id1`) AND (`c1`.`Id2` = `c2`.`OneToMany_Required_Inverse4Id2`) -ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, CHAR_LENGTH(`c0`.`Name`), `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -INNER JOIN `CompositeFours` AS `c2` ON (`c1`.`Id1` = `c2`.`OneToMany_Optional_Inverse4Id1`) AND (`c1`.`Id2` = `c2`.`OneToMany_Optional_Inverse4Id2`) -ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, CHAR_LENGTH(`c0`.`Name`), `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c1`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, CHAR_LENGTH(`c0`.`Name`), `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` -FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -INNER JOIN `CompositeFours` AS `c2` ON (`c1`.`Id1` = `c2`.`OneToMany_Optional_Inverse4Id1`) AND (`c1`.`Id2` = `c2`.`OneToMany_Optional_Inverse4Id2`) -ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, CHAR_LENGTH(`c0`.`Name`), `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`", - // - @"SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2` + AssertSql( +""" +SELECT `c`.`Id1`, `c`.`Id2` FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -INNER JOIN `CompositeThrees` AS `c1` ON (`c0`.`Id1` = `c1`.`OneToMany_Optional_Inverse3Id1`) AND (`c0`.`Id2` = `c1`.`OneToMany_Optional_Inverse3Id2`) -INNER JOIN `CompositeFours` AS `c2` ON (`c1`.`Id1` = `c2`.`OneToMany_Required_Inverse4Id1`) AND (`c1`.`Id2` = `c2`.`OneToMany_Required_Inverse4Id2`) -ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, CHAR_LENGTH(`c0`.`Name`), `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`, `c1`.`Id2`, CONCAT(`c2`.`Id1`, CAST(`c2`.`Id2` AS char)) DESC"); +ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2` +""", + // + """ +SELECT `c62`.`Name`, `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c62` ON (`c`.`Id1` = `c62`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c62`.`OneToMany_Optional_Inverse2Id2`) +ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2` +""", + // + """ +SELECT `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c75`.`Id1`, `c75`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c62` ON (`c`.`Id1` = `c62`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c62`.`OneToMany_Optional_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c75` ON (`c62`.`Id1` = `c75`.`OneToMany_Required_Inverse3Id1`) AND (`c62`.`Id2` = `c75`.`OneToMany_Required_Inverse3Id2`) +ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c75`.`Id2` DESC, `c75`.`Id1` DESC +""", + // + """ +SELECT `c87`.`Name`, `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c87`.`Id1`, `c87`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c62` ON (`c`.`Id1` = `c62`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c62`.`OneToMany_Optional_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c87` ON (`c62`.`Id1` = `c87`.`OneToMany_Optional_Inverse3Id1`) AND (`c62`.`Id2` = `c87`.`OneToMany_Optional_Inverse3Id2`) +ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c87`.`Id1`, `c87`.`Id2` +""", + // + """ +SELECT `c90`.`Id1`, `c90`.`Id2`, `c90`.`Level3_Optional_Id1`, `c90`.`Level3_Optional_Id2`, `c90`.`Level3_Required_Id1`, `c90`.`Level3_Required_Id2`, `c90`.`Name`, `c90`.`OneToMany_Optional_Inverse4Id1`, `c90`.`OneToMany_Optional_Inverse4Id2`, `c90`.`OneToMany_Optional_Self_Inverse4Id1`, `c90`.`OneToMany_Optional_Self_Inverse4Id2`, `c90`.`OneToMany_Required_Inverse4Id1`, `c90`.`OneToMany_Required_Inverse4Id2`, `c90`.`OneToMany_Required_Self_Inverse4Id1`, `c90`.`OneToMany_Required_Self_Inverse4Id2`, `c90`.`OneToOne_Optional_PK_Inverse4Id1`, `c90`.`OneToOne_Optional_PK_Inverse4Id2`, `c90`.`OneToOne_Optional_Self4Id1`, `c90`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c87`.`Id1`, `c87`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c62` ON (`c`.`Id1` = `c62`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c62`.`OneToMany_Optional_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c87` ON (`c62`.`Id1` = `c87`.`OneToMany_Optional_Inverse3Id1`) AND (`c62`.`Id2` = `c87`.`OneToMany_Optional_Inverse3Id2`) +INNER JOIN `CompositeFours` AS `c90` ON (`c87`.`Id1` = `c90`.`OneToMany_Required_Inverse4Id1`) AND (`c87`.`Id2` = `c90`.`OneToMany_Required_Inverse4Id2`) +ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c87`.`Id1`, `c87`.`Id2` +""", + // + """ +SELECT `c92`.`Id1`, `c92`.`Id2`, `c92`.`Level3_Optional_Id1`, `c92`.`Level3_Optional_Id2`, `c92`.`Level3_Required_Id1`, `c92`.`Level3_Required_Id2`, `c92`.`Name`, `c92`.`OneToMany_Optional_Inverse4Id1`, `c92`.`OneToMany_Optional_Inverse4Id2`, `c92`.`OneToMany_Optional_Self_Inverse4Id1`, `c92`.`OneToMany_Optional_Self_Inverse4Id2`, `c92`.`OneToMany_Required_Inverse4Id1`, `c92`.`OneToMany_Required_Inverse4Id2`, `c92`.`OneToMany_Required_Self_Inverse4Id1`, `c92`.`OneToMany_Required_Self_Inverse4Id2`, `c92`.`OneToOne_Optional_PK_Inverse4Id1`, `c92`.`OneToOne_Optional_PK_Inverse4Id2`, `c92`.`OneToOne_Optional_Self4Id1`, `c92`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c87`.`Id1`, `c87`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c62` ON (`c`.`Id1` = `c62`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c62`.`OneToMany_Optional_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c87` ON (`c62`.`Id1` = `c87`.`OneToMany_Optional_Inverse3Id1`) AND (`c62`.`Id2` = `c87`.`OneToMany_Optional_Inverse3Id2`) +INNER JOIN `CompositeFours` AS `c92` ON (`c87`.`Id1` = `c92`.`OneToMany_Optional_Inverse4Id1`) AND (`c87`.`Id2` = `c92`.`OneToMany_Optional_Inverse4Id2`) +ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `c62`.`Id1`, `c62`.`Id2`, `c87`.`Id1`, `c87`.`Id2` +""", + // + """ +SELECT `c124`.`Name`, `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c124` ON (`c`.`Id1` = `c124`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c124`.`OneToMany_Required_Inverse2Id2`) +ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, CHAR_LENGTH(`c124`.`Name`), `c124`.`Id1`, `c124`.`Id2` +""", + // + """ +SELECT `c137`.`Name`, `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c137`.`Id1`, `c137`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c124` ON (`c`.`Id1` = `c124`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c124`.`OneToMany_Required_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c137` ON (`c124`.`Id1` = `c137`.`OneToMany_Optional_Inverse3Id1`) AND (`c124`.`Id2` = `c137`.`OneToMany_Optional_Inverse3Id2`) +ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, CHAR_LENGTH(`c124`.`Name`), `c124`.`Id1`, `c124`.`Id2`, `c137`.`Id1`, `c137`.`Id2` +""", + // + """ +SELECT `c140`.`Id1`, `c140`.`Id2`, `c140`.`Level3_Optional_Id1`, `c140`.`Level3_Optional_Id2`, `c140`.`Level3_Required_Id1`, `c140`.`Level3_Required_Id2`, `c140`.`Name`, `c140`.`OneToMany_Optional_Inverse4Id1`, `c140`.`OneToMany_Optional_Inverse4Id2`, `c140`.`OneToMany_Optional_Self_Inverse4Id1`, `c140`.`OneToMany_Optional_Self_Inverse4Id2`, `c140`.`OneToMany_Required_Inverse4Id1`, `c140`.`OneToMany_Required_Inverse4Id2`, `c140`.`OneToMany_Required_Self_Inverse4Id1`, `c140`.`OneToMany_Required_Self_Inverse4Id2`, `c140`.`OneToOne_Optional_PK_Inverse4Id1`, `c140`.`OneToOne_Optional_PK_Inverse4Id2`, `c140`.`OneToOne_Optional_Self4Id1`, `c140`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c137`.`Id1`, `c137`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c124` ON (`c`.`Id1` = `c124`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c124`.`OneToMany_Required_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c137` ON (`c124`.`Id1` = `c137`.`OneToMany_Optional_Inverse3Id1`) AND (`c124`.`Id2` = `c137`.`OneToMany_Optional_Inverse3Id2`) +INNER JOIN `CompositeFours` AS `c140` ON (`c137`.`Id1` = `c140`.`OneToMany_Required_Inverse4Id1`) AND (`c137`.`Id2` = `c140`.`OneToMany_Required_Inverse4Id2`) +ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, CHAR_LENGTH(`c124`.`Name`), `c124`.`Id1`, `c124`.`Id2`, `c137`.`Id1`, `c137`.`Id2` +""", + // + """ +SELECT `c142`.`Id1`, `c142`.`Id2`, `c142`.`Level3_Optional_Id1`, `c142`.`Level3_Optional_Id2`, `c142`.`Level3_Required_Id1`, `c142`.`Level3_Required_Id2`, `c142`.`Name`, `c142`.`OneToMany_Optional_Inverse4Id1`, `c142`.`OneToMany_Optional_Inverse4Id2`, `c142`.`OneToMany_Optional_Self_Inverse4Id1`, `c142`.`OneToMany_Optional_Self_Inverse4Id2`, `c142`.`OneToMany_Required_Inverse4Id1`, `c142`.`OneToMany_Required_Inverse4Id2`, `c142`.`OneToMany_Required_Self_Inverse4Id1`, `c142`.`OneToMany_Required_Self_Inverse4Id2`, `c142`.`OneToOne_Optional_PK_Inverse4Id1`, `c142`.`OneToOne_Optional_PK_Inverse4Id2`, `c142`.`OneToOne_Optional_Self4Id1`, `c142`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c137`.`Id1`, `c137`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c124` ON (`c`.`Id1` = `c124`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c124`.`OneToMany_Required_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c137` ON (`c124`.`Id1` = `c137`.`OneToMany_Optional_Inverse3Id1`) AND (`c124`.`Id2` = `c137`.`OneToMany_Optional_Inverse3Id2`) +INNER JOIN `CompositeFours` AS `c142` ON (`c137`.`Id1` = `c142`.`OneToMany_Optional_Inverse4Id1`) AND (`c137`.`Id2` = `c142`.`OneToMany_Optional_Inverse4Id2`) +ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, CHAR_LENGTH(`c124`.`Name`), `c124`.`Id1`, `c124`.`Id2`, `c137`.`Id1`, `c137`.`Id2` +""", + // + """ +SELECT `c149`.`Name`, `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c149`.`Id1`, `c149`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c124` ON (`c`.`Id1` = `c124`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c124`.`OneToMany_Required_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c149` ON (`c124`.`Id1` = `c149`.`OneToMany_Optional_Inverse3Id1`) AND (`c124`.`Id2` = `c149`.`OneToMany_Optional_Inverse3Id2`) +ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, CHAR_LENGTH(`c124`.`Name`), `c124`.`Id1`, `c124`.`Id2`, `c149`.`Id1`, `c149`.`Id2` +""", + // + """ +SELECT `c152`.`Id1`, `c152`.`Id2`, `c152`.`Level3_Optional_Id1`, `c152`.`Level3_Optional_Id2`, `c152`.`Level3_Required_Id1`, `c152`.`Level3_Required_Id2`, `c152`.`Name`, `c152`.`OneToMany_Optional_Inverse4Id1`, `c152`.`OneToMany_Optional_Inverse4Id2`, `c152`.`OneToMany_Optional_Self_Inverse4Id1`, `c152`.`OneToMany_Optional_Self_Inverse4Id2`, `c152`.`OneToMany_Required_Inverse4Id1`, `c152`.`OneToMany_Required_Inverse4Id2`, `c152`.`OneToMany_Required_Self_Inverse4Id1`, `c152`.`OneToMany_Required_Self_Inverse4Id2`, `c152`.`OneToOne_Optional_PK_Inverse4Id1`, `c152`.`OneToOne_Optional_PK_Inverse4Id2`, `c152`.`OneToOne_Optional_Self4Id1`, `c152`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c149`.`Id1`, `c149`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c124` ON (`c`.`Id1` = `c124`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c124`.`OneToMany_Required_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c149` ON (`c124`.`Id1` = `c149`.`OneToMany_Optional_Inverse3Id1`) AND (`c124`.`Id2` = `c149`.`OneToMany_Optional_Inverse3Id2`) +INNER JOIN `CompositeFours` AS `c152` ON (`c149`.`Id1` = `c152`.`OneToMany_Optional_Inverse4Id1`) AND (`c149`.`Id2` = `c152`.`OneToMany_Optional_Inverse4Id2`) +ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, CHAR_LENGTH(`c124`.`Name`), `c124`.`Id1`, `c124`.`Id2`, `c149`.`Id1`, `c149`.`Id2` +""", + // + """ +SELECT `c154`.`Id1`, `c154`.`Id2`, `c154`.`Level3_Optional_Id1`, `c154`.`Level3_Optional_Id2`, `c154`.`Level3_Required_Id1`, `c154`.`Level3_Required_Id2`, `c154`.`Name`, `c154`.`OneToMany_Optional_Inverse4Id1`, `c154`.`OneToMany_Optional_Inverse4Id2`, `c154`.`OneToMany_Optional_Self_Inverse4Id1`, `c154`.`OneToMany_Optional_Self_Inverse4Id2`, `c154`.`OneToMany_Required_Inverse4Id1`, `c154`.`OneToMany_Required_Inverse4Id2`, `c154`.`OneToMany_Required_Self_Inverse4Id1`, `c154`.`OneToMany_Required_Self_Inverse4Id2`, `c154`.`OneToOne_Optional_PK_Inverse4Id1`, `c154`.`OneToOne_Optional_PK_Inverse4Id2`, `c154`.`OneToOne_Optional_Self4Id1`, `c154`.`OneToOne_Optional_Self4Id2`, `c`.`Id1`, `c`.`Id2`, `c124`.`Id1`, `c124`.`Id2`, `c149`.`Id1`, `c149`.`Id2` +FROM `CompositeOnes` AS `c` +INNER JOIN `CompositeTwos` AS `c124` ON (`c`.`Id1` = `c124`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c124`.`OneToMany_Required_Inverse2Id2`) +INNER JOIN `CompositeThrees` AS `c149` ON (`c124`.`Id1` = `c149`.`OneToMany_Optional_Inverse3Id1`) AND (`c124`.`Id2` = `c149`.`OneToMany_Optional_Inverse3Id2`) +INNER JOIN `CompositeFours` AS `c154` ON (`c149`.`Id1` = `c154`.`OneToMany_Required_Inverse4Id1`) AND (`c149`.`Id2` = `c154`.`OneToMany_Required_Inverse4Id2`) +ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, CHAR_LENGTH(`c124`.`Name`), `c124`.`Id1`, `c124`.`Id2`, `c149`.`Id1`, `c149`.`Id2`, CONCAT(`c154`.`Id1`, CAST(`c154`.`Id2` AS char)) DESC +"""); } public override async Task Projecting_multiple_collections_same_level_top_level_ordering(bool async) @@ -216,19 +271,25 @@ public override async Task Projecting_multiple_collections_same_level_top_level_ await base.Projecting_multiple_collections_same_level_top_level_ordering(async); AssertSql( - @"SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2` +""" +SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2` FROM `CompositeOnes` AS `c` -ORDER BY `c`.`Id2`, `c`.`Id1`", +ORDER BY `c`.`Id2`, `c`.`Id1` +""", // - @"SELECT `c0`.`Id1`, `c0`.`Id2`, `c0`.`Date`, `c0`.`Level1_Optional_Id1`, `c0`.`Level1_Optional_Id2`, `c0`.`Level1_Required_Id1`, `c0`.`Level1_Required_Id2`, `c0`.`Name`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2`, `c0`.`OneToMany_Optional_Self_Inverse2Id1`, `c0`.`OneToMany_Optional_Self_Inverse2Id2`, `c0`.`OneToMany_Required_Inverse2Id1`, `c0`.`OneToMany_Required_Inverse2Id2`, `c0`.`OneToMany_Required_Self_Inverse2Id1`, `c0`.`OneToMany_Required_Self_Inverse2Id2`, `c0`.`OneToOne_Optional_PK_Inverse2Id1`, `c0`.`OneToOne_Optional_PK_Inverse2Id2`, `c0`.`OneToOne_Optional_Self2Id1`, `c0`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` + """ +SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Date`, `c2`.`Level1_Optional_Id1`, `c2`.`Level1_Optional_Id2`, `c2`.`Level1_Required_Id1`, `c2`.`Level1_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse2Id1`, `c2`.`OneToMany_Optional_Inverse2Id2`, `c2`.`OneToMany_Optional_Self_Inverse2Id1`, `c2`.`OneToMany_Optional_Self_Inverse2Id2`, `c2`.`OneToMany_Required_Inverse2Id1`, `c2`.`OneToMany_Required_Inverse2Id2`, `c2`.`OneToMany_Required_Self_Inverse2Id1`, `c2`.`OneToMany_Required_Self_Inverse2Id2`, `c2`.`OneToOne_Optional_PK_Inverse2Id1`, `c2`.`OneToOne_Optional_PK_Inverse2Id2`, `c2`.`OneToOne_Optional_Self2Id1`, `c2`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -ORDER BY `c`.`Id2`, `c`.`Id1`", +INNER JOIN `CompositeTwos` AS `c2` ON (`c`.`Id1` = `c2`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c2`.`OneToMany_Optional_Inverse2Id2`) +ORDER BY `c`.`Id2`, `c`.`Id1` +""", // - @"SELECT `c0`.`Id1`, `c0`.`Id2`, `c0`.`Date`, `c0`.`Level1_Optional_Id1`, `c0`.`Level1_Optional_Id2`, `c0`.`Level1_Required_Id1`, `c0`.`Level1_Required_Id2`, `c0`.`Name`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2`, `c0`.`OneToMany_Optional_Self_Inverse2Id1`, `c0`.`OneToMany_Optional_Self_Inverse2Id2`, `c0`.`OneToMany_Required_Inverse2Id1`, `c0`.`OneToMany_Required_Inverse2Id2`, `c0`.`OneToMany_Required_Self_Inverse2Id1`, `c0`.`OneToMany_Required_Self_Inverse2Id2`, `c0`.`OneToOne_Optional_PK_Inverse2Id1`, `c0`.`OneToOne_Optional_PK_Inverse2Id2`, `c0`.`OneToOne_Optional_Self2Id1`, `c0`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` + """ +SELECT `c4`.`Id1`, `c4`.`Id2`, `c4`.`Date`, `c4`.`Level1_Optional_Id1`, `c4`.`Level1_Optional_Id2`, `c4`.`Level1_Required_Id1`, `c4`.`Level1_Required_Id2`, `c4`.`Name`, `c4`.`OneToMany_Optional_Inverse2Id1`, `c4`.`OneToMany_Optional_Inverse2Id2`, `c4`.`OneToMany_Optional_Self_Inverse2Id1`, `c4`.`OneToMany_Optional_Self_Inverse2Id2`, `c4`.`OneToMany_Required_Inverse2Id1`, `c4`.`OneToMany_Required_Inverse2Id2`, `c4`.`OneToMany_Required_Self_Inverse2Id1`, `c4`.`OneToMany_Required_Self_Inverse2Id2`, `c4`.`OneToOne_Optional_PK_Inverse2Id1`, `c4`.`OneToOne_Optional_PK_Inverse2Id2`, `c4`.`OneToOne_Optional_Self2Id1`, `c4`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -ORDER BY `c`.`Id2`, `c`.`Id1`"); +INNER JOIN `CompositeTwos` AS `c4` ON (`c`.`Id1` = `c4`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c4`.`OneToMany_Required_Inverse2Id2`) +ORDER BY `c`.`Id2`, `c`.`Id1` +"""); } public override async Task Projecting_multiple_collections_same_level_top_level_ordering_using_entire_composite_key(bool async) @@ -236,19 +297,25 @@ public override async Task Projecting_multiple_collections_same_level_top_level_ await base.Projecting_multiple_collections_same_level_top_level_ordering_using_entire_composite_key(async); AssertSql( - @"SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2` +""" +SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2` FROM `CompositeOnes` AS `c` -ORDER BY `c`.`Id2`, `c`.`Id1` DESC", +ORDER BY `c`.`Id2`, `c`.`Id1` DESC +""", // - @"SELECT `c0`.`Id1`, `c0`.`Id2`, `c0`.`Date`, `c0`.`Level1_Optional_Id1`, `c0`.`Level1_Optional_Id2`, `c0`.`Level1_Required_Id1`, `c0`.`Level1_Required_Id2`, `c0`.`Name`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2`, `c0`.`OneToMany_Optional_Self_Inverse2Id1`, `c0`.`OneToMany_Optional_Self_Inverse2Id2`, `c0`.`OneToMany_Required_Inverse2Id1`, `c0`.`OneToMany_Required_Inverse2Id2`, `c0`.`OneToMany_Required_Self_Inverse2Id1`, `c0`.`OneToMany_Required_Self_Inverse2Id2`, `c0`.`OneToOne_Optional_PK_Inverse2Id1`, `c0`.`OneToOne_Optional_PK_Inverse2Id2`, `c0`.`OneToOne_Optional_Self2Id1`, `c0`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` + """ +SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Date`, `c2`.`Level1_Optional_Id1`, `c2`.`Level1_Optional_Id2`, `c2`.`Level1_Required_Id1`, `c2`.`Level1_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse2Id1`, `c2`.`OneToMany_Optional_Inverse2Id2`, `c2`.`OneToMany_Optional_Self_Inverse2Id1`, `c2`.`OneToMany_Optional_Self_Inverse2Id2`, `c2`.`OneToMany_Required_Inverse2Id1`, `c2`.`OneToMany_Required_Inverse2Id2`, `c2`.`OneToMany_Required_Self_Inverse2Id1`, `c2`.`OneToMany_Required_Self_Inverse2Id2`, `c2`.`OneToOne_Optional_PK_Inverse2Id1`, `c2`.`OneToOne_Optional_PK_Inverse2Id2`, `c2`.`OneToOne_Optional_Self2Id1`, `c2`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -ORDER BY `c`.`Id2`, `c`.`Id1` DESC", +INNER JOIN `CompositeTwos` AS `c2` ON (`c`.`Id1` = `c2`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c2`.`OneToMany_Optional_Inverse2Id2`) +ORDER BY `c`.`Id2`, `c`.`Id1` DESC +""", // - @"SELECT `c0`.`Id1`, `c0`.`Id2`, `c0`.`Date`, `c0`.`Level1_Optional_Id1`, `c0`.`Level1_Optional_Id2`, `c0`.`Level1_Required_Id1`, `c0`.`Level1_Required_Id2`, `c0`.`Name`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2`, `c0`.`OneToMany_Optional_Self_Inverse2Id1`, `c0`.`OneToMany_Optional_Self_Inverse2Id2`, `c0`.`OneToMany_Required_Inverse2Id1`, `c0`.`OneToMany_Required_Inverse2Id2`, `c0`.`OneToMany_Required_Self_Inverse2Id1`, `c0`.`OneToMany_Required_Self_Inverse2Id2`, `c0`.`OneToOne_Optional_PK_Inverse2Id1`, `c0`.`OneToOne_Optional_PK_Inverse2Id2`, `c0`.`OneToOne_Optional_Self2Id1`, `c0`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` + """ +SELECT `c4`.`Id1`, `c4`.`Id2`, `c4`.`Date`, `c4`.`Level1_Optional_Id1`, `c4`.`Level1_Optional_Id2`, `c4`.`Level1_Required_Id1`, `c4`.`Level1_Required_Id2`, `c4`.`Name`, `c4`.`OneToMany_Optional_Inverse2Id1`, `c4`.`OneToMany_Optional_Inverse2Id2`, `c4`.`OneToMany_Optional_Self_Inverse2Id1`, `c4`.`OneToMany_Optional_Self_Inverse2Id2`, `c4`.`OneToMany_Required_Inverse2Id1`, `c4`.`OneToMany_Required_Inverse2Id2`, `c4`.`OneToMany_Required_Self_Inverse2Id1`, `c4`.`OneToMany_Required_Self_Inverse2Id2`, `c4`.`OneToOne_Optional_PK_Inverse2Id1`, `c4`.`OneToOne_Optional_PK_Inverse2Id2`, `c4`.`OneToOne_Optional_Self2Id1`, `c4`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -ORDER BY `c`.`Id2`, `c`.`Id1` DESC"); +INNER JOIN `CompositeTwos` AS `c4` ON (`c`.`Id1` = `c4`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c4`.`OneToMany_Required_Inverse2Id2`) +ORDER BY `c`.`Id2`, `c`.`Id1` DESC +"""); } public override async Task Projecting_multiple_collections_with_ordering_same_level(bool async) @@ -256,19 +323,25 @@ public override async Task Projecting_multiple_collections_with_ordering_same_le await base.Projecting_multiple_collections_with_ordering_same_level(async); AssertSql( - @"SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2` +""" +SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2` FROM `CompositeOnes` AS `c` -ORDER BY `c`.`Id1`, `c`.`Id2`", +ORDER BY `c`.`Id1`, `c`.`Id2` +""", // - @"SELECT `c0`.`Id1`, `c0`.`Id2`, `c0`.`Date`, `c0`.`Level1_Optional_Id1`, `c0`.`Level1_Optional_Id2`, `c0`.`Level1_Required_Id1`, `c0`.`Level1_Required_Id2`, `c0`.`Name`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2`, `c0`.`OneToMany_Optional_Self_Inverse2Id1`, `c0`.`OneToMany_Optional_Self_Inverse2Id2`, `c0`.`OneToMany_Required_Inverse2Id1`, `c0`.`OneToMany_Required_Inverse2Id2`, `c0`.`OneToMany_Required_Self_Inverse2Id1`, `c0`.`OneToMany_Required_Self_Inverse2Id2`, `c0`.`OneToOne_Optional_PK_Inverse2Id1`, `c0`.`OneToOne_Optional_PK_Inverse2Id2`, `c0`.`OneToOne_Optional_Self2Id1`, `c0`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` + """ +SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Date`, `c2`.`Level1_Optional_Id1`, `c2`.`Level1_Optional_Id2`, `c2`.`Level1_Required_Id1`, `c2`.`Level1_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse2Id1`, `c2`.`OneToMany_Optional_Inverse2Id2`, `c2`.`OneToMany_Optional_Self_Inverse2Id1`, `c2`.`OneToMany_Optional_Self_Inverse2Id2`, `c2`.`OneToMany_Required_Inverse2Id1`, `c2`.`OneToMany_Required_Inverse2Id2`, `c2`.`OneToMany_Required_Self_Inverse2Id1`, `c2`.`OneToMany_Required_Self_Inverse2Id2`, `c2`.`OneToOne_Optional_PK_Inverse2Id1`, `c2`.`OneToOne_Optional_PK_Inverse2Id2`, `c2`.`OneToOne_Optional_Self2Id1`, `c2`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -ORDER BY `c`.`Id1`, `c`.`Id2`, `c0`.`Id2`", +INNER JOIN `CompositeTwos` AS `c2` ON (`c`.`Id1` = `c2`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c2`.`OneToMany_Optional_Inverse2Id2`) +ORDER BY `c`.`Id1`, `c`.`Id2`, `c2`.`Id2` +""", // - @"SELECT `c0`.`Id1`, `c0`.`Id2`, `c0`.`Date`, `c0`.`Level1_Optional_Id1`, `c0`.`Level1_Optional_Id2`, `c0`.`Level1_Required_Id1`, `c0`.`Level1_Required_Id2`, `c0`.`Name`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2`, `c0`.`OneToMany_Optional_Self_Inverse2Id1`, `c0`.`OneToMany_Optional_Self_Inverse2Id2`, `c0`.`OneToMany_Required_Inverse2Id1`, `c0`.`OneToMany_Required_Inverse2Id2`, `c0`.`OneToMany_Required_Self_Inverse2Id1`, `c0`.`OneToMany_Required_Self_Inverse2Id2`, `c0`.`OneToOne_Optional_PK_Inverse2Id1`, `c0`.`OneToOne_Optional_PK_Inverse2Id2`, `c0`.`OneToOne_Optional_Self2Id1`, `c0`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` + """ +SELECT `c4`.`Id1`, `c4`.`Id2`, `c4`.`Date`, `c4`.`Level1_Optional_Id1`, `c4`.`Level1_Optional_Id2`, `c4`.`Level1_Required_Id1`, `c4`.`Level1_Required_Id2`, `c4`.`Name`, `c4`.`OneToMany_Optional_Inverse2Id1`, `c4`.`OneToMany_Optional_Inverse2Id2`, `c4`.`OneToMany_Optional_Self_Inverse2Id1`, `c4`.`OneToMany_Optional_Self_Inverse2Id2`, `c4`.`OneToMany_Required_Inverse2Id1`, `c4`.`OneToMany_Required_Inverse2Id2`, `c4`.`OneToMany_Required_Self_Inverse2Id1`, `c4`.`OneToMany_Required_Self_Inverse2Id2`, `c4`.`OneToOne_Optional_PK_Inverse2Id1`, `c4`.`OneToOne_Optional_PK_Inverse2Id2`, `c4`.`OneToOne_Optional_Self2Id1`, `c4`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -ORDER BY `c`.`Id1`, `c`.`Id2`, `c0`.`Name` DESC"); +INNER JOIN `CompositeTwos` AS `c4` ON (`c`.`Id1` = `c4`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c4`.`OneToMany_Required_Inverse2Id2`) +ORDER BY `c`.`Id1`, `c`.`Id2`, `c4`.`Name` DESC +"""); } public override async Task Projecting_multiple_collections_with_ordering_same_level_top_level_ordering(bool async) @@ -276,19 +349,25 @@ public override async Task Projecting_multiple_collections_with_ordering_same_le await base.Projecting_multiple_collections_with_ordering_same_level_top_level_ordering(async); AssertSql( - @"SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2` +""" +SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2` FROM `CompositeOnes` AS `c` -ORDER BY `c`.`Id2`, `c`.`Id1`", +ORDER BY `c`.`Id2`, `c`.`Id1` +""", // - @"SELECT `c0`.`Id1`, `c0`.`Id2`, `c0`.`Date`, `c0`.`Level1_Optional_Id1`, `c0`.`Level1_Optional_Id2`, `c0`.`Level1_Required_Id1`, `c0`.`Level1_Required_Id2`, `c0`.`Name`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2`, `c0`.`OneToMany_Optional_Self_Inverse2Id1`, `c0`.`OneToMany_Optional_Self_Inverse2Id2`, `c0`.`OneToMany_Required_Inverse2Id1`, `c0`.`OneToMany_Required_Inverse2Id2`, `c0`.`OneToMany_Required_Self_Inverse2Id1`, `c0`.`OneToMany_Required_Self_Inverse2Id2`, `c0`.`OneToOne_Optional_PK_Inverse2Id1`, `c0`.`OneToOne_Optional_PK_Inverse2Id2`, `c0`.`OneToOne_Optional_Self2Id1`, `c0`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` + """ +SELECT `c2`.`Id1`, `c2`.`Id2`, `c2`.`Date`, `c2`.`Level1_Optional_Id1`, `c2`.`Level1_Optional_Id2`, `c2`.`Level1_Required_Id1`, `c2`.`Level1_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse2Id1`, `c2`.`OneToMany_Optional_Inverse2Id2`, `c2`.`OneToMany_Optional_Self_Inverse2Id1`, `c2`.`OneToMany_Optional_Self_Inverse2Id2`, `c2`.`OneToMany_Required_Inverse2Id1`, `c2`.`OneToMany_Required_Inverse2Id2`, `c2`.`OneToMany_Required_Self_Inverse2Id1`, `c2`.`OneToMany_Required_Self_Inverse2Id2`, `c2`.`OneToOne_Optional_PK_Inverse2Id1`, `c2`.`OneToOne_Optional_PK_Inverse2Id2`, `c2`.`OneToOne_Optional_Self2Id1`, `c2`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`) -ORDER BY `c`.`Id2`, `c`.`Id1`, `c0`.`Id2`", +INNER JOIN `CompositeTwos` AS `c2` ON (`c`.`Id1` = `c2`.`OneToMany_Optional_Inverse2Id1`) AND (`c`.`Id2` = `c2`.`OneToMany_Optional_Inverse2Id2`) +ORDER BY `c`.`Id2`, `c`.`Id1`, `c2`.`Id2` +""", // - @"SELECT `c0`.`Id1`, `c0`.`Id2`, `c0`.`Date`, `c0`.`Level1_Optional_Id1`, `c0`.`Level1_Optional_Id2`, `c0`.`Level1_Required_Id1`, `c0`.`Level1_Required_Id2`, `c0`.`Name`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2`, `c0`.`OneToMany_Optional_Self_Inverse2Id1`, `c0`.`OneToMany_Optional_Self_Inverse2Id2`, `c0`.`OneToMany_Required_Inverse2Id1`, `c0`.`OneToMany_Required_Inverse2Id2`, `c0`.`OneToMany_Required_Self_Inverse2Id1`, `c0`.`OneToMany_Required_Self_Inverse2Id2`, `c0`.`OneToOne_Optional_PK_Inverse2Id1`, `c0`.`OneToOne_Optional_PK_Inverse2Id2`, `c0`.`OneToOne_Optional_Self2Id1`, `c0`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` + """ +SELECT `c4`.`Id1`, `c4`.`Id2`, `c4`.`Date`, `c4`.`Level1_Optional_Id1`, `c4`.`Level1_Optional_Id2`, `c4`.`Level1_Required_Id1`, `c4`.`Level1_Required_Id2`, `c4`.`Name`, `c4`.`OneToMany_Optional_Inverse2Id1`, `c4`.`OneToMany_Optional_Inverse2Id2`, `c4`.`OneToMany_Optional_Self_Inverse2Id1`, `c4`.`OneToMany_Optional_Self_Inverse2Id2`, `c4`.`OneToMany_Required_Inverse2Id1`, `c4`.`OneToMany_Required_Inverse2Id2`, `c4`.`OneToMany_Required_Self_Inverse2Id1`, `c4`.`OneToMany_Required_Self_Inverse2Id2`, `c4`.`OneToOne_Optional_PK_Inverse2Id1`, `c4`.`OneToOne_Optional_PK_Inverse2Id2`, `c4`.`OneToOne_Optional_Self2Id1`, `c4`.`OneToOne_Optional_Self2Id2`, `c`.`Id1`, `c`.`Id2` FROM `CompositeOnes` AS `c` -INNER JOIN `CompositeTwos` AS `c0` ON (`c`.`Id1` = `c0`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c0`.`OneToMany_Required_Inverse2Id2`) -ORDER BY `c`.`Id2`, `c`.`Id1`, `c0`.`Name` DESC"); +INNER JOIN `CompositeTwos` AS `c4` ON (`c`.`Id1` = `c4`.`OneToMany_Required_Inverse2Id1`) AND (`c`.`Id2` = `c4`.`OneToMany_Required_Inverse2Id2`) +ORDER BY `c`.`Id2`, `c`.`Id1`, `c4`.`Name` DESC +"""); } private void AssertSql(params string[] expected) diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/DateOnlyQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/DateOnlyQuerySingleStoreTest.cs index da5c272e3..da9fd785c 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/DateOnlyQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/DateOnlyQuerySingleStoreTest.cs @@ -183,7 +183,7 @@ protected DateOnlyQuerySingleStoreTestBase(TFixture fixture) protected virtual DbContext CreateContext() => Fixture.CreateContext(); - public abstract class DateOnlyQuerySingleStoreFixtureBase : SharedStoreFixtureBase, IQueryFixtureBase + public abstract class DateOnlyQuerySingleStoreFixtureBase : SharedStoreFixtureBase, IQueryFixtureBase, ITestSqlLoggerFactory { protected override string StoreName => "DateOnlyQueryTest"; public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/Ef6GroupBySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/Ef6GroupBySingleStoreTest.cs index 21dab32fb..e6787a4bb 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/Ef6GroupBySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/Ef6GroupBySingleStoreTest.cs @@ -21,7 +21,7 @@ public Ef6GroupBySingleStoreTest(Ef6GroupBySingleStoreFixture fixture, ITestOutp [ConditionalFact] public virtual void Check_all_tests_overridden() - => TestHelpers.AssertAllMethodsOverridden(GetType()); + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); public override async Task GroupBy_is_optimized_when_projecting_group_key(bool async) { @@ -165,16 +165,14 @@ public override async Task GroupBy_is_optimized_when_projecting_conditional_expr await base.GroupBy_is_optimized_when_projecting_conditional_expression_containing_group_key(async); AssertSql( -""" -@__p_0='False' - -SELECT CASE - WHEN `a`.`FirstName` IS NULL THEN 'is null' - ELSE 'not null' -END AS `keyIsNull`, @__p_0 AS `logicExpression` -FROM `ArubaOwner` AS `a` -GROUP BY `a`.`FirstName` -"""); + """ + SELECT CASE + WHEN `a`.`FirstName` IS NULL THEN 'is null' + ELSE 'not null' + END AS `keyIsNull`, FALSE AS `logicExpression` + FROM `ArubaOwner` AS `a` + GROUP BY `a`.`FirstName` + """); // EF6 SQL: // @"SELECT @@ -187,18 +185,18 @@ GROUP BY `a`.`FirstName` // ) AS [Distinct1]"; } - public override async Task GroupBy_is_optimized_when_filerting_and_projecting_anonymous_type_with_group_key_and_function_aggregate( + public override async Task GroupBy_is_optimized_when_filtering_and_projecting_anonymous_type_with_group_key_and_function_aggregate( bool async) { - await base.GroupBy_is_optimized_when_filerting_and_projecting_anonymous_type_with_group_key_and_function_aggregate(async); + await base.GroupBy_is_optimized_when_filtering_and_projecting_anonymous_type_with_group_key_and_function_aggregate(async); AssertSql( -$""" -SELECT `a`.`FirstName`, AVG({SingleStoreTestHelpers.CastAsDouble("`a`.`Id`")}) AS `AverageId` -FROM `ArubaOwner` AS `a` -WHERE `a`.`Id` > 5 -GROUP BY `a`.`FirstName` -"""); + $""" + SELECT `a`.`FirstName`, AVG({SingleStoreTestHelpers.CastAsDouble("`a`.`Id`")}) AS `AverageId` + FROM `ArubaOwner` AS `a` + WHERE `a`.`Id` > 5 + GROUP BY `a`.`FirstName` + """); // EF6 SQL: // @"SELECT @@ -487,17 +485,16 @@ public override async Task Group_Join_from_LINQ_101(bool async) await base.Group_Join_from_LINQ_101(async); AssertSql( -""" -SELECT `c`.`Id`, `c`.`CompanyName`, `c`.`Region`, `t`.`Id`, `t`.`CustomerId`, `t`.`OrderDate`, `t`.`Total`, `t`.`Id0` -FROM `CustomerForLinq` AS `c` -LEFT JOIN LATERAL ( - SELECT `o`.`Id`, `o`.`CustomerId`, `o`.`OrderDate`, `o`.`Total`, `c0`.`Id` AS `Id0` - FROM `OrderForLinq` AS `o` - LEFT JOIN `CustomerForLinq` AS `c0` ON `o`.`CustomerId` = `c0`.`Id` - WHERE `c`.`Id` = `c0`.`Id` -) AS `t` ON TRUE -ORDER BY `c`.`Id`, `t`.`Id` -"""); + """ + SELECT `c`.`Id`, `c`.`CompanyName`, `c`.`Region`, `s`.`Id`, `s`.`CustomerId`, `s`.`OrderDate`, `s`.`Total`, `s`.`Id0` + FROM `CustomerForLinq` AS `c` + LEFT JOIN ( + SELECT `o`.`Id`, `o`.`CustomerId`, `o`.`OrderDate`, `o`.`Total`, `c0`.`Id` AS `Id0` + FROM `OrderForLinq` AS `o` + LEFT JOIN `CustomerForLinq` AS `c0` ON `o`.`CustomerId` = `c0`.`Id` + ) AS `s` ON `c`.`Id` = `s`.`Id0` + ORDER BY `c`.`Id`, `s`.`Id` + """); } [ConditionalTheory(Skip = "Check why this does not throw in CI (MySQL 8.0.x), but does locally in the mysql:latest docker container.")] @@ -558,24 +555,24 @@ public override async Task Whats_new_2021_sample_15(bool async) await base.Whats_new_2021_sample_15(async); AssertSql( -""" -SELECT `t0`.`Id`, `t0`.`Age`, `t0`.`FirstName`, `t0`.`LastName`, `t0`.`MiddleInitial` -FROM ( - SELECT `f`.`Id`, `f`.`Size` - FROM `Person` AS `p` - LEFT JOIN `Feet` AS `f` ON `p`.`Id` = `f`.`Id` - GROUP BY `f`.`Id`, `f`.`Size` -) AS `t` -LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`Age`, `t1`.`FirstName`, `t1`.`LastName`, `t1`.`MiddleInitial`, `t1`.`Id0`, `t1`.`Size` - FROM ( - SELECT `p0`.`Id`, `p0`.`Age`, `p0`.`FirstName`, `p0`.`LastName`, `p0`.`MiddleInitial`, `f0`.`Id` AS `Id0`, `f0`.`Size`, ROW_NUMBER() OVER(PARTITION BY `f0`.`Id`, `f0`.`Size` ORDER BY `p0`.`Id` DESC) AS `row` - FROM `Person` AS `p0` - LEFT JOIN `Feet` AS `f0` ON `p0`.`Id` = `f0`.`Id` - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON ((`t`.`Id` = `t0`.`Id0`) OR (`t`.`Id` IS NULL AND (`t0`.`Id0` IS NULL))) AND ((`t`.`Size` = `t0`.`Size`) OR (`t`.`Size` IS NULL AND (`t0`.`Size` IS NULL))) -"""); + """ + SELECT `s1`.`Id`, `s1`.`Age`, `s1`.`FirstName`, `s1`.`LastName`, `s1`.`MiddleInitial` + FROM ( + SELECT `f`.`Id`, `f`.`Size` + FROM `Person` AS `p` + LEFT JOIN `Feet` AS `f` ON `p`.`Id` = `f`.`Id` + GROUP BY `f`.`Id`, `f`.`Size` + ) AS `s` + LEFT JOIN ( + SELECT `s0`.`Id`, `s0`.`Age`, `s0`.`FirstName`, `s0`.`LastName`, `s0`.`MiddleInitial`, `s0`.`Id0`, `s0`.`Size` + FROM ( + SELECT `p0`.`Id`, `p0`.`Age`, `p0`.`FirstName`, `p0`.`LastName`, `p0`.`MiddleInitial`, `f0`.`Id` AS `Id0`, `f0`.`Size`, ROW_NUMBER() OVER(PARTITION BY `f0`.`Id`, `f0`.`Size` ORDER BY `p0`.`Id` DESC) AS `row` + FROM `Person` AS `p0` + LEFT JOIN `Feet` AS `f0` ON `p0`.`Id` = `f0`.`Id` + ) AS `s0` + WHERE `s0`.`row` <= 1 + ) AS `s1` ON ((`s`.`Id` = `s1`.`Id0`) OR (`s`.`Id` IS NULL AND (`s1`.`Id0` IS NULL))) AND ((`s`.`Size` = `s1`.`Size`) OR (`s`.`Size` IS NULL AND (`s1`.`Size` IS NULL))) + """); } public override async Task Whats_new_2021_sample_16(bool async) @@ -614,15 +611,15 @@ public override async Task Whats_new_2021_sample_8(bool async) await base.Whats_new_2021_sample_8(async); AssertSql( -""" -SELECT COUNT(*) -FROM ( - SELECT `f`.`Id`, `f`.`Size` - FROM `Person` AS `p` - LEFT JOIN `Feet` AS `f` ON `p`.`Id` = `f`.`Id` - GROUP BY `f`.`Id`, `f`.`Size` -) AS `t` -"""); + """ + SELECT COUNT(*) + FROM ( + SELECT 1 + FROM `Person` AS `p` + LEFT JOIN `Feet` AS `f` ON `p`.`Id` = `f`.`Id` + GROUP BY `f`.`Id`, `f`.`Size` + ) AS `s` + """); } public override async Task Whats_new_2021_sample_12(bool async) @@ -630,20 +627,20 @@ public override async Task Whats_new_2021_sample_12(bool async) await base.Whats_new_2021_sample_12(async); AssertSql( -""" -SELECT `t`.`FirstName`, `t0`.`Id`, `t0`.`Age`, `t0`.`FirstName`, `t0`.`LastName`, `t0`.`MiddleInitial`, `t0`.`Id0`, `t0`.`Age0`, `t0`.`PersonId`, `t0`.`Style` -FROM ( - SELECT `p`.`FirstName` - FROM `Person` AS `p` - GROUP BY `p`.`FirstName` -) AS `t` -LEFT JOIN ( - SELECT `p0`.`Id`, `p0`.`Age`, `p0`.`FirstName`, `p0`.`LastName`, `p0`.`MiddleInitial`, `s`.`Id` AS `Id0`, `s`.`Age` AS `Age0`, `s`.`PersonId`, `s`.`Style` - FROM `Person` AS `p0` - LEFT JOIN `Shoes` AS `s` ON `p0`.`Id` = `s`.`PersonId` -) AS `t0` ON `t`.`FirstName` = `t0`.`FirstName` -ORDER BY `t`.`FirstName`, `t0`.`Id` -"""); + """ + SELECT `p1`.`FirstName`, `s0`.`Id`, `s0`.`Age`, `s0`.`FirstName`, `s0`.`LastName`, `s0`.`MiddleInitial`, `s0`.`Id0`, `s0`.`Age0`, `s0`.`PersonId`, `s0`.`Style` + FROM ( + SELECT `p`.`FirstName` + FROM `Person` AS `p` + GROUP BY `p`.`FirstName` + ) AS `p1` + LEFT JOIN ( + SELECT `p0`.`Id`, `p0`.`Age`, `p0`.`FirstName`, `p0`.`LastName`, `p0`.`MiddleInitial`, `s`.`Id` AS `Id0`, `s`.`Age` AS `Age0`, `s`.`PersonId`, `s`.`Style` + FROM `Person` AS `p0` + LEFT JOIN `Shoes` AS `s` ON `p0`.`Id` = `s`.`PersonId` + ) AS `s0` ON `p1`.`FirstName` = `s0`.`FirstName` + ORDER BY `p1`.`FirstName`, `s0`.`Id` + """); } public override async Task Whats_new_2021_sample_10(bool async) @@ -651,21 +648,21 @@ public override async Task Whats_new_2021_sample_10(bool async) await base.Whats_new_2021_sample_10(async); AssertSql( -""" -SELECT `t`.`Id`, `t`.`Age`, `t`.`Style`, `t0`.`Id`, `t0`.`Style`, `t0`.`Age`, `t0`.`Id0` -FROM ( - SELECT `p`.`Id`, `s`.`Age`, `s`.`Style` - FROM `Person` AS `p` - INNER JOIN `Shoes` AS `s` ON `p`.`Age` = `s`.`Age` - GROUP BY `p`.`Id`, `s`.`Style`, `s`.`Age` -) AS `t` -LEFT JOIN ( - SELECT `s0`.`Id`, `s0`.`Style`, `s0`.`Age`, `p0`.`Id` AS `Id0` - FROM `Person` AS `p0` - INNER JOIN `Shoes` AS `s0` ON `p0`.`Age` = `s0`.`Age` -) AS `t0` ON ((`t`.`Id` = `t0`.`Id0`) AND ((`t`.`Style` = `t0`.`Style`) OR (`t`.`Style` IS NULL AND (`t0`.`Style` IS NULL)))) AND (`t`.`Age` = `t0`.`Age`) -ORDER BY `t`.`Id`, `t`.`Style`, `t`.`Age`, `t0`.`Id0` -"""); + """ + SELECT `s1`.`Id`, `s1`.`Age`, `s1`.`Style`, `s2`.`Id`, `s2`.`Style`, `s2`.`Age`, `s2`.`Id0` + FROM ( + SELECT `p`.`Id`, `s`.`Age`, `s`.`Style` + FROM `Person` AS `p` + INNER JOIN `Shoes` AS `s` ON `p`.`Age` = `s`.`Age` + GROUP BY `p`.`Id`, `s`.`Style`, `s`.`Age` + ) AS `s1` + LEFT JOIN ( + SELECT `s0`.`Id`, `s0`.`Style`, `s0`.`Age`, `p0`.`Id` AS `Id0` + FROM `Person` AS `p0` + INNER JOIN `Shoes` AS `s0` ON `p0`.`Age` = `s0`.`Age` + ) AS `s2` ON ((`s1`.`Id` = `s2`.`Id0`) AND ((`s1`.`Style` = `s2`.`Style`) OR (`s1`.`Style` IS NULL AND (`s2`.`Style` IS NULL)))) AND (`s1`.`Age` = `s2`.`Age`) + ORDER BY `s1`.`Id`, `s1`.`Style`, `s1`.`Age`, `s2`.`Id0` + """); } public override async Task Whats_new_2021_sample_13(bool async) @@ -673,16 +670,16 @@ public override async Task Whats_new_2021_sample_13(bool async) await base.Whats_new_2021_sample_13(async); AssertSql( -""" -SELECT `t`.`FirstName`, `t`.`MiddleInitial`, `p0`.`Id`, `p0`.`Age`, `p0`.`FirstName`, `p0`.`LastName`, `p0`.`MiddleInitial` -FROM ( - SELECT `p`.`FirstName`, `p`.`MiddleInitial` - FROM `Person` AS `p` - GROUP BY `p`.`FirstName`, `p`.`MiddleInitial` -) AS `t` -LEFT JOIN `Person` AS `p0` ON ((`t`.`FirstName` = `p0`.`FirstName`) OR (`t`.`FirstName` IS NULL AND (`p0`.`FirstName` IS NULL))) AND ((`t`.`MiddleInitial` = `p0`.`MiddleInitial`) OR (`t`.`MiddleInitial` IS NULL AND (`p0`.`MiddleInitial` IS NULL))) -ORDER BY `t`.`FirstName`, `t`.`MiddleInitial`, `p0`.`Id` -"""); + """ + SELECT `p1`.`FirstName`, `p1`.`MiddleInitial`, `p0`.`Id`, `p0`.`Age`, `p0`.`FirstName`, `p0`.`LastName`, `p0`.`MiddleInitial` + FROM ( + SELECT `p`.`FirstName`, `p`.`MiddleInitial` + FROM `Person` AS `p` + GROUP BY `p`.`FirstName`, `p`.`MiddleInitial` + ) AS `p1` + LEFT JOIN `Person` AS `p0` ON ((`p1`.`FirstName` = `p0`.`FirstName`) OR (`p1`.`FirstName` IS NULL AND (`p0`.`FirstName` IS NULL))) AND ((`p1`.`MiddleInitial` = `p0`.`MiddleInitial`) OR (`p1`.`MiddleInitial` IS NULL AND (`p0`.`MiddleInitial` IS NULL))) + ORDER BY `p1`.`FirstName`, `p1`.`MiddleInitial`, `p0`.`Id` + """); } public override async Task Cross_Join_with_Group_Join_from_LINQ_101(bool async) @@ -690,15 +687,15 @@ public override async Task Cross_Join_with_Group_Join_from_LINQ_101(bool async) await base.Cross_Join_with_Group_Join_from_LINQ_101(async); AssertSql( -""" -SELECT `c`.`Id`, `c`.`CompanyName`, `c`.`Region`, `t`.`Id` -FROM `CustomerForLinq` AS `c` -INNER JOIN ( - SELECT `o`.`Id`, `c0`.`Id` AS `Id0` - FROM `OrderForLinq` AS `o` - LEFT JOIN `CustomerForLinq` AS `c0` ON `o`.`CustomerId` = `c0`.`Id` -) AS `t` ON `c`.`Id` = `t`.`Id0` -"""); + """ + SELECT `c`.`Id`, `c`.`CompanyName`, `c`.`Region`, `s`.`Id` + FROM `CustomerForLinq` AS `c` + INNER JOIN ( + SELECT `o`.`Id`, `c0`.`Id` AS `Id0` + FROM `OrderForLinq` AS `o` + LEFT JOIN `CustomerForLinq` AS `c0` ON `o`.`CustomerId` = `c0`.`Id` + ) AS `s` ON `c`.`Id` = `s`.`Id0` + """); } public override async Task Whats_new_2021_sample_2(bool async) @@ -706,25 +703,25 @@ public override async Task Whats_new_2021_sample_2(bool async) await base.Whats_new_2021_sample_2(async); AssertSql( -""" -SELECT `t0`.`FirstName`, `t0`.`FullName`, `t0`.`c` -FROM ( - SELECT `p`.`FirstName` - FROM `Person` AS `p` - GROUP BY `p`.`FirstName` - ORDER BY `p`.`FirstName` - LIMIT 1 -) AS `t` -LEFT JOIN ( - SELECT `t1`.`FirstName`, `t1`.`FullName`, `t1`.`c` - FROM ( - SELECT `p0`.`FirstName`, CONCAT(CONCAT(CONCAT(CONCAT(COALESCE(`p0`.`FirstName`, ''), ' '), COALESCE(`p0`.`MiddleInitial`, '')), ' '), COALESCE(`p0`.`LastName`, '')) AS `FullName`, 1 AS `c`, ROW_NUMBER() OVER(PARTITION BY `p0`.`FirstName` ORDER BY `p0`.`Id`) AS `row` - FROM `Person` AS `p0` - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`FirstName` = `t0`.`FirstName` -ORDER BY `t`.`FirstName` -"""); + """ + SELECT `p3`.`FirstName`, `p3`.`FullName`, `p3`.`c` + FROM ( + SELECT `p`.`FirstName` + FROM `Person` AS `p` + GROUP BY `p`.`FirstName` + ORDER BY `p`.`FirstName` + LIMIT 1 + ) AS `p1` + LEFT JOIN ( + SELECT `p2`.`FirstName`, `p2`.`FullName`, `p2`.`c` + FROM ( + SELECT `p0`.`FirstName`, CONCAT(CONCAT(CONCAT(CONCAT(COALESCE(`p0`.`FirstName`, ''), ' '), COALESCE(`p0`.`MiddleInitial`, '')), ' '), COALESCE(`p0`.`LastName`, '')) AS `FullName`, 1 AS `c`, ROW_NUMBER() OVER(PARTITION BY `p0`.`FirstName` ORDER BY `p0`.`Id`) AS `row` + FROM `Person` AS `p0` + ) AS `p2` + WHERE `p2`.`row` <= 1 + ) AS `p3` ON `p1`.`FirstName` = `p3`.`FirstName` + ORDER BY `p1`.`FirstName` + """); } public override async Task Whats_new_2021_sample_1(bool async) @@ -732,24 +729,24 @@ public override async Task Whats_new_2021_sample_1(bool async) await base.Whats_new_2021_sample_1(async); AssertSql( -""" -SELECT `t0`.`Id`, `t0`.`Age`, `t0`.`FirstName`, `t0`.`LastName`, `t0`.`MiddleInitial`, `t`.`FirstName`, `s`.`Id`, `s`.`Age`, `s`.`PersonId`, `s`.`Style` -FROM ( - SELECT `p`.`FirstName` - FROM `Person` AS `p` - GROUP BY `p`.`FirstName` -) AS `t` -LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`Age`, `t1`.`FirstName`, `t1`.`LastName`, `t1`.`MiddleInitial` - FROM ( - SELECT `p0`.`Id`, `p0`.`Age`, `p0`.`FirstName`, `p0`.`LastName`, `p0`.`MiddleInitial`, ROW_NUMBER() OVER(PARTITION BY `p0`.`FirstName` ORDER BY `p0`.`FirstName`, `p0`.`LastName`) AS `row` - FROM `Person` AS `p0` - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`FirstName` = `t0`.`FirstName` -LEFT JOIN `Shoes` AS `s` ON `t0`.`Id` = `s`.`PersonId` -ORDER BY `t`.`FirstName`, `t0`.`Id` -"""); + """ + SELECT `p3`.`Id`, `p3`.`Age`, `p3`.`FirstName`, `p3`.`LastName`, `p3`.`MiddleInitial`, `p1`.`FirstName`, `s`.`Id`, `s`.`Age`, `s`.`PersonId`, `s`.`Style` + FROM ( + SELECT `p`.`FirstName` + FROM `Person` AS `p` + GROUP BY `p`.`FirstName` + ) AS `p1` + LEFT JOIN ( + SELECT `p2`.`Id`, `p2`.`Age`, `p2`.`FirstName`, `p2`.`LastName`, `p2`.`MiddleInitial` + FROM ( + SELECT `p0`.`Id`, `p0`.`Age`, `p0`.`FirstName`, `p0`.`LastName`, `p0`.`MiddleInitial`, ROW_NUMBER() OVER(PARTITION BY `p0`.`FirstName` ORDER BY `p0`.`FirstName`, `p0`.`LastName`) AS `row` + FROM `Person` AS `p0` + ) AS `p2` + WHERE `p2`.`row` <= 1 + ) AS `p3` ON `p1`.`FirstName` = `p3`.`FirstName` + LEFT JOIN `Shoes` AS `s` ON `p3`.`Id` = `s`.`PersonId` + ORDER BY `p1`.`FirstName`, `p3`.`Id` + """); } [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed")] @@ -853,20 +850,20 @@ public override async Task Left_Outer_Join_with_Group_Join_from_LINQ_101(bool as await base.Left_Outer_Join_with_Group_Join_from_LINQ_101(async); AssertSql( -""" -SELECT `c`.`Id`, `c`.`CompanyName`, `c`.`Region`, `t`.`Id`, `t`.`Id0`, `o0`.`Id`, `o0`.`CustomerId`, `o0`.`OrderDate`, `o0`.`Total`, CASE - WHEN `t`.`Id` IS NULL THEN -1 - ELSE `t`.`Id` -END -FROM `CustomerForLinq` AS `c` -LEFT JOIN ( - SELECT `o`.`Id`, `c0`.`Id` AS `Id0` - FROM `OrderForLinq` AS `o` - LEFT JOIN `CustomerForLinq` AS `c0` ON `o`.`CustomerId` = `c0`.`Id` -) AS `t` ON `c`.`Id` = `t`.`Id0` -LEFT JOIN `OrderForLinq` AS `o0` ON `c`.`Id` = `o0`.`CustomerId` -ORDER BY `c`.`Id`, `t`.`Id`, `t`.`Id0` -"""); + """ + SELECT `c`.`Id`, `c`.`CompanyName`, `c`.`Region`, `s`.`Id`, `s`.`Id0`, `o0`.`Id`, `o0`.`CustomerId`, `o0`.`OrderDate`, `o0`.`Total`, CASE + WHEN `s`.`Id` IS NULL THEN -1 + ELSE `s`.`Id` + END + FROM `CustomerForLinq` AS `c` + LEFT JOIN ( + SELECT `o`.`Id`, `c0`.`Id` AS `Id0` + FROM `OrderForLinq` AS `o` + LEFT JOIN `CustomerForLinq` AS `c0` ON `o`.`CustomerId` = `c0`.`Id` + ) AS `s` ON `c`.`Id` = `s`.`Id0` + LEFT JOIN `OrderForLinq` AS `o0` ON `c`.`Id` = `o0`.`CustomerId` + ORDER BY `c`.`Id`, `s`.`Id`, `s`.`Id0` + """); } public override async Task Max_Grouped_from_LINQ_101(bool async) @@ -886,37 +883,37 @@ public override async Task Whats_new_2021_sample_11(bool async) await base.Whats_new_2021_sample_11(async); AssertSql( -""" -SELECT `t`.`LastName`, `t`.`c`, `t0`.`Id`, `t2`.`Id`, `t2`.`Age`, `t2`.`FirstName`, `t2`.`LastName`, `t2`.`MiddleInitial`, `t0`.`Age`, `t0`.`FirstName`, `t0`.`LastName`, `t0`.`MiddleInitial` -FROM ( - SELECT `p`.`LastName`, COUNT(*) AS `c` - FROM `Person` AS `p` - GROUP BY `p`.`LastName` -) AS `t` -LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`Age`, `t1`.`FirstName`, `t1`.`LastName`, `t1`.`MiddleInitial` - FROM ( - SELECT `p0`.`Id`, `p0`.`Age`, `p0`.`FirstName`, `p0`.`LastName`, `p0`.`MiddleInitial`, ROW_NUMBER() OVER(PARTITION BY `p0`.`LastName` ORDER BY `p0`.`Id`) AS `row` - FROM `Person` AS `p0` - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`LastName` = `t0`.`LastName` -LEFT JOIN ( - SELECT `t3`.`Id`, `t3`.`Age`, `t3`.`FirstName`, `t3`.`LastName`, `t3`.`MiddleInitial` - FROM ( - SELECT `p1`.`Id`, `p1`.`Age`, `p1`.`FirstName`, `p1`.`LastName`, `p1`.`MiddleInitial`, ROW_NUMBER() OVER(PARTITION BY `p1`.`LastName` ORDER BY `p1`.`Id`) AS `row` - FROM `Person` AS `p1` - ) AS `t3` - WHERE `t3`.`row` <= 2 -) AS `t2` ON `t`.`LastName` = `t2`.`LastName` -ORDER BY `t`.`LastName` DESC, `t0`.`Id`, `t2`.`LastName`, `t2`.`Id` -"""); + """ + SELECT `p2`.`LastName`, `p2`.`c`, `p4`.`Id`, `p6`.`Id`, `p6`.`Age`, `p6`.`FirstName`, `p6`.`LastName`, `p6`.`MiddleInitial`, `p4`.`Age`, `p4`.`FirstName`, `p4`.`LastName`, `p4`.`MiddleInitial` + FROM ( + SELECT `p`.`LastName`, COUNT(*) AS `c` + FROM `Person` AS `p` + GROUP BY `p`.`LastName` + ) AS `p2` + LEFT JOIN ( + SELECT `p3`.`Id`, `p3`.`Age`, `p3`.`FirstName`, `p3`.`LastName`, `p3`.`MiddleInitial` + FROM ( + SELECT `p0`.`Id`, `p0`.`Age`, `p0`.`FirstName`, `p0`.`LastName`, `p0`.`MiddleInitial`, ROW_NUMBER() OVER(PARTITION BY `p0`.`LastName` ORDER BY `p0`.`Id`) AS `row` + FROM `Person` AS `p0` + ) AS `p3` + WHERE `p3`.`row` <= 1 + ) AS `p4` ON `p2`.`LastName` = `p4`.`LastName` + LEFT JOIN ( + SELECT `p5`.`Id`, `p5`.`Age`, `p5`.`FirstName`, `p5`.`LastName`, `p5`.`MiddleInitial` + FROM ( + SELECT `p1`.`Id`, `p1`.`Age`, `p1`.`FirstName`, `p1`.`LastName`, `p1`.`MiddleInitial`, ROW_NUMBER() OVER(PARTITION BY `p1`.`LastName` ORDER BY `p1`.`Id`) AS `row` + FROM `Person` AS `p1` + ) AS `p5` + WHERE `p5`.`row` <= 2 + ) AS `p6` ON `p2`.`LastName` = `p6`.`LastName` + ORDER BY `p2`.`LastName` DESC, `p4`.`Id`, `p6`.`LastName`, `p6`.`Id` + """); } private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - public class Ef6GroupBySingleStoreFixture : Ef6GroupByFixtureBase + public class Ef6GroupBySingleStoreFixture : Ef6GroupByFixtureBase, ITestSqlLoggerFactory { public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/EntitySplittingQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/EntitySplittingQuerySingleStoreTest.cs index c403b2d27..9075bae25 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/EntitySplittingQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/EntitySplittingQuerySingleStoreTest.cs @@ -17,7 +17,7 @@ public EntitySplittingQuerySingleStoreTest(ITestOutputHelper testOutputHelper) [ConditionalFact] public virtual void Check_all_tests_overridden() - => TestHelpers.AssertAllMethodsOverridden(GetType()); + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); public override async Task Can_query_entity_which_is_split_in_two(bool async) { @@ -60,11 +60,11 @@ public override async Task Can_query_entity_which_is_split_selecting_only_part_2 await base.Can_query_entity_which_is_split_selecting_only_part_2_properties(async); AssertSql( -""" -SELECT `e`.`Id`, `s0`.`IntValue3`, `s0`.`StringValue3` -FROM `EntityOne` AS `e` -INNER JOIN `SplitEntityOnePart2` AS `s0` ON `e`.`Id` = `s0`.`Id` -"""); + """ + SELECT `e`.`Id`, `s`.`IntValue3`, `s`.`StringValue3` + FROM `EntityOne` AS `e` + INNER JOIN `SplitEntityOnePart2` AS `s` ON `e`.`Id` = `s`.`Id` + """); } public override async Task Can_query_entity_which_is_split_selecting_only_part_3_properties(bool async) @@ -72,11 +72,11 @@ public override async Task Can_query_entity_which_is_split_selecting_only_part_3 await base.Can_query_entity_which_is_split_selecting_only_part_3_properties(async); AssertSql( -""" -SELECT `e`.`Id`, `s`.`IntValue4`, `s`.`StringValue4` -FROM `EntityOne` AS `e` -INNER JOIN `SplitEntityOnePart3` AS `s` ON `e`.`Id` = `s`.`Id` -"""); + """ + SELECT `e`.`Id`, `s`.`IntValue4`, `s`.`StringValue4` + FROM `EntityOne` AS `e` + INNER JOIN `SplitEntityOnePart3` AS `s` ON `e`.`Id` = `s`.`Id` + """); } public override async Task Include_reference_to_split_entity(bool async) @@ -84,16 +84,16 @@ public override async Task Include_reference_to_split_entity(bool async) await base.Include_reference_to_split_entity(async); AssertSql( -""" -SELECT `e`.`Id`, `e`.`EntityOneId`, `e`.`Name`, `t`.`Id`, `t`.`EntityThreeId`, `t`.`IntValue1`, `t`.`IntValue2`, `t`.`IntValue3`, `t`.`IntValue4`, `t`.`StringValue1`, `t`.`StringValue2`, `t`.`StringValue3`, `t`.`StringValue4` -FROM `EntityTwo` AS `e` -LEFT JOIN ( - SELECT `e0`.`Id`, `e0`.`EntityThreeId`, `e0`.`IntValue1`, `e0`.`IntValue2`, `s0`.`IntValue3`, `s`.`IntValue4`, `e0`.`StringValue1`, `e0`.`StringValue2`, `s0`.`StringValue3`, `s`.`StringValue4` - FROM `EntityOne` AS `e0` - INNER JOIN `SplitEntityOnePart3` AS `s` ON `e0`.`Id` = `s`.`Id` - INNER JOIN `SplitEntityOnePart2` AS `s0` ON `e0`.`Id` = `s0`.`Id` -) AS `t` ON `e`.`EntityOneId` = `t`.`Id` -"""); + """ + SELECT `e`.`Id`, `e`.`EntityOneId`, `e`.`Name`, `s1`.`Id`, `s1`.`EntityThreeId`, `s1`.`IntValue1`, `s1`.`IntValue2`, `s1`.`IntValue3`, `s1`.`IntValue4`, `s1`.`StringValue1`, `s1`.`StringValue2`, `s1`.`StringValue3`, `s1`.`StringValue4` + FROM `EntityTwo` AS `e` + LEFT JOIN ( + SELECT `e0`.`Id`, `e0`.`EntityThreeId`, `e0`.`IntValue1`, `e0`.`IntValue2`, `s0`.`IntValue3`, `s`.`IntValue4`, `e0`.`StringValue1`, `e0`.`StringValue2`, `s0`.`StringValue3`, `s`.`StringValue4` + FROM `EntityOne` AS `e0` + INNER JOIN `SplitEntityOnePart3` AS `s` ON `e0`.`Id` = `s`.`Id` + INNER JOIN `SplitEntityOnePart2` AS `s0` ON `e0`.`Id` = `s0`.`Id` + ) AS `s1` ON `e`.`EntityOneId` = `s1`.`Id` + """); } public override async Task Include_collection_to_split_entity(bool async) @@ -102,14 +102,14 @@ public override async Task Include_collection_to_split_entity(bool async) AssertSql( """ -SELECT `e`.`Id`, `e`.`Name`, `t`.`Id`, `t`.`EntityThreeId`, `t`.`IntValue1`, `t`.`IntValue2`, `t`.`IntValue3`, `t`.`IntValue4`, `t`.`StringValue1`, `t`.`StringValue2`, `t`.`StringValue3`, `t`.`StringValue4` +SELECT `e`.`Id`, `e`.`Name`, `s1`.`Id`, `s1`.`EntityThreeId`, `s1`.`IntValue1`, `s1`.`IntValue2`, `s1`.`IntValue3`, `s1`.`IntValue4`, `s1`.`StringValue1`, `s1`.`StringValue2`, `s1`.`StringValue3`, `s1`.`StringValue4` FROM `EntityThree` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`EntityThreeId`, `e0`.`IntValue1`, `e0`.`IntValue2`, `s0`.`IntValue3`, `s`.`IntValue4`, `e0`.`StringValue1`, `e0`.`StringValue2`, `s0`.`StringValue3`, `s`.`StringValue4` FROM `EntityOne` AS `e0` INNER JOIN `SplitEntityOnePart3` AS `s` ON `e0`.`Id` = `s`.`Id` INNER JOIN `SplitEntityOnePart2` AS `s0` ON `e0`.`Id` = `s0`.`Id` -) AS `t` ON `e`.`Id` = `t`.`EntityThreeId` +) AS `s1` ON `e`.`Id` = `s1`.`EntityThreeId` ORDER BY `e`.`Id` """); } @@ -120,15 +120,15 @@ public override async Task Include_reference_to_split_entity_including_reference AssertSql( """ -SELECT `e`.`Id`, `e`.`EntityOneId`, `e`.`Name`, `t`.`Id`, `t`.`EntityThreeId`, `t`.`IntValue1`, `t`.`IntValue2`, `t`.`IntValue3`, `t`.`IntValue4`, `t`.`StringValue1`, `t`.`StringValue2`, `t`.`StringValue3`, `t`.`StringValue4`, `e1`.`Id`, `e1`.`Name` +SELECT `e`.`Id`, `e`.`EntityOneId`, `e`.`Name`, `s1`.`Id`, `s1`.`EntityThreeId`, `s1`.`IntValue1`, `s1`.`IntValue2`, `s1`.`IntValue3`, `s1`.`IntValue4`, `s1`.`StringValue1`, `s1`.`StringValue2`, `s1`.`StringValue3`, `s1`.`StringValue4`, `e1`.`Id`, `e1`.`Name` FROM `EntityTwo` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`EntityThreeId`, `e0`.`IntValue1`, `e0`.`IntValue2`, `s0`.`IntValue3`, `s`.`IntValue4`, `e0`.`StringValue1`, `e0`.`StringValue2`, `s0`.`StringValue3`, `s`.`StringValue4` FROM `EntityOne` AS `e0` INNER JOIN `SplitEntityOnePart3` AS `s` ON `e0`.`Id` = `s`.`Id` INNER JOIN `SplitEntityOnePart2` AS `s0` ON `e0`.`Id` = `s0`.`Id` -) AS `t` ON `e`.`EntityOneId` = `t`.`Id` -LEFT JOIN `EntityThree` AS `e1` ON `t`.`EntityThreeId` = `e1`.`Id` +) AS `s1` ON `e`.`EntityOneId` = `s1`.`Id` +LEFT JOIN `EntityThree` AS `e1` ON `s1`.`EntityThreeId` = `e1`.`Id` """); } @@ -138,7 +138,7 @@ public override async Task Include_collection_to_split_entity_including_collecti AssertSql( """ -SELECT `e`.`Id`, `e`.`Name`, `t`.`Id`, `t`.`EntityThreeId`, `t`.`IntValue1`, `t`.`IntValue2`, `t`.`IntValue3`, `t`.`IntValue4`, `t`.`StringValue1`, `t`.`StringValue2`, `t`.`StringValue3`, `t`.`StringValue4`, `t`.`Id0`, `t`.`EntityOneId`, `t`.`Name` +SELECT `e`.`Id`, `e`.`Name`, `s1`.`Id`, `s1`.`EntityThreeId`, `s1`.`IntValue1`, `s1`.`IntValue2`, `s1`.`IntValue3`, `s1`.`IntValue4`, `s1`.`StringValue1`, `s1`.`StringValue2`, `s1`.`StringValue3`, `s1`.`StringValue4`, `s1`.`Id0`, `s1`.`EntityOneId`, `s1`.`Name` FROM `EntityThree` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`EntityThreeId`, `e0`.`IntValue1`, `e0`.`IntValue2`, `s0`.`IntValue3`, `s`.`IntValue4`, `e0`.`StringValue1`, `e0`.`StringValue2`, `s0`.`StringValue3`, `s`.`StringValue4`, `e1`.`Id` AS `Id0`, `e1`.`EntityOneId`, `e1`.`Name` @@ -146,8 +146,8 @@ LEFT JOIN ( INNER JOIN `SplitEntityOnePart3` AS `s` ON `e0`.`Id` = `s`.`Id` INNER JOIN `SplitEntityOnePart2` AS `s0` ON `e0`.`Id` = `s0`.`Id` LEFT JOIN `EntityTwo` AS `e1` ON `e0`.`Id` = `e1`.`EntityOneId` -) AS `t` ON `e`.`Id` = `t`.`EntityThreeId` -ORDER BY `e`.`Id`, `t`.`Id` +) AS `s1` ON `e`.`Id` = `s1`.`EntityThreeId` +ORDER BY `e`.`Id`, `s1`.`Id` """); } @@ -185,12 +185,12 @@ public override async Task Custom_projection_trim_when_multiple_tables(bool asyn await base.Custom_projection_trim_when_multiple_tables(async); AssertSql( -""" -SELECT `e`.`IntValue1`, `s0`.`IntValue3`, `e0`.`Id`, `e0`.`Name` -FROM `EntityOne` AS `e` -INNER JOIN `SplitEntityOnePart2` AS `s0` ON `e`.`Id` = `s0`.`Id` -LEFT JOIN `EntityThree` AS `e0` ON `e`.`EntityThreeId` = `e0`.`Id` -"""); + """ + SELECT `e`.`IntValue1`, `s`.`IntValue3`, `e0`.`Id`, `e0`.`Name` + FROM `EntityOne` AS `e` + INNER JOIN `SplitEntityOnePart2` AS `s` ON `e`.`Id` = `s`.`Id` + LEFT JOIN `EntityThree` AS `e0` ON `e`.`EntityThreeId` = `e0`.`Id` + """); } public override async Task Normal_entity_owning_a_split_reference_with_main_fragment_sharing(bool async) @@ -454,7 +454,7 @@ public override async Task Tpc_entity_owning_a_split_reference_on_leaf_with_tabl AssertSql( """ -SELECT `t`.`Id`, `t`.`BaseValue`, `t`.`MiddleValue`, `t`.`SiblingValue`, `t`.`LeafValue`, `t`.`Discriminator`, `l`.`Id`, `l`.`OwnedReference_Id`, `l`.`OwnedReference_OwnedIntValue1`, `l`.`OwnedReference_OwnedIntValue2`, `o0`.`OwnedIntValue3`, `o`.`OwnedIntValue4`, `l`.`OwnedReference_OwnedStringValue1`, `l`.`OwnedReference_OwnedStringValue2`, `o0`.`OwnedStringValue3`, `o`.`OwnedStringValue4` +SELECT `u`.`Id`, `u`.`BaseValue`, `u`.`MiddleValue`, `u`.`SiblingValue`, `u`.`LeafValue`, `u`.`Discriminator`, `l0`.`Id`, `l0`.`OwnedReference_Id`, `l0`.`OwnedReference_OwnedIntValue1`, `l0`.`OwnedReference_OwnedIntValue2`, `o0`.`OwnedIntValue3`, `o`.`OwnedIntValue4`, `l0`.`OwnedReference_OwnedStringValue1`, `l0`.`OwnedReference_OwnedStringValue2`, `o0`.`OwnedStringValue3`, `o`.`OwnedStringValue4` FROM ( SELECT `b`.`Id`, `b`.`BaseValue`, NULL AS `MiddleValue`, NULL AS `SiblingValue`, NULL AS `LeafValue`, 'BaseEntity' AS `Discriminator` FROM `BaseEntity` AS `b` @@ -465,12 +465,12 @@ UNION ALL SELECT `s`.`Id`, `s`.`BaseValue`, NULL AS `MiddleValue`, `s`.`SiblingValue`, NULL AS `LeafValue`, 'SiblingEntity' AS `Discriminator` FROM `SiblingEntity` AS `s` UNION ALL - SELECT `l0`.`Id`, `l0`.`BaseValue`, `l0`.`MiddleValue`, NULL AS `SiblingValue`, `l0`.`LeafValue`, 'LeafEntity' AS `Discriminator` - FROM `LeafEntity` AS `l0` -) AS `t` -LEFT JOIN `LeafEntity` AS `l` ON `t`.`Id` = `l`.`Id` -LEFT JOIN `OwnedReferencePart4` AS `o` ON `l`.`Id` = `o`.`LeafEntityId` -LEFT JOIN `OwnedReferencePart3` AS `o0` ON `l`.`Id` = `o0`.`LeafEntityId` + SELECT `l`.`Id`, `l`.`BaseValue`, `l`.`MiddleValue`, NULL AS `SiblingValue`, `l`.`LeafValue`, 'LeafEntity' AS `Discriminator` + FROM `LeafEntity` AS `l` +) AS `u` +LEFT JOIN `LeafEntity` AS `l0` ON `u`.`Id` = `l0`.`Id` +LEFT JOIN `OwnedReferencePart4` AS `o` ON `l0`.`Id` = `o`.`LeafEntityId` +LEFT JOIN `OwnedReferencePart3` AS `o0` ON `l0`.`Id` = `o0`.`LeafEntityId` """); } @@ -555,10 +555,10 @@ public override async Task Tpc_entity_owning_a_split_reference_on_leaf_with_tabl await base.Tpc_entity_owning_a_split_reference_on_leaf_with_table_sharing_querying_sibling(async); AssertSql( -""" -SELECT `s`.`Id`, `s`.`BaseValue`, `s`.`SiblingValue` -FROM `SiblingEntity` AS `s` -"""); + """ + SELECT `s`.`Id`, `s`.`BaseValue`, `s`.`SiblingValue` + FROM `SiblingEntity` AS `s` + """); } [ConditionalTheory(Skip = "Issue29075")] @@ -583,7 +583,7 @@ public override async Task Tpc_entity_owning_a_split_reference_on_base_without_t AssertSql( """ -SELECT `t`.`Id`, `t`.`BaseValue`, `t`.`MiddleValue`, `t`.`SiblingValue`, `t`.`LeafValue`, `t`.`Discriminator`, `o`.`BaseEntityId`, `o`.`Id`, `o`.`OwnedIntValue1`, `o`.`OwnedIntValue2`, `o1`.`OwnedIntValue3`, `o0`.`OwnedIntValue4`, `o`.`OwnedStringValue1`, `o`.`OwnedStringValue2`, `o1`.`OwnedStringValue3`, `o0`.`OwnedStringValue4` +SELECT `u`.`Id`, `u`.`BaseValue`, `u`.`MiddleValue`, `u`.`SiblingValue`, `u`.`LeafValue`, `u`.`Discriminator`, `o`.`BaseEntityId`, `o`.`Id`, `o`.`OwnedIntValue1`, `o`.`OwnedIntValue2`, `o1`.`OwnedIntValue3`, `o0`.`OwnedIntValue4`, `o`.`OwnedStringValue1`, `o`.`OwnedStringValue2`, `o1`.`OwnedStringValue3`, `o0`.`OwnedStringValue4` FROM ( SELECT `b`.`Id`, `b`.`BaseValue`, NULL AS `MiddleValue`, NULL AS `SiblingValue`, NULL AS `LeafValue`, 'BaseEntity' AS `Discriminator` FROM `BaseEntity` AS `b` @@ -596,8 +596,8 @@ UNION ALL UNION ALL SELECT `l`.`Id`, `l`.`BaseValue`, `l`.`MiddleValue`, NULL AS `SiblingValue`, `l`.`LeafValue`, 'LeafEntity' AS `Discriminator` FROM `LeafEntity` AS `l` -) AS `t` -LEFT JOIN `OwnedReferencePart1` AS `o` ON `t`.`Id` = `o`.`BaseEntityId` +) AS `u` +LEFT JOIN `OwnedReferencePart1` AS `o` ON `u`.`Id` = `o`.`BaseEntityId` LEFT JOIN `OwnedReferencePart4` AS `o0` ON `o`.`BaseEntityId` = `o0`.`BaseEntityId` LEFT JOIN `OwnedReferencePart3` AS `o1` ON `o`.`BaseEntityId` = `o1`.`BaseEntityId` """); @@ -625,7 +625,7 @@ public override async Task Tpc_entity_owning_a_split_reference_on_middle_without AssertSql( """ -SELECT `t`.`Id`, `t`.`BaseValue`, `t`.`MiddleValue`, `t`.`SiblingValue`, `t`.`LeafValue`, `t`.`Discriminator`, `o`.`MiddleEntityId`, `o`.`Id`, `o`.`OwnedIntValue1`, `o`.`OwnedIntValue2`, `o1`.`OwnedIntValue3`, `o0`.`OwnedIntValue4`, `o`.`OwnedStringValue1`, `o`.`OwnedStringValue2`, `o1`.`OwnedStringValue3`, `o0`.`OwnedStringValue4` +SELECT `u`.`Id`, `u`.`BaseValue`, `u`.`MiddleValue`, `u`.`SiblingValue`, `u`.`LeafValue`, `u`.`Discriminator`, `o`.`MiddleEntityId`, `o`.`Id`, `o`.`OwnedIntValue1`, `o`.`OwnedIntValue2`, `o1`.`OwnedIntValue3`, `o0`.`OwnedIntValue4`, `o`.`OwnedStringValue1`, `o`.`OwnedStringValue2`, `o1`.`OwnedStringValue3`, `o0`.`OwnedStringValue4` FROM ( SELECT `b`.`Id`, `b`.`BaseValue`, NULL AS `MiddleValue`, NULL AS `SiblingValue`, NULL AS `LeafValue`, 'BaseEntity' AS `Discriminator` FROM `BaseEntity` AS `b` @@ -638,8 +638,8 @@ UNION ALL UNION ALL SELECT `l`.`Id`, `l`.`BaseValue`, `l`.`MiddleValue`, NULL AS `SiblingValue`, `l`.`LeafValue`, 'LeafEntity' AS `Discriminator` FROM `LeafEntity` AS `l` -) AS `t` -LEFT JOIN `OwnedReferencePart1` AS `o` ON `t`.`Id` = `o`.`MiddleEntityId` +) AS `u` +LEFT JOIN `OwnedReferencePart1` AS `o` ON `u`.`Id` = `o`.`MiddleEntityId` LEFT JOIN `OwnedReferencePart4` AS `o0` ON `o`.`MiddleEntityId` = `o0`.`MiddleEntityId` LEFT JOIN `OwnedReferencePart3` AS `o1` ON `o`.`MiddleEntityId` = `o1`.`MiddleEntityId` """); @@ -691,7 +691,7 @@ public override async Task Tpc_entity_owning_a_split_collection_on_base(bool asy AssertSql( """ -SELECT `t`.`Id`, `t`.`BaseValue`, `t`.`MiddleValue`, `t`.`SiblingValue`, `t`.`LeafValue`, `t`.`Discriminator`, `t0`.`BaseEntityId`, `t0`.`Id`, `t0`.`OwnedIntValue1`, `t0`.`OwnedIntValue2`, `t0`.`OwnedIntValue3`, `t0`.`OwnedIntValue4`, `t0`.`OwnedStringValue1`, `t0`.`OwnedStringValue2`, `t0`.`OwnedStringValue3`, `t0`.`OwnedStringValue4` +SELECT `u`.`Id`, `u`.`BaseValue`, `u`.`MiddleValue`, `u`.`SiblingValue`, `u`.`LeafValue`, `u`.`Discriminator`, `s0`.`BaseEntityId`, `s0`.`Id`, `s0`.`OwnedIntValue1`, `s0`.`OwnedIntValue2`, `s0`.`OwnedIntValue3`, `s0`.`OwnedIntValue4`, `s0`.`OwnedStringValue1`, `s0`.`OwnedStringValue2`, `s0`.`OwnedStringValue3`, `s0`.`OwnedStringValue4` FROM ( SELECT `b`.`Id`, `b`.`BaseValue`, NULL AS `MiddleValue`, NULL AS `SiblingValue`, NULL AS `LeafValue`, 'BaseEntity' AS `Discriminator` FROM `BaseEntity` AS `b` @@ -704,14 +704,14 @@ UNION ALL UNION ALL SELECT `l`.`Id`, `l`.`BaseValue`, `l`.`MiddleValue`, NULL AS `SiblingValue`, `l`.`LeafValue`, 'LeafEntity' AS `Discriminator` FROM `LeafEntity` AS `l` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `o`.`BaseEntityId`, `o`.`Id`, `o`.`OwnedIntValue1`, `o`.`OwnedIntValue2`, `o1`.`OwnedIntValue3`, `o0`.`OwnedIntValue4`, `o`.`OwnedStringValue1`, `o`.`OwnedStringValue2`, `o1`.`OwnedStringValue3`, `o0`.`OwnedStringValue4` FROM `OwnedReferencePart1` AS `o` INNER JOIN `OwnedReferencePart4` AS `o0` ON (`o`.`BaseEntityId` = `o0`.`BaseEntityId`) AND (`o`.`Id` = `o0`.`Id`) INNER JOIN `OwnedReferencePart3` AS `o1` ON (`o`.`BaseEntityId` = `o1`.`BaseEntityId`) AND (`o`.`Id` = `o1`.`Id`) -) AS `t0` ON `t`.`Id` = `t0`.`BaseEntityId` -ORDER BY `t`.`Id`, `t0`.`BaseEntityId` +) AS `s0` ON `u`.`Id` = `s0`.`BaseEntityId` +ORDER BY `u`.`Id`, `s0`.`BaseEntityId` """); } @@ -736,29 +736,29 @@ public override async Task Tpc_entity_owning_a_split_collection_on_middle(bool a await base.Tpc_entity_owning_a_split_collection_on_middle(async); AssertSql( -""" -SELECT `t`.`Id`, `t`.`BaseValue`, `t`.`MiddleValue`, `t`.`SiblingValue`, `t`.`LeafValue`, `t`.`Discriminator`, `t0`.`MiddleEntityId`, `t0`.`Id`, `t0`.`OwnedIntValue1`, `t0`.`OwnedIntValue2`, `t0`.`OwnedIntValue3`, `t0`.`OwnedIntValue4`, `t0`.`OwnedStringValue1`, `t0`.`OwnedStringValue2`, `t0`.`OwnedStringValue3`, `t0`.`OwnedStringValue4` -FROM ( - SELECT `b`.`Id`, `b`.`BaseValue`, NULL AS `MiddleValue`, NULL AS `SiblingValue`, NULL AS `LeafValue`, 'BaseEntity' AS `Discriminator` - FROM `BaseEntity` AS `b` - UNION ALL - SELECT `m`.`Id`, `m`.`BaseValue`, `m`.`MiddleValue`, NULL AS `SiblingValue`, NULL AS `LeafValue`, 'MiddleEntity' AS `Discriminator` - FROM `MiddleEntity` AS `m` - UNION ALL - SELECT `s`.`Id`, `s`.`BaseValue`, NULL AS `MiddleValue`, `s`.`SiblingValue`, NULL AS `LeafValue`, 'SiblingEntity' AS `Discriminator` - FROM `SiblingEntity` AS `s` - UNION ALL - SELECT `l`.`Id`, `l`.`BaseValue`, `l`.`MiddleValue`, NULL AS `SiblingValue`, `l`.`LeafValue`, 'LeafEntity' AS `Discriminator` - FROM `LeafEntity` AS `l` -) AS `t` -LEFT JOIN ( - SELECT `o`.`MiddleEntityId`, `o`.`Id`, `o`.`OwnedIntValue1`, `o`.`OwnedIntValue2`, `o1`.`OwnedIntValue3`, `o0`.`OwnedIntValue4`, `o`.`OwnedStringValue1`, `o`.`OwnedStringValue2`, `o1`.`OwnedStringValue3`, `o0`.`OwnedStringValue4` - FROM `OwnedReferencePart1` AS `o` - INNER JOIN `OwnedReferencePart4` AS `o0` ON (`o`.`MiddleEntityId` = `o0`.`MiddleEntityId`) AND (`o`.`Id` = `o0`.`Id`) - INNER JOIN `OwnedReferencePart3` AS `o1` ON (`o`.`MiddleEntityId` = `o1`.`MiddleEntityId`) AND (`o`.`Id` = `o1`.`Id`) -) AS `t0` ON `t`.`Id` = `t0`.`MiddleEntityId` -ORDER BY `t`.`Id`, `t0`.`MiddleEntityId` -"""); + """ + SELECT `u`.`Id`, `u`.`BaseValue`, `u`.`MiddleValue`, `u`.`SiblingValue`, `u`.`LeafValue`, `u`.`Discriminator`, `s0`.`MiddleEntityId`, `s0`.`Id`, `s0`.`OwnedIntValue1`, `s0`.`OwnedIntValue2`, `s0`.`OwnedIntValue3`, `s0`.`OwnedIntValue4`, `s0`.`OwnedStringValue1`, `s0`.`OwnedStringValue2`, `s0`.`OwnedStringValue3`, `s0`.`OwnedStringValue4` + FROM ( + SELECT `b`.`Id`, `b`.`BaseValue`, NULL AS `MiddleValue`, NULL AS `SiblingValue`, NULL AS `LeafValue`, 'BaseEntity' AS `Discriminator` + FROM `BaseEntity` AS `b` + UNION ALL + SELECT `m`.`Id`, `m`.`BaseValue`, `m`.`MiddleValue`, NULL AS `SiblingValue`, NULL AS `LeafValue`, 'MiddleEntity' AS `Discriminator` + FROM `MiddleEntity` AS `m` + UNION ALL + SELECT `s`.`Id`, `s`.`BaseValue`, NULL AS `MiddleValue`, `s`.`SiblingValue`, NULL AS `LeafValue`, 'SiblingEntity' AS `Discriminator` + FROM `SiblingEntity` AS `s` + UNION ALL + SELECT `l`.`Id`, `l`.`BaseValue`, `l`.`MiddleValue`, NULL AS `SiblingValue`, `l`.`LeafValue`, 'LeafEntity' AS `Discriminator` + FROM `LeafEntity` AS `l` + ) AS `u` + LEFT JOIN ( + SELECT `o`.`MiddleEntityId`, `o`.`Id`, `o`.`OwnedIntValue1`, `o`.`OwnedIntValue2`, `o1`.`OwnedIntValue3`, `o0`.`OwnedIntValue4`, `o`.`OwnedStringValue1`, `o`.`OwnedStringValue2`, `o1`.`OwnedStringValue3`, `o0`.`OwnedStringValue4` + FROM `OwnedReferencePart1` AS `o` + INNER JOIN `OwnedReferencePart4` AS `o0` ON (`o`.`MiddleEntityId` = `o0`.`MiddleEntityId`) AND (`o`.`Id` = `o0`.`Id`) + INNER JOIN `OwnedReferencePart3` AS `o1` ON (`o`.`MiddleEntityId` = `o1`.`MiddleEntityId`) AND (`o`.`Id` = `o1`.`Id`) + ) AS `s0` ON `u`.`Id` = `s0`.`MiddleEntityId` + ORDER BY `u`.`Id`, `s0`.`MiddleEntityId` + """); } [ConditionalTheory(Skip = "Issue29075")] diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/EscapesSingleStoreNoBackslashesTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/EscapesSingleStoreNoBackslashesTest.cs index 40ea59c14..a32b082ff 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/EscapesSingleStoreNoBackslashesTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/EscapesSingleStoreNoBackslashesTest.cs @@ -18,9 +18,9 @@ public EscapesSingleStoreNoBackslashesTest(EscapesSingleStoreNoBackslashesFixtur } [ConditionalFact] - public override void Input_query_escapes_parameter() + public override async Task Input_query_escapes_parameter() { - base.Input_query_escapes_parameter(); + await base.Input_query_escapes_parameter(); if (AppConfig.ServerVersion.Supports.Returning) { diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/EscapesSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/EscapesSingleStoreTest.cs index a70ca3f03..1e338c869 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/EscapesSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/EscapesSingleStoreTest.cs @@ -16,9 +16,9 @@ public EscapesSingleStoreTest(EscapesSingleStoreFixture fixture, ITestOutputHelp } [ConditionalFact] - public override void Input_query_escapes_parameter() + public override async Task Input_query_escapes_parameter() { - base.Input_query_escapes_parameter(); + await base.Input_query_escapes_parameter(); if (AppConfig.ServerVersion.Supports.Returning) { diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/EscapesSingleStoreTestBase.cs b/test/EFCore.SingleStore.FunctionalTests/Query/EscapesSingleStoreTestBase.cs index cb4877560..f90e90155 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/EscapesSingleStoreTestBase.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/EscapesSingleStoreTestBase.cs @@ -24,21 +24,21 @@ protected EscapesSingleStoreTestBase(TFixture fixture) } [ConditionalFact] - public virtual void Input_query_escapes_parameter() + public virtual async Task Input_query_escapes_parameter() { - ExecuteWithStrategyInTransaction( - context => + await ExecuteWithStrategyInTransactionAsync( + async context => { context.Artists.Add(new Artist { Name = @"Back\slash's Garden Party", }); - context.SaveChanges(); + await context.SaveChangesAsync(); }, - context => + async context => { - var artists = context.Artists.Where(x => x.Name.EndsWith(" Garden Party")).ToList(); + var artists = await context.Artists.Where(x => x.Name.EndsWith(" Garden Party")).ToListAsync(); Assert.Single(artists); Assert.True(artists[0].Name == @"Back\slash's Garden Party"); }); @@ -108,18 +108,16 @@ public virtual async Task Where_contains_query_escapes(bool async) protected void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - protected virtual void ExecuteWithStrategyInTransaction( - Action testOperation, - Action nestedTestOperation1 = null, - Action nestedTestOperation2 = null) - { - TestHelpers.ExecuteWithStrategyInTransaction( + protected virtual Task ExecuteWithStrategyInTransactionAsync( + Func testOperation, + Func nestedTestOperation1 = null, + Func nestedTestOperation2 = null) + => TestHelpers.ExecuteWithStrategyInTransactionAsync( CreateContext, UseTransaction, testOperation, nestedTestOperation1, nestedTestOperation2); - } protected virtual void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) => facade.UseTransaction(transaction.GetDbTransaction()); @@ -158,7 +156,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con SingleStoreTestHelpers.Instance.EnsureSufficientKeySpace(modelBuilder.Model, TestStore); } - protected override void Seed(MusicStoreContext context) + protected override async Task SeedAsync(MusicStoreContext context) { context.Artists.AddRange( new Artist { Name = @"Back\slasher's" }, @@ -166,7 +164,7 @@ protected override void Seed(MusicStoreContext context) new Artist { Name = @"John's Chill Box" } ); - context.SaveChanges(); + await context.SaveChangesAsync(); } } } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/FunkyDataQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/FunkyDataQuerySingleStoreTest.cs index bd0089ba9..dfbefc935 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/FunkyDataQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/FunkyDataQuerySingleStoreTest.cs @@ -1,6 +1,8 @@ -using System.Threading.Tasks; +using System.Linq; +using System.Threading.Tasks; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.TestModels.FunkyDataModel; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -175,29 +177,25 @@ WHERE FALSE """); } - public override async Task String_Contains_and_StartsWith_with_same_parameter(bool async) + public override Task String_Contains_and_StartsWith_with_same_parameter(bool async) { - await base.String_Contains_and_StartsWith_with_same_parameter(async); - - AssertSql( - """ - @__s_0_contains='%B%' (Size = 4000) - @__s_0_startswith='B%' (Size = 4000) - - SELECT `f`.`Id`, `f`.`FirstName`, `f`.`LastName`, `f`.`NullableBool` - FROM `FunkyCustomers` AS `f` - WHERE (`f`.`FirstName` LIKE @__s_0_contains) OR (`f`.`LastName` LIKE @__s_0_startswith) - """); + var s = "B"; + + return AssertQuery( + async, + ss => ss.Set().Where( + c => c.FirstName.Contains(s) || c.LastName.StartsWith(s)), + ss => ss.Set().Where( + c => c.FirstName.MaybeScalar(f => f.Contains(s)) == true || c.LastName.MaybeScalar(l => l.StartsWith(s)) == true)); } - protected override void ClearLog() => Fixture.TestSqlLoggerFactory.Clear(); private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); - public class FunkyDataQuerySingleStoreFixture : FunkyDataQueryFixtureBase + public class FunkyDataQuerySingleStoreFixture : FunkyDataQueryFixtureBase, ITestSqlLoggerFactory { public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ServiceProvider.GetRequiredService(); diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/GearsOfWarQuerySingleStoreTest.SingleStore.cs b/test/EFCore.SingleStore.FunctionalTests/Query/GearsOfWarQuerySingleStoreTest.SingleStore.cs index 4b2e0be4c..cb90887ee 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/GearsOfWarQuerySingleStoreTest.SingleStore.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/GearsOfWarQuerySingleStoreTest.SingleStore.cs @@ -208,7 +208,7 @@ await AssertQuery( AssertSql( """ - SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` + SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE `m`.`Timeline` = `m`.`Timeline` """); @@ -225,7 +225,7 @@ await AssertQuery( AssertSql( """ - SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` + SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE `m`.`Timeline` = `m`.`Timeline` """); diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/GearsOfWarQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/GearsOfWarQuerySingleStoreTest.cs index 82dc1d72d..99db900f0 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/GearsOfWarQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/GearsOfWarQuerySingleStoreTest.cs @@ -21,9 +21,6 @@ public GearsOfWarQuerySingleStoreTest(GearsOfWarQuerySingleStoreFixture fixture, //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) { var dto = SingleStoreTestHelpers.GetExpectedValue(new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0))); @@ -453,12 +450,12 @@ public override async Task Group_by_on_StartsWith_with_null_parameter_as_argumen AssertSql( """ -SELECT `t`.`Key` +SELECT `g0`.`Key` FROM ( SELECT FALSE AS `Key` FROM `Gears` AS `g` -) AS `t` -GROUP BY `t`.`Key` +) AS `g0` +GROUP BY `g0`.`Key` """); } @@ -522,10 +519,13 @@ public override async Task Group_by_with_having_StartsWith_with_null_parameter_a AssertSql( """ -SELECT `g`.`FullName` -FROM `Gears` AS `g` -GROUP BY `g`.`FullName` -HAVING FALSE +SELECT `g0`.`FullName` +FROM ( + SELECT `g`.`FullName`, FALSE AS `c` + FROM `Gears` AS `g` + GROUP BY `g`.`FullName`, `c` + HAVING `c` +) AS `g0` """); } @@ -558,7 +558,7 @@ await AssertQuery( AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(hour FROM `m`.`Timeline`) = 8 """); @@ -575,5 +575,12 @@ public override async Task Nav_expansion_with_member_pushdown_inside_Contains_ar { await base.Nav_expansion_with_member_pushdown_inside_Contains_argument(async); } + + // TODO: Implement once TimeSpan is translated as ticks instead of TIME. + public override async Task Non_string_concat_uses_appropriate_type_mapping(bool async) + { + var exception = await Assert.ThrowsAsync(() => base.Non_string_concat_uses_appropriate_type_mapping(async)); + Assert.Equal("Unable to cast object of type 'System.Byte[]' to type 'System.TimeSpan'.", exception.Message); + } } } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/IncludeOneToOneSingleStoreTestBase.cs b/test/EFCore.SingleStore.FunctionalTests/Query/IncludeOneToOneSingleStoreTestBase.cs index 3625da428..35051d687 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/IncludeOneToOneSingleStoreTestBase.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/IncludeOneToOneSingleStoreTestBase.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Linq; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.TestUtilities; using Xunit; @@ -164,7 +165,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con .HasForeignKey("PersonId")); } - protected override void Seed(PoolableDbContext context) + protected override async Task SeedAsync(PoolableDbContext context) { var address1 = new Address { Street = "3 Dragons Way", City = "Meereen" }; var address2 = new Address { Street = "42 Castle Black", City = "The Wall" }; @@ -204,7 +205,7 @@ protected override void Seed(PoolableDbContext context) context.Set().AddRange(address21, address22, address23); - context.SaveChanges(); + await context.SaveChangesAsync(); } } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/JsonMicrosoftDomChangeTrackingTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/JsonMicrosoftDomChangeTrackingTest.cs index b2feb9413..09e1e38ab 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/JsonMicrosoftDomChangeTrackingTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/JsonMicrosoftDomChangeTrackingTest.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Text.Json; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -226,7 +227,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) } } - public void Seed() + public async Task SeedAsync() { var (customer1, customer2, customer3) = (CreateCustomer1(), CreateCustomer2(), CreateCustomer3()); @@ -234,7 +235,7 @@ public void Seed() new JsonEntity { Id = 1, CustomerDocument = customer1, CustomerElement = customer1.RootElement }, new JsonEntity { Id = 2, CustomerDocument = customer2, CustomerElement = customer2.RootElement }, new JsonEntity { Id = 3, CustomerDocument = customer3, CustomerElement = customer3.RootElement }); - SaveChanges(); + await SaveChangesAsync(); } public static JsonDocument CreateCustomer1() @@ -324,7 +325,7 @@ public class JsonMicrosoftDomChangeTrackingFixture : ServiceProviderPerContextFi { protected override string StoreName => "JsonMicrosoftDomChangeTrackingTest"; protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; - protected override void Seed(JsonMicrosoftDomChangeTrackingContext context) => context.Seed(); + protected override Task SeedAsync(JsonMicrosoftDomChangeTrackingContext context) => context.SeedAsync(); protected override IServiceCollection AddServices(IServiceCollection serviceCollection) { diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/JsonMicrosoftDomQueryTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/JsonMicrosoftDomQueryTest.cs index 7c8b54e7c..288632bee 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/JsonMicrosoftDomQueryTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/JsonMicrosoftDomQueryTest.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Text.Json; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -319,6 +320,70 @@ WHERE JSON_UNQUOTE(`j`.`CustomerElement`) = 'foo' #region Functions + [ConditionalFact] + [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonOverlaps))] + public void JsonOverlaps_with_json_element() + { + using var ctx = CreateContext(); + var element = JsonDocument.Parse(@"{""Name"": ""Joe"", ""Age"": -1}").RootElement; + var count = ctx.JsonEntities.Count(e => + EF.Functions.JsonOverlaps(e.CustomerElement, element)); + + Assert.Equal(1, count); + AssertSql( + $@"@__element_1='{{""Name"":""Joe"",""Age"":-1}}' (Nullable = false) (Size = 4000) +SELECT COUNT(*) +FROM `JsonEntities` AS `j` +WHERE JSON_OVERLAPS(`j`.`CustomerElement`, {InsertJsonConvert("@__element_1")})"); + } + + [ConditionalFact] + [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonOverlaps))] + public void JsonOverlaps_with_string() + { + using var ctx = CreateContext(); + var count = ctx.JsonEntities.Count(e => + EF.Functions.JsonOverlaps(e.CustomerElement, @"{""Name"": ""Joe"", ""Age"": -1}")); + + Assert.Equal(1, count); + AssertSql( + @"SELECT COUNT(*) +FROM `JsonEntities` AS `j` +WHERE JSON_OVERLAPS(`j`.`CustomerElement`, '{""Name"": ""Joe"", ""Age"": -1}')"); + } + + [ConditionalFact] + [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonOverlaps))] + public void JsonOverlaps_using_JsonExtract_with_json_element() + { + using var ctx = CreateContext(); + var element = JsonDocument.Parse(@"[3,-1]").RootElement; + var count = ctx.JsonEntities.Count(e => + EF.Functions.JsonOverlaps(EF.Functions.JsonExtract(e.CustomerElement, "$.Statistics.Nested.IntArray"), element)); + + Assert.Equal(1, count); + AssertSql( + $@"@__element_1='[3,-1]' (Nullable = false) (Size = 4000) +SELECT COUNT(*) +FROM `JsonEntities` AS `j` +WHERE JSON_OVERLAPS(JSON_EXTRACT(`j`.`CustomerElement`, '$.Statistics.Nested.IntArray'), {InsertJsonConvert("@__element_1")})"); + } + + [ConditionalFact] + [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonOverlaps))] + public void JsonOverlaps_using_JsonExtract_with_json_string() + { + using var ctx = CreateContext(); + var count = ctx.JsonEntities.Count(e => + EF.Functions.JsonOverlaps(EF.Functions.JsonExtract(e.CustomerElement, "$.Statistics.Nested.IntArray"), @"[3,-1]")); + + Assert.Equal(1, count); + AssertSql( + $@"SELECT COUNT(*) +FROM `JsonEntities` AS `j` +WHERE JSON_OVERLAPS(JSON_EXTRACT(`j`.`CustomerElement`, '$.Statistics.Nested.IntArray'), '[3,-1]')"); + } + [Fact] public void JsonContains_with_json_element() { @@ -476,7 +541,7 @@ public class JsonDomQueryContext : PoolableDbContext public JsonDomQueryContext(DbContextOptions options) : base(options) {} - public static void Seed(JsonDomQueryContext context) + public static async Task SeedAsync(JsonDomQueryContext context) { var (customer1, customer2, customer3) = (createCustomer1(), createCustomer2(), createCustomer3()); @@ -484,7 +549,7 @@ public static void Seed(JsonDomQueryContext context) new JsonEntity { Id = 1, CustomerDocument = customer1, CustomerElement = customer1.RootElement }, new JsonEntity { Id = 2, CustomerDocument = customer2, CustomerElement = customer2.RootElement }, new JsonEntity { Id = 3, CustomerDocument = customer3, CustomerElement = customer3.RootElement }); - context.SaveChanges(); + await context.SaveChangesAsync(); static JsonDocument createCustomer1() => JsonDocument.Parse(@" { @@ -564,7 +629,7 @@ public class JsonMicrosoftDomQueryFixture : SharedStoreFixtureBase "JsonMicrosoftDomQueryTest"; protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - protected override void Seed(JsonDomQueryContext context) => JsonDomQueryContext.Seed(context); + protected override Task SeedAsync(JsonDomQueryContext context) => JsonDomQueryContext.SeedAsync(context); protected override IServiceCollection AddServices(IServiceCollection serviceCollection) { diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/JsonNewtonsoftDomChangeTrackingTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/JsonNewtonsoftDomChangeTrackingTest.cs index d7025b565..c712ecb02 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/JsonNewtonsoftDomChangeTrackingTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/JsonNewtonsoftDomChangeTrackingTest.cs @@ -1,4 +1,5 @@ using System.Linq; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -226,7 +227,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) } } - public void Seed() + public async Task SeedAsync() { var (customer1, customer2, customer3) = (CreateCustomer1(), CreateCustomer2(), CreateCustomer3()); @@ -234,7 +235,7 @@ public void Seed() new JsonEntity { Id = 1, CustomerJObject = customer1, CustomerJToken = customer1}, new JsonEntity { Id = 2, CustomerJObject = customer2, CustomerJToken = customer2}, new JsonEntity { Id = 3, CustomerJObject = null, CustomerJToken = customer3}); - SaveChanges(); + await SaveChangesAsync(); } public static JObject CreateCustomer1() @@ -324,7 +325,7 @@ public class JsonMicrosoftDomChangeTrackingFixture : ServiceProviderPerContextFi { protected override string StoreName => "JsonNewtonsoftDomChangeTrackingTest"; protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; - protected override void Seed(JsonMicrosoftDomChangeTrackingContext context) => context.Seed(); + protected override Task SeedAsync(JsonMicrosoftDomChangeTrackingContext context) => context.SeedAsync(); protected override IServiceCollection AddServices(IServiceCollection serviceCollection) { diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/JsonNewtonsoftDomQueryTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/JsonNewtonsoftDomQueryTest.cs index 7332a8bc6..4434eabcf 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/JsonNewtonsoftDomQueryTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/JsonNewtonsoftDomQueryTest.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -345,7 +346,71 @@ WHERE JSON_UNQUOTE(`j`.`CustomerJToken`) = 'foo' LIMIT 2"); } - #region Functions + #region Functions + + [ConditionalFact] + [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonOverlaps))] + public void JsonOverlaps_with_json_element() + { + using var ctx = CreateContext(); + var element = JObject.Parse(@"{""Name"": ""Joe"", ""Age"": -1}").Root; + var count = ctx.JsonEntities.Count(e => + EF.Functions.JsonOverlaps(e.CustomerJToken, element)); + + Assert.Equal(1, count); + AssertSql( + $@"@__element_1='{{""Name"":""Joe"",""Age"":-1}}' (Size = 4000) +SELECT COUNT(*) +FROM `JsonEntities` AS `j` +WHERE JSON_OVERLAPS(`j`.`CustomerJToken`, {InsertJsonConvert("@__element_1")})"); + } + + [ConditionalFact] + [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonOverlaps))] + public void JsonOverlaps_with_string() + { + using var ctx = CreateContext(); + var count = ctx.JsonEntities.Count(e => + EF.Functions.JsonOverlaps(e.CustomerJToken, @"{""Name"": ""Joe"", ""Age"": -1}")); + + Assert.Equal(1, count); + AssertSql( + @"SELECT COUNT(*) +FROM `JsonEntities` AS `j` +WHERE JSON_OVERLAPS(`j`.`CustomerJToken`, '{""Name"": ""Joe"", ""Age"": -1}')"); + } + + [ConditionalFact] + [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonOverlaps))] + public void JsonOverlaps_using_JsonExtract_with_json_element() + { + using var ctx = CreateContext(); + var element = JArray.Parse(@"[3,-1]"); + var count = ctx.JsonEntities.Count(e => + EF.Functions.JsonOverlaps(EF.Functions.JsonExtract(e.CustomerJToken, "$.Statistics.Nested.IntArray"), element)); + + Assert.Equal(1, count); + AssertSql( + $@"@__element_1='[3,-1]' (Size = 4000) +SELECT COUNT(*) +FROM `JsonEntities` AS `j` +WHERE JSON_OVERLAPS(JSON_EXTRACT(`j`.`CustomerJToken`, '$.Statistics.Nested.IntArray'), {InsertJsonConvert("@__element_1")})"); + } + + [ConditionalFact] + [SupportedServerVersionCondition(nameof(ServerVersionSupport.JsonOverlaps))] + public void JsonOverlaps_using_JsonExtract_with_json_string() + { + using var ctx = CreateContext(); + var count = ctx.JsonEntities.Count(e => + EF.Functions.JsonOverlaps(EF.Functions.JsonExtract(e.CustomerJToken, "$.Statistics.Nested.IntArray"), @"[3,-1]")); + + Assert.Equal(1, count); + AssertSql( + $@"SELECT COUNT(*) +FROM `JsonEntities` AS `j` +WHERE JSON_OVERLAPS(JSON_EXTRACT(`j`.`CustomerJToken`, '$.Statistics.Nested.IntArray'), '[3,-1]')"); + } [Fact] public void JsonContains_with_json_element() @@ -504,7 +569,7 @@ public class JsonDomQueryContext : PoolableDbContext public JsonDomQueryContext(DbContextOptions options) : base(options) {} - public static void Seed(JsonDomQueryContext context) + public static async Task SeedAsync(JsonDomQueryContext context) { var (customer1, customer2, customer3) = (createCustomer1(), createCustomer2(), createCustomer3()); @@ -512,7 +577,7 @@ public static void Seed(JsonDomQueryContext context) new JsonEntity { Id = 1, CustomerJObject = customer1, CustomerJToken = customer1}, new JsonEntity { Id = 2, CustomerJObject = customer2, CustomerJToken = customer2}, new JsonEntity { Id = 3, CustomerJObject = null, CustomerJToken = customer3}); - context.SaveChanges(); + await context.SaveChangesAsync(); static JObject createCustomer1() => JObject.Parse(@" { @@ -592,7 +657,7 @@ public class JsonNewtonsoftDomQueryFixture : SharedStoreFixtureBase "JsonNewtonsoftDomQueryTest"; protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - protected override void Seed(JsonDomQueryContext context) => JsonDomQueryContext.Seed(context); + protected override Task SeedAsync(JsonDomQueryContext context) => JsonDomQueryContext.SeedAsync(context); protected override IServiceCollection AddServices(IServiceCollection serviceCollection) { diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/JsonPocoChangeTrackingTestBase.cs b/test/EFCore.SingleStore.FunctionalTests/Query/JsonPocoChangeTrackingTestBase.cs index 182307546..bdb9ad165 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/JsonPocoChangeTrackingTestBase.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/JsonPocoChangeTrackingTestBase.cs @@ -1,6 +1,7 @@ using System; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -248,12 +249,12 @@ private void SetGlobalJsonChangeTrackingOptions( addOrUpdateExtensionMethod.Invoke(optionsBuilder, new object[] {mySqlJsonOptions}); } - public void Seed() + public async Task SeedAsync() { JsonEntities.AddRange( new JsonEntity { Id = 1, Customer = CreateCustomer1(), ToplevelArray = new[] { "one", "two", "three" } }, new JsonEntity { Id = 2, Customer = CreateCustomer2() }); - SaveChanges(); + await SaveChangesAsync(); } public static Customer CreateCustomer1() @@ -300,7 +301,7 @@ public class JsonPocoChangeTrackingFixtureBase : ServiceProviderPerContextFixtur { protected override string StoreName => "JsonPocoChangeTrackingTest"; protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; - protected override void Seed(JsonPocoChangeTrackingContext context) => context.Seed(); + protected override Task SeedAsync(JsonPocoChangeTrackingContext context) => context.SeedAsync(); public virtual DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder, SingleStoreJsonChangeTrackingOptions? changeTrackingOptions) => builder; diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/JsonPocoQueryTestBase.cs b/test/EFCore.SingleStore.FunctionalTests/Query/JsonPocoQueryTestBase.cs index 594a7d9c1..fe7b4feb7 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/JsonPocoQueryTestBase.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/JsonPocoQueryTestBase.cs @@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text.Json.Serialization; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.TestUtilities; using Newtonsoft.Json; @@ -474,12 +475,12 @@ public class JsonPocoQueryContext : PoolableDbContext public JsonPocoQueryContext(DbContextOptions options) : base(options) {} - public static void Seed(JsonPocoQueryContext context) + public static async Task SeedAsync(JsonPocoQueryContext context) { context.JsonEntities.AddRange( new JsonEntity { Id = 1, Customer = createCustomer1(), ToplevelArray = new[] { "one", "two", "three" } }, new JsonEntity { Id = 2, Customer = createCustomer2() }); - context.SaveChanges(); + await context.SaveChangesAsync(); static Customer createCustomer1() => new Customer { @@ -567,7 +568,7 @@ public class JsonPocoQueryFixtureBase : SharedStoreFixtureBase SingleStoreTestStoreFactory.GuidBinary16Instance; public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - protected override void Seed(JsonPocoQueryContext context) => JsonPocoQueryContext.Seed(context); + protected override Task SeedAsync(JsonPocoQueryContext context) => JsonPocoQueryContext.SeedAsync(context); } public class Customer diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/JsonStringChangeTrackingTestBase.cs b/test/EFCore.SingleStore.FunctionalTests/Query/JsonStringChangeTrackingTestBase.cs index c5fa5fe23..fbbef5538 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/JsonStringChangeTrackingTestBase.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/JsonStringChangeTrackingTestBase.cs @@ -1,5 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Linq; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.TestUtilities; @@ -293,12 +294,12 @@ private void SetGlobalJsonChangeTrackingOptions( addOrUpdateExtensionMethod.Invoke(optionsBuilder, new object[] {mySqlJsonOptions}); } - public void Seed() + public async Task SeedAsync() { JsonEntities.AddRange( new JsonEntity {Id = 1, Customer = Customer1}, new JsonEntity {Id = 2, Customer = Customer2}); - SaveChanges(); + await SaveChangesAsync(); } public class JsonPocoChangeTrackingContextOptions @@ -320,7 +321,7 @@ public class JsonStringChangeTrackingFixtureBase : ServiceProviderPerContextFixt { protected override string StoreName => "JsonStringChangeTrackingTest"; protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; - protected override void Seed(JsonStringChangeTrackingContext context) => context.Seed(); + protected override Task SeedAsync(JsonStringChangeTrackingContext context) => context.SeedAsync(); public virtual DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder, SingleStoreJsonChangeTrackingOptions? changeTrackingOptions) => builder; diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/JsonStringQueryTestBase.cs b/test/EFCore.SingleStore.FunctionalTests/Query/JsonStringQueryTestBase.cs index e64bf622d..aa288cfab 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/JsonStringQueryTestBase.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/JsonStringQueryTestBase.cs @@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text.Json; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.TestUtilities; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; @@ -243,7 +244,7 @@ public class JsonStringQueryContext : PoolableDbContext public JsonStringQueryContext(DbContextOptions options) : base(options) {} - public static void Seed(JsonStringQueryContext context) + public static async Task SeedAsync(JsonStringQueryContext context) { const string customer1 = @" { @@ -303,7 +304,7 @@ public static void Seed(JsonStringQueryContext context) context.JsonEntities.AddRange( new JsonEntity { Id = 1, CustomerJson = customer1 }, new JsonEntity { Id = 2, CustomerJson = customer2 }); - context.SaveChanges(); + await context.SaveChangesAsync(); } } @@ -320,7 +321,7 @@ public class JsonStringQueryFixtureBase : SharedStoreFixtureBase "JsonStringQueryTest"; protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - protected override void Seed(JsonStringQueryContext context) => JsonStringQueryContext.Seed(context); + protected override Task SeedAsync(JsonStringQueryContext context) => JsonStringQueryContext.SeedAsync(context); } #endregion diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/ManyToManyFieldsLoadSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/ManyToManyFieldsLoadSingleStoreTest.cs index 7948191d8..a986c37a2 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/ManyToManyFieldsLoadSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/ManyToManyFieldsLoadSingleStoreTest.cs @@ -15,7 +15,7 @@ public ManyToManyFieldsLoadSingleStoreTest(ManyToManyFieldsLoadSingleStoreFixtur { } - public class ManyToManyFieldsLoadSingleStoreFixture : ManyToManyFieldsLoadFixtureBase + public class ManyToManyFieldsLoadSingleStoreFixture : ManyToManyFieldsLoadFixtureBase, ITestSqlLoggerFactory { public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/ManyToManyHeterogeneousQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/ManyToManyHeterogeneousQuerySingleStoreTest.cs deleted file mode 100644 index 4c27d7c6f..000000000 --- a/test/EFCore.SingleStore.FunctionalTests/Query/ManyToManyHeterogeneousQuerySingleStoreTest.cs +++ /dev/null @@ -1,150 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.TestUtilities; -using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; -using Microsoft.EntityFrameworkCore; -using System.Collections.Generic; -using System.Linq; -using EntityFrameworkCore.SingleStore.Tests; -using Xunit; - -namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query -{ - public class ManyToManyHeterogeneousQuerySingleStoreTest : ManyToManyHeterogeneousQueryRelationalTestBase - { - protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; - - public override async Task Many_to_many_load_works_when_join_entity_has_custom_key(bool async) - { - // We're skipping this test when we're running tests on Managed Service due to the specifics of - // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) - if (AppConfig.ManagedService) - { - return; - } - - var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => - { - // We're changing the data type of the fields from INT to BIGINT, because in SingleStore - // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - }); - - int id; - using (var context = contextFactory.CreateContext()) - { - var m = new ManyM_DB(); - var n = new ManyN_DB(); - context.AddRange(m, n); - m.ManyN_DB = new List { n }; - - context.SaveChanges(); - - id = m.Id; - } - - ClearLog(); - - using (var context = contextFactory.CreateContext()) - { - var m = context.Find(id); - - if (async) - { - await context.Entry(m).Collection(x => x.ManyN_DB).LoadAsync(); - } - else - { - context.Entry(m).Collection(x => x.ManyN_DB).Load(); - } - - Assert.Equal(3, context.ChangeTracker.Entries().Count()); - Assert.Equal(1, m.ManyN_DB.Count); - Assert.Equal(1, m.ManyN_DB.Single().ManyM_DB.Count); - Assert.Equal(1, m.ManyNM_DB.Count); - Assert.Equal(1, m.ManyN_DB.Single().ManyNM_DB.Count); - - id = m.ManyN_DB.Single().Id; - } - - using (var context = contextFactory.CreateContext()) - { - var n = context.Find(id); - - if (async) - { - await context.Entry(n).Collection(x => x.ManyM_DB).LoadAsync(); - } - else - { - context.Entry(n).Collection(x => x.ManyM_DB).Load(); - } - - Assert.Equal(3, context.ChangeTracker.Entries().Count()); - Assert.Equal(1, n.ManyM_DB.Count); - Assert.Equal(1, n.ManyM_DB.Single().ManyN_DB.Count); - Assert.Equal(1, n.ManyNM_DB.Count); - Assert.Equal(1, n.ManyM_DB.Single().ManyNM_DB.Count); - } - - AssertSql( - @"@__p_0='1' - -SELECT `m`.`Id` -FROM `ManyM_DB` AS `m` -WHERE `m`.`Id` = @__p_0 -LIMIT 1", - // - @"@__p_0='1' - -SELECT `t`.`Id`, `m`.`Id`, `t`.`Id0`, `t0`.`Id`, `t0`.`ManyM_Id`, `t0`.`ManyN_Id`, `t0`.`Id0` -FROM `ManyM_DB` AS `m` -INNER JOIN ( - SELECT `m1`.`Id`, `m0`.`Id` AS `Id0`, `m0`.`ManyM_Id` - FROM `ManyMN_DB` AS `m0` - LEFT JOIN `ManyN_DB` AS `m1` ON `m0`.`ManyN_Id` = `m1`.`Id` -) AS `t` ON `m`.`Id` = `t`.`ManyM_Id` -LEFT JOIN ( - SELECT `m2`.`Id`, `m2`.`ManyM_Id`, `m2`.`ManyN_Id`, `m3`.`Id` AS `Id0` - FROM `ManyMN_DB` AS `m2` - INNER JOIN `ManyM_DB` AS `m3` ON `m2`.`ManyM_Id` = `m3`.`Id` - WHERE `m3`.`Id` = @__p_0 -) AS `t0` ON `t`.`Id` = `t0`.`ManyN_Id` -WHERE `m`.`Id` = @__p_0 -ORDER BY `m`.`Id`, `t`.`Id0`, `t`.`Id`, `t0`.`Id`", - // - @"@__p_0='1' - -SELECT `m`.`Id` -FROM `ManyN_DB` AS `m` -WHERE `m`.`Id` = @__p_0 -LIMIT 1", - // - @"@__p_0='1' - -SELECT `t`.`Id`, `m`.`Id`, `t`.`Id0`, `t0`.`Id`, `t0`.`ManyM_Id`, `t0`.`ManyN_Id`, `t0`.`Id0` -FROM `ManyN_DB` AS `m` -INNER JOIN ( - SELECT `m1`.`Id`, `m0`.`Id` AS `Id0`, `m0`.`ManyN_Id` - FROM `ManyMN_DB` AS `m0` - INNER JOIN `ManyM_DB` AS `m1` ON `m0`.`ManyM_Id` = `m1`.`Id` -) AS `t` ON `m`.`Id` = `t`.`ManyN_Id` -LEFT JOIN ( - SELECT `m2`.`Id`, `m2`.`ManyM_Id`, `m2`.`ManyN_Id`, `m3`.`Id` AS `Id0` - FROM `ManyMN_DB` AS `m2` - INNER JOIN `ManyN_DB` AS `m3` ON `m2`.`ManyN_Id` = `m3`.`Id` - WHERE `m3`.`Id` = @__p_0 -) AS `t0` ON `t`.`Id` = `t0`.`ManyM_Id` -WHERE `m`.`Id` = @__p_0 -ORDER BY `m`.`Id`, `t`.`Id0`, `t`.`Id`, `t0`.`Id`"); - } - } -} diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/ManyToManyNoTrackingQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/ManyToManyNoTrackingQuerySingleStoreTest.cs index cc9582131..6d4e960cf 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/ManyToManyNoTrackingQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/ManyToManyNoTrackingQuerySingleStoreTest.cs @@ -13,8 +13,5 @@ public ManyToManyNoTrackingQuerySingleStoreTest(ManyToManyQuerySingleStoreFixtur Fixture.TestSqlLoggerFactory.Clear(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - - protected override bool CanExecuteQueryString - => true; } } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/ManyToManyQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/ManyToManyQuerySingleStoreTest.cs index 5c321868b..ec9cbdf89 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/ManyToManyQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/ManyToManyQuerySingleStoreTest.cs @@ -11,8 +11,5 @@ public ManyToManyQuerySingleStoreTest(ManyToManyQuerySingleStoreFixture fixture, { Fixture.TestSqlLoggerFactory.Clear(); } - - protected override bool CanExecuteQueryString - => true; } } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/MatchQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/MatchQuerySingleStoreTest.cs index cf39042c3..e8bd6917d 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/MatchQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/MatchQuerySingleStoreTest.cs @@ -374,7 +374,7 @@ protected MatchQuerySingleStoreTestBase(TFixture fixture) protected virtual DbContext CreateContext() => Fixture.CreateContext(); - public abstract class MatchQuerySingleStoreFixtureBase : SharedStoreFixtureBase, IQueryFixtureBase + public abstract class MatchQuerySingleStoreFixtureBase : SharedStoreFixtureBase, IQueryFixtureBase, ITestSqlLoggerFactory { protected override string StoreName { get; } = "MatchQueryTest"; public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySingleStoreTest.cs index 0ee7e9200..6a74bc7d5 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NonSharedPrimitiveCollectionsQuerySingleStoreTest.cs @@ -1,8 +1,11 @@ using System; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; +using EntityFrameworkCore.SingleStore.Internal; using EntityFrameworkCore.SingleStore.Tests; using Xunit; @@ -378,10 +381,6 @@ LIMIT 2 """); } - [ConditionalFact] - public override Task Array_of_array_is_not_supported() - => base.Array_of_array_is_not_supported(); - [ConditionalFact] public override Task Multidimensional_array_is_not_supported() => base.Multidimensional_array_is_not_supported(); @@ -474,29 +473,122 @@ LIMIT 2 public override async Task Column_collection_inside_json_owned_entity() { - await base.Column_collection_inside_json_owned_entity(); + var exception = await Assert.ThrowsAsync(() => base.Column_collection_inside_json_owned_entity()); + Assert.Equal(SingleStoreStrings.Ef7CoreJsonMappingNotSupported, exception.Message); + } + + #endregion Type mapping inference + + public override async Task Parameter_collection_Count_with_column_predicate_with_default_constants() + { + await base.Parameter_collection_Count_with_column_predicate_with_default_constants(); AssertSql( - """ -SELECT TOP(2) [t].[Id], [t].[Owned] -FROM [TestOwner] AS [t] +$""" +SELECT `t`.`Id` +FROM `TestEntity` AS `t` WHERE ( SELECT COUNT(*) - FROM OPENJSON(JSON_VALUE([t].[Owned], '$.Strings')) AS [s]) = 2 -""", - // - """ -SELECT TOP(2) [t].[Id], [t].[Owned] -FROM [TestOwner] AS [t] -WHERE JSON_VALUE(JSON_VALUE([t].[Owned], '$.Strings'), '$[1]') = N'bar' + FROM (SELECT 2 AS `Value` UNION ALL VALUES {(AppConfig.ServerVersion.Supports.ValuesWithRows ? "ROW" : string.Empty)}(999)) AS `i` + WHERE `i`.`Value` > `t`.`Id`) = 1 """); } - #endregion Type mapping inference + public override async Task Parameter_collection_of_ints_Contains_int_with_default_constants() + { + await base.Parameter_collection_of_ints_Contains_int_with_default_constants(); + + AssertSql( +""" +SELECT `t`.`Id` +FROM `TestEntity` AS `t` +WHERE `t`.`Id` IN (2, 999) +"""); + } + + public override async Task Parameter_collection_Count_with_column_predicate_with_default_constants_EF_Parameter() + { + await base.Parameter_collection_Count_with_column_predicate_with_default_constants_EF_Parameter(); + + AssertSql(); + } + + public override async Task Parameter_collection_of_ints_Contains_int_with_default_constants_EF_Parameter() + { + await base.Parameter_collection_of_ints_Contains_int_with_default_constants_EF_Parameter(); + + AssertSql(); + } + + public override async Task Parameter_collection_Count_with_column_predicate_with_default_parameters() + { + await base.Parameter_collection_Count_with_column_predicate_with_default_parameters(); + + AssertSql(); + } + + public override async Task Parameter_collection_of_ints_Contains_int_with_default_parameters() + { + await base.Parameter_collection_of_ints_Contains_int_with_default_parameters(); + + AssertSql(); + } + + public override async Task Parameter_collection_Count_with_column_predicate_with_default_parameters_EF_Constant() + { + await base.Parameter_collection_Count_with_column_predicate_with_default_parameters_EF_Constant(); + + AssertSql( +$""" +SELECT `t`.`Id` +FROM `TestEntity` AS `t` +WHERE ( + SELECT COUNT(*) + FROM (SELECT 2 AS `Value` UNION ALL VALUES {(AppConfig.ServerVersion.Supports.ValuesWithRows ? "ROW" : string.Empty)}(999)) AS `i` + WHERE `i`.`Value` > `t`.`Id`) = 1 +"""); + } + + public override async Task Parameter_collection_of_ints_Contains_int_with_default_parameters_EF_Constant() + { + await base.Parameter_collection_of_ints_Contains_int_with_default_parameters_EF_Constant(); + + AssertSql( +""" +SELECT `t`.`Id` +FROM `TestEntity` AS `t` +WHERE `t`.`Id` IN (2, 999) +"""); + } + + public override async Task Project_collection_from_entity_type_with_owned() + { + await base.Project_collection_from_entity_type_with_owned(); + + AssertSql( +""" +SELECT `t`.`Ints` +FROM `TestEntityWithOwned` AS `t` +"""); + } [ConditionalFact] public virtual void Check_all_tests_overridden() - => TestHelpers.AssertAllMethodsOverridden(GetType()); + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); + + protected override DbContextOptionsBuilder SetTranslateParameterizedCollectionsToConstants(DbContextOptionsBuilder optionsBuilder) + { + new SingleStoreDbContextOptionsBuilder(optionsBuilder).TranslateParameterizedCollectionsToConstants(); + + return optionsBuilder; + } + + protected override DbContextOptionsBuilder SetTranslateParameterizedCollectionsToParameters(DbContextOptionsBuilder optionsBuilder) + { + new SingleStoreDbContextOptionsBuilder(optionsBuilder).TranslateParameterizedCollectionsToParameters(); + + return optionsBuilder; + } protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySingleStoreTest.cs index 2c209e44d..e00d7fbd4 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySingleStoreTest.cs @@ -22,7 +22,7 @@ public NorthwindAggregateOperatorsQuerySingleStoreTest( } [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] - public override Task Average_over_max_subquery_is_client_eval(bool async) + public override Task Average_over_max_subquery(bool async) => AssertAverage( async, ss => ss.Set().OrderBy(c => c.CustomerID).Take(3), @@ -30,13 +30,28 @@ public override Task Average_over_max_subquery_is_client_eval(bool async) asserter: (a, b) => Assert.Equal(a, b, 12)); // added flouting point precision tolerance [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] - public override Task Average_over_nested_subquery_is_client_eval(bool async) + public override Task Average_over_nested_subquery(bool async) => AssertAverage( async, ss => ss.Set().OrderBy(c => c.CustomerID).Take(3), selector: c => (decimal)c.Orders.Average(o => 5 + o.OrderDetails.Average(od => od.ProductID)), asserter: (a, b) => Assert.Equal(a, b, 12)); // added flouting point precision tolerance + public override async Task Type_casting_inside_sum(bool async) + { + await AssertSum( + async, + ss => ss.Set(), + x => (decimal)x.Discount, + asserter: (a, b) => Assert.Equal(a, b, 3)); // added flouting point precision tolerance + + AssertSql( + """ + SELECT COALESCE(SUM(CAST(`o`.`Discount` AS decimal(65,30))), 0.0) + FROM `Order Details` AS `o` + """); + } + // TODO: Implement TranslatePrimitiveCollection. public override async Task Contains_with_local_anonymous_type_array_closure(bool async) { @@ -97,45 +112,45 @@ public override Task Multiple_collection_navigation_with_FirstOrDefault_chained_ } [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] - public override Task Average_over_subquery_is_client_eval(bool async) + public override Task Average_over_subquery(bool async) { - return base.Average_over_max_subquery_is_client_eval(async); + return base.Average_over_max_subquery(async); } [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] - public override Task Max_over_nested_subquery_is_client_eval(bool async) + public override Task Max_over_nested_subquery(bool async) { - return base.Max_over_nested_subquery_is_client_eval(async); + return base.Max_over_nested_subquery(async); } [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] - public override Task Max_over_subquery_is_client_eval(bool async) + public override Task Max_over_subquery(bool async) { - return base.Max_over_subquery_is_client_eval(async); + return base.Max_over_subquery(async); } [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] - public override Task Max_over_sum_subquery_is_client_eval(bool async) + public override Task Max_over_sum_subquery(bool async) { - return base.Max_over_sum_subquery_is_client_eval(async); + return base.Max_over_sum_subquery(async); } [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] - public override Task Min_over_max_subquery_is_client_eval(bool async) + public override Task Min_over_max_subquery(bool async) { - return base.Min_over_max_subquery_is_client_eval(async); + return base.Min_over_max_subquery(async); } [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] - public override Task Min_over_nested_subquery_is_client_eval(bool async) + public override Task Min_over_nested_subquery(bool async) { - return base.Min_over_nested_subquery_is_client_eval(async); + return base.Min_over_nested_subquery(async); } [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] - public override Task Min_over_subquery_is_client_eval(bool async) + public override Task Min_over_subquery(bool async) { - return base.Min_over_subquery_is_client_eval(async); + return base.Min_over_subquery(async); } [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] @@ -145,21 +160,39 @@ public override Task Sum_on_float_column_in_subquery(bool async) } [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] - public override Task Sum_over_min_subquery_is_client_eval(bool async) + public override Task Sum_over_min_subquery(bool async) { - return base.Sum_over_min_subquery_is_client_eval(async); + return base.Sum_over_min_subquery(async); } [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] - public override Task Sum_over_nested_subquery_is_client_eval(bool async) + public override Task Sum_over_nested_subquery(bool async) { - return base.Sum_over_nested_subquery_is_client_eval(async); + return base.Sum_over_nested_subquery(async); } [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] - public override Task Sum_over_subquery_is_client_eval(bool async) + public override Task Sum_over_subquery(bool async) { - return base.Sum_over_subquery_is_client_eval(async); + return base.Sum_over_subquery(async); + } + + [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] + public override Task Sum_over_scalar_returning_subquery(bool async) + { + return base.Sum_over_scalar_returning_subquery(async); + } + + [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] + public override async Task Sum_over_uncorrelated_subquery(bool async) + { + await base.Sum_over_uncorrelated_subquery(async); + } + + [ConditionalTheory(Skip = "Feature 'Subselect in aggregate functions' is not supported by SingleStore")] + public override Task Sum_over_Any_subquery(bool async) + { + return base.Sum_over_Any_subquery(async); } public override async Task Contains_inside_Average_without_GroupBy(bool async) @@ -182,9 +215,6 @@ ELSE 0.0 """); } - protected override bool CanExecuteQueryString - => true; - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindDbFunctionsQuerySingleStoreTest.SingleStore.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindDbFunctionsQuerySingleStoreTest.SingleStore.cs index 8cf4ab2d5..56532aee5 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindDbFunctionsQuerySingleStoreTest.SingleStore.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindDbFunctionsQuerySingleStoreTest.SingleStore.cs @@ -22,7 +22,42 @@ public virtual void DateDiff_Year() AssertSql( @"SELECT COUNT(*) FROM `Orders` AS `o` -WHERE TIMESTAMPDIFF(YEAR, `o`.`OrderDate`, CURRENT_TIMESTAMP()) = 0"); +WHERE TIMESTAMPDIFF(YEAR, `o`.`OrderDate`, CURRENT_TIMESTAMP(6)) = 0"); + } + } + + + [ConditionalFact] + public virtual void DateDiff_Quarter() + { + using (var context = CreateContext()) + { + var count = context.Orders + .Count(c => EF.Functions.DateDiffQuarter(c.OrderDate, DateTime.Now) == 0); + + Assert.Equal(0, count); + + AssertSql( + @"SELECT COUNT(*) +FROM `Orders` AS `o` +WHERE TIMESTAMPDIFF(QUARTER, `o`.`OrderDate`, CURRENT_TIMESTAMP(6)) = 0"); + } + } + + [ConditionalFact] + public virtual void DateDiff_Week() + { + using (var context = CreateContext()) + { + var count = context.Orders + .Count(c => EF.Functions.DateDiffWeek(c.OrderDate, DateTime.Now) == 0); + + Assert.Equal(0, count); + + AssertSql( + @"SELECT COUNT(*) +FROM `Orders` AS `o` +WHERE TIMESTAMPDIFF(WEEK, `o`.`OrderDate`, CURRENT_TIMESTAMP(6)) = 0"); } } @@ -39,7 +74,7 @@ public virtual void DateDiff_Month() AssertSql( @"SELECT COUNT(*) FROM `Orders` AS `o` -WHERE TIMESTAMPDIFF(MONTH, `o`.`OrderDate`, CURRENT_TIMESTAMP()) = 0"); +WHERE TIMESTAMPDIFF(MONTH, `o`.`OrderDate`, CURRENT_TIMESTAMP(6)) = 0"); } } @@ -56,7 +91,7 @@ public virtual void DateDiff_Day() AssertSql( @"SELECT COUNT(*) FROM `Orders` AS `o` -WHERE TIMESTAMPDIFF(DAY, `o`.`OrderDate`, CURRENT_TIMESTAMP()) = 0"); +WHERE TIMESTAMPDIFF(DAY, `o`.`OrderDate`, CURRENT_TIMESTAMP(6)) = 0"); } } @@ -73,7 +108,7 @@ public virtual void DateDiff_Hour() AssertSql( @"SELECT COUNT(*) FROM `Orders` AS `o` -WHERE TIMESTAMPDIFF(HOUR, `o`.`OrderDate`, CURRENT_TIMESTAMP()) = 0"); +WHERE TIMESTAMPDIFF(HOUR, `o`.`OrderDate`, CURRENT_TIMESTAMP(6)) = 0"); } } @@ -90,7 +125,7 @@ public virtual void DateDiff_Minute() AssertSql( @"SELECT COUNT(*) FROM `Orders` AS `o` -WHERE TIMESTAMPDIFF(MINUTE, `o`.`OrderDate`, CURRENT_TIMESTAMP()) = 0"); +WHERE TIMESTAMPDIFF(MINUTE, `o`.`OrderDate`, CURRENT_TIMESTAMP(6)) = 0"); } } @@ -107,7 +142,24 @@ public virtual void DateDiff_Second() AssertSql( @"SELECT COUNT(*) FROM `Orders` AS `o` -WHERE TIMESTAMPDIFF(SECOND, `o`.`OrderDate`, CURRENT_TIMESTAMP()) = 0"); +WHERE TIMESTAMPDIFF(SECOND, `o`.`OrderDate`, CURRENT_TIMESTAMP(6)) = 0"); + } + } + + [ConditionalFact] + public virtual void DateDiff_Millisecond() + { + using (var context = CreateContext()) + { + var count = context.Orders + .Count(o => EF.Functions.DateDiffMillisecond(DateTime.Now, DateTime.Now.AddSeconds(1)) == 0); + + Assert.Equal(0, count); + + AssertSql( + @"SELECT COUNT(*) +FROM `Orders` AS `o` +WHERE (TIMESTAMPDIFF(MICROSECOND, CURRENT_TIMESTAMP(6), DATE_ADD(CURRENT_TIMESTAMP(6), INTERVAL CAST(1.0 AS signed) second))) DIV (1000) = 0"); } } @@ -124,7 +176,41 @@ public virtual void DateDiff_Microsecond() AssertSql( @"SELECT COUNT(*) FROM `Orders` AS `o` -WHERE TIMESTAMPDIFF(MICROSECOND, CURRENT_TIMESTAMP(), DATE_ADD(CURRENT_TIMESTAMP(), INTERVAL CAST(1.0 AS signed) second)) = 0"); +WHERE TIMESTAMPDIFF(MICROSECOND, CURRENT_TIMESTAMP(6), DATE_ADD(CURRENT_TIMESTAMP(6), INTERVAL CAST(1.0 AS signed) second)) = 0"); + } + } + + [ConditionalFact] + public virtual void DateDiff_Tick() + { + using (var context = CreateContext()) + { + var count = context.Orders + .Count(o => EF.Functions.DateDiffTick(DateTime.Now, DateTime.Now.AddSeconds(1)) == 0); + + Assert.Equal(0, count); + + AssertSql( + @"SELECT COUNT(*) +FROM `Orders` AS `o` +WHERE (TIMESTAMPDIFF(MICROSECOND, CURRENT_TIMESTAMP(6), DATE_ADD(CURRENT_TIMESTAMP(6), INTERVAL CAST(1.0 AS signed) second)) * 10) = 0"); + } + } + + [ConditionalFact] + public virtual void DateDiff_Nanosecond() + { + using (var context = CreateContext()) + { + var count = context.Orders + .Count(o => EF.Functions.DateDiffNanosecond(DateTime.Now, DateTime.Now.AddSeconds(1)) == 0); + + Assert.Equal(0, count); + + AssertSql( + @"SELECT COUNT(*) +FROM `Orders` AS `o` +WHERE (TIMESTAMPDIFF(MICROSECOND, CURRENT_TIMESTAMP(6), DATE_ADD(CURRENT_TIMESTAMP(6), INTERVAL CAST(1.0 AS signed) second)) * 1000) = 0"); } } @@ -305,5 +391,101 @@ public virtual void Radians() WHERE `c`.`CustomerID` = 'VINET' LIMIT 1"); } + + [ConditionalFact] + public virtual void Contains_with_escape_char() + { + using var context = CreateContext(); + var count = context.Customers.Count(c => c.CompanyName.Replace("/", @"\").Contains(@"\")); + + Assert.Equal(1, count); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Customers` AS `c` +WHERE REPLACE(`c`.`CompanyName`, '/', '\\') LIKE '%\\\\%' +"""); + } + + [ConditionalFact] + public virtual void Contains_with_wild_char() + { + using var context = CreateContext(); + var count = context.Customers.Count(c => c.CompanyName.Replace("/", "%").Contains("%")); + + Assert.Equal(1, count); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Customers` AS `c` +WHERE REPLACE(`c`.`CompanyName`, '/', '%') LIKE '%\\%%' +"""); + } + + [ConditionalFact] + public virtual void StartsWith_with_escape_char() + { + using var context = CreateContext(); + var count = context.Customers.Count(c => c.CompanyName.Replace("A", @"\").StartsWith(@"\")); + + Assert.Equal(4, count); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Customers` AS `c` +WHERE REPLACE(`c`.`CompanyName`, 'A', '\\') LIKE '\\\\%' +"""); + } + + [ConditionalFact] + public virtual void StartsWith_with_wild_char() + { + using var context = CreateContext(); + var count = context.Customers.Count(c => c.CompanyName.Replace("A", @"%").StartsWith(@"%")); + + Assert.Equal(4, count); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Customers` AS `c` +WHERE REPLACE(`c`.`CompanyName`, 'A', '%') LIKE '\\%%' +"""); + } + + [ConditionalFact] + public virtual void EndsWith_with_escape_char() + { + using var context = CreateContext(); + var count = context.Customers.Count(c => c.CompanyName.Replace("a", @"\").EndsWith(@"\")); + + Assert.Equal(7, count); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Customers` AS `c` +WHERE REPLACE(`c`.`CompanyName`, 'a', '\\') LIKE '%\\\\' +"""); + } + + [ConditionalFact] + public virtual void EndsWith_with_wild_char() + { + using var context = CreateContext(); + var count = context.Customers.Count(c => c.CompanyName.Replace("a", @"%").EndsWith(@"%")); + + Assert.Equal(7, count); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Customers` AS `c` +WHERE REPLACE(`c`.`CompanyName`, 'a', '%') LIKE '%\\%' +"""); + } } } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySingleStoreTest.cs index b52dc5a60..495c68d90 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySingleStoreTest.cs @@ -7,8 +7,6 @@ using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; -using EntityFrameworkCore.SingleStore.Tests; -using Microsoft.CodeAnalysis.VisualBasic.Syntax; using Xunit; namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query; @@ -25,7 +23,7 @@ public NorthwindEFPropertyIncludeQuerySingleStoreTest(NorthwindQuerySingleStoreF [ConditionalFact] public virtual void Check_all_tests_overridden() - => TestHelpers.AssertAllMethodsOverridden(GetType()); + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); public override async Task Include_collection_with_last_no_orderby(bool async) { @@ -56,17 +54,17 @@ public override async Task Include_collection_order_by_non_key_with_first_or_def await base.Include_collection_order_by_non_key_with_first_or_default(async); AssertSql( -""" -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM ( - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` - FROM `Customers` AS `c` - ORDER BY `c`.`CompanyName` DESC - LIMIT 1 -) AS `t` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -ORDER BY `t`.`CompanyName` DESC, `t`.`CustomerID` -"""); + """ + SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Customers` AS `c` + ORDER BY `c`.`CompanyName` DESC + LIMIT 1 + ) AS `c0` + LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` + ORDER BY `c0`.`CompanyName` DESC, `c0`.`CustomerID` + """); } public override async Task Include_with_cycle_does_not_throw_when_AsTracking_NoTrackingWithIdentityResolution(bool async) @@ -182,19 +180,19 @@ public override async Task Include_collection_with_cross_join_clause_with_filter await base.Include_collection_with_cross_join_clause_with_filter(async); AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `t`.`OrderID`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` -FROM `Customers` AS `c` -CROSS JOIN ( - SELECT `o`.`OrderID` - FROM `Orders` AS `o` - ORDER BY `o`.`OrderID` - LIMIT 5 -) AS `t` -LEFT JOIN `Orders` AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` -WHERE `c`.`CustomerID` LIKE 'F%' -ORDER BY `c`.`CustomerID`, `t`.`OrderID` -"""); + """ + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o0`.`OrderID`, `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate` + FROM `Customers` AS `c` + CROSS JOIN ( + SELECT `o`.`OrderID` + FROM `Orders` AS `o` + ORDER BY `o`.`OrderID` + LIMIT 5 + ) AS `o0` + LEFT JOIN `Orders` AS `o1` ON `c`.`CustomerID` = `o1`.`CustomerID` + WHERE `c`.`CustomerID` LIKE 'F%' + ORDER BY `c`.`CustomerID`, `o0`.`OrderID` + """); } public override async Task Join_Include_reference_GroupBy_Select(bool async) @@ -202,25 +200,25 @@ public override async Task Join_Include_reference_GroupBy_Select(bool async) await base.Join_Include_reference_GroupBy_Select(async); AssertSql( -""" -SELECT `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `t0`.`CustomerID0`, `t0`.`Address`, `t0`.`City`, `t0`.`CompanyName`, `t0`.`ContactName`, `t0`.`ContactTitle`, `t0`.`Country`, `t0`.`Fax`, `t0`.`Phone`, `t0`.`PostalCode`, `t0`.`Region` -FROM ( - SELECT `o0`.`OrderID` - FROM `Order Details` AS `o` - INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` - GROUP BY `o0`.`OrderID` -) AS `t` -LEFT JOIN ( - SELECT `t1`.`OrderID`, `t1`.`CustomerID`, `t1`.`EmployeeID`, `t1`.`OrderDate`, `t1`.`CustomerID0`, `t1`.`Address`, `t1`.`City`, `t1`.`CompanyName`, `t1`.`ContactName`, `t1`.`ContactTitle`, `t1`.`Country`, `t1`.`Fax`, `t1`.`Phone`, `t1`.`PostalCode`, `t1`.`Region` - FROM ( - SELECT `o2`.`OrderID`, `o2`.`CustomerID`, `o2`.`EmployeeID`, `o2`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, ROW_NUMBER() OVER(PARTITION BY `o2`.`OrderID` ORDER BY `o2`.`OrderID`) AS `row` - FROM `Order Details` AS `o1` - INNER JOIN `Orders` AS `o2` ON `o1`.`OrderID` = `o2`.`OrderID` - LEFT JOIN `Customers` AS `c` ON `o2`.`CustomerID` = `c`.`CustomerID` - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`OrderID` = `t0`.`OrderID` -"""); + """ + SELECT `s1`.`OrderID`, `s1`.`CustomerID`, `s1`.`EmployeeID`, `s1`.`OrderDate`, `s1`.`CustomerID0`, `s1`.`Address`, `s1`.`City`, `s1`.`CompanyName`, `s1`.`ContactName`, `s1`.`ContactTitle`, `s1`.`Country`, `s1`.`Fax`, `s1`.`Phone`, `s1`.`PostalCode`, `s1`.`Region` + FROM ( + SELECT `o0`.`OrderID` + FROM `Order Details` AS `o` + INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` + GROUP BY `o0`.`OrderID` + ) AS `s` + LEFT JOIN ( + SELECT `s0`.`OrderID`, `s0`.`CustomerID`, `s0`.`EmployeeID`, `s0`.`OrderDate`, `s0`.`CustomerID0`, `s0`.`Address`, `s0`.`City`, `s0`.`CompanyName`, `s0`.`ContactName`, `s0`.`ContactTitle`, `s0`.`Country`, `s0`.`Fax`, `s0`.`Phone`, `s0`.`PostalCode`, `s0`.`Region` + FROM ( + SELECT `o2`.`OrderID`, `o2`.`CustomerID`, `o2`.`EmployeeID`, `o2`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, ROW_NUMBER() OVER(PARTITION BY `o2`.`OrderID` ORDER BY `o2`.`OrderID`) AS `row` + FROM `Order Details` AS `o1` + INNER JOIN `Orders` AS `o2` ON `o1`.`OrderID` = `o2`.`OrderID` + LEFT JOIN `Customers` AS `c` ON `o2`.`CustomerID` = `c`.`CustomerID` + ) AS `s0` + WHERE `s0`.`row` <= 1 + ) AS `s1` ON `s`.`OrderID` = `s1`.`OrderID` + """); } public override async Task Include_multi_level_reference_and_collection_predicate(bool async) @@ -228,18 +226,18 @@ public override async Task Include_multi_level_reference_and_collection_predicat await base.Include_multi_level_reference_and_collection_predicate(async); AssertSql( -""" -SELECT `t`.`OrderID`, `t`.`CustomerID`, `t`.`EmployeeID`, `t`.`OrderDate`, `t`.`CustomerID0`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` -FROM ( - SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` - FROM `Orders` AS `o` - LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` - WHERE `o`.`OrderID` = 10248 - LIMIT 2 -) AS `t` -LEFT JOIN `Orders` AS `o0` ON `t`.`CustomerID0` = `o0`.`CustomerID` -ORDER BY `t`.`OrderID`, `t`.`CustomerID0` -"""); + """ + SELECT `s`.`OrderID`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate`, `s`.`CustomerID0`, `s`.`Address`, `s`.`City`, `s`.`CompanyName`, `s`.`ContactName`, `s`.`ContactTitle`, `s`.`Country`, `s`.`Fax`, `s`.`Phone`, `s`.`PostalCode`, `s`.`Region`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` + FROM ( + SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Orders` AS `o` + LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` + WHERE `o`.`OrderID` = 10248 + LIMIT 2 + ) AS `s` + LEFT JOIN `Orders` AS `o0` ON `s`.`CustomerID0` = `o0`.`CustomerID` + ORDER BY `s`.`OrderID`, `s`.`CustomerID0` + """); } public override async Task Include_references_then_include_collection(bool async) @@ -262,17 +260,17 @@ public override async Task Include_collection_on_additional_from_clause_with_fil await base.Include_collection_on_additional_from_clause_with_filter(async); AssertSql( -""" -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `c`.`CustomerID`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM `Customers` AS `c` -CROSS JOIN ( - SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` - FROM `Customers` AS `c0` - WHERE `c0`.`CustomerID` = 'ALFKI' -) AS `t` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -ORDER BY `c`.`CustomerID`, `t`.`CustomerID` -"""); + """ + SELECT `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region`, `c`.`CustomerID`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + FROM `Customers` AS `c` + CROSS JOIN ( + SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` + FROM `Customers` AS `c0` + WHERE `c0`.`CustomerID` = 'ALFKI' + ) AS `c1` + LEFT JOIN `Orders` AS `o` ON `c1`.`CustomerID` = `o`.`CustomerID` + ORDER BY `c`.`CustomerID`, `c1`.`CustomerID` + """); } public override async Task Include_duplicate_reference3(bool async) @@ -280,25 +278,25 @@ public override async Task Include_duplicate_reference3(bool async) await base.Include_duplicate_reference3(async); AssertSql( -""" -@__p_0='2' - -SELECT `t`.`OrderID`, `t`.`CustomerID`, `t`.`EmployeeID`, `t`.`OrderDate`, `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM ( - SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` - FROM `Orders` AS `o` - ORDER BY `o`.`OrderID` - LIMIT @__p_0 -) AS `t` -CROSS JOIN ( - SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` - FROM `Orders` AS `o0` - ORDER BY `o0`.`OrderID` - LIMIT 2 OFFSET 2 -) AS `t0` -LEFT JOIN `Customers` AS `c` ON `t0`.`CustomerID` = `c`.`CustomerID` -ORDER BY `t`.`OrderID` -"""); + """ + @__p_0='2' + + SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate`, `o2`.`OrderID`, `o2`.`CustomerID`, `o2`.`EmployeeID`, `o2`.`OrderDate`, `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM ( + SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + FROM `Orders` AS `o` + ORDER BY `o`.`OrderID` + LIMIT @__p_0 + ) AS `o1` + CROSS JOIN ( + SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` + FROM `Orders` AS `o0` + ORDER BY `o0`.`OrderID` + LIMIT 2 OFFSET 2 + ) AS `o2` + LEFT JOIN `Customers` AS `c` ON `o2`.`CustomerID` = `c`.`CustomerID` + ORDER BY `o1`.`OrderID` + """); } public override async Task Include_collection_order_by_non_key_with_take(bool async) @@ -306,19 +304,19 @@ public override async Task Include_collection_order_by_non_key_with_take(bool as await base.Include_collection_order_by_non_key_with_take(async); AssertSql( -""" -@__p_0='10' - -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM ( - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` - FROM `Customers` AS `c` - ORDER BY `c`.`ContactTitle` - LIMIT @__p_0 -) AS `t` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -ORDER BY `t`.`ContactTitle`, `t`.`CustomerID` -"""); + """ + @__p_0='10' + + SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Customers` AS `c` + ORDER BY `c`.`ContactTitle` + LIMIT @__p_0 + ) AS `c0` + LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` + ORDER BY `c0`.`ContactTitle`, `c0`.`CustomerID` + """); } public override async Task Include_collection_then_include_collection_predicate(bool async) @@ -326,21 +324,21 @@ public override async Task Include_collection_then_include_collection_predicate( await base.Include_collection_then_include_collection_predicate(async); AssertSql( -""" -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `t0`.`OrderID0`, `t0`.`ProductID`, `t0`.`Discount`, `t0`.`Quantity`, `t0`.`UnitPrice` -FROM ( - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` - FROM `Customers` AS `c` - WHERE `c`.`CustomerID` = 'ALFKI' - LIMIT 2 -) AS `t` -LEFT JOIN ( - SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `o0`.`OrderID` AS `OrderID0`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` - FROM `Orders` AS `o` - LEFT JOIN `Order Details` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` -) AS `t0` ON `t`.`CustomerID` = `t0`.`CustomerID` -ORDER BY `t`.`CustomerID`, `t0`.`OrderID`, `t0`.`OrderID0` -"""); + """ + SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `s`.`OrderID`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate`, `s`.`OrderID0`, `s`.`ProductID`, `s`.`Discount`, `s`.`Quantity`, `s`.`UnitPrice` + FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` = 'ALFKI' + LIMIT 2 + ) AS `c0` + LEFT JOIN ( + SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `o0`.`OrderID` AS `OrderID0`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` + FROM `Orders` AS `o` + LEFT JOIN `Order Details` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` + ) AS `s` ON `c0`.`CustomerID` = `s`.`CustomerID` + ORDER BY `c0`.`CustomerID`, `s`.`OrderID`, `s`.`OrderID0` + """); } [ConditionalTheory(Skip = "SingleStore's ORDER BY behavior inconsistent with MySQL")] @@ -368,24 +366,24 @@ public override async Task Include_collection_principal_already_tracked(bool asy await base.Include_collection_principal_already_tracked(async); AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` = 'ALFKI' -LIMIT 2 -""", - // - """ -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` -FROM ( - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` - FROM `Customers` AS `c` - WHERE `c`.`CustomerID` = 'ALFKI' - LIMIT 2 -) AS `t` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -ORDER BY `t`.`CustomerID` -"""); + """ + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` = 'ALFKI' + LIMIT 2 + """, + // + """ + SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` = 'ALFKI' + LIMIT 2 + ) AS `c0` + LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` + ORDER BY `c0`.`CustomerID` + """); } public override async Task Include_collection_OrderBy_object(bool async) @@ -467,7 +465,7 @@ await AssertQuery( """ @__p_0='2' -SELECT `t`.`OrderID`, `t`.`CustomerID`, `t`.`EmployeeID`, `t`.`OrderDate`, `t`.`CustomerID0`, `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` +SELECT `s`.`OrderID`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate`, `s`.`CustomerID0`, `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` FROM ( SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0`, `c`.`CustomerID` IS NOT NULL AS `c`, CASE WHEN `c`.`CustomerID` IS NOT NULL THEN `c`.`CustomerID` @@ -480,9 +478,9 @@ END AS `c0` ELSE '' END, `o`.`EmployeeID` LIMIT @__p_0 -) AS `t` -LEFT JOIN `Order Details` AS `o0` ON `t`.`OrderID` = `o0`.`OrderID` -ORDER BY `t`.`c`, `t`.`c0`, `t`.`EmployeeID`, `t`.`OrderID`, `t`.`CustomerID0`, `o0`.`OrderID` +) AS `s` +LEFT JOIN `Order Details` AS `o0` ON `s`.`OrderID` = `o0`.`OrderID` +ORDER BY `s`.`c`, `s`.`c0`, `s`.`EmployeeID`, `s`.`OrderID`, `s`.`CustomerID0`, `o0`.`OrderID` """); } @@ -492,15 +490,15 @@ public override async Task Include_collection_single_or_default_no_result(bool a AssertSql( """ -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`CustomerID` = 'ALFKI ?' LIMIT 2 -) AS `t` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -ORDER BY `t`.`CustomerID` +) AS `c0` +LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c0`.`CustomerID` """); } @@ -510,7 +508,7 @@ public override async Task Include_collection_with_cross_apply_with_filter(bool AssertSql( """ -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `t`.`OrderID`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o0`.`OrderID`, `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate` FROM `Customers` AS `c` JOIN LATERAL ( SELECT `o`.`OrderID` @@ -518,10 +516,10 @@ JOIN LATERAL ( WHERE `o`.`CustomerID` = `c`.`CustomerID` ORDER BY `c`.`CustomerID` LIMIT 5 -) AS `t` ON TRUE -LEFT JOIN `Orders` AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` +) AS `o0` ON TRUE +LEFT JOIN `Orders` AS `o1` ON `c`.`CustomerID` = `o1`.`CustomerID` WHERE `c`.`CustomerID` LIKE 'F%' -ORDER BY `c`.`CustomerID`, `t`.`OrderID` +ORDER BY `c`.`CustomerID`, `o0`.`OrderID` """); } @@ -548,22 +546,22 @@ public override async Task Include_duplicate_collection(bool async) """ @__p_0='2' -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `t0`.`CustomerID`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `t0`.`Address`, `t0`.`City`, `t0`.`CompanyName`, `t0`.`ContactName`, `t0`.`ContactTitle`, `t0`.`Country`, `t0`.`Fax`, `t0`.`Phone`, `t0`.`PostalCode`, `t0`.`Region`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` +SELECT `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region`, `c2`.`CustomerID`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `c2`.`Address`, `c2`.`City`, `c2`.`CompanyName`, `c2`.`ContactName`, `c2`.`ContactTitle`, `c2`.`Country`, `c2`.`Fax`, `c2`.`Phone`, `c2`.`PostalCode`, `c2`.`Region`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` ORDER BY `c`.`CustomerID` LIMIT @__p_0 -) AS `t` +) AS `c1` CROSS JOIN ( SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` FROM `Customers` AS `c0` ORDER BY `c0`.`CustomerID` LIMIT 2 OFFSET 2 -) AS `t0` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -LEFT JOIN `Orders` AS `o0` ON `t0`.`CustomerID` = `o0`.`CustomerID` -ORDER BY `t`.`CustomerID`, `t0`.`CustomerID`, `o`.`OrderID` +) AS `c2` +LEFT JOIN `Orders` AS `o` ON `c1`.`CustomerID` = `o`.`CustomerID` +LEFT JOIN `Orders` AS `o0` ON `c2`.`CustomerID` = `o0`.`CustomerID` +ORDER BY `c1`.`CustomerID`, `c2`.`CustomerID`, `o`.`OrderID` """); } @@ -586,21 +584,21 @@ public override async Task Include_collection_then_include_collection_then_inclu await base.Include_collection_then_include_collection_then_include_reference(async); AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `t0`.`OrderID0`, `t0`.`ProductID`, `t0`.`Discount`, `t0`.`Quantity`, `t0`.`UnitPrice`, `t0`.`ProductID0`, `t0`.`Discontinued`, `t0`.`ProductName`, `t0`.`SupplierID`, `t0`.`UnitPrice0`, `t0`.`UnitsInStock` -FROM `Customers` AS `c` -LEFT JOIN ( - SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `t`.`OrderID` AS `OrderID0`, `t`.`ProductID`, `t`.`Discount`, `t`.`Quantity`, `t`.`UnitPrice`, `t`.`ProductID0`, `t`.`Discontinued`, `t`.`ProductName`, `t`.`SupplierID`, `t`.`UnitPrice0`, `t`.`UnitsInStock` - FROM `Orders` AS `o` - LEFT JOIN ( - SELECT `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice`, `p`.`ProductID` AS `ProductID0`, `p`.`Discontinued`, `p`.`ProductName`, `p`.`SupplierID`, `p`.`UnitPrice` AS `UnitPrice0`, `p`.`UnitsInStock` - FROM `Order Details` AS `o0` - INNER JOIN `Products` AS `p` ON `o0`.`ProductID` = `p`.`ProductID` - ) AS `t` ON `o`.`OrderID` = `t`.`OrderID` -) AS `t0` ON `c`.`CustomerID` = `t0`.`CustomerID` -WHERE `c`.`CustomerID` LIKE 'F%' -ORDER BY `c`.`CustomerID`, `t0`.`OrderID`, `t0`.`OrderID0`, `t0`.`ProductID` -"""); + """ + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `s0`.`OrderID`, `s0`.`CustomerID`, `s0`.`EmployeeID`, `s0`.`OrderDate`, `s0`.`OrderID0`, `s0`.`ProductID`, `s0`.`Discount`, `s0`.`Quantity`, `s0`.`UnitPrice`, `s0`.`ProductID0`, `s0`.`Discontinued`, `s0`.`ProductName`, `s0`.`SupplierID`, `s0`.`UnitPrice0`, `s0`.`UnitsInStock` + FROM `Customers` AS `c` + LEFT JOIN ( + SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `s`.`OrderID` AS `OrderID0`, `s`.`ProductID`, `s`.`Discount`, `s`.`Quantity`, `s`.`UnitPrice`, `s`.`ProductID0`, `s`.`Discontinued`, `s`.`ProductName`, `s`.`SupplierID`, `s`.`UnitPrice0`, `s`.`UnitsInStock` + FROM `Orders` AS `o` + LEFT JOIN ( + SELECT `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice`, `p`.`ProductID` AS `ProductID0`, `p`.`Discontinued`, `p`.`ProductName`, `p`.`SupplierID`, `p`.`UnitPrice` AS `UnitPrice0`, `p`.`UnitsInStock` + FROM `Order Details` AS `o0` + INNER JOIN `Products` AS `p` ON `o0`.`ProductID` = `p`.`ProductID` + ) AS `s` ON `o`.`OrderID` = `s`.`OrderID` + ) AS `s0` ON `c`.`CustomerID` = `s0`.`CustomerID` + WHERE `c`.`CustomerID` LIKE 'F%' + ORDER BY `c`.`CustomerID`, `s0`.`OrderID`, `s0`.`OrderID0`, `s0`.`ProductID` + """); } public override async Task Include_reference_GroupBy_Select(bool async) @@ -608,25 +606,25 @@ public override async Task Include_reference_GroupBy_Select(bool async) await base.Include_reference_GroupBy_Select(async); AssertSql( -""" -SELECT `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `t0`.`CustomerID0`, `t0`.`Address`, `t0`.`City`, `t0`.`CompanyName`, `t0`.`ContactName`, `t0`.`ContactTitle`, `t0`.`Country`, `t0`.`Fax`, `t0`.`Phone`, `t0`.`PostalCode`, `t0`.`Region` -FROM ( - SELECT `o`.`OrderID` - FROM `Orders` AS `o` - WHERE `o`.`OrderID` = 10248 - GROUP BY `o`.`OrderID` -) AS `t` -LEFT JOIN ( - SELECT `t1`.`OrderID`, `t1`.`CustomerID`, `t1`.`EmployeeID`, `t1`.`OrderDate`, `t1`.`CustomerID0`, `t1`.`Address`, `t1`.`City`, `t1`.`CompanyName`, `t1`.`ContactName`, `t1`.`ContactTitle`, `t1`.`Country`, `t1`.`Fax`, `t1`.`Phone`, `t1`.`PostalCode`, `t1`.`Region` - FROM ( - SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, ROW_NUMBER() OVER(PARTITION BY `o0`.`OrderID` ORDER BY `o0`.`OrderID`) AS `row` - FROM `Orders` AS `o0` - LEFT JOIN `Customers` AS `c` ON `o0`.`CustomerID` = `c`.`CustomerID` - WHERE `o0`.`OrderID` = 10248 - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`OrderID` = `t0`.`OrderID` -"""); + """ + SELECT `s0`.`OrderID`, `s0`.`CustomerID`, `s0`.`EmployeeID`, `s0`.`OrderDate`, `s0`.`CustomerID0`, `s0`.`Address`, `s0`.`City`, `s0`.`CompanyName`, `s0`.`ContactName`, `s0`.`ContactTitle`, `s0`.`Country`, `s0`.`Fax`, `s0`.`Phone`, `s0`.`PostalCode`, `s0`.`Region` + FROM ( + SELECT `o`.`OrderID` + FROM `Orders` AS `o` + WHERE `o`.`OrderID` = 10248 + GROUP BY `o`.`OrderID` + ) AS `o1` + LEFT JOIN ( + SELECT `s`.`OrderID`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate`, `s`.`CustomerID0`, `s`.`Address`, `s`.`City`, `s`.`CompanyName`, `s`.`ContactName`, `s`.`ContactTitle`, `s`.`Country`, `s`.`Fax`, `s`.`Phone`, `s`.`PostalCode`, `s`.`Region` + FROM ( + SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, ROW_NUMBER() OVER(PARTITION BY `o0`.`OrderID` ORDER BY `o0`.`OrderID`) AS `row` + FROM `Orders` AS `o0` + LEFT JOIN `Customers` AS `c` ON `o0`.`CustomerID` = `c`.`CustomerID` + WHERE `o0`.`OrderID` = 10248 + ) AS `s` + WHERE `s`.`row` <= 1 + ) AS `s0` ON `o1`.`OrderID` = `s0`.`OrderID` + """); } public override async Task Include_multiple_references_multi_level_reverse(bool async) @@ -666,49 +664,50 @@ public override async Task Include_collection_OrderBy_list_does_not_contains(boo if (SingleStoreTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { AssertSql( - """ - @__p_1='1' - SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` - FROM ( - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, NOT (COALESCE(`c`.`CustomerID` IN ( - SELECT `l`.`value` - FROM JSON_TABLE('["ALFKI"]', '$[*]' COLUMNS ( - `key` FOR ORDINALITY, - `value` char(5) PATH '$[0]' - )) AS `l` - ), FALSE)) AS `c` - FROM `Customers` AS `c` - WHERE `c`.`CustomerID` LIKE 'A%' - ORDER BY NOT (COALESCE(`c`.`CustomerID` IN ( - SELECT `l`.`value` - FROM JSON_TABLE('["ALFKI"]', '$[*]' COLUMNS ( - `key` FOR ORDINALITY, - `value` char(5) PATH '$[0]' - )) AS `l` - ), FALSE)) - LIMIT 18446744073709551610 OFFSET @__p_1 - ) AS `t` - LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` - ORDER BY `t`.`c`, `t`.`CustomerID` - """); +""" +@__p_1='1' + +SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, NOT (COALESCE(`c`.`CustomerID` IN ( + SELECT `l`.`value` + FROM JSON_TABLE('["ALFKI"]', '$[*]' COLUMNS ( + `key` FOR ORDINALITY, + `value` char(5) PATH '$[0]' + )) AS `l` + ), FALSE)) AS `c` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'A%' + ORDER BY NOT (COALESCE(`c`.`CustomerID` IN ( + SELECT `l`.`value` + FROM JSON_TABLE('["ALFKI"]', '$[*]' COLUMNS ( + `key` FOR ORDINALITY, + `value` char(5) PATH '$[0]' + )) AS `l` + ), FALSE)) + LIMIT 18446744073709551610 OFFSET @__p_1 +) AS `t` +LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` +ORDER BY `t`.`c`, `t`.`CustomerID` +"""); } else { - AssertSql( - """ - @__p_1='1' + AssertSql( +""" +@__p_1='1' - SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` - FROM ( - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `c`.`CustomerID` <> 'ALFKI' AS `c` - FROM `Customers` AS `c` - WHERE `c`.`CustomerID` LIKE 'A%' - ORDER BY `c`.`CustomerID` <> 'ALFKI' - LIMIT 18446744073709551610 OFFSET @__p_1 - ) AS `t` - LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` - ORDER BY `t`.`c`, `t`.`CustomerID` - """); +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `c`.`CustomerID` <> 'ALFKI' AS `c` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'A%' + ORDER BY `c`.`CustomerID` <> 'ALFKI' + LIMIT 18446744073709551610 OFFSET @__p_1 +) AS `c0` +LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c0`.`c`, `c0`.`CustomerID` +"""); } } @@ -750,26 +749,26 @@ public override async Task Include_duplicate_reference(bool async) await base.Include_duplicate_reference(async); AssertSql( -""" -@__p_0='2' - -SELECT `t`.`OrderID`, `t`.`CustomerID`, `t`.`EmployeeID`, `t`.`OrderDate`, `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` -FROM ( - SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` - FROM `Orders` AS `o` - ORDER BY `o`.`CustomerID`, `o`.`OrderID` - LIMIT @__p_0 -) AS `t` -CROSS JOIN ( - SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` - FROM `Orders` AS `o0` - ORDER BY `o0`.`CustomerID`, `o0`.`OrderID` - LIMIT 2 OFFSET 2 -) AS `t0` -LEFT JOIN `Customers` AS `c` ON `t`.`CustomerID` = `c`.`CustomerID` -LEFT JOIN `Customers` AS `c0` ON `t0`.`CustomerID` = `c0`.`CustomerID` -ORDER BY `t`.`CustomerID`, `t`.`OrderID` -"""); + """ + @__p_0='2' + + SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate`, `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o2`.`OrderID`, `o2`.`CustomerID`, `o2`.`EmployeeID`, `o2`.`OrderDate`, `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` + FROM ( + SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + FROM `Orders` AS `o` + ORDER BY `o`.`CustomerID`, `o`.`OrderID` + LIMIT @__p_0 + ) AS `o1` + CROSS JOIN ( + SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` + FROM `Orders` AS `o0` + ORDER BY `o0`.`CustomerID`, `o0`.`OrderID` + LIMIT 2 OFFSET 2 + ) AS `o2` + LEFT JOIN `Customers` AS `c` ON `o1`.`CustomerID` = `c`.`CustomerID` + LEFT JOIN `Customers` AS `c0` ON `o2`.`CustomerID` = `c0`.`CustomerID` + ORDER BY `o1`.`CustomerID`, `o1`.`OrderID` + """); } public override async Task Include_with_complex_projection(bool async) @@ -792,16 +791,16 @@ public override async Task Include_collection_order_by_non_key_with_skip(bool as """ @__p_0='2' -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'F%' ORDER BY `c`.`ContactTitle` LIMIT 18446744073709551610 OFFSET @__p_0 -) AS `t` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -ORDER BY `t`.`ContactTitle`, `t`.`CustomerID` +) AS `c0` +LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c0`.`ContactTitle`, `c0`.`CustomerID` """); } @@ -828,25 +827,25 @@ public override async Task Multi_level_includes_are_applied_with_take(bool async """ @__p_0='1' -SELECT `t0`.`CustomerID`, `t1`.`OrderID`, `t1`.`CustomerID`, `t1`.`EmployeeID`, `t1`.`OrderDate`, `t1`.`OrderID0`, `t1`.`ProductID`, `t1`.`Discount`, `t1`.`Quantity`, `t1`.`UnitPrice` +SELECT `c1`.`CustomerID`, `s`.`OrderID`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate`, `s`.`OrderID0`, `s`.`ProductID`, `s`.`Discount`, `s`.`Quantity`, `s`.`UnitPrice` FROM ( - SELECT `t`.`CustomerID` + SELECT `c0`.`CustomerID` FROM ( SELECT `c`.`CustomerID` FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'A%' ORDER BY `c`.`CustomerID` LIMIT @__p_0 - ) AS `t` - ORDER BY `t`.`CustomerID` + ) AS `c0` + ORDER BY `c0`.`CustomerID` LIMIT 1 -) AS `t0` +) AS `c1` LEFT JOIN ( SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `o0`.`OrderID` AS `OrderID0`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` FROM `Orders` AS `o` LEFT JOIN `Order Details` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` -) AS `t1` ON `t0`.`CustomerID` = `t1`.`CustomerID` -ORDER BY `t0`.`CustomerID`, `t1`.`OrderID`, `t1`.`OrderID0` +) AS `s` ON `c1`.`CustomerID` = `s`.`CustomerID` +ORDER BY `c1`.`CustomerID`, `s`.`OrderID`, `s`.`OrderID0` """); } @@ -873,15 +872,15 @@ public override async Task Include_collection_then_reference(bool async) AssertSql( """ -SELECT `p`.`ProductID`, `p`.`Discontinued`, `p`.`ProductName`, `p`.`SupplierID`, `p`.`UnitPrice`, `p`.`UnitsInStock`, `t`.`OrderID`, `t`.`ProductID`, `t`.`Discount`, `t`.`Quantity`, `t`.`UnitPrice`, `t`.`OrderID0`, `t`.`CustomerID`, `t`.`EmployeeID`, `t`.`OrderDate` +SELECT `p`.`ProductID`, `p`.`Discontinued`, `p`.`ProductName`, `p`.`SupplierID`, `p`.`UnitPrice`, `p`.`UnitsInStock`, `s`.`OrderID`, `s`.`ProductID`, `s`.`Discount`, `s`.`Quantity`, `s`.`UnitPrice`, `s`.`OrderID0`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate` FROM `Products` AS `p` LEFT JOIN ( SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice`, `o0`.`OrderID` AS `OrderID0`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` FROM `Order Details` AS `o` INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` -) AS `t` ON `p`.`ProductID` = `t`.`ProductID` +) AS `s` ON `p`.`ProductID` = `s`.`ProductID` WHERE (`p`.`ProductID` % 17) = 5 -ORDER BY `p`.`ProductID`, `t`.`OrderID`, `t`.`ProductID` +ORDER BY `p`.`ProductID`, `s`.`OrderID`, `s`.`ProductID` """); } @@ -905,7 +904,7 @@ public override async Task Include_collection_with_outer_apply_with_filter(bool AssertSql( """ -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `t`.`OrderID`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o0`.`OrderID`, `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate` FROM `Customers` AS `c` LEFT JOIN LATERAL ( SELECT `o`.`OrderID` @@ -913,10 +912,10 @@ LEFT JOIN LATERAL ( WHERE `o`.`CustomerID` = `c`.`CustomerID` ORDER BY `c`.`CustomerID` LIMIT 5 -) AS `t` ON TRUE -LEFT JOIN `Orders` AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` +) AS `o0` ON TRUE +LEFT JOIN `Orders` AS `o1` ON `c`.`CustomerID` = `o1`.`CustomerID` WHERE `c`.`CustomerID` LIKE 'F%' -ORDER BY `c`.`CustomerID`, `t`.`OrderID` +ORDER BY `c`.`CustomerID`, `o0`.`OrderID` """); } @@ -928,15 +927,15 @@ public override async Task Include_collection_on_additional_from_clause2(bool as """ @__p_0='5' -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region` +SELECT `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` ORDER BY `c`.`CustomerID` LIMIT @__p_0 -) AS `t` +) AS `c1` CROSS JOIN `Customers` AS `c0` -ORDER BY `t`.`CustomerID` +ORDER BY `c1`.`CustomerID` """); } @@ -952,15 +951,15 @@ public override async Task Include_collection_dependent_already_tracked(bool asy """, // """ -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`CustomerID` = 'ALFKI' LIMIT 2 -) AS `t` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -ORDER BY `t`.`CustomerID` +) AS `c0` +LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c0`.`CustomerID` """); } @@ -989,19 +988,19 @@ public override async Task Include_multi_level_collection_and_then_include_refer AssertSql( """ -SELECT `t`.`OrderID`, `t`.`CustomerID`, `t`.`EmployeeID`, `t`.`OrderDate`, `t0`.`OrderID`, `t0`.`ProductID`, `t0`.`Discount`, `t0`.`Quantity`, `t0`.`UnitPrice`, `t0`.`ProductID0`, `t0`.`Discontinued`, `t0`.`ProductName`, `t0`.`SupplierID`, `t0`.`UnitPrice0`, `t0`.`UnitsInStock` +SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate`, `s`.`OrderID`, `s`.`ProductID`, `s`.`Discount`, `s`.`Quantity`, `s`.`UnitPrice`, `s`.`ProductID0`, `s`.`Discontinued`, `s`.`ProductName`, `s`.`SupplierID`, `s`.`UnitPrice0`, `s`.`UnitsInStock` FROM ( SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderID` = 10248 LIMIT 2 -) AS `t` +) AS `o1` LEFT JOIN ( SELECT `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice`, `p`.`ProductID` AS `ProductID0`, `p`.`Discontinued`, `p`.`ProductName`, `p`.`SupplierID`, `p`.`UnitPrice` AS `UnitPrice0`, `p`.`UnitsInStock` FROM `Order Details` AS `o0` INNER JOIN `Products` AS `p` ON `o0`.`ProductID` = `p`.`ProductID` -) AS `t0` ON `t`.`OrderID` = `t0`.`OrderID` -ORDER BY `t`.`OrderID`, `t0`.`OrderID`, `t0`.`ProductID` +) AS `s` ON `o1`.`OrderID` = `s`.`OrderID` +ORDER BY `o1`.`OrderID`, `s`.`OrderID`, `s`.`ProductID` """); } @@ -1013,25 +1012,25 @@ public override async Task Multi_level_includes_are_applied_with_skip_take(bool """ @__p_0='1' -SELECT `t0`.`CustomerID`, `t1`.`OrderID`, `t1`.`CustomerID`, `t1`.`EmployeeID`, `t1`.`OrderDate`, `t1`.`OrderID0`, `t1`.`ProductID`, `t1`.`Discount`, `t1`.`Quantity`, `t1`.`UnitPrice` +SELECT `c1`.`CustomerID`, `s`.`OrderID`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate`, `s`.`OrderID0`, `s`.`ProductID`, `s`.`Discount`, `s`.`Quantity`, `s`.`UnitPrice` FROM ( - SELECT `t`.`CustomerID` + SELECT `c0`.`CustomerID` FROM ( SELECT `c`.`CustomerID` FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'A%' ORDER BY `c`.`CustomerID` LIMIT @__p_0 OFFSET @__p_0 - ) AS `t` - ORDER BY `t`.`CustomerID` + ) AS `c0` + ORDER BY `c0`.`CustomerID` LIMIT 1 -) AS `t0` +) AS `c1` LEFT JOIN ( SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `o0`.`OrderID` AS `OrderID0`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` FROM `Orders` AS `o` LEFT JOIN `Order Details` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` -) AS `t1` ON `t0`.`CustomerID` = `t1`.`CustomerID` -ORDER BY `t0`.`CustomerID`, `t1`.`OrderID`, `t1`.`OrderID0` +) AS `s` ON `c1`.`CustomerID` = `s`.`CustomerID` +ORDER BY `c1`.`CustomerID`, `s`.`OrderID`, `s`.`OrderID0` """); } @@ -1043,48 +1042,49 @@ public override async Task Include_collection_OrderBy_empty_list_contains(bool a if (SingleStoreTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { AssertSql( - """ - @__p_1='1' - SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` - FROM ( - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, COALESCE(`c`.`CustomerID` IN ( - SELECT `l`.`value` - FROM JSON_TABLE('[]', '$[*]' COLUMNS ( - `key` FOR ORDINALITY, - `value` char(5) PATH '$[0]' - )) AS `l` - ), FALSE) AS `c` - FROM `Customers` AS `c` - WHERE `c`.`CustomerID` LIKE 'A%' - ORDER BY COALESCE(`c`.`CustomerID` IN ( - SELECT `l`.`value` - FROM JSON_TABLE('[]', '$[*]' COLUMNS ( - `key` FOR ORDINALITY, - `value` char(5) PATH '$[0]' - )) AS `l` - ), FALSE) - LIMIT 18446744073709551610 OFFSET @__p_1 - ) AS `t` - LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` - ORDER BY `t`.`c`, `t`.`CustomerID` - """); +""" +@__p_1='1' + +SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, COALESCE(`c`.`CustomerID` IN ( + SELECT `l`.`value` + FROM JSON_TABLE('[]', '$[*]' COLUMNS ( + `key` FOR ORDINALITY, + `value` char(5) PATH '$[0]' + )) AS `l` + ), FALSE) AS `c` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'A%' + ORDER BY COALESCE(`c`.`CustomerID` IN ( + SELECT `l`.`value` + FROM JSON_TABLE('[]', '$[*]' COLUMNS ( + `key` FOR ORDINALITY, + `value` char(5) PATH '$[0]' + )) AS `l` + ), FALSE) + LIMIT 18446744073709551610 OFFSET @__p_1 +) AS `t` +LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` +ORDER BY `t`.`c`, `t`.`CustomerID` +"""); } else { - AssertSql( + AssertSql( """ @__p_1='1' -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, FALSE AS `c` FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'A%' ORDER BY (SELECT 1) LIMIT 18446744073709551610 OFFSET @__p_1 -) AS `t` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -ORDER BY `t`.`c`, `t`.`CustomerID` +) AS `c0` +LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c0`.`c`, `c0`.`CustomerID` """); } } @@ -1122,22 +1122,21 @@ public override async Task Include_collection_force_alias_uniquefication(bool as public override async Task Include_collection_with_outer_apply_with_filter_non_equality(bool async) { await base.Include_collection_with_outer_apply_with_filter_non_equality(async); - AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `t`.`OrderID`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` -FROM `Customers` AS `c` -LEFT JOIN LATERAL ( - SELECT `o`.`OrderID` - FROM `Orders` AS `o` - WHERE (`o`.`CustomerID` <> `c`.`CustomerID`) OR `o`.`CustomerID` IS NULL - ORDER BY `c`.`CustomerID` - LIMIT 5 -) AS `t` ON TRUE -LEFT JOIN `Orders` AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` -WHERE `c`.`CustomerID` LIKE 'F%' -ORDER BY `c`.`CustomerID`, `t`.`OrderID` -"""); + """ + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o0`.`OrderID`, `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate` + FROM `Customers` AS `c` + LEFT JOIN LATERAL ( + SELECT `o`.`OrderID` + FROM `Orders` AS `o` + WHERE (`o`.`CustomerID` <> `c`.`CustomerID`) OR `o`.`CustomerID` IS NULL + ORDER BY `c`.`CustomerID` + LIMIT 5 + ) AS `o0` ON TRUE + LEFT JOIN `Orders` AS `o1` ON `c`.`CustomerID` = `o1`.`CustomerID` + WHERE `c`.`CustomerID` LIKE 'F%' + ORDER BY `c`.`CustomerID`, `o0`.`OrderID` + """); } public override async Task Include_in_let_followed_by_FirstOrDefault(bool async) @@ -1145,21 +1144,21 @@ public override async Task Include_in_let_followed_by_FirstOrDefault(bool async) await base.Include_in_let_followed_by_FirstOrDefault(async); AssertSql( -""" -SELECT `c`.`CustomerID`, `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` -FROM `Customers` AS `c` -LEFT JOIN ( - SELECT `t`.`OrderID`, `t`.`CustomerID`, `t`.`EmployeeID`, `t`.`OrderDate` - FROM ( - SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, ROW_NUMBER() OVER(PARTITION BY `o`.`CustomerID` ORDER BY `o`.`OrderDate`) AS `row` - FROM `Orders` AS `o` - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `c`.`CustomerID` = `t0`.`CustomerID` -LEFT JOIN `Order Details` AS `o0` ON `t0`.`OrderID` = `o0`.`OrderID` -WHERE `c`.`CustomerID` LIKE 'F%' -ORDER BY `c`.`CustomerID`, `t0`.`OrderID`, `o0`.`OrderID` -"""); + """ + SELECT `c`.`CustomerID`, `o2`.`OrderID`, `o2`.`CustomerID`, `o2`.`EmployeeID`, `o2`.`OrderDate`, `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` + FROM `Customers` AS `c` + LEFT JOIN ( + SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate` + FROM ( + SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, ROW_NUMBER() OVER(PARTITION BY `o`.`CustomerID` ORDER BY `o`.`OrderDate`) AS `row` + FROM `Orders` AS `o` + ) AS `o1` + WHERE `o1`.`row` <= 1 + ) AS `o2` ON `c`.`CustomerID` = `o2`.`CustomerID` + LEFT JOIN `Order Details` AS `o0` ON `o2`.`OrderID` = `o0`.`OrderID` + WHERE `c`.`CustomerID` LIKE 'F%' + ORDER BY `c`.`CustomerID`, `o2`.`OrderID`, `o0`.`OrderID` + """); } public override async Task Include_references_multi_level(bool async) @@ -1182,15 +1181,15 @@ public override async Task Include_collection_then_include_collection(bool async AssertSql( """ -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `t`.`OrderID`, `t`.`CustomerID`, `t`.`EmployeeID`, `t`.`OrderDate`, `t`.`OrderID0`, `t`.`ProductID`, `t`.`Discount`, `t`.`Quantity`, `t`.`UnitPrice` +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `s`.`OrderID`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate`, `s`.`OrderID0`, `s`.`ProductID`, `s`.`Discount`, `s`.`Quantity`, `s`.`UnitPrice` FROM `Customers` AS `c` LEFT JOIN ( SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `o0`.`OrderID` AS `OrderID0`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` FROM `Orders` AS `o` LEFT JOIN `Order Details` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` -) AS `t` ON `c`.`CustomerID` = `t`.`CustomerID` +) AS `s` ON `c`.`CustomerID` = `s`.`CustomerID` WHERE `c`.`CustomerID` LIKE 'F%' -ORDER BY `c`.`CustomerID`, `t`.`OrderID`, `t`.`OrderID0` +ORDER BY `c`.`CustomerID`, `s`.`OrderID`, `s`.`OrderID0` """); } @@ -1212,7 +1211,7 @@ await AssertQuery( """ @__p_0='5' -SELECT `t`.`OrderID`, `t`.`CustomerID`, `t`.`EmployeeID`, `t`.`OrderDate`, `t`.`CustomerID0`, `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` +SELECT `s`.`OrderID`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate`, `s`.`CustomerID0`, `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` FROM ( SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0`, `o`.`OrderID` > 0 AS `c`, CASE WHEN `c`.`CustomerID` IS NOT NULL THEN `c`.`City` @@ -1225,9 +1224,9 @@ END AS `c0` ELSE '' END, `o`.`OrderID` LIMIT @__p_0 -) AS `t` -LEFT JOIN `Order Details` AS `o0` ON `t`.`OrderID` = `o0`.`OrderID` -ORDER BY `t`.`c`, `t`.`c0`, `t`.`OrderID`, `t`.`CustomerID0`, `o0`.`OrderID` +) AS `s` +LEFT JOIN `Order Details` AS `o0` ON `s`.`OrderID` = `o0`.`OrderID` +ORDER BY `s`.`c`, `s`.`c0`, `s`.`OrderID`, `s`.`CustomerID0`, `o0`.`OrderID` """); } @@ -1307,27 +1306,27 @@ public override async Task Include_reference_Join_GroupBy_Select(bool async) await base.Include_reference_Join_GroupBy_Select(async); AssertSql( -""" -SELECT `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `t0`.`CustomerID0`, `t0`.`Address`, `t0`.`City`, `t0`.`CompanyName`, `t0`.`ContactName`, `t0`.`ContactTitle`, `t0`.`Country`, `t0`.`Fax`, `t0`.`Phone`, `t0`.`PostalCode`, `t0`.`Region` -FROM ( - SELECT `o`.`OrderID` - FROM `Orders` AS `o` - INNER JOIN `Order Details` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` - WHERE `o`.`OrderID` = 10248 - GROUP BY `o`.`OrderID` -) AS `t` -LEFT JOIN ( - SELECT `t1`.`OrderID`, `t1`.`CustomerID`, `t1`.`EmployeeID`, `t1`.`OrderDate`, `t1`.`CustomerID0`, `t1`.`Address`, `t1`.`City`, `t1`.`CompanyName`, `t1`.`ContactName`, `t1`.`ContactTitle`, `t1`.`Country`, `t1`.`Fax`, `t1`.`Phone`, `t1`.`PostalCode`, `t1`.`Region` - FROM ( - SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, ROW_NUMBER() OVER(PARTITION BY `o1`.`OrderID` ORDER BY `o1`.`OrderID`) AS `row` - FROM `Orders` AS `o1` - INNER JOIN `Order Details` AS `o2` ON `o1`.`OrderID` = `o2`.`OrderID` - LEFT JOIN `Customers` AS `c` ON `o1`.`CustomerID` = `c`.`CustomerID` - WHERE `o1`.`OrderID` = 10248 - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`OrderID` = `t0`.`OrderID` -"""); + """ + SELECT `s1`.`OrderID`, `s1`.`CustomerID`, `s1`.`EmployeeID`, `s1`.`OrderDate`, `s1`.`CustomerID0`, `s1`.`Address`, `s1`.`City`, `s1`.`CompanyName`, `s1`.`ContactName`, `s1`.`ContactTitle`, `s1`.`Country`, `s1`.`Fax`, `s1`.`Phone`, `s1`.`PostalCode`, `s1`.`Region` + FROM ( + SELECT `o`.`OrderID` + FROM `Orders` AS `o` + INNER JOIN `Order Details` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` + WHERE `o`.`OrderID` = 10248 + GROUP BY `o`.`OrderID` + ) AS `s` + LEFT JOIN ( + SELECT `s0`.`OrderID`, `s0`.`CustomerID`, `s0`.`EmployeeID`, `s0`.`OrderDate`, `s0`.`CustomerID0`, `s0`.`Address`, `s0`.`City`, `s0`.`CompanyName`, `s0`.`ContactName`, `s0`.`ContactTitle`, `s0`.`Country`, `s0`.`Fax`, `s0`.`Phone`, `s0`.`PostalCode`, `s0`.`Region` + FROM ( + SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, ROW_NUMBER() OVER(PARTITION BY `o1`.`OrderID` ORDER BY `o1`.`OrderID`) AS `row` + FROM `Orders` AS `o1` + INNER JOIN `Order Details` AS `o2` ON `o1`.`OrderID` = `o2`.`OrderID` + LEFT JOIN `Customers` AS `c` ON `o1`.`CustomerID` = `c`.`CustomerID` + WHERE `o1`.`OrderID` = 10248 + ) AS `s0` + WHERE `s0`.`row` <= 1 + ) AS `s1` ON `s`.`OrderID` = `s1`.`OrderID` + """); } public override async Task Include_collection_when_projection(bool async) @@ -1346,27 +1345,27 @@ public override async Task Include_reference_SelectMany_GroupBy_Select(bool asyn await base.Include_reference_SelectMany_GroupBy_Select(async); AssertSql( -""" -SELECT `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `t0`.`CustomerID0`, `t0`.`Address`, `t0`.`City`, `t0`.`CompanyName`, `t0`.`ContactName`, `t0`.`ContactTitle`, `t0`.`Country`, `t0`.`Fax`, `t0`.`Phone`, `t0`.`PostalCode`, `t0`.`Region` -FROM ( - SELECT `o`.`OrderID` - FROM `Orders` AS `o` - CROSS JOIN `Order Details` AS `o0` - WHERE `o`.`OrderID` = 10248 - GROUP BY `o`.`OrderID` -) AS `t` -LEFT JOIN ( - SELECT `t1`.`OrderID`, `t1`.`CustomerID`, `t1`.`EmployeeID`, `t1`.`OrderDate`, `t1`.`CustomerID0`, `t1`.`Address`, `t1`.`City`, `t1`.`CompanyName`, `t1`.`ContactName`, `t1`.`ContactTitle`, `t1`.`Country`, `t1`.`Fax`, `t1`.`Phone`, `t1`.`PostalCode`, `t1`.`Region` - FROM ( - SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, ROW_NUMBER() OVER(PARTITION BY `o1`.`OrderID` ORDER BY `o1`.`OrderID`) AS `row` - FROM `Orders` AS `o1` - CROSS JOIN `Order Details` AS `o2` - LEFT JOIN `Customers` AS `c` ON `o1`.`CustomerID` = `c`.`CustomerID` - WHERE `o1`.`OrderID` = 10248 - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`OrderID` = `t0`.`OrderID` -"""); + """ + SELECT `s1`.`OrderID`, `s1`.`CustomerID`, `s1`.`EmployeeID`, `s1`.`OrderDate`, `s1`.`CustomerID0`, `s1`.`Address`, `s1`.`City`, `s1`.`CompanyName`, `s1`.`ContactName`, `s1`.`ContactTitle`, `s1`.`Country`, `s1`.`Fax`, `s1`.`Phone`, `s1`.`PostalCode`, `s1`.`Region` + FROM ( + SELECT `o`.`OrderID` + FROM `Orders` AS `o` + CROSS JOIN `Order Details` AS `o0` + WHERE `o`.`OrderID` = 10248 + GROUP BY `o`.`OrderID` + ) AS `s` + LEFT JOIN ( + SELECT `s0`.`OrderID`, `s0`.`CustomerID`, `s0`.`EmployeeID`, `s0`.`OrderDate`, `s0`.`CustomerID0`, `s0`.`Address`, `s0`.`City`, `s0`.`CompanyName`, `s0`.`ContactName`, `s0`.`ContactTitle`, `s0`.`Country`, `s0`.`Fax`, `s0`.`Phone`, `s0`.`PostalCode`, `s0`.`Region` + FROM ( + SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, ROW_NUMBER() OVER(PARTITION BY `o1`.`OrderID` ORDER BY `o1`.`OrderID`) AS `row` + FROM `Orders` AS `o1` + CROSS JOIN `Order Details` AS `o2` + LEFT JOIN `Customers` AS `c` ON `o1`.`CustomerID` = `c`.`CustomerID` + WHERE `o1`.`OrderID` = 10248 + ) AS `s0` + WHERE `s0`.`row` <= 1 + ) AS `s1` ON `s`.`OrderID` = `s1`.`OrderID` + """); } public override async Task Include_multiple_references_then_include_collection_multi_level(bool async) @@ -1391,27 +1390,27 @@ public override async Task SelectMany_Include_reference_GroupBy_Select(bool asyn await base.SelectMany_Include_reference_GroupBy_Select(async); AssertSql( -""" -SELECT `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `t0`.`CustomerID0`, `t0`.`Address`, `t0`.`City`, `t0`.`CompanyName`, `t0`.`ContactName`, `t0`.`ContactTitle`, `t0`.`Country`, `t0`.`Fax`, `t0`.`Phone`, `t0`.`PostalCode`, `t0`.`Region` -FROM ( - SELECT `o0`.`OrderID` - FROM `Order Details` AS `o` - CROSS JOIN `Orders` AS `o0` - WHERE `o`.`OrderID` = 10248 - GROUP BY `o0`.`OrderID` -) AS `t` -LEFT JOIN ( - SELECT `t1`.`OrderID`, `t1`.`CustomerID`, `t1`.`EmployeeID`, `t1`.`OrderDate`, `t1`.`CustomerID0`, `t1`.`Address`, `t1`.`City`, `t1`.`CompanyName`, `t1`.`ContactName`, `t1`.`ContactTitle`, `t1`.`Country`, `t1`.`Fax`, `t1`.`Phone`, `t1`.`PostalCode`, `t1`.`Region` - FROM ( - SELECT `o2`.`OrderID`, `o2`.`CustomerID`, `o2`.`EmployeeID`, `o2`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, ROW_NUMBER() OVER(PARTITION BY `o2`.`OrderID` ORDER BY `o2`.`OrderID`) AS `row` - FROM `Order Details` AS `o1` - CROSS JOIN `Orders` AS `o2` - LEFT JOIN `Customers` AS `c` ON `o2`.`CustomerID` = `c`.`CustomerID` - WHERE `o1`.`OrderID` = 10248 - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`OrderID` = `t0`.`OrderID` -"""); + """ + SELECT `s1`.`OrderID`, `s1`.`CustomerID`, `s1`.`EmployeeID`, `s1`.`OrderDate`, `s1`.`CustomerID0`, `s1`.`Address`, `s1`.`City`, `s1`.`CompanyName`, `s1`.`ContactName`, `s1`.`ContactTitle`, `s1`.`Country`, `s1`.`Fax`, `s1`.`Phone`, `s1`.`PostalCode`, `s1`.`Region` + FROM ( + SELECT `o0`.`OrderID` + FROM `Order Details` AS `o` + CROSS JOIN `Orders` AS `o0` + WHERE `o`.`OrderID` = 10248 + GROUP BY `o0`.`OrderID` + ) AS `s` + LEFT JOIN ( + SELECT `s0`.`OrderID`, `s0`.`CustomerID`, `s0`.`EmployeeID`, `s0`.`OrderDate`, `s0`.`CustomerID0`, `s0`.`Address`, `s0`.`City`, `s0`.`CompanyName`, `s0`.`ContactName`, `s0`.`ContactTitle`, `s0`.`Country`, `s0`.`Fax`, `s0`.`Phone`, `s0`.`PostalCode`, `s0`.`Region` + FROM ( + SELECT `o2`.`OrderID`, `o2`.`CustomerID`, `o2`.`EmployeeID`, `o2`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, ROW_NUMBER() OVER(PARTITION BY `o2`.`OrderID` ORDER BY `o2`.`OrderID`) AS `row` + FROM `Order Details` AS `o1` + CROSS JOIN `Orders` AS `o2` + LEFT JOIN `Customers` AS `c` ON `o2`.`CustomerID` = `c`.`CustomerID` + WHERE `o1`.`OrderID` = 10248 + ) AS `s0` + WHERE `s0`.`row` <= 1 + ) AS `s1` ON `s`.`OrderID` = `s1`.`OrderID` + """); } public override async Task Include_collection_SelectMany_GroupBy_Select(bool async) @@ -1419,31 +1418,32 @@ public override async Task Include_collection_SelectMany_GroupBy_Select(bool asy await base.Include_collection_SelectMany_GroupBy_Select(async); AssertSql( -""" -SELECT `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `t`.`OrderID`, `t0`.`OrderID0`, `t0`.`ProductID`, `o3`.`OrderID`, `o3`.`ProductID`, `o3`.`Discount`, `o3`.`Quantity`, `o3`.`UnitPrice` -FROM ( - SELECT `o`.`OrderID` - FROM `Orders` AS `o` - CROSS JOIN `Order Details` AS `o0` - WHERE `o`.`OrderID` = 10248 - GROUP BY `o`.`OrderID` -) AS `t` -LEFT JOIN ( - SELECT `t1`.`OrderID`, `t1`.`CustomerID`, `t1`.`EmployeeID`, `t1`.`OrderDate`, `t1`.`OrderID0`, `t1`.`ProductID` - FROM ( - SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate`, `o2`.`OrderID` AS `OrderID0`, `o2`.`ProductID`, ROW_NUMBER() OVER(PARTITION BY `o1`.`OrderID` ORDER BY `o1`.`OrderID`) AS `row` - FROM `Orders` AS `o1` - CROSS JOIN `Order Details` AS `o2` - WHERE `o1`.`OrderID` = 10248 - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`OrderID` = `t0`.`OrderID` -LEFT JOIN `Order Details` AS `o3` ON `t0`.`OrderID` = `o3`.`OrderID` -ORDER BY `t`.`OrderID`, `t0`.`OrderID`, `t0`.`OrderID0`, `t0`.`ProductID`, `o3`.`OrderID` -"""); + """ + SELECT `s1`.`OrderID`, `s1`.`CustomerID`, `s1`.`EmployeeID`, `s1`.`OrderDate`, `s`.`OrderID`, `s1`.`OrderID0`, `s1`.`ProductID`, `o3`.`OrderID`, `o3`.`ProductID`, `o3`.`Discount`, `o3`.`Quantity`, `o3`.`UnitPrice` + FROM ( + SELECT `o`.`OrderID` + FROM `Orders` AS `o` + CROSS JOIN `Order Details` AS `o0` + WHERE `o`.`OrderID` = 10248 + GROUP BY `o`.`OrderID` + ) AS `s` + LEFT JOIN ( + SELECT `s0`.`OrderID`, `s0`.`CustomerID`, `s0`.`EmployeeID`, `s0`.`OrderDate`, `s0`.`OrderID0`, `s0`.`ProductID` + FROM ( + SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate`, `o2`.`OrderID` AS `OrderID0`, `o2`.`ProductID`, ROW_NUMBER() OVER(PARTITION BY `o1`.`OrderID` ORDER BY `o1`.`OrderID`) AS `row` + FROM `Orders` AS `o1` + CROSS JOIN `Order Details` AS `o2` + WHERE `o1`.`OrderID` = 10248 + ) AS `s0` + WHERE `s0`.`row` <= 1 + ) AS `s1` ON `s`.`OrderID` = `s1`.`OrderID` + LEFT JOIN `Order Details` AS `o3` ON `s1`.`OrderID` = `o3`.`OrderID` + ORDER BY `s`.`OrderID`, `s1`.`OrderID`, `s1`.`OrderID0`, `s1`.`ProductID`, `o3`.`OrderID` + """); } [ConditionalTheory(Skip = "SingleStore does not support this type of query: correlated subselect in ORDER BY")] + public override async Task Include_collection_OrderBy_list_contains(bool async) { await base.Include_collection_OrderBy_list_contains(async); @@ -1451,49 +1451,50 @@ public override async Task Include_collection_OrderBy_list_contains(bool async) if (SingleStoreTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { AssertSql( - """ - @__p_1='1' - SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` - FROM ( - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, COALESCE(`c`.`CustomerID` IN ( - SELECT `l`.`value` - FROM JSON_TABLE('["ALFKI"]', '$[*]' COLUMNS ( - `key` FOR ORDINALITY, - `value` char(5) PATH '$[0]' - )) AS `l` - ), FALSE) AS `c` - FROM `Customers` AS `c` - WHERE `c`.`CustomerID` LIKE 'A%' - ORDER BY COALESCE(`c`.`CustomerID` IN ( - SELECT `l`.`value` - FROM JSON_TABLE('["ALFKI"]', '$[*]' COLUMNS ( - `key` FOR ORDINALITY, - `value` char(5) PATH '$[0]' - )) AS `l` - ), FALSE) - LIMIT 18446744073709551610 OFFSET @__p_1 - ) AS `t` - LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` - ORDER BY `t`.`c`, `t`.`CustomerID` - """); +""" +@__p_1='1' + +SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, COALESCE(`c`.`CustomerID` IN ( + SELECT `l`.`value` + FROM JSON_TABLE('["ALFKI"]', '$[*]' COLUMNS ( + `key` FOR ORDINALITY, + `value` char(5) PATH '$[0]' + )) AS `l` + ), FALSE) AS `c` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'A%' + ORDER BY COALESCE(`c`.`CustomerID` IN ( + SELECT `l`.`value` + FROM JSON_TABLE('["ALFKI"]', '$[*]' COLUMNS ( + `key` FOR ORDINALITY, + `value` char(5) PATH '$[0]' + )) AS `l` + ), FALSE) + LIMIT 18446744073709551610 OFFSET @__p_1 +) AS `t` +LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` +ORDER BY `t`.`c`, `t`.`CustomerID` +"""); } else { - AssertSql( - """ - @__p_1='1' + AssertSql( +""" +@__p_1='1' - SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` - FROM ( - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `c`.`CustomerID` = 'ALFKI' AS `c` - FROM `Customers` AS `c` - WHERE `c`.`CustomerID` LIKE 'A%' - ORDER BY `c`.`CustomerID` = 'ALFKI' - LIMIT 18446744073709551610 OFFSET @__p_1 - ) AS `t` - LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` - ORDER BY `t`.`c`, `t`.`CustomerID` - """); +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `c`.`CustomerID` = 'ALFKI' AS `c` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'A%' + ORDER BY `c`.`CustomerID` = 'ALFKI' + LIMIT 18446744073709551610 OFFSET @__p_1 +) AS `c0` +LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c0`.`c`, `c0`.`CustomerID` +"""); } } @@ -1505,20 +1506,20 @@ public override async Task Multi_level_includes_are_applied_with_skip(bool async """ @__p_0='1' -SELECT `t`.`CustomerID`, `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `t0`.`OrderID0`, `t0`.`ProductID`, `t0`.`Discount`, `t0`.`Quantity`, `t0`.`UnitPrice` +SELECT `c0`.`CustomerID`, `s`.`OrderID`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate`, `s`.`OrderID0`, `s`.`ProductID`, `s`.`Discount`, `s`.`Quantity`, `s`.`UnitPrice` FROM ( SELECT `c`.`CustomerID` FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'A%' ORDER BY `c`.`CustomerID` LIMIT 1 OFFSET @__p_0 -) AS `t` +) AS `c0` LEFT JOIN ( SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `o0`.`OrderID` AS `OrderID0`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` FROM `Orders` AS `o` LEFT JOIN `Order Details` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` -) AS `t0` ON `t`.`CustomerID` = `t0`.`CustomerID` -ORDER BY `t`.`CustomerID`, `t0`.`OrderID`, `t0`.`OrderID0` +) AS `s` ON `c0`.`CustomerID` = `s`.`CustomerID` +ORDER BY `c0`.`CustomerID`, `s`.`OrderID`, `s`.`OrderID0` """); } @@ -1530,20 +1531,20 @@ public override async Task Include_collection_on_additional_from_clause(bool asy """ @__p_0='5' -SELECT `t0`.`CustomerID`, `t0`.`Address`, `t0`.`City`, `t0`.`CompanyName`, `t0`.`ContactName`, `t0`.`ContactTitle`, `t0`.`Country`, `t0`.`Fax`, `t0`.`Phone`, `t0`.`PostalCode`, `t0`.`Region`, `t`.`CustomerID`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +SELECT `c2`.`CustomerID`, `c2`.`Address`, `c2`.`City`, `c2`.`CompanyName`, `c2`.`ContactName`, `c2`.`ContactTitle`, `c2`.`Country`, `c2`.`Fax`, `c2`.`Phone`, `c2`.`PostalCode`, `c2`.`Region`, `c1`.`CustomerID`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID` FROM `Customers` AS `c` ORDER BY `c`.`CustomerID` LIMIT @__p_0 -) AS `t` +) AS `c1` CROSS JOIN ( SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` FROM `Customers` AS `c0` WHERE `c0`.`CustomerID` LIKE 'F%' -) AS `t0` -LEFT JOIN `Orders` AS `o` ON `t0`.`CustomerID` = `o`.`CustomerID` -ORDER BY `t`.`CustomerID`, `t0`.`CustomerID` +) AS `c2` +LEFT JOIN `Orders` AS `o` ON `c2`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c1`.`CustomerID`, `c2`.`CustomerID` """); } @@ -1553,13 +1554,13 @@ public override async Task Include_reference_distinct_is_server_evaluated(bool a AssertSql( """ -SELECT `t`.`OrderID`, `t`.`CustomerID`, `t`.`EmployeeID`, `t`.`OrderDate`, `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate`, `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM ( SELECT DISTINCT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderID` < 10250 -) AS `t` -LEFT JOIN `Customers` AS `c` ON `t`.`CustomerID` = `c`.`CustomerID` +) AS `o0` +LEFT JOIN `Customers` AS `c` ON `o0`.`CustomerID` = `c`.`CustomerID` """); } @@ -1569,14 +1570,14 @@ public override async Task Include_collection_distinct_is_server_evaluated(bool AssertSql( """ -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT DISTINCT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`CustomerID` LIKE 'A%' -) AS `t` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -ORDER BY `t`.`CustomerID` +) AS `c0` +LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c0`.`CustomerID` """); } @@ -1614,9 +1615,9 @@ from c2 in ss.Set().Include(c => c.Orders).OrderBy(c => c.CustomerID). @__p_0='2' @__p_1='1' -SELECT `t1`.`CustomerID`, `t1`.`Address`, `t1`.`City`, `t1`.`CompanyName`, `t1`.`ContactName`, `t1`.`ContactTitle`, `t1`.`Country`, `t1`.`Fax`, `t1`.`Phone`, `t1`.`PostalCode`, `t1`.`Region`, `t1`.`CustomerID0`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate`, `t1`.`Address0`, `t1`.`City0`, `t1`.`CompanyName0`, `t1`.`ContactName0`, `t1`.`ContactTitle0`, `t1`.`Country0`, `t1`.`Fax0`, `t1`.`Phone0`, `t1`.`PostalCode0`, `t1`.`Region0`, `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate` +SELECT `s`.`CustomerID`, `s`.`Address`, `s`.`City`, `s`.`CompanyName`, `s`.`ContactName`, `s`.`ContactTitle`, `s`.`Country`, `s`.`Fax`, `s`.`Phone`, `s`.`PostalCode`, `s`.`Region`, `s`.`CustomerID0`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate`, `s`.`Address0`, `s`.`City0`, `s`.`CompanyName0`, `s`.`ContactName0`, `s`.`ContactTitle0`, `s`.`Country0`, `s`.`Fax0`, `s`.`Phone0`, `s`.`PostalCode0`, `s`.`Region0`, `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate` FROM ( - SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `t0`.`CustomerID` AS `CustomerID0`, `t0`.`Address` AS `Address0`, `t0`.`City` AS `City0`, `t0`.`CompanyName` AS `CompanyName0`, `t0`.`ContactName` AS `ContactName0`, `t0`.`ContactTitle` AS `ContactTitle0`, `t0`.`Country` AS `Country0`, `t0`.`Fax` AS `Fax0`, `t0`.`Phone` AS `Phone0`, `t0`.`PostalCode` AS `PostalCode0`, `t0`.`Region` AS `Region0` + SELECT `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region`, `c2`.`CustomerID` AS `CustomerID0`, `c2`.`Address` AS `Address0`, `c2`.`City` AS `City0`, `c2`.`CompanyName` AS `CompanyName0`, `c2`.`ContactName` AS `ContactName0`, `c2`.`ContactTitle` AS `ContactTitle0`, `c2`.`Country` AS `Country0`, `c2`.`Fax` AS `Fax0`, `c2`.`Phone` AS `Phone0`, `c2`.`PostalCode` AS `PostalCode0`, `c2`.`Region` AS `Region0` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` @@ -1626,19 +1627,19 @@ from c2 in ss.Set().Include(c => c.Orders).OrderBy(c => c.CustomerID). WHERE `c`.`CustomerID` = `o`.`CustomerID` LIMIT 1) LIMIT @__p_0 - ) AS `t` + ) AS `c1` CROSS JOIN ( SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` FROM `Customers` AS `c0` ORDER BY `c0`.`CustomerID` LIMIT 2 OFFSET 2 - ) AS `t0` - ORDER BY `t`.`CustomerID`, `t0`.`CustomerID` + ) AS `c2` + ORDER BY `c1`.`CustomerID`, `c2`.`CustomerID` LIMIT @__p_1 -) AS `t1` -LEFT JOIN `Orders` AS `o0` ON `t1`.`CustomerID` = `o0`.`CustomerID` -LEFT JOIN `Orders` AS `o1` ON `t1`.`CustomerID0` = `o1`.`CustomerID` -ORDER BY `t1`.`CustomerID`, `t1`.`CustomerID0`, `o0`.`OrderID` +) AS `s` +LEFT JOIN `Orders` AS `o0` ON `s`.`CustomerID` = `o0`.`CustomerID` +LEFT JOIN `Orders` AS `o1` ON `s`.`CustomerID0` = `o1`.`CustomerID` +ORDER BY `s`.`CustomerID`, `s`.`CustomerID0`, `o0`.`OrderID` """); } @@ -1678,14 +1679,14 @@ public override async Task Include_closes_reader(bool async) AssertSql( """ -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` LIMIT 1 -) AS `t` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -ORDER BY `t`.`CustomerID` +) AS `c0` +LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c0`.`CustomerID` """, // """ @@ -1702,15 +1703,15 @@ public override async Task Include_with_skip(bool async) """ @__p_0='80' -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` ORDER BY `c`.`ContactName` LIMIT 18446744073709551610 OFFSET @__p_0 -) AS `t` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -ORDER BY `t`.`ContactName`, `t`.`CustomerID` +) AS `c0` +LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c0`.`ContactName`, `c0`.`CustomerID` """); } @@ -1720,26 +1721,26 @@ public override async Task Include_collection_Join_GroupBy_Select(bool async) AssertSql( """ -SELECT `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `t`.`OrderID`, `t0`.`OrderID0`, `t0`.`ProductID`, `o3`.`OrderID`, `o3`.`ProductID`, `o3`.`Discount`, `o3`.`Quantity`, `o3`.`UnitPrice` +SELECT `s1`.`OrderID`, `s1`.`CustomerID`, `s1`.`EmployeeID`, `s1`.`OrderDate`, `s`.`OrderID`, `s1`.`OrderID0`, `s1`.`ProductID`, `o3`.`OrderID`, `o3`.`ProductID`, `o3`.`Discount`, `o3`.`Quantity`, `o3`.`UnitPrice` FROM ( SELECT `o`.`OrderID` FROM `Orders` AS `o` INNER JOIN `Order Details` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` WHERE `o`.`OrderID` = 10248 GROUP BY `o`.`OrderID` -) AS `t` +) AS `s` LEFT JOIN ( - SELECT `t1`.`OrderID`, `t1`.`CustomerID`, `t1`.`EmployeeID`, `t1`.`OrderDate`, `t1`.`OrderID0`, `t1`.`ProductID` + SELECT `s0`.`OrderID`, `s0`.`CustomerID`, `s0`.`EmployeeID`, `s0`.`OrderDate`, `s0`.`OrderID0`, `s0`.`ProductID` FROM ( SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate`, `o2`.`OrderID` AS `OrderID0`, `o2`.`ProductID`, ROW_NUMBER() OVER(PARTITION BY `o1`.`OrderID` ORDER BY `o1`.`OrderID`) AS `row` FROM `Orders` AS `o1` INNER JOIN `Order Details` AS `o2` ON `o1`.`OrderID` = `o2`.`OrderID` WHERE `o1`.`OrderID` = 10248 - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`OrderID` = `t0`.`OrderID` -LEFT JOIN `Order Details` AS `o3` ON `t0`.`OrderID` = `o3`.`OrderID` -ORDER BY `t`.`OrderID`, `t0`.`OrderID`, `t0`.`OrderID0`, `t0`.`ProductID`, `o3`.`OrderID` + ) AS `s0` + WHERE `s0`.`row` <= 1 +) AS `s1` ON `s`.`OrderID` = `s1`.`OrderID` +LEFT JOIN `Order Details` AS `o3` ON `s1`.`OrderID` = `o3`.`OrderID` +ORDER BY `s`.`OrderID`, `s1`.`OrderID`, `s1`.`OrderID0`, `s1`.`ProductID`, `o3`.`OrderID` """); } @@ -1749,24 +1750,24 @@ public override async Task Include_collection_GroupBy_Select(bool async) AssertSql( """ -SELECT `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `t`.`OrderID`, `o1`.`OrderID`, `o1`.`ProductID`, `o1`.`Discount`, `o1`.`Quantity`, `o1`.`UnitPrice` +SELECT `o4`.`OrderID`, `o4`.`CustomerID`, `o4`.`EmployeeID`, `o4`.`OrderDate`, `o2`.`OrderID`, `o1`.`OrderID`, `o1`.`ProductID`, `o1`.`Discount`, `o1`.`Quantity`, `o1`.`UnitPrice` FROM ( SELECT `o`.`OrderID` FROM `Orders` AS `o` WHERE `o`.`OrderID` = 10248 GROUP BY `o`.`OrderID` -) AS `t` +) AS `o2` LEFT JOIN ( - SELECT `t1`.`OrderID`, `t1`.`CustomerID`, `t1`.`EmployeeID`, `t1`.`OrderDate` + SELECT `o3`.`OrderID`, `o3`.`CustomerID`, `o3`.`EmployeeID`, `o3`.`OrderDate` FROM ( SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate`, ROW_NUMBER() OVER(PARTITION BY `o0`.`OrderID` ORDER BY `o0`.`OrderID`) AS `row` FROM `Orders` AS `o0` WHERE `o0`.`OrderID` = 10248 - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`OrderID` = `t0`.`OrderID` -LEFT JOIN `Order Details` AS `o1` ON `t0`.`OrderID` = `o1`.`OrderID` -ORDER BY `t`.`OrderID`, `t0`.`OrderID`, `o1`.`OrderID` + ) AS `o3` + WHERE `o3`.`row` <= 1 +) AS `o4` ON `o2`.`OrderID` = `o4`.`OrderID` +LEFT JOIN `Order Details` AS `o1` ON `o4`.`OrderID` = `o1`.`OrderID` +ORDER BY `o2`.`OrderID`, `o4`.`OrderID`, `o1`.`OrderID` """); } @@ -1778,15 +1779,15 @@ public override async Task Include_collection_orderby_take(bool async) """ @__p_0='5' -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` ORDER BY `c`.`CustomerID` LIMIT @__p_0 -) AS `t` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -ORDER BY `t`.`CustomerID` +) AS `c0` +LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c0`.`CustomerID` """); } @@ -1796,26 +1797,26 @@ public override async Task Join_Include_collection_GroupBy_Select(bool async) AssertSql( """ -SELECT `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `t`.`OrderID`, `t0`.`OrderID0`, `t0`.`ProductID`, `o3`.`OrderID`, `o3`.`ProductID`, `o3`.`Discount`, `o3`.`Quantity`, `o3`.`UnitPrice` +SELECT `s1`.`OrderID`, `s1`.`CustomerID`, `s1`.`EmployeeID`, `s1`.`OrderDate`, `s`.`OrderID`, `s1`.`OrderID0`, `s1`.`ProductID`, `o3`.`OrderID`, `o3`.`ProductID`, `o3`.`Discount`, `o3`.`Quantity`, `o3`.`UnitPrice` FROM ( SELECT `o0`.`OrderID` FROM `Order Details` AS `o` INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` WHERE `o`.`OrderID` = 10248 GROUP BY `o0`.`OrderID` -) AS `t` +) AS `s` LEFT JOIN ( - SELECT `t1`.`OrderID`, `t1`.`CustomerID`, `t1`.`EmployeeID`, `t1`.`OrderDate`, `t1`.`OrderID0`, `t1`.`ProductID` + SELECT `s0`.`OrderID`, `s0`.`CustomerID`, `s0`.`EmployeeID`, `s0`.`OrderDate`, `s0`.`OrderID0`, `s0`.`ProductID` FROM ( SELECT `o2`.`OrderID`, `o2`.`CustomerID`, `o2`.`EmployeeID`, `o2`.`OrderDate`, `o1`.`OrderID` AS `OrderID0`, `o1`.`ProductID`, ROW_NUMBER() OVER(PARTITION BY `o2`.`OrderID` ORDER BY `o2`.`OrderID`) AS `row` FROM `Order Details` AS `o1` INNER JOIN `Orders` AS `o2` ON `o1`.`OrderID` = `o2`.`OrderID` WHERE `o1`.`OrderID` = 10248 - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`OrderID` = `t0`.`OrderID` -LEFT JOIN `Order Details` AS `o3` ON `t0`.`OrderID` = `o3`.`OrderID` -ORDER BY `t`.`OrderID`, `t0`.`OrderID0`, `t0`.`ProductID`, `t0`.`OrderID`, `o3`.`OrderID` + ) AS `s0` + WHERE `s0`.`row` <= 1 +) AS `s1` ON `s`.`OrderID` = `s1`.`OrderID` +LEFT JOIN `Order Details` AS `o3` ON `s1`.`OrderID` = `o3`.`OrderID` +ORDER BY `s`.`OrderID`, `s1`.`OrderID0`, `s1`.`ProductID`, `s1`.`OrderID`, `o3`.`OrderID` """); } @@ -1853,21 +1854,21 @@ public override async Task Include_duplicate_reference2(bool async) """ @__p_0='2' -SELECT `t`.`OrderID`, `t`.`CustomerID`, `t`.`EmployeeID`, `t`.`OrderDate`, `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate` +SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate`, `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o2`.`OrderID`, `o2`.`CustomerID`, `o2`.`EmployeeID`, `o2`.`OrderDate` FROM ( SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` ORDER BY `o`.`OrderID` LIMIT @__p_0 -) AS `t` +) AS `o1` CROSS JOIN ( SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` FROM `Orders` AS `o0` ORDER BY `o0`.`OrderID` LIMIT 2 OFFSET 2 -) AS `t0` -LEFT JOIN `Customers` AS `c` ON `t`.`CustomerID` = `c`.`CustomerID` -ORDER BY `t`.`OrderID` +) AS `o2` +LEFT JOIN `Customers` AS `c` ON `o1`.`CustomerID` = `c`.`CustomerID` +ORDER BY `o1`.`OrderID` """); } @@ -1923,26 +1924,26 @@ public override async Task SelectMany_Include_collection_GroupBy_Select(bool asy AssertSql( """ -SELECT `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `t`.`OrderID`, `t0`.`OrderID0`, `t0`.`ProductID`, `o3`.`OrderID`, `o3`.`ProductID`, `o3`.`Discount`, `o3`.`Quantity`, `o3`.`UnitPrice` +SELECT `s1`.`OrderID`, `s1`.`CustomerID`, `s1`.`EmployeeID`, `s1`.`OrderDate`, `s`.`OrderID`, `s1`.`OrderID0`, `s1`.`ProductID`, `o3`.`OrderID`, `o3`.`ProductID`, `o3`.`Discount`, `o3`.`Quantity`, `o3`.`UnitPrice` FROM ( SELECT `o0`.`OrderID` FROM `Order Details` AS `o` CROSS JOIN `Orders` AS `o0` WHERE `o`.`OrderID` = 10248 GROUP BY `o0`.`OrderID` -) AS `t` +) AS `s` LEFT JOIN ( - SELECT `t1`.`OrderID`, `t1`.`CustomerID`, `t1`.`EmployeeID`, `t1`.`OrderDate`, `t1`.`OrderID0`, `t1`.`ProductID` + SELECT `s0`.`OrderID`, `s0`.`CustomerID`, `s0`.`EmployeeID`, `s0`.`OrderDate`, `s0`.`OrderID0`, `s0`.`ProductID` FROM ( SELECT `o2`.`OrderID`, `o2`.`CustomerID`, `o2`.`EmployeeID`, `o2`.`OrderDate`, `o1`.`OrderID` AS `OrderID0`, `o1`.`ProductID`, ROW_NUMBER() OVER(PARTITION BY `o2`.`OrderID` ORDER BY `o2`.`OrderID`) AS `row` FROM `Order Details` AS `o1` CROSS JOIN `Orders` AS `o2` WHERE `o1`.`OrderID` = 10248 - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`OrderID` = `t0`.`OrderID` -LEFT JOIN `Order Details` AS `o3` ON `t0`.`OrderID` = `o3`.`OrderID` -ORDER BY `t`.`OrderID`, `t0`.`OrderID0`, `t0`.`ProductID`, `t0`.`OrderID`, `o3`.`OrderID` + ) AS `s0` + WHERE `s0`.`row` <= 1 +) AS `s1` ON `s`.`OrderID` = `s1`.`OrderID` +LEFT JOIN `Order Details` AS `o3` ON `s1`.`OrderID` = `o3`.`OrderID` +ORDER BY `s`.`OrderID`, `s1`.`OrderID0`, `s1`.`ProductID`, `s1`.`OrderID`, `o3`.`OrderID` """); } @@ -1952,15 +1953,15 @@ public override async Task Include_collection_with_last(bool async) AssertSql( """ -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` ORDER BY `c`.`CompanyName` DESC LIMIT 1 -) AS `t` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -ORDER BY `t`.`CompanyName` DESC, `t`.`CustomerID` +) AS `c0` +LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c0`.`CompanyName` DESC, `c0`.`CustomerID` """); } @@ -1972,49 +1973,50 @@ public override async Task Include_collection_OrderBy_empty_list_does_not_contai if (SingleStoreTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { AssertSql( - """ - @__p_1='1' - SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` - FROM ( - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, NOT (COALESCE(`c`.`CustomerID` IN ( - SELECT `l`.`value` - FROM JSON_TABLE('[]', '$[*]' COLUMNS ( - `key` FOR ORDINALITY, - `value` char(5) PATH '$[0]' - )) AS `l` - ), FALSE)) AS `c` - FROM `Customers` AS `c` - WHERE `c`.`CustomerID` LIKE 'A%' - ORDER BY NOT (COALESCE(`c`.`CustomerID` IN ( - SELECT `l`.`value` - FROM JSON_TABLE('[]', '$[*]' COLUMNS ( - `key` FOR ORDINALITY, - `value` char(5) PATH '$[0]' - )) AS `l` - ), FALSE)) - LIMIT 18446744073709551610 OFFSET @__p_1 - ) AS `t` - LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` - ORDER BY `t`.`c`, `t`.`CustomerID` - """); +""" +@__p_1='1' + +SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, NOT (COALESCE(`c`.`CustomerID` IN ( + SELECT `l`.`value` + FROM JSON_TABLE('[]', '$[*]' COLUMNS ( + `key` FOR ORDINALITY, + `value` char(5) PATH '$[0]' + )) AS `l` + ), FALSE)) AS `c` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'A%' + ORDER BY NOT (COALESCE(`c`.`CustomerID` IN ( + SELECT `l`.`value` + FROM JSON_TABLE('[]', '$[*]' COLUMNS ( + `key` FOR ORDINALITY, + `value` char(5) PATH '$[0]' + )) AS `l` + ), FALSE)) + LIMIT 18446744073709551610 OFFSET @__p_1 +) AS `t` +LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` +ORDER BY `t`.`c`, `t`.`CustomerID` +"""); } else { - AssertSql( - """ - @__p_1='1' + AssertSql( +""" +@__p_1='1' - SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` - FROM ( - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, TRUE AS `c` - FROM `Customers` AS `c` - WHERE `c`.`CustomerID` LIKE 'A%' - ORDER BY (SELECT 1) - LIMIT 18446744073709551610 OFFSET @__p_1 - ) AS `t` - LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` - ORDER BY `t`.`c`, `t`.`CustomerID` - """); +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, TRUE AS `c` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` LIKE 'A%' + ORDER BY (SELECT 1) + LIMIT 18446744073709551610 OFFSET @__p_1 +) AS `c0` +LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c0`.`c`, `c0`.`CustomerID` +"""); } } @@ -2082,7 +2084,7 @@ public override async Task Include_collection_order_by_subquery(bool async) AssertSql( """ -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, ( SELECT `o`.`OrderDate` @@ -2099,9 +2101,9 @@ ORDER BY ( ORDER BY `o`.`EmployeeID` LIMIT 1) LIMIT 1 -) AS `t` -LEFT JOIN `Orders` AS `o0` ON `t`.`CustomerID` = `o0`.`CustomerID` -ORDER BY `t`.`c`, `t`.`CustomerID` +) AS `c0` +LEFT JOIN `Orders` AS `o0` ON `c0`.`CustomerID` = `o0`.`CustomerID` +ORDER BY `c0`.`c`, `c0`.`CustomerID` """); } @@ -2127,7 +2129,7 @@ public override async Task Then_include_collection_order_by_collection_column(bo AssertSql( """ -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `t0`.`OrderID0`, `t0`.`ProductID`, `t0`.`Discount`, `t0`.`Quantity`, `t0`.`UnitPrice` +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `s`.`OrderID`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate`, `s`.`OrderID0`, `s`.`ProductID`, `s`.`Discount`, `s`.`Quantity`, `s`.`UnitPrice` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, ( SELECT `o`.`OrderDate` @@ -2144,13 +2146,13 @@ ORDER BY ( ORDER BY `o`.`OrderDate` DESC LIMIT 1) DESC LIMIT 1 -) AS `t` +) AS `c0` LEFT JOIN ( SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate`, `o1`.`OrderID` AS `OrderID0`, `o1`.`ProductID`, `o1`.`Discount`, `o1`.`Quantity`, `o1`.`UnitPrice` FROM `Orders` AS `o0` LEFT JOIN `Order Details` AS `o1` ON `o0`.`OrderID` = `o1`.`OrderID` -) AS `t0` ON `t`.`CustomerID` = `t0`.`CustomerID` -ORDER BY `t`.`c` DESC, `t`.`CustomerID`, `t0`.`OrderID`, `t0`.`OrderID0` +) AS `s` ON `c0`.`CustomerID` = `s`.`CustomerID` +ORDER BY `c0`.`c` DESC, `c0`.`CustomerID`, `s`.`OrderID`, `s`.`OrderID0` """); } @@ -2178,14 +2180,14 @@ public override async Task Include_collection_skip_no_order_by(bool async) """ @__p_0='10' -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` LIMIT 18446744073709551610 OFFSET @__p_0 -) AS `t` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -ORDER BY `t`.`CustomerID` +) AS `c0` +LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c0`.`CustomerID` """); } @@ -2195,16 +2197,16 @@ public override async Task Include_multi_level_reference_then_include_collection AssertSql( """ -SELECT `t`.`OrderID`, `t`.`CustomerID`, `t`.`EmployeeID`, `t`.`OrderDate`, `t`.`CustomerID0`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` +SELECT `s`.`OrderID`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate`, `s`.`CustomerID0`, `s`.`Address`, `s`.`City`, `s`.`CompanyName`, `s`.`ContactName`, `s`.`ContactTitle`, `s`.`Country`, `s`.`Fax`, `s`.`Phone`, `s`.`PostalCode`, `s`.`Region`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` FROM ( SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `c`.`CustomerID` AS `CustomerID0`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Orders` AS `o` LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` WHERE `o`.`OrderID` = 10248 LIMIT 2 -) AS `t` -LEFT JOIN `Orders` AS `o0` ON `t`.`CustomerID0` = `o0`.`CustomerID` -ORDER BY `t`.`OrderID`, `t`.`CustomerID0` +) AS `s` +LEFT JOIN `Orders` AS `o0` ON `s`.`CustomerID0` = `o0`.`CustomerID` +ORDER BY `s`.`OrderID`, `s`.`CustomerID0` """); } @@ -2241,9 +2243,9 @@ public override async Task Include_where_skip_take_projection(bool async) WHERE `o`.`Quantity` = 10 ORDER BY `o`.`OrderID`, `o`.`ProductID` LIMIT @__p_1 OFFSET @__p_0 -) AS `t` -INNER JOIN `Orders` AS `o0` ON `t`.`OrderID` = `o0`.`OrderID` -ORDER BY `t`.`OrderID`, `t`.`ProductID` +) AS `o1` +INNER JOIN `Orders` AS `o0` ON `o1`.`OrderID` = `o0`.`OrderID` +ORDER BY `o1`.`OrderID`, `o1`.`ProductID` """); } @@ -2255,15 +2257,15 @@ public override async Task Include_with_take(bool async) """ @__p_0='10' -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` ORDER BY `c`.`ContactName` DESC LIMIT @__p_0 -) AS `t` -LEFT JOIN `Orders` AS `o` ON `t`.`CustomerID` = `o`.`CustomerID` -ORDER BY `t`.`ContactName` DESC, `t`.`CustomerID` +) AS `c0` +LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c0`.`ContactName` DESC, `c0`.`CustomerID` """); } @@ -2287,15 +2289,15 @@ public override async Task Include_list(bool async) AssertSql( """ -SELECT `p`.`ProductID`, `p`.`Discontinued`, `p`.`ProductName`, `p`.`SupplierID`, `p`.`UnitPrice`, `p`.`UnitsInStock`, `t`.`OrderID`, `t`.`ProductID`, `t`.`Discount`, `t`.`Quantity`, `t`.`UnitPrice`, `t`.`OrderID0`, `t`.`CustomerID`, `t`.`EmployeeID`, `t`.`OrderDate` +SELECT `p`.`ProductID`, `p`.`Discontinued`, `p`.`ProductName`, `p`.`SupplierID`, `p`.`UnitPrice`, `p`.`UnitsInStock`, `s`.`OrderID`, `s`.`ProductID`, `s`.`Discount`, `s`.`Quantity`, `s`.`UnitPrice`, `s`.`OrderID0`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate` FROM `Products` AS `p` LEFT JOIN ( SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice`, `o0`.`OrderID` AS `OrderID0`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` FROM `Order Details` AS `o` INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` -) AS `t` ON `p`.`ProductID` = `t`.`ProductID` +) AS `s` ON `p`.`ProductID` = `s`.`ProductID` WHERE ((`p`.`ProductID` % 17) = 5) AND (`p`.`UnitPrice` < 20.0) -ORDER BY `p`.`ProductID`, `t`.`OrderID`, `t`.`ProductID` +ORDER BY `p`.`ProductID`, `s`.`OrderID`, `s`.`ProductID` """); } @@ -2387,7 +2389,7 @@ public override async Task Filtered_include_with_multiple_ordering(bool async) AssertSql( """ -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `t`.`OrderID`, `t`.`CustomerID`, `t`.`EmployeeID`, `t`.`OrderDate` +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` FROM `Customers` AS `c` LEFT JOIN LATERAL ( SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` @@ -2395,9 +2397,9 @@ LEFT JOIN LATERAL ( WHERE `c`.`CustomerID` = `o`.`CustomerID` ORDER BY `o`.`OrderID` LIMIT 18446744073709551610 OFFSET 1 -) AS `t` ON TRUE +) AS `o0` ON TRUE WHERE `c`.`CustomerID` LIKE 'F%' -ORDER BY `c`.`CustomerID`, `t`.`OrderDate` DESC +ORDER BY `c`.`CustomerID`, `o0`.`OrderDate` DESC """); } @@ -2420,14 +2422,14 @@ public override async Task Outer_identifier_correctly_determined_when_doing_incl await base.Outer_identifier_correctly_determined_when_doing_include_on_right_side_of_left_join(async); AssertSql( - """ - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` - FROM `Customers` AS `c` - LEFT JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID` - LEFT JOIN `Order Details` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` - WHERE `c`.`City` = 'Seattle' - ORDER BY `c`.`CustomerID`, `o`.`OrderID`, `o0`.`OrderID` - """); +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` +FROM `Customers` AS `c` +LEFT JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID` +LEFT JOIN `Order Details` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` +WHERE `c`.`City` = 'Seattle' +ORDER BY `c`.`CustomerID`, `o`.`OrderID`, `o0`.`OrderID` +"""); } private void AssertSql(params string[] expected) diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindFunctionsQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindFunctionsQuerySingleStoreTest.cs index 83f7f68d7..5fcadcee2 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindFunctionsQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindFunctionsQuerySingleStoreTest.cs @@ -1,10 +1,8 @@ using System; -using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; -using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Xunit; using Xunit.Abstractions; @@ -22,9 +20,6 @@ public NorthwindFunctionsQuerySingleStoreTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - [ConditionalTheory] public override async Task String_StartsWith_Literal(bool async) { @@ -135,11 +130,9 @@ public override async Task String_Contains_Literal(bool async) await base.String_Contains_Literal(async); AssertSql( -""" -SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` -WHERE `c`.`ContactName` LIKE '%M%' -"""); +WHERE `c`.`ContactName` LIKE '%M%'"); } [ConditionalTheory] @@ -160,11 +153,11 @@ public override async Task String_Contains_Column(bool async) { await base.String_Contains_Column(async); - AssertSql( + AssertSql( """ SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` -WHERE `c`.`ContactName` IS NOT NULL AND ((LOCATE(`c`.`ContactName`, `c`.`ContactName`) > 0) OR (`c`.`ContactName` LIKE '')) +WHERE `c`.`ContactName` IS NOT NULL AND ((LOCATE(`c`.`ContactName`, `c`.`CompanyName`) > 0) OR (`c`.`ContactName` LIKE '')) """); } @@ -174,7 +167,7 @@ public override async Task String_Contains_MethodCall(bool async) await base.String_Contains_MethodCall(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`ContactName` LIKE '%M%'"); } @@ -185,7 +178,7 @@ public override async Task IsNullOrWhiteSpace_in_predicate(bool async) await base.IsNullOrWhiteSpace_in_predicate(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`Region` IS NULL OR (TRIM(`c`.`Region`) = '')"); } @@ -195,10 +188,12 @@ public override async Task Indexof_with_emptystring(bool async) { await base.Indexof_with_emptystring(async); - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` -WHERE (LOCATE('', `c`.`ContactName`) - 1) = 0"); +WHERE (LOCATE('', `c`.`Region`) - 1) = 0 +"""); } [ConditionalTheory] @@ -253,7 +248,7 @@ public override async Task Substring_with_two_args_with_zero_startindex(bool asy await base.Substring_with_two_args_with_zero_startindex(async); AssertSql( - $@"SELECT SUBSTRING(`c`.`ContactName`, 0 + 1, 3) + @"SELECT SUBSTRING(`c`.`ContactName`, 0 + 1, 3) FROM `Customers` AS `c` WHERE `c`.`CustomerID` = 'ALFKI'"); } @@ -264,7 +259,7 @@ public override async Task Substring_with_two_args_with_zero_length(bool async) await base.Substring_with_two_args_with_zero_length(async); AssertSql( - $@"SELECT SUBSTRING(`c`.`ContactName`, 2 + 1, 0) + @"SELECT SUBSTRING(`c`.`ContactName`, 2 + 1, 0) FROM `Customers` AS `c` WHERE `c`.`CustomerID` = 'ALFKI'"); } @@ -275,7 +270,7 @@ public override async Task Substring_with_two_args_with_constant(bool async) await base.Substring_with_two_args_with_constant(async); AssertSql( - $@"SELECT SUBSTRING(`c`.`ContactName`, 1 + 1, 3) + @"SELECT SUBSTRING(`c`.`ContactName`, 1 + 1, 3) FROM `Customers` AS `c` WHERE `c`.`CustomerID` = 'ALFKI'"); } @@ -286,7 +281,7 @@ public override async Task Substring_with_two_args_with_closure(bool async) await base.Substring_with_two_args_with_closure(async); AssertSql( - $@"@__start_0='2' + @"@__start_0='2' SELECT SUBSTRING(`c`.`ContactName`, @__start_0 + 1, 3) FROM `Customers` AS `c` @@ -299,7 +294,7 @@ public override async Task Substring_with_two_args_with_Index_of(bool async) await base.Substring_with_two_args_with_Index_of(async); AssertSql( - $@"SELECT SUBSTRING(`c`.`ContactName`, (LOCATE('a', `c`.`ContactName`) - 1) + 1, 3) + @"SELECT SUBSTRING(`c`.`ContactName`, (LOCATE('a', `c`.`ContactName`) - 1) + 1, 3) FROM `Customers` AS `c` WHERE `c`.`CustomerID` = 'ALFKI'"); } @@ -352,7 +347,6 @@ public override async Task Where_math_abs2(bool async) public override async Task Where_math_abs_uncorrelated(bool async) { await base.Where_math_abs_uncorrelated(async); - AssertSql( """ SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` @@ -378,7 +372,7 @@ public override async Task Where_math_min(bool async) await base.Where_math_min(async); AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` + @"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` WHERE (`o`.`OrderID` = 11077) AND (LEAST(`o`.`OrderID`, `o`.`ProductID`) = `o`.`ProductID`)"); } @@ -389,7 +383,7 @@ public override async Task Where_math_max(bool async) await base.Where_math_max(async); AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` + @"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` WHERE (`o`.`OrderID` = 11077) AND (GREATEST(`o`.`OrderID`, `o`.`ProductID`) = `o`.`OrderID`)"); } @@ -400,7 +394,7 @@ public override async Task Where_string_to_lower(bool async) await base.Where_string_to_lower(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE LOWER(`c`.`CustomerID`) = 'alfki'"); } @@ -411,7 +405,7 @@ public override async Task Where_string_to_upper(bool async) await base.Where_string_to_upper(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE UPPER(`c`.`CustomerID`) = 'ALFKI'"); } @@ -422,7 +416,7 @@ public override async Task TrimStart_without_arguments_in_predicate(bool async) await base.TrimStart_without_arguments_in_predicate(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE TRIM(LEADING FROM `c`.`ContactTitle`) = 'Owner'"); } @@ -433,7 +427,7 @@ public override async Task TrimStart_with_char_argument_in_predicate(bool async) await base.TrimStart_with_char_argument_in_predicate(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE TRIM(LEADING 'O' FROM `c`.`ContactTitle`) = 'wner'"); } @@ -453,7 +447,7 @@ public override async Task TrimEnd_without_arguments_in_predicate(bool async) await base.TrimEnd_without_arguments_in_predicate(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE TRIM(TRAILING FROM `c`.`ContactTitle`) = 'Owner'"); } @@ -464,7 +458,7 @@ public override async Task TrimEnd_with_char_argument_in_predicate(bool async) await base.TrimEnd_with_char_argument_in_predicate(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE TRIM(TRAILING 'r' FROM `c`.`ContactTitle`) = 'Owne'"); } @@ -484,7 +478,7 @@ public override async Task Trim_without_argument_in_predicate(bool async) await base.Trim_without_argument_in_predicate(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE TRIM(`c`.`ContactTitle`) = 'Owner'"); } @@ -495,7 +489,7 @@ public override async Task Trim_with_char_argument_in_predicate(bool async) await base.Trim_with_char_argument_in_predicate(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE TRIM('O' FROM `c`.`ContactTitle`) = 'wner'"); } @@ -514,7 +508,7 @@ public override async Task String_FirstOrDefault_MethodCall(bool async) await base.String_FirstOrDefault_MethodCall(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE SUBSTRING(`c`.`ContactName`, 1, 1) = 'A'"); } @@ -524,7 +518,7 @@ public override async Task String_Contains_constant_with_whitespace(bool async) await base.String_Contains_constant_with_whitespace(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`ContactName` LIKE '% %'"); } @@ -533,7 +527,7 @@ public override async Task String_Contains_parameter_with_whitespace(bool async) { await base.String_Contains_parameter_with_whitespace(async); - AssertSql( + AssertSql( """ @__pattern_0_contains='% %' (Size = 30) @@ -548,7 +542,7 @@ public override async Task String_LastOrDefault_MethodCall(bool async) await base.String_LastOrDefault_MethodCall(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE SUBSTRING(`c`.`ContactName`, CHAR_LENGTH(`c`.`ContactName`), 1) = 's'"); } @@ -628,7 +622,7 @@ public override async Task Where_math_round2(bool async) await base.Where_math_round2(async); AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` + @"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` WHERE ROUND(`o`.`UnitPrice`, 2) > 100.0"); } @@ -680,7 +674,7 @@ public override async Task Where_math_log_new_base(bool async) AssertSql( $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` -WHERE ((`o`.`OrderID` = 11077) AND (`o`.`Discount` > 0)) AND (LOG(7.0, {SingleStoreTestHelpers.CastAsDouble("`o`.`Discount`")}) < 0.0)"); +WHERE ((`o`.`OrderID` = 11077) AND (`o`.`Discount` > 0)) AND (LOG(7.0, {SingleStoreTestHelpers.CastAsDouble("`o`.`Discount`")}) < -1.0)"); } public override async Task Where_math_sqrt(bool async) @@ -768,7 +762,7 @@ public override async Task Where_math_sign(bool async) await base.Where_math_sign(async); AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` + @"SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` WHERE (`o`.`OrderID` = 11077) AND (SIGN(`o`.`Discount`) > 0)"); } @@ -798,7 +792,7 @@ public override async Task IsNullOrEmpty_in_predicate(bool async) await base.IsNullOrEmpty_in_predicate(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`Region` IS NULL OR (`c`.`Region` = '')"); } @@ -818,7 +812,7 @@ public override async Task IsNullOrWhiteSpace_in_predicate_on_non_nullable_colum await base.IsNullOrWhiteSpace_in_predicate_on_non_nullable_column(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE TRIM(`c`.`CustomerID`) = ''"); } @@ -828,7 +822,7 @@ public override async Task Order_by_length_twice(bool async) await base.Order_by_length_twice(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` ORDER BY CHAR_LENGTH(`c`.`CustomerID`), `c`.`CustomerID`"); } @@ -838,7 +832,7 @@ public override async Task Order_by_length_twice_followed_by_projection_of_naked await base.Order_by_length_twice_followed_by_projection_of_naked_collection_navigation(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + @"SELECT `c`.`CustomerID`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Customers` AS `c` LEFT JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID` ORDER BY CHAR_LENGTH(`c`.`CustomerID`), `c`.`CustomerID`"); @@ -849,7 +843,7 @@ public override async Task Static_string_equals_in_predicate(bool async) await base.Static_string_equals_in_predicate(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`CustomerID` = 'ANATR'"); } @@ -859,7 +853,7 @@ public override async Task Static_equals_nullable_datetime_compared_to_non_nulla await base.Static_equals_nullable_datetime_compared_to_non_nullable(async); AssertSql( - $@"@__arg_0='1996-07-04T00:00:00.0000000' (DbType = DateTime) + @"@__arg_0='1996-07-04T00:00:00.0000000' (DbType = DateTime) SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` @@ -871,7 +865,7 @@ public override async Task Static_equals_int_compared_to_long(bool async) await base.Static_equals_int_compared_to_long(async); AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + @"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE FALSE"); } @@ -1052,7 +1046,7 @@ public override async Task String_Compare_simple_more_than_one(bool async) await base.String_Compare_simple_more_than_one(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE CASE WHEN `c`.`CustomerID` = 'ALFKI' THEN 0 @@ -1060,7 +1054,7 @@ WHERE CASE WHEN `c`.`CustomerID` < 'ALFKI' THEN -1 END = 42", // - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE CASE WHEN `c`.`CustomerID` = 'ALFKI' THEN 0 @@ -1068,7 +1062,7 @@ WHERE CASE WHEN `c`.`CustomerID` < 'ALFKI' THEN -1 END > 42", // - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE 42 > CASE WHEN `c`.`CustomerID` = 'ALFKI' THEN 0 @@ -1082,27 +1076,27 @@ public override async Task String_Compare_nested(bool async) await base.String_Compare_nested(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`CustomerID` = (CONCAT('M', `c`.`CustomerID`))", // - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`CustomerID` <> UPPER(`c`.`CustomerID`)", // - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`CustomerID` > REPLACE('ALFKI', 'ALF', `c`.`CustomerID`)", // - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`CustomerID` <= (CONCAT('M', `c`.`CustomerID`))", // - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`CustomerID` > UPPER(`c`.`CustomerID`)", // - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE `c`.`CustomerID` < REPLACE('ALFKI', 'ALF', `c`.`CustomerID`)"); } @@ -1112,11 +1106,11 @@ public override async Task String_Compare_multi_predicate(bool async) await base.String_Compare_multi_predicate(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE (`c`.`CustomerID` >= 'ALFKI') AND (`c`.`CustomerID` < 'CACTU')", // - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE (`c`.`ContactTitle` = 'Owner') AND ((`c`.`Country` <> 'USA') OR `c`.`Country` IS NULL)"); } @@ -1264,7 +1258,7 @@ public override async Task String_Compare_to_simple_more_than_one(bool async) await base.String_Compare_to_simple_more_than_one(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE CASE WHEN `c`.`CustomerID` = 'ALFKI' THEN 0 @@ -1272,7 +1266,7 @@ WHERE CASE WHEN `c`.`CustomerID` < 'ALFKI' THEN -1 END = 42", // - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE CASE WHEN `c`.`CustomerID` = 'ALFKI' THEN 0 @@ -1280,7 +1274,7 @@ WHERE CASE WHEN `c`.`CustomerID` < 'ALFKI' THEN -1 END > 42", // - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE 42 > CASE WHEN `c`.`CustomerID` = 'ALFKI' THEN 0 @@ -1336,11 +1330,11 @@ public override async Task String_Compare_to_multi_predicate(bool async) await base.String_Compare_to_multi_predicate(async); AssertSql( - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE (`c`.`CustomerID` >= 'ALFKI') AND (`c`.`CustomerID` < 'CACTU')", // - $@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` WHERE (`c`.`ContactTitle` = 'Owner') AND ((`c`.`Country` <> 'USA') OR `c`.`Country` IS NULL)"); } @@ -1350,37 +1344,37 @@ public override async Task DateTime_Compare_to_simple_zero(bool async, bool comp await base.DateTime_Compare_to_simple_zero(async, compareTo); AssertSql( - $@"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) + @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderDate` = @__myDatetime_0", // - $@"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) + @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE (`o`.`OrderDate` <> @__myDatetime_0) OR `o`.`OrderDate` IS NULL", // - $@"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) + @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderDate` > @__myDatetime_0", // - $@"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) + @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderDate` <= @__myDatetime_0", // - $@"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) + @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderDate` > @__myDatetime_0", // - $@"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) + @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` @@ -1392,37 +1386,37 @@ public override async Task TimeSpan_Compare_to_simple_zero(bool async, bool comp await base.TimeSpan_Compare_to_simple_zero(async, compareTo); AssertSql( - $@"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) + @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderDate` = @__myDatetime_0", // - $@"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) + @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE (`o`.`OrderDate` <> @__myDatetime_0) OR `o`.`OrderDate` IS NULL", // - $@"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) + @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderDate` > @__myDatetime_0", // - $@"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) + @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderDate` <= @__myDatetime_0", // - $@"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) + @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderDate` > @__myDatetime_0", // - $@"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) + @"@__myDatetime_0='1998-05-04T00:00:00.0000000' (DbType = DateTime) SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` @@ -1434,37 +1428,37 @@ public override async Task Int_Compare_to_simple_zero(bool async) await base.Int_Compare_to_simple_zero(async); AssertSql( - $@"@__orderId_0='10250' + @"@__orderId_0='10250' SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderID` = @__orderId_0", // - $@"@__orderId_0='10250' + @"@__orderId_0='10250' SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderID` <> @__orderId_0", // - $@"@__orderId_0='10250' + @"@__orderId_0='10250' SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderID` > @__orderId_0", // - $@"@__orderId_0='10250' + @"@__orderId_0='10250' SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderID` <= @__orderId_0", // - $@"@__orderId_0='10250' + @"@__orderId_0='10250' SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderID` > @__orderId_0", // - $@"@__orderId_0='10250' + @"@__orderId_0='10250' SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` @@ -1475,122 +1469,192 @@ public override async Task Convert_ToBoolean(bool async) { await base.Convert_ToBoolean(async); - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(`o`.`OrderID` % 3 AS signed)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(`o`.`OrderID` % 3 AS signed) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(CAST(`o`.`OrderID` % 3 AS unsigned) AS signed)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(CAST(`o`.`OrderID` % 3 AS unsigned) AS signed) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(CAST(`o`.`OrderID` % 3 AS decimal(65,30)) AS signed)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(CAST(`o`.`OrderID` % 3 AS decimal(65,30)) AS signed) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST({SingleStoreTestHelpers.CastAsDouble("`o`.`OrderID` % 3")} AS signed)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST((`o`.`OrderID` % 3 :> double) AS signed) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST({SingleStoreTestHelpers.CastAsDouble("`o`.`OrderID` % 3")} AS signed)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST((`o`.`OrderID` % 3 :> double) AS signed) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(`o`.`OrderID` % 3 AS signed)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(`o`.`OrderID` % 3 AS signed) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(`o`.`OrderID` % 3 AS signed)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(`o`.`OrderID` % 3 AS signed) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM `Orders` AS `o` +WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(`o`.`OrderID` % 3 AS signed) +""", + // + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(`o`.`OrderID` % 3 AS signed)"); +WHERE (`o`.`CustomerID` = 'ALFKI') AND CAST(`o`.`OrderID` % 3 AS signed) +"""); } public override async Task Convert_ToByte(bool async) { await base.Convert_ToByte(async); - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS unsigned) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS unsigned) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS unsigned) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS unsigned) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS decimal(65,30)) AS unsigned) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS decimal(65,30)) AS unsigned) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST({SingleStoreTestHelpers.CastAsDouble("`o`.`OrderID` % 1")} AS unsigned) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST((`o`.`OrderID` % 1 :> double) AS unsigned) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST({SingleStoreTestHelpers.CastAsDouble("`o`.`OrderID` % 1")} AS unsigned) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST((`o`.`OrderID` % 1 :> double) AS unsigned) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS unsigned) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS unsigned) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM `Orders` AS `o` +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS unsigned) >= 0) +""", + // + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS unsigned) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS unsigned) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS unsigned) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS unsigned) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS unsigned) >= 0)"); +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS unsigned) >= 0) +"""); } public override async Task Convert_ToDecimal(bool async) { await base.Convert_ToDecimal(async); - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS decimal(65,30)) >= 0.0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS decimal(65,30)) >= 0.0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS unsigned) AS decimal(65,30)) >= 0.0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS unsigned) AS decimal(65,30)) >= 0.0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS decimal(65,30)) >= 0.0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS decimal(65,30)) >= 0.0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST({SingleStoreTestHelpers.CastAsDouble("`o`.`OrderID` % 1")} AS decimal(65,30)) >= 0.0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST((`o`.`OrderID` % 1 :> double) AS decimal(65,30)) >= 0.0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST({SingleStoreTestHelpers.CastAsDouble("`o`.`OrderID` % 1")} AS decimal(65,30)) >= 0.0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST((`o`.`OrderID` % 1 :> double) AS decimal(65,30)) >= 0.0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS decimal(65,30)) >= 0.0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS decimal(65,30)) >= 0.0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS decimal(65,30)) >= 0.0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS decimal(65,30)) >= 0.0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS decimal(65,30)) >= 0.0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS decimal(65,30)) >= 0.0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS decimal(65,30)) >= 0.0)"); +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS decimal(65,30)) >= 0.0) +""", + // + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM `Orders` AS `o` +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS decimal(65,30)) >= 0.0) +"""); } public override async Task Convert_ToDouble(bool async) @@ -1632,6 +1696,10 @@ public override async Task Convert_ToDouble(bool async) // $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` +WHERE (`o`.`CustomerID` = 'ALFKI') AND ({SingleStoreTestHelpers.CastAsDouble("CAST(`o`.`OrderID` % 1 AS char)")} >= 0.0)", + // + $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM `Orders` AS `o` WHERE (`o`.`CustomerID` = 'ALFKI') AND ({SingleStoreTestHelpers.CastAsDouble("CAST(`o`.`OrderID` % 1 AS char)")} >= 0.0)"); } @@ -1639,179 +1707,277 @@ public override async Task Convert_ToInt16(bool async) { await base.Convert_ToInt16(async); - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS unsigned) AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS unsigned) AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS decimal(65,30)) AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS decimal(65,30)) AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST({SingleStoreTestHelpers.CastAsDouble("`o`.`OrderID` % 1")} AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST((`o`.`OrderID` % 1 :> double) AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST({SingleStoreTestHelpers.CastAsDouble("`o`.`OrderID` % 1")} AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST((`o`.`OrderID` % 1 :> double) AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM `Orders` AS `o` +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) +""", + // + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS signed) >= 0)"); +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS signed) >= 0) +"""); } public override async Task Convert_ToInt32(bool async) { await base.Convert_ToInt32(async); - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS unsigned) AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS unsigned) AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS decimal(65,30)) AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS decimal(65,30)) AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST({SingleStoreTestHelpers.CastAsDouble("`o`.`OrderID` % 1")} AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST((`o`.`OrderID` % 1 :> double) AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST({SingleStoreTestHelpers.CastAsDouble("`o`.`OrderID` % 1")} AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST((`o`.`OrderID` % 1 :> double) AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM `Orders` AS `o` +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS signed) >= 0) +""", + // + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS signed) >= 0)"); +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS signed) >= 0) +"""); } public override async Task Convert_ToInt64(bool async) { await base.Convert_ToInt64(async); - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS unsigned) AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS unsigned) AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS decimal(65,30)) AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS decimal(65,30)) AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST({SingleStoreTestHelpers.CastAsDouble("`o`.`OrderID` % 1")} AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST((`o`.`OrderID` % 1 :> double) AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST({SingleStoreTestHelpers.CastAsDouble("`o`.`OrderID` % 1")} AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST((`o`.`OrderID` % 1 :> double) AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0)", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS signed) >= 0) +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM `Orders` AS `o` +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS signed) >= 0) +""", + // + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS signed) >= 0)"); +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS char) AS signed) >= 0) +"""); } public override async Task Convert_ToString(bool async) { await base.Convert_ToString(async); - AssertSql( - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS char) <> '10')", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS char) <> '10') +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS unsigned) AS char) <> '10')", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS unsigned) AS char) <> '10') +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS decimal(65,30)) AS char) <> '10')", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS decimal(65,30)) AS char) <> '10') +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST({SingleStoreTestHelpers.CastAsDouble("`o`.`OrderID` % 1")} AS char) <> '10')", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST((`o`.`OrderID` % 1 :> double) AS char) <> '10') +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST({SingleStoreTestHelpers.CastAsDouble("`o`.`OrderID` % 1")} AS char) <> '10')", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST((`o`.`OrderID` % 1 :> double) AS char) <> '10') +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS char) <> '10')", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS char) <> '10') +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS char) <> '10')", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS char) <> '10') +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS char) <> '10')", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(CAST(`o`.`OrderID` % 1 AS signed) AS char) <> '10') +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS char) <> '10')", +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS char) <> '10') +""", // - $@"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM `Orders` AS `o` +WHERE (`o`.`CustomerID` = 'ALFKI') AND (CAST(`o`.`OrderID` % 1 AS char) <> '10') +""", + // + """ +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`CustomerID` = 'ALFKI') AND ((CAST(`o`.`OrderDate` AS char) LIKE '%1997%') OR (CAST(`o`.`OrderDate` AS char) LIKE '%1998%'))"); +WHERE (`o`.`CustomerID` = 'ALFKI') AND ((CAST(`o`.`OrderDate` AS char) LIKE '%1997%') OR (CAST(`o`.`OrderDate` AS char) LIKE '%1998%')) +"""); } - public override async Task String_StartsWith_Parameter(bool async) + public override async Task String_StartsWith_Parameter(bool async) { await base.String_StartsWith_Parameter(async); - AssertSql( + AssertSql( """ @__pattern_0_startswith='M%' (Size = 30) @@ -1825,7 +1991,7 @@ public override async Task String_EndsWith_Parameter(bool async) { await base.String_EndsWith_Parameter(async); - AssertSql( + AssertSql( """ @__pattern_0_endswith='%b' (Size = 30) @@ -1839,16 +2005,16 @@ public override async Task String_Join_over_non_nullable_column(bool async) { await base.String_Join_over_non_nullable_column(async); - AssertSql( + AssertSql( """ -SELECT `t`.`City`, `c0`.`CustomerID` +SELECT `c1`.`City`, `c0`.`CustomerID` FROM ( SELECT `c`.`City` FROM `Customers` AS `c` GROUP BY `c`.`City` -) AS `t` -LEFT JOIN `Customers` AS `c0` ON `t`.`City` = `c0`.`City` -ORDER BY `t`.`City` +) AS `c1` +LEFT JOIN `Customers` AS `c0` ON `c1`.`City` = `c0`.`City` +ORDER BY `c1`.`City` """); } @@ -1856,20 +2022,20 @@ public override async Task String_Join_with_predicate(bool async) { await base.String_Join_with_predicate(async); - AssertSql( + AssertSql( """ -SELECT `t`.`City`, `t0`.`CustomerID` +SELECT `c1`.`City`, `c2`.`CustomerID` FROM ( SELECT `c`.`City` FROM `Customers` AS `c` GROUP BY `c`.`City` -) AS `t` +) AS `c1` LEFT JOIN ( SELECT `c0`.`CustomerID`, `c0`.`City` FROM `Customers` AS `c0` WHERE CHAR_LENGTH(`c0`.`ContactName`) > 10 -) AS `t0` ON `t`.`City` = `t0`.`City` -ORDER BY `t`.`City` +) AS `c2` ON `c1`.`City` = `c2`.`City` +ORDER BY `c1`.`City` """); } @@ -1877,16 +2043,16 @@ public override async Task String_Join_with_ordering(bool async) { await base.String_Join_with_ordering(async); - AssertSql( + AssertSql( """ -SELECT `t`.`City`, `c0`.`CustomerID` +SELECT `c1`.`City`, `c0`.`CustomerID` FROM ( SELECT `c`.`City` FROM `Customers` AS `c` GROUP BY `c`.`City` -) AS `t` -LEFT JOIN `Customers` AS `c0` ON `t`.`City` = `c0`.`City` -ORDER BY `t`.`City`, `c0`.`CustomerID` DESC +) AS `c1` +LEFT JOIN `Customers` AS `c0` ON `c1`.`City` = `c0`.`City` +ORDER BY `c1`.`City`, `c0`.`CustomerID` DESC """); } @@ -1894,16 +2060,16 @@ public override async Task String_Join_over_nullable_column(bool async) { await base.String_Join_over_nullable_column(async); - AssertSql( + AssertSql( """ -SELECT `t`.`City`, `c0`.`Region`, `c0`.`CustomerID` +SELECT `c1`.`City`, `c0`.`Region`, `c0`.`CustomerID` FROM ( SELECT `c`.`City` FROM `Customers` AS `c` GROUP BY `c`.`City` -) AS `t` -LEFT JOIN `Customers` AS `c0` ON `t`.`City` = `c0`.`City` -ORDER BY `t`.`City` +) AS `c1` +LEFT JOIN `Customers` AS `c0` ON `c1`.`City` = `c0`.`City` +ORDER BY `c1`.`City` """); } @@ -1911,16 +2077,16 @@ public override async Task String_Concat(bool async) { await base.String_Concat(async); - AssertSql( + AssertSql( """ -SELECT `t`.`City`, `c0`.`CustomerID` +SELECT `c1`.`City`, `c0`.`CustomerID` FROM ( SELECT `c`.`City` FROM `Customers` AS `c` GROUP BY `c`.`City` -) AS `t` -LEFT JOIN `Customers` AS `c0` ON `t`.`City` = `c0`.`City` -ORDER BY `t`.`City` +) AS `c1` +LEFT JOIN `Customers` AS `c0` ON `c1`.`City` = `c0`.`City` +ORDER BY `c1`.`City` """); } @@ -2180,11 +2346,11 @@ public override async Task Where_mathf_log_new_base(bool async) { await base.Where_mathf_log_new_base(async); - AssertSql( + AssertSql( """ SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` FROM `Order Details` AS `o` -WHERE ((`o`.`OrderID` = 11077) AND (`o`.`Discount` > 0)) AND (LOG(7, `o`.`Discount`) < 0) +WHERE ((`o`.`OrderID` = 11077) AND (`o`.`Discount` > 0)) AND (LOG(7, `o`.`Discount`) < -1) """); } @@ -2408,9 +2574,196 @@ public override async Task Where_DateOnly_FromDateTime(bool async) """); } + public override async Task String_StartsWith_with_StringComparison_Ordinal(bool async) + { + await base.String_StartsWith_with_StringComparison_Ordinal(async); + + AssertSql(); + } + + public override async Task String_StartsWith_with_StringComparison_OrdinalIgnoreCase(bool async) + { + await base.String_StartsWith_with_StringComparison_OrdinalIgnoreCase(async); + + AssertSql(); + } + + public override async Task String_EndsWith_with_StringComparison_Ordinal(bool async) + { + await base.String_EndsWith_with_StringComparison_Ordinal(async); + + AssertSql(); + } + + public override async Task String_EndsWith_with_StringComparison_OrdinalIgnoreCase(bool async) + { + await base.String_EndsWith_with_StringComparison_OrdinalIgnoreCase(async); + + AssertSql(); + } + + public override async Task String_Contains_with_StringComparison_Ordinal(bool async) + { + await base.String_Contains_with_StringComparison_Ordinal(async); + + AssertSql(); + } + + public override async Task String_Contains_with_StringComparison_OrdinalIgnoreCase(bool async) + { + await base.String_Contains_with_StringComparison_OrdinalIgnoreCase(async); + + AssertSql(); + } + + public override async Task String_StartsWith_with_StringComparison_unsupported(bool async) + { + await base.String_StartsWith_with_StringComparison_unsupported(async); + + AssertSql(); + } + + public override async Task String_EndsWith_with_StringComparison_unsupported(bool async) + { + await base.String_EndsWith_with_StringComparison_unsupported(async); + + AssertSql(); + } + + public override async Task String_Contains_in_projection(bool async) + { + await base.String_Contains_in_projection(async); + + AssertSql( +""" +SELECT `c`.`CustomerID` AS `Id`, `c`.`ContactName` IS NOT NULL AND ((LOCATE(`c`.`ContactName`, `c`.`CompanyName`) > 0) OR (`c`.`ContactName` LIKE '')) AS `Value` +FROM `Customers` AS `c` +"""); + } + + public override async Task String_Contains_negated_in_predicate(bool async) + { + await base.String_Contains_negated_in_predicate(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`ContactName` IS NULL OR ((LOCATE(`c`.`ContactName`, `c`.`CompanyName`) <= 0) AND `c`.`ContactName` NOT LIKE '') +"""); + } + + public override async Task String_Contains_negated_in_projection(bool async) + { + await base.String_Contains_negated_in_projection(async); + + AssertSql( +""" +SELECT `c`.`CustomerID` AS `Id`, `c`.`ContactName` IS NULL OR ((LOCATE(`c`.`ContactName`, `c`.`CompanyName`) <= 0) AND `c`.`ContactName` NOT LIKE '') AS `Value` +FROM `Customers` AS `c` +"""); + } + + public override async Task String_Contains_with_StringComparison_unsupported(bool async) + { + await base.String_Contains_with_StringComparison_unsupported(async); + + AssertSql(); + } + + public override async Task String_Join_non_aggregate(bool async) + { + await base.String_Join_non_aggregate(async); + + AssertSql( +""" +@__foo_0='foo' (Size = 4000) + +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE CONCAT_WS('|', `c`.`CompanyName`, @__foo_0, '', 'bar') = 'Around the Horn|foo||bar' +"""); + } + + public override async Task Where_math_max_nested(bool async) + { + await base.Where_math_max_nested(async); + + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` +FROM `Order Details` AS `o` +WHERE (`o`.`OrderID` = 11077) AND (GREATEST(`o`.`OrderID`, `o`.`ProductID`, 1) = `o`.`OrderID`) +"""); + } + + public override async Task Where_math_max_nested_twice(bool async) + { + await base.Where_math_max_nested_twice(async); + + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` +FROM `Order Details` AS `o` +WHERE (`o`.`OrderID` = 11077) AND (GREATEST(1, `o`.`OrderID`, 2, `o`.`ProductID`) = `o`.`OrderID`) +"""); + } + + public override async Task Where_math_min_nested(bool async) + { + await base.Where_math_min_nested(async); + + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` +FROM `Order Details` AS `o` +WHERE (`o`.`OrderID` = 11077) AND (LEAST(`o`.`OrderID`, `o`.`ProductID`, 99999) = `o`.`ProductID`) +"""); + } + + public override async Task Where_math_min_nested_twice(bool async) + { + await base.Where_math_min_nested_twice(async); + + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` +FROM `Order Details` AS `o` +WHERE (`o`.`OrderID` = 11077) AND (LEAST(99999, `o`.`OrderID`, 99998, `o`.`ProductID`) = `o`.`ProductID`) +"""); + } + + public override async Task Select_ToString_IndexOf(bool async) + { + await base.Select_ToString_IndexOf(async); + + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM `Orders` AS `o` +WHERE (LOCATE('123', CAST(`o`.`OrderID` AS char)) - 1) = -1 +"""); + } + + public override async Task Select_IndexOf_ToString(bool async) + { + await base.Select_IndexOf_ToString(async); + + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM `Orders` AS `o` +WHERE (LOCATE(CAST(`o`.`OrderID` AS char), '123') - 1) = -1 +"""); + } + public override Task Datetime_subtraction_TotalDays(bool async) => AssertTranslationFailed(() => base.Datetime_subtraction_TotalDays(async)); + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindGroupByQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindGroupByQuerySingleStoreTest.cs index ab910d96b..59f91f276 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindGroupByQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindGroupByQuerySingleStoreTest.cs @@ -1,7 +1,9 @@ using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using EntityFrameworkCore.SingleStore.Infrastructure; +using EntityFrameworkCore.SingleStore.Tests; using EntityFrameworkCore.SingleStore.Tests.TestUtilities.Attributes; using Xunit; using Xunit.Abstractions; @@ -20,150 +22,110 @@ public NorthwindGroupByQuerySingleStoreTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - - [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore")] - public override Task GroupBy_complex_key_aggregate_2(bool async) - { - return base.GroupBy_complex_key_aggregate_2(async); - } - - [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore")] - public override Task GroupBy_aggregate_Contains(bool async) - { - return base.GroupBy_aggregate_Contains(async); - } - - [ConditionalTheory(Skip = "Feature 'Dependent aggregate inside subselect' is not supported by SingleStore.")] - public override Task GroupBy_aggregate_from_multiple_query_in_same_projection_2(bool async) - { - return base.GroupBy_aggregate_from_multiple_query_in_same_projection_2(async); - } - - [ConditionalTheory(Skip = "SingleStore does not support this type of query: scalar subselect references field belonging to outer select that is more than one level up")] - public override Task GroupBy_aggregate_from_multiple_query_in_same_projection_3(bool async) - { - return base.GroupBy_aggregate_from_multiple_query_in_same_projection_3(async); - } - - [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore")] - public override Task GroupBy_scalar_subquery(bool async) - { - return base.GroupBy_scalar_subquery(async); - } - - [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore")] - public override Task GroupBy_Shadow(bool async) - { - return base.GroupBy_Shadow(async); - } - - [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore")] - public override Task GroupBy_with_aggregate_through_navigation_property(bool async) - { - return base.GroupBy_with_aggregate_through_navigation_property(async); - } - - [ConditionalTheory(Skip = "SingleStore does not support this type of query: scalar subselect references field belonging to outer select that is more than one level up")] - public override Task GroupBy_with_aggregate_containing_complex_where(bool async) - { - return base.GroupBy_with_aggregate_containing_complex_where(async); - } public override async Task AsEnumerable_in_subquery_for_GroupBy(bool async) { await base.AsEnumerable_in_subquery_for_GroupBy(async); - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `t2`.`OrderID`, `t2`.`CustomerID`, `t2`.`EmployeeID`, `t2`.`OrderDate`, `t2`.`CustomerID0` + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `s`.`OrderID`, `s`.`CustomerID`, `s`.`EmployeeID`, `s`.`OrderDate`, `s`.`CustomerID0` FROM `Customers` AS `c` LEFT JOIN LATERAL ( - SELECT `t0`.`OrderID`, `t0`.`CustomerID`, `t0`.`EmployeeID`, `t0`.`OrderDate`, `t`.`CustomerID` AS `CustomerID0` + SELECT `o3`.`OrderID`, `o3`.`CustomerID`, `o3`.`EmployeeID`, `o3`.`OrderDate`, `o1`.`CustomerID` AS `CustomerID0` FROM ( SELECT `o`.`CustomerID` FROM `Orders` AS `o` WHERE `o`.`CustomerID` = `c`.`CustomerID` GROUP BY `o`.`CustomerID` - ) AS `t` + ) AS `o1` LEFT JOIN ( - SELECT `t1`.`OrderID`, `t1`.`CustomerID`, `t1`.`EmployeeID`, `t1`.`OrderDate` + SELECT `o2`.`OrderID`, `o2`.`CustomerID`, `o2`.`EmployeeID`, `o2`.`OrderDate` FROM ( SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate`, ROW_NUMBER() OVER(PARTITION BY `o0`.`CustomerID` ORDER BY `o0`.`OrderDate` DESC) AS `row` FROM `Orders` AS `o0` WHERE `o0`.`CustomerID` = `c`.`CustomerID` - ) AS `t1` - WHERE `t1`.`row` <= 1 - ) AS `t0` ON `t`.`CustomerID` = `t0`.`CustomerID` -) AS `t2` ON TRUE + ) AS `o2` + WHERE `o2`.`row` <= 1 + ) AS `o3` ON `o1`.`CustomerID` = `o3`.`CustomerID` +) AS `s` ON TRUE WHERE `c`.`CustomerID` LIKE 'F%' -ORDER BY `c`.`CustomerID`, `t2`.`CustomerID0`"); +ORDER BY `c`.`CustomerID`, `s`.`CustomerID0` +"""); } public override async Task Complex_query_with_groupBy_in_subquery1(bool async) { await base.Complex_query_with_groupBy_in_subquery1(async); - AssertSql( - @"SELECT `c`.`CustomerID`, `t`.`Sum`, `t`.`CustomerID` + AssertSql( +""" +SELECT `c`.`CustomerID`, `o0`.`Sum`, `o0`.`CustomerID` FROM `Customers` AS `c` LEFT JOIN LATERAL ( SELECT COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, `o`.`CustomerID` FROM `Orders` AS `o` WHERE `c`.`CustomerID` = `o`.`CustomerID` GROUP BY `o`.`CustomerID` -) AS `t` ON TRUE -ORDER BY `c`.`CustomerID`"); +) AS `o0` ON TRUE +ORDER BY `c`.`CustomerID` +"""); } public override async Task Complex_query_with_groupBy_in_subquery2(bool async) { await base.Complex_query_with_groupBy_in_subquery2(async); - AssertSql( - @"SELECT `c`.`CustomerID`, `t`.`Max`, `t`.`Sum`, `t`.`CustomerID` + AssertSql( +""" +SELECT `c`.`CustomerID`, `o0`.`Max`, `o0`.`Sum`, `o0`.`CustomerID` FROM `Customers` AS `c` LEFT JOIN LATERAL ( SELECT MAX(CHAR_LENGTH(`o`.`CustomerID`)) AS `Max`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, `o`.`CustomerID` FROM `Orders` AS `o` WHERE `c`.`CustomerID` = `o`.`CustomerID` GROUP BY `o`.`CustomerID` -) AS `t` ON TRUE -ORDER BY `c`.`CustomerID`"); +) AS `o0` ON TRUE +ORDER BY `c`.`CustomerID` +"""); } public override async Task Complex_query_with_groupBy_in_subquery3(bool async) { await base.Complex_query_with_groupBy_in_subquery3(async); - AssertSql( - @"SELECT `c`.`CustomerID`, `t`.`Max`, `t`.`Sum`, `t`.`CustomerID` + AssertSql( +""" +SELECT `c`.`CustomerID`, `o0`.`Max`, `o0`.`Sum`, `o0`.`CustomerID` FROM `Customers` AS `c` LEFT JOIN LATERAL ( SELECT MAX(CHAR_LENGTH(`o`.`CustomerID`)) AS `Max`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, `o`.`CustomerID` FROM `Orders` AS `o` GROUP BY `o`.`CustomerID` -) AS `t` ON TRUE -ORDER BY `c`.`CustomerID`"); +) AS `o0` ON TRUE +ORDER BY `c`.`CustomerID` +"""); } public override async Task Select_nested_collection_with_groupby(bool async) { await base.Select_nested_collection_with_groupby(async); - AssertSql( - @"SELECT EXISTS ( + AssertSql( +""" +SELECT EXISTS ( SELECT 1 FROM `Orders` AS `o` - WHERE `c`.`CustomerID` = `o`.`CustomerID`), `c`.`CustomerID`, `t`.`OrderID` + WHERE `c`.`CustomerID` = `o`.`CustomerID`), `c`.`CustomerID`, `o1`.`OrderID` FROM `Customers` AS `c` LEFT JOIN LATERAL ( SELECT `o0`.`OrderID` FROM `Orders` AS `o0` WHERE `c`.`CustomerID` = `o0`.`CustomerID` GROUP BY `o0`.`OrderID` -) AS `t` ON TRUE +) AS `o1` ON TRUE WHERE `c`.`CustomerID` LIKE 'F%' -ORDER BY `c`.`CustomerID`"); +ORDER BY `c`.`CustomerID` +"""); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.OuterReferenceInMultiLevelSubquery))] @@ -177,26 +139,3669 @@ public override async Task GroupBy_group_Distinct_Select_Distinct_aggregate(bool GROUP BY `o`.`CustomerID`"); } - [SupportedServerVersionCondition(nameof(ServerVersionSupport.OuterReferenceInMultiLevelSubquery))] - public override Task GroupBy_Count_in_projection(bool async) + public override async Task GroupBy_Property_Select_Average(bool async) { - return base.GroupBy_Count_in_projection(async); + await base.GroupBy_Property_Select_Average(async); + + AssertSql( +""" +SELECT AVG((`o`.`OrderID` :> double)) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); } - [SupportedServerVersionCondition("8.0.22-mysql", "0.0.0-mariadb")] - public override Task GroupBy_group_Where_Select_Distinct_aggregate(bool async) + public override async Task GroupBy_Property_Select_Average_with_group_enumerable_projected(bool async) { - // See https://github.com/mysql-net/MySqlConnector/issues/898. - return base.GroupBy_group_Where_Select_Distinct_aggregate(async); + await base.GroupBy_Property_Select_Average_with_group_enumerable_projected(async); + + AssertSql(); } - [SupportedServerVersionCondition("8.0.0-mysql", "0.0.0-mariadb")] // Is an issue issue in MySQL 5.7.34, but not in 8.0.25. - public override Task GroupBy_constant_with_where_on_grouping_with_aggregate_operators(bool async) + public override async Task GroupBy_Property_Select_Count(bool async) { - // See https://github.com/mysql-net/MySqlConnector/issues/980. - return base.GroupBy_constant_with_where_on_grouping_with_aggregate_operators(async); + await base.GroupBy_Property_Select_Count(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_LongCount(bool async) + { + await base.GroupBy_Property_Select_LongCount(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_Count_with_nulls(bool async) + { + await base.GroupBy_Property_Select_Count_with_nulls(async); + + AssertSql( +""" +SELECT `c`.`City`, COUNT(*) AS `Faxes` +FROM `Customers` AS `c` +GROUP BY `c`.`City` +"""); + } + + public override async Task GroupBy_Property_Select_LongCount_with_nulls(bool async) + { + await base.GroupBy_Property_Select_LongCount_with_nulls(async); + + AssertSql( +""" +SELECT `c`.`City`, COUNT(*) AS `Faxes` +FROM `Customers` AS `c` +GROUP BY `c`.`City` +"""); + } + + public override async Task GroupBy_Property_Select_Max(bool async) + { + await base.GroupBy_Property_Select_Max(async); + + AssertSql( +""" +SELECT MAX(`o`.`OrderID`) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_Min(bool async) + { + await base.GroupBy_Property_Select_Min(async); + + AssertSql( +""" +SELECT MIN(`o`.`OrderID`) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_Sum(bool async) + { + await base.GroupBy_Property_Select_Sum(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_Sum_Min_Max_Avg(bool async) + { + await base.GroupBy_Property_Select_Sum_Min_Max_Avg(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, MIN(`o`.`OrderID`) AS `Min`, MAX(`o`.`OrderID`) AS `Max`, AVG((`o`.`OrderID` :> double)) AS `Avg` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_Key_Average(bool async) + { + await base.GroupBy_Property_Select_Key_Average(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, AVG((`o`.`OrderID` :> double)) AS `Average` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_Key_Count(bool async) + { + await base.GroupBy_Property_Select_Key_Count(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, COUNT(*) AS `Count` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_Key_LongCount(bool async) + { + await base.GroupBy_Property_Select_Key_LongCount(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, COUNT(*) AS `LongCount` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_Key_Max(bool async) + { + await base.GroupBy_Property_Select_Key_Max(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, MAX(`o`.`OrderID`) AS `Max` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_Key_Min(bool async) + { + await base.GroupBy_Property_Select_Key_Min(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, MIN(`o`.`OrderID`) AS `Min` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_Key_Sum(bool async) + { + await base.GroupBy_Property_Select_Key_Sum(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_Key_Sum_Min_Max_Avg(bool async) + { + await base.GroupBy_Property_Select_Key_Sum_Min_Max_Avg(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, MIN(`o`.`OrderID`) AS `Min`, MAX(`o`.`OrderID`) AS `Max`, AVG((`o`.`OrderID` :> double)) AS `Avg` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_Sum_Min_Key_Max_Avg(bool async) + { + await base.GroupBy_Property_Select_Sum_Min_Key_Max_Avg(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, MIN(`o`.`OrderID`) AS `Min`, `o`.`CustomerID` AS `Key`, MAX(`o`.`OrderID`) AS `Max`, AVG((`o`.`OrderID` :> double)) AS `Avg` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_key_multiple_times_and_aggregate(bool async) + { + await base.GroupBy_Property_Select_key_multiple_times_and_aggregate(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key1`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_Key_with_constant(bool async) + { + await base.GroupBy_Property_Select_Key_with_constant(async); + + AssertSql( +""" +SELECT `o0`.`Name`, `o0`.`CustomerID` AS `Value`, COUNT(*) AS `Count` +FROM ( + SELECT `o`.`CustomerID`, 'CustomerID' AS `Name` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Name`, `o0`.`CustomerID` +"""); + } + + public override async Task GroupBy_aggregate_projecting_conditional_expression(bool async) + { + await base.GroupBy_aggregate_projecting_conditional_expression(async); + + AssertSql( +""" +SELECT `o`.`OrderDate` AS `Key`, CASE + WHEN COUNT(*) = 0 THEN 1 + ELSE COALESCE(SUM(CASE + WHEN (`o`.`OrderID` % 2) = 0 THEN 1 + ELSE 0 + END), 0) / COUNT(*) +END AS `SomeValue` +FROM `Orders` AS `o` +GROUP BY `o`.`OrderDate` +"""); + } + + public override async Task GroupBy_aggregate_projecting_conditional_expression_based_on_group_key(bool async) + { + await base.GroupBy_aggregate_projecting_conditional_expression_based_on_group_key(async); + + AssertSql( +""" +SELECT CASE + WHEN `o`.`OrderDate` IS NULL THEN 'is null' + ELSE 'is not null' +END AS `Key`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum` +FROM `Orders` AS `o` +GROUP BY `o`.`OrderDate` +"""); + } + + public override async Task GroupBy_with_group_key_access_thru_navigation(bool async) + { + await base.GroupBy_with_group_key_access_thru_navigation(async); + + AssertSql( +""" +SELECT `o0`.`CustomerID` AS `Key`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Aggregate` +FROM `Order Details` AS `o` +INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` +GROUP BY `o0`.`CustomerID` +"""); + } + + public override async Task GroupBy_with_group_key_access_thru_nested_navigation(bool async) + { + await base.GroupBy_with_group_key_access_thru_nested_navigation(async); + + AssertSql( +""" +SELECT `c`.`Country` AS `Key`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Aggregate` +FROM `Order Details` AS `o` +INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` +LEFT JOIN `Customers` AS `c` ON `o0`.`CustomerID` = `c`.`CustomerID` +GROUP BY `c`.`Country` +"""); + } + + public override async Task GroupBy_with_grouping_key_using_Like(bool async) + { + await base.GroupBy_with_grouping_key_using_Like(async); + + AssertSql( +""" +SELECT `o0`.`Key`, COUNT(*) AS `Count` +FROM ( + SELECT (`o`.`CustomerID` LIKE 'A%') AND `o`.`CustomerID` IS NOT NULL AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_with_grouping_key_DateTime_Day(bool async) + { + await base.GroupBy_with_grouping_key_DateTime_Day(async); + + AssertSql( +""" +SELECT `o0`.`Key`, COUNT(*) AS `Count` +FROM ( + SELECT EXTRACT(day FROM `o`.`OrderDate`) AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_with_cast_inside_grouping_aggregate(bool async) + { + await base.GroupBy_with_cast_inside_grouping_aggregate(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, COUNT(*) AS `Count`, COALESCE(SUM(CAST(`o`.`OrderID` AS signed)), 0) AS `Sum` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task Group_by_with_arithmetic_operation_inside_aggregate(bool async) + { + await base.Group_by_with_arithmetic_operation_inside_aggregate(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, COALESCE(SUM(`o`.`OrderID` + CHAR_LENGTH(`o`.`CustomerID`)), 0) AS `Sum` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task Group_by_with_projection_into_DTO(bool async) + { + await base.Group_by_with_projection_into_DTO(async); + + AssertSql( +""" +SELECT CAST(`o`.`OrderID` AS signed) AS `Id`, COUNT(*) AS `Count` +FROM `Orders` AS `o` +GROUP BY `o`.`OrderID` +"""); + } + + public override async Task Where_select_function_groupby_followed_by_another_select_with_aggregates(bool async) + { + await base.Where_select_function_groupby_followed_by_another_select_with_aggregates(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, COALESCE(SUM(CASE + WHEN (2020 - EXTRACT(year FROM `o`.`OrderDate`)) <= 30 THEN `o`.`OrderID` + ELSE 0 +END), 0) AS `Sum1`, COALESCE(SUM(CASE + WHEN ((2020 - EXTRACT(year FROM `o`.`OrderDate`)) > 30) AND ((2020 - EXTRACT(year FROM `o`.`OrderDate`)) <= 60) THEN `o`.`OrderID` + ELSE 0 +END), 0) AS `Sum2` +FROM `Orders` AS `o` +WHERE `o`.`CustomerID` LIKE 'A%' +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task Group_by_column_project_constant(bool async) + { + await base.Group_by_column_project_constant(async); + + AssertSql( +""" +SELECT 42 +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +ORDER BY `o`.`CustomerID` +"""); + } + + public override async Task Key_plus_key_in_projection(bool async) + { + await base.Key_plus_key_in_projection(async); + + AssertSql( +""" +SELECT `o`.`OrderID` + `o`.`OrderID` AS `Value`, AVG((`o`.`OrderID` :> double)) AS `Average` +FROM `Orders` AS `o` +LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` +GROUP BY `o`.`OrderID` +"""); + } + + [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore")] + public override async Task GroupBy_with_aggregate_through_navigation_property(bool async) + { + await base.GroupBy_with_aggregate_through_navigation_property(async); + + AssertSql( +""" +SELECT ( + SELECT MAX(`c`.`Region`) + FROM `Orders` AS `o0` + LEFT JOIN `Customers` AS `c` ON `o0`.`CustomerID` = `c`.`CustomerID` + WHERE (`o`.`EmployeeID` = `o0`.`EmployeeID`) OR (`o`.`EmployeeID` IS NULL AND (`o0`.`EmployeeID` IS NULL))) AS `max` +FROM `Orders` AS `o` +GROUP BY `o`.`EmployeeID` +"""); + } + + [ConditionalTheory(Skip = "SingleStore does not support this type of query: scalar subselect references field belonging to outer select that is more than one level up")] + public override async Task GroupBy_with_aggregate_containing_complex_where(bool async) + { + await base.GroupBy_with_aggregate_containing_complex_where(async); + + AssertSql( +""" +SELECT `o`.`EmployeeID` AS `Key`, ( + SELECT MAX(`o0`.`OrderID`) + FROM `Orders` AS `o0` + WHERE (CAST(`o0`.`EmployeeID` AS signed) = CAST(MAX(`o`.`OrderID`) * 6 AS signed)) OR (`o0`.`EmployeeID` IS NULL AND (MAX(`o`.`OrderID`) IS NULL))) AS `Max` +FROM `Orders` AS `o` +GROUP BY `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_anonymous_Select_Average(bool async) + { + await base.GroupBy_anonymous_Select_Average(async); + + AssertSql( +""" +SELECT AVG((`o`.`OrderID` :> double)) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_anonymous_Select_Count(bool async) + { + await base.GroupBy_anonymous_Select_Count(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); } + public override async Task GroupBy_anonymous_Select_LongCount(bool async) + { + await base.GroupBy_anonymous_Select_LongCount(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_anonymous_Select_Max(bool async) + { + await base.GroupBy_anonymous_Select_Max(async); + + AssertSql( +""" +SELECT MAX(`o`.`OrderID`) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_anonymous_Select_Min(bool async) + { + await base.GroupBy_anonymous_Select_Min(async); + + AssertSql( +""" +SELECT MIN(`o`.`OrderID`) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_anonymous_Select_Sum(bool async) + { + await base.GroupBy_anonymous_Select_Sum(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_anonymous_Select_Sum_Min_Max_Avg(bool async) + { + await base.GroupBy_anonymous_Select_Sum_Min_Max_Avg(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, MIN(`o`.`OrderID`) AS `Min`, MAX(`o`.`OrderID`) AS `Max`, AVG((`o`.`OrderID` :> double)) AS `Avg` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_anonymous_with_alias_Select_Key_Sum(bool async) + { + await base.GroupBy_anonymous_with_alias_Select_Key_Sum(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Composite_Select_Average(bool async) + { + await base.GroupBy_Composite_Select_Average(async); + + AssertSql( +""" +SELECT AVG((`o`.`OrderID` :> double)) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_Count(bool async) + { + await base.GroupBy_Composite_Select_Count(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_LongCount(bool async) + { + await base.GroupBy_Composite_Select_LongCount(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_Max(bool async) + { + await base.GroupBy_Composite_Select_Max(async); + + AssertSql( +""" +SELECT MAX(`o`.`OrderID`) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_Min(bool async) + { + await base.GroupBy_Composite_Select_Min(async); + + AssertSql( +""" +SELECT MIN(`o`.`OrderID`) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_Sum(bool async) + { + await base.GroupBy_Composite_Select_Sum(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_Sum_Min_Max_Avg(bool async) + { + await base.GroupBy_Composite_Select_Sum_Min_Max_Avg(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, MIN(`o`.`OrderID`) AS `Min`, MAX(`o`.`OrderID`) AS `Max`, AVG((`o`.`OrderID` :> double)) AS `Avg` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_Key_Average(bool async) + { + await base.GroupBy_Composite_Select_Key_Average(async); + + AssertSql( +""" +SELECT `o`.`CustomerID`, `o`.`EmployeeID`, AVG((`o`.`OrderID` :> double)) AS `Average` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_Key_Count(bool async) + { + await base.GroupBy_Composite_Select_Key_Count(async); + + AssertSql( +""" +SELECT `o`.`CustomerID`, `o`.`EmployeeID`, COUNT(*) AS `Count` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_Key_LongCount(bool async) + { + await base.GroupBy_Composite_Select_Key_LongCount(async); + + AssertSql( +""" +SELECT `o`.`CustomerID`, `o`.`EmployeeID`, COUNT(*) AS `LongCount` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_Key_Max(bool async) + { + await base.GroupBy_Composite_Select_Key_Max(async); + + AssertSql( +""" +SELECT `o`.`CustomerID`, `o`.`EmployeeID`, MAX(`o`.`OrderID`) AS `Max` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_Key_Min(bool async) + { + await base.GroupBy_Composite_Select_Key_Min(async); + + AssertSql( +""" +SELECT `o`.`CustomerID`, `o`.`EmployeeID`, MIN(`o`.`OrderID`) AS `Min` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_Key_Sum(bool async) + { + await base.GroupBy_Composite_Select_Key_Sum(async); + + AssertSql( +""" +SELECT `o`.`CustomerID`, `o`.`EmployeeID`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_Key_Sum_Min_Max_Avg(bool async) + { + await base.GroupBy_Composite_Select_Key_Sum_Min_Max_Avg(async); + + AssertSql( +""" +SELECT `o`.`CustomerID`, `o`.`EmployeeID`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, MIN(`o`.`OrderID`) AS `Min`, MAX(`o`.`OrderID`) AS `Max`, AVG((`o`.`OrderID` :> double)) AS `Avg` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_Sum_Min_Key_Max_Avg(bool async) + { + await base.GroupBy_Composite_Select_Sum_Min_Key_Max_Avg(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, MIN(`o`.`OrderID`) AS `Min`, `o`.`CustomerID`, `o`.`EmployeeID`, MAX(`o`.`OrderID`) AS `Max`, AVG((`o`.`OrderID` :> double)) AS `Avg` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_Sum_Min_Key_flattened_Max_Avg(bool async) + { + await base.GroupBy_Composite_Select_Sum_Min_Key_flattened_Max_Avg(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, MIN(`o`.`OrderID`) AS `Min`, `o`.`CustomerID`, `o`.`EmployeeID`, MAX(`o`.`OrderID`) AS `Max`, AVG((`o`.`OrderID` :> double)) AS `Avg` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Dto_as_key_Select_Sum(bool async) + { + await base.GroupBy_Dto_as_key_Select_Sum(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, `o`.`CustomerID`, `o`.`EmployeeID` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Dto_as_element_selector_Select_Sum(bool async) + { + await base.GroupBy_Dto_as_element_selector_Select_Sum(async); + + AssertSql( +""" +SELECT COALESCE(SUM(CAST(`o`.`EmployeeID` AS signed)), 0) AS `Sum`, `o`.`CustomerID` AS `Key` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Composite_Select_Dto_Sum_Min_Key_flattened_Max_Avg(bool async) + { + await base.GroupBy_Composite_Select_Dto_Sum_Min_Key_flattened_Max_Avg(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, MIN(`o`.`OrderID`) AS `Min`, `o`.`CustomerID` AS `CustomerId`, `o`.`EmployeeID` AS `EmployeeId`, MAX(`o`.`OrderID`) AS `Max`, AVG((`o`.`OrderID` :> double)) AS `Avg` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Composite_Select_Sum_Min_part_Key_flattened_Max_Avg(bool async) + { + await base.GroupBy_Composite_Select_Sum_Min_part_Key_flattened_Max_Avg(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, MIN(`o`.`OrderID`) AS `Min`, `o`.`CustomerID`, MAX(`o`.`OrderID`) AS `Max`, AVG((`o`.`OrderID` :> double)) AS `Avg` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID`, `o`.`EmployeeID` +"""); + } + + public override async Task GroupBy_Constant_Select_Sum_Min_Key_Max_Avg(bool async) + { + await base.GroupBy_Constant_Select_Sum_Min_Key_Max_Avg(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum`, MIN(`o0`.`OrderID`) AS `Min`, `o0`.`Key`, MAX(`o0`.`OrderID`) AS `Max`, AVG((`o0`.`OrderID` :> double)) AS `Avg` +FROM ( + SELECT `o`.`OrderID`, 2 AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_Constant_with_element_selector_Select_Sum(bool async) + { + await base.GroupBy_Constant_with_element_selector_Select_Sum(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum` +FROM ( + SELECT `o`.`OrderID`, 2 AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_Constant_with_element_selector_Select_Sum2(bool async) + { + await base.GroupBy_Constant_with_element_selector_Select_Sum2(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum` +FROM ( + SELECT `o`.`OrderID`, 2 AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_Constant_with_element_selector_Select_Sum3(bool async) + { + await base.GroupBy_Constant_with_element_selector_Select_Sum3(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum` +FROM ( + SELECT `o`.`OrderID`, 2 AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_after_predicate_Constant_Select_Sum_Min_Key_Max_Avg(bool async) + { + await base.GroupBy_after_predicate_Constant_Select_Sum_Min_Key_Max_Avg(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum`, MIN(`o0`.`OrderID`) AS `Min`, `o0`.`Key` AS `Random`, MAX(`o0`.`OrderID`) AS `Max`, AVG((`o0`.`OrderID` :> double)) AS `Avg` +FROM ( + SELECT `o`.`OrderID`, 2 AS `Key` + FROM `Orders` AS `o` + WHERE `o`.`OrderID` > 10500 +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_Constant_with_element_selector_Select_Sum_Min_Key_Max_Avg(bool async) + { + await base.GroupBy_Constant_with_element_selector_Select_Sum_Min_Key_Max_Avg(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum`, `o0`.`Key` +FROM ( + SELECT `o`.`OrderID`, 2 AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_param_Select_Sum_Min_Key_Max_Avg(bool async) + { + await base.GroupBy_param_Select_Sum_Min_Key_Max_Avg(async); + + AssertSql( +""" +@__a_0='2' + +SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum`, MIN(`o0`.`OrderID`) AS `Min`, `o0`.`Key`, MAX(`o0`.`OrderID`) AS `Max`, AVG((`o0`.`OrderID` :> double)) AS `Avg` +FROM ( + SELECT `o`.`OrderID`, @__a_0 AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_param_with_element_selector_Select_Sum(bool async) + { + await base.GroupBy_param_with_element_selector_Select_Sum(async); + + AssertSql( +""" +@__a_0='2' + +SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum` +FROM ( + SELECT `o`.`OrderID`, @__a_0 AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_param_with_element_selector_Select_Sum2(bool async) + { + await base.GroupBy_param_with_element_selector_Select_Sum2(async); + + AssertSql( +""" +@__a_0='2' + +SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum` +FROM ( + SELECT `o`.`OrderID`, @__a_0 AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_param_with_element_selector_Select_Sum3(bool async) + { + await base.GroupBy_param_with_element_selector_Select_Sum3(async); + + AssertSql( +""" +@__a_0='2' + +SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum` +FROM ( + SELECT `o`.`OrderID`, @__a_0 AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_param_with_element_selector_Select_Sum_Min_Key_Max_Avg(bool async) + { + await base.GroupBy_param_with_element_selector_Select_Sum_Min_Key_Max_Avg(async); + + AssertSql( +""" +@__a_0='2' + +SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum`, `o0`.`Key` +FROM ( + SELECT `o`.`OrderID`, @__a_0 AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_anonymous_key_type_mismatch_with_aggregate(bool async) + { + await base.GroupBy_anonymous_key_type_mismatch_with_aggregate(async); + + AssertSql( +""" +SELECT COUNT(*) AS `I0`, `o0`.`I0` AS `I1` +FROM ( + SELECT EXTRACT(year FROM `o`.`OrderDate`) AS `I0` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`I0` +ORDER BY `o0`.`I0` +"""); + } + + public override async Task GroupBy_based_on_renamed_property_simple(bool async) + { + await base.GroupBy_based_on_renamed_property_simple(async); + + AssertSql( +""" +SELECT `c`.`City` AS `Renamed`, COUNT(*) AS `Count` +FROM `Customers` AS `c` +GROUP BY `c`.`City` +"""); + } + + public override async Task GroupBy_based_on_renamed_property_complex(bool async) + { + await base.GroupBy_based_on_renamed_property_complex(async); + + AssertSql( +""" +SELECT `c0`.`Renamed` AS `Key`, COUNT(*) AS `Count` +FROM ( + SELECT DISTINCT `c`.`City` AS `Renamed`, `c`.`CustomerID` + FROM `Customers` AS `c` +) AS `c0` +GROUP BY `c0`.`Renamed` +"""); + } + + public override async Task Join_groupby_anonymous_orderby_anonymous_projection(bool async) + { + await base.Join_groupby_anonymous_orderby_anonymous_projection(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `o`.`OrderDate` +FROM `Customers` AS `c` +INNER JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID` +GROUP BY `c`.`CustomerID`, `o`.`OrderDate` +ORDER BY `o`.`OrderDate` +"""); + } + + public override async Task Odata_groupby_empty_key(bool async) + { + await base.Odata_groupby_empty_key(async); + + AssertSql( +""" +SELECT 'TotalAmount' AS `Name`, COALESCE(SUM(CAST(`o0`.`OrderID` AS decimal(65,30))), 0.0) AS `Value` +FROM ( + SELECT `o`.`OrderID`, 1 AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_Property_scalar_element_selector_Average(bool async) + { + await base.GroupBy_Property_scalar_element_selector_Average(async); + + AssertSql( +""" +SELECT AVG((`o`.`OrderID` :> double)) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_scalar_element_selector_Count(bool async) + { + await base.GroupBy_Property_scalar_element_selector_Count(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_scalar_element_selector_LongCount(bool async) + { + await base.GroupBy_Property_scalar_element_selector_LongCount(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_scalar_element_selector_Max(bool async) + { + await base.GroupBy_Property_scalar_element_selector_Max(async); + + AssertSql( +""" +SELECT MAX(`o`.`OrderID`) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_scalar_element_selector_Min(bool async) + { + await base.GroupBy_Property_scalar_element_selector_Min(async); + + AssertSql( +""" +SELECT MIN(`o`.`OrderID`) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_scalar_element_selector_Sum(bool async) + { + await base.GroupBy_Property_scalar_element_selector_Sum(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_scalar_element_selector_Sum_Min_Max_Avg(bool async) + { + await base.GroupBy_Property_scalar_element_selector_Sum_Min_Max_Avg(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, MIN(`o`.`OrderID`) AS `Min`, MAX(`o`.`OrderID`) AS `Max`, AVG((`o`.`OrderID` :> double)) AS `Avg` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_anonymous_element_selector_Average(bool async) + { + await base.GroupBy_Property_anonymous_element_selector_Average(async); + + AssertSql( +""" +SELECT AVG((`o`.`OrderID` :> double)) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_anonymous_element_selector_Count(bool async) + { + await base.GroupBy_Property_anonymous_element_selector_Count(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_anonymous_element_selector_LongCount(bool async) + { + await base.GroupBy_Property_anonymous_element_selector_LongCount(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_anonymous_element_selector_Max(bool async) + { + await base.GroupBy_Property_anonymous_element_selector_Max(async); + + AssertSql( +""" +SELECT MAX(`o`.`OrderID`) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_anonymous_element_selector_Min(bool async) + { + await base.GroupBy_Property_anonymous_element_selector_Min(async); + + AssertSql( +""" +SELECT MIN(`o`.`OrderID`) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_anonymous_element_selector_Sum(bool async) + { + await base.GroupBy_Property_anonymous_element_selector_Sum(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_anonymous_element_selector_Sum_Min_Max_Avg(bool async) + { + await base.GroupBy_Property_anonymous_element_selector_Sum_Min_Max_Avg(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, MIN(`o`.`EmployeeID`) AS `Min`, MAX(`o`.`EmployeeID`) AS `Max`, AVG((`o`.`OrderID` :> double)) AS `Avg` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_element_selector_complex_aggregate(bool async) + { + await base.GroupBy_element_selector_complex_aggregate(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID` + 1), 0) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_element_selector_complex_aggregate2(bool async) + { + await base.GroupBy_element_selector_complex_aggregate2(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID` + 1), 0) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_element_selector_complex_aggregate3(bool async) + { + await base.GroupBy_element_selector_complex_aggregate3(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID` + 1), 0) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_element_selector_complex_aggregate4(bool async) + { + await base.GroupBy_element_selector_complex_aggregate4(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID` + 1), 0) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task Element_selector_with_case_block_repeated_inside_another_case_block_in_projection(bool async) + { + await base.Element_selector_with_case_block_repeated_inside_another_case_block_in_projection(async); + + AssertSql( +""" +SELECT `o`.`OrderID`, COALESCE(SUM(CASE + WHEN `o`.`CustomerID` = 'ALFKI' THEN CASE + WHEN `o`.`OrderID` > 1000 THEN `o`.`OrderID` + ELSE -`o`.`OrderID` + END + ELSE -CASE + WHEN `o`.`OrderID` > 1000 THEN `o`.`OrderID` + ELSE -`o`.`OrderID` + END +END), 0) AS `Aggregate` +FROM `Orders` AS `o` +GROUP BY `o`.`OrderID` +"""); + } + + public override async Task GroupBy_conditional_properties(bool async) + { + await base.GroupBy_conditional_properties(async); + + AssertSql( +""" +SELECT `o0`.`OrderMonth`, `o0`.`CustomerID` AS `Customer`, COUNT(*) AS `Count` +FROM ( + SELECT `o`.`CustomerID`, NULL AS `OrderMonth` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`OrderMonth`, `o0`.`CustomerID` +"""); + } + + public override async Task GroupBy_empty_key_Aggregate(bool async) + { + await base.GroupBy_empty_key_Aggregate(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o0`.`OrderID`), 0) +FROM ( + SELECT `o`.`OrderID`, 1 AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_empty_key_Aggregate_Key(bool async) + { + await base.GroupBy_empty_key_Aggregate_Key(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o0`.`OrderID`), 0) AS `Sum` +FROM ( + SELECT `o`.`OrderID`, 1 AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task OrderBy_GroupBy_Aggregate(bool async) + { + await base.OrderBy_GroupBy_Aggregate(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task OrderBy_Skip_GroupBy_Aggregate(bool async) + { + await base.OrderBy_Skip_GroupBy_Aggregate(async); + + AssertSql( +""" +@__p_0='80' + +SELECT AVG((`o0`.`OrderID` :> double)) +FROM ( + SELECT `o`.`OrderID`, `o`.`CustomerID` + FROM `Orders` AS `o` + ORDER BY `o`.`OrderID` + LIMIT 18446744073709551610 OFFSET @__p_0 +) AS `o0` +GROUP BY `o0`.`CustomerID` +"""); + } + + public override async Task OrderBy_Take_GroupBy_Aggregate(bool async) + { + await base.OrderBy_Take_GroupBy_Aggregate(async); + + AssertSql( +""" +@__p_0='500' + +SELECT MIN(`o0`.`OrderID`) +FROM ( + SELECT `o`.`OrderID`, `o`.`CustomerID` + FROM `Orders` AS `o` + ORDER BY `o`.`OrderID` + LIMIT @__p_0 +) AS `o0` +GROUP BY `o0`.`CustomerID` +"""); + } + + public override async Task OrderBy_Skip_Take_GroupBy_Aggregate(bool async) + { + await base.OrderBy_Skip_Take_GroupBy_Aggregate(async); + + AssertSql( +""" +@__p_1='500' +@__p_0='80' + +SELECT MAX(`o0`.`OrderID`) +FROM ( + SELECT `o`.`OrderID`, `o`.`CustomerID` + FROM `Orders` AS `o` + ORDER BY `o`.`OrderID` + LIMIT @__p_1 OFFSET @__p_0 +) AS `o0` +GROUP BY `o0`.`CustomerID` +"""); + } + + public override async Task Distinct_GroupBy_Aggregate(bool async) + { + await base.Distinct_GroupBy_Aggregate(async); + + AssertSql( +""" +SELECT `o0`.`CustomerID` AS `Key`, COUNT(*) AS `c` +FROM ( + SELECT DISTINCT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`CustomerID` +"""); + } + + public override async Task Anonymous_projection_Distinct_GroupBy_Aggregate(bool async) + { + await base.Anonymous_projection_Distinct_GroupBy_Aggregate(async); + + AssertSql( +""" +SELECT `o0`.`EmployeeID` AS `Key`, COUNT(*) AS `c` +FROM ( + SELECT DISTINCT `o`.`OrderID`, `o`.`EmployeeID` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`EmployeeID` +"""); + } + + public override async Task SelectMany_GroupBy_Aggregate(bool async) + { + await base.SelectMany_GroupBy_Aggregate(async); + + AssertSql( +""" +SELECT `o`.`EmployeeID` AS `Key`, COUNT(*) AS `c` +FROM `Customers` AS `c` +INNER JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID` +GROUP BY `o`.`EmployeeID` +"""); + } + + public override async Task Join_GroupBy_Aggregate(bool async) + { + await base.Join_GroupBy_Aggregate(async); + + AssertSql( +""" +SELECT `c`.`CustomerID` AS `Key`, AVG((`o`.`OrderID` :> double)) AS `Count` +FROM `Orders` AS `o` +INNER JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` +GROUP BY `c`.`CustomerID` +"""); + } + + public override async Task GroupBy_required_navigation_member_Aggregate(bool async) + { + await base.GroupBy_required_navigation_member_Aggregate(async); + + AssertSql( +""" +SELECT `o0`.`CustomerID` AS `CustomerId`, COUNT(*) AS `Count` +FROM `Order Details` AS `o` +INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` +GROUP BY `o0`.`CustomerID` +"""); + } + + public override async Task Join_complex_GroupBy_Aggregate(bool async) + { + await base.Join_complex_GroupBy_Aggregate(async); + + AssertSql( +""" +@__p_0='100' +@__p_2='50' +@__p_1='10' + +SELECT `c0`.`CustomerID` AS `Key`, AVG((`o0`.`OrderID` :> double)) AS `Count` +FROM ( + SELECT `o`.`OrderID`, `o`.`CustomerID` + FROM `Orders` AS `o` + WHERE `o`.`OrderID` < 10400 + ORDER BY `o`.`OrderDate` + LIMIT @__p_0 +) AS `o0` +INNER JOIN ( + SELECT `c`.`CustomerID` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` NOT IN ('DRACD', 'FOLKO') + ORDER BY `c`.`City` + LIMIT @__p_2 OFFSET @__p_1 +) AS `c0` ON `o0`.`CustomerID` = `c0`.`CustomerID` +GROUP BY `c0`.`CustomerID` +"""); + } + + public override async Task GroupJoin_GroupBy_Aggregate(bool async) + { + await base.GroupJoin_GroupBy_Aggregate(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, AVG((`o`.`OrderID` :> double)) AS `Average` +FROM `Customers` AS `c` +LEFT JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID` +WHERE `o`.`OrderID` IS NOT NULL +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupJoin_GroupBy_Aggregate_2(bool async) + { + await base.GroupJoin_GroupBy_Aggregate_2(async); + + AssertSql( +""" +SELECT `c`.`CustomerID` AS `Key`, MAX(`c`.`City`) AS `Max` +FROM `Customers` AS `c` +LEFT JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID` +GROUP BY `c`.`CustomerID` +"""); + } + + public override async Task GroupJoin_GroupBy_Aggregate_3(bool async) + { + await base.GroupJoin_GroupBy_Aggregate_3(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, AVG((`o`.`OrderID` :> double)) AS `Average` +FROM `Orders` AS `o` +LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupJoin_GroupBy_Aggregate_4(bool async) + { + await base.GroupJoin_GroupBy_Aggregate_4(async); + + AssertSql( +""" +SELECT `c`.`CustomerID` AS `Value`, MAX(`c`.`City`) AS `Max` +FROM `Customers` AS `c` +LEFT JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID` +GROUP BY `c`.`CustomerID` +"""); + } + + public override async Task GroupJoin_GroupBy_Aggregate_5(bool async) + { + await base.GroupJoin_GroupBy_Aggregate_5(async); + + AssertSql( +""" +SELECT `o`.`OrderID` AS `Value`, AVG((`o`.`OrderID` :> double)) AS `Average` +FROM `Orders` AS `o` +LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` +GROUP BY `o`.`OrderID` +"""); + } + + public override async Task GroupBy_optional_navigation_member_Aggregate(bool async) + { + await base.GroupBy_optional_navigation_member_Aggregate(async); + + AssertSql( +""" +SELECT `c`.`Country`, COUNT(*) AS `Count` +FROM `Orders` AS `o` +LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` +GROUP BY `c`.`Country` +"""); + } + + public override async Task GroupJoin_complex_GroupBy_Aggregate(bool async) + { + await base.GroupJoin_complex_GroupBy_Aggregate(async); + + AssertSql( +""" +@__p_1='50' +@__p_0='10' +@__p_2='100' + +SELECT `o0`.`CustomerID` AS `Key`, AVG((`o0`.`OrderID` :> double)) AS `Count` +FROM ( + SELECT `c`.`CustomerID` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` NOT IN ('DRACD', 'FOLKO') + ORDER BY `c`.`City` + LIMIT @__p_1 OFFSET @__p_0 +) AS `c0` +INNER JOIN ( + SELECT `o`.`OrderID`, `o`.`CustomerID` + FROM `Orders` AS `o` + WHERE `o`.`OrderID` < 10400 + ORDER BY `o`.`OrderDate` + LIMIT @__p_2 +) AS `o0` ON `c0`.`CustomerID` = `o0`.`CustomerID` +WHERE `o0`.`OrderID` > 10300 +GROUP BY `o0`.`CustomerID` +"""); + } + + public override async Task Self_join_GroupBy_Aggregate(bool async) + { + await base.Self_join_GroupBy_Aggregate(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, AVG((`o0`.`OrderID` :> double)) AS `Count` +FROM `Orders` AS `o` +INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` +WHERE `o`.`OrderID` < 10400 +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_multi_navigation_members_Aggregate(bool async) + { + await base.GroupBy_multi_navigation_members_Aggregate(async); + + AssertSql( +""" +SELECT `o0`.`CustomerID`, `p`.`ProductName`, COUNT(*) AS `Count` +FROM `Order Details` AS `o` +INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` +INNER JOIN `Products` AS `p` ON `o`.`ProductID` = `p`.`ProductID` +GROUP BY `o0`.`CustomerID`, `p`.`ProductName` +"""); + } + + public override async Task Union_simple_groupby(bool async) + { + await base.Union_simple_groupby(async); + + AssertSql( +""" +SELECT `u`.`City` AS `Key`, COUNT(*) AS `Total` +FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Customers` AS `c` + WHERE `c`.`ContactTitle` = 'Owner' + UNION + SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` + FROM `Customers` AS `c0` + WHERE `c0`.`City` = 'México D.F.' +) AS `u` +GROUP BY `u`.`City` +"""); + } + + public override async Task Select_anonymous_GroupBy_Aggregate(bool async) + { + await base.Select_anonymous_GroupBy_Aggregate(async); + + AssertSql( +""" +SELECT MIN(`o`.`OrderDate`) AS `Min`, MAX(`o`.`OrderDate`) AS `Max`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, AVG((`o`.`OrderID` :> double)) AS `Avg` +FROM `Orders` AS `o` +WHERE `o`.`OrderID` < 10300 +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_principal_key_property_optimization(bool async) + { + await base.GroupBy_principal_key_property_optimization(async); + + AssertSql( +""" +SELECT `c`.`CustomerID` AS `Key`, COUNT(*) AS `Count` +FROM `Orders` AS `o` +LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` +GROUP BY `c`.`CustomerID` +"""); + } + + public override async Task GroupBy_after_anonymous_projection_and_distinct_followed_by_another_anonymous_projection(bool async) + { + await base.GroupBy_after_anonymous_projection_and_distinct_followed_by_another_anonymous_projection(async); + + AssertSql( +""" +SELECT `o0`.`CustomerID` AS `Key`, COUNT(*) AS `Count` +FROM ( + SELECT DISTINCT `o`.`CustomerID`, `o`.`OrderID` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`CustomerID` +"""); + } + + public override async Task GroupBy_complex_key_aggregate(bool async) + { + await base.GroupBy_complex_key_aggregate(async); + + AssertSql( +""" +SELECT `s`.`Key`, COUNT(*) AS `Count` +FROM ( + SELECT SUBSTRING(`c`.`CustomerID`, 0 + 1, 1) AS `Key` + FROM `Orders` AS `o` + LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` +) AS `s` +GROUP BY `s`.`Key` +"""); + } + + [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore")] + public override async Task GroupBy_complex_key_aggregate_2(bool async) + { + await base.GroupBy_complex_key_aggregate_2(async); + + AssertSql( +""" +SELECT `o0`.`Key` AS `Month`, COALESCE(SUM(`o0`.`OrderID`), 0) AS `Total`, ( + SELECT COALESCE(SUM(`o1`.`OrderID`), 0) + FROM `Orders` AS `o1` + WHERE (EXTRACT(month FROM `o1`.`OrderDate`) = `o0`.`Key`) OR (EXTRACT(month FROM `o1`.`OrderDate`) IS NULL AND (`o0`.`Key` IS NULL))) AS `Payment` +FROM ( + SELECT `o`.`OrderID`, EXTRACT(month FROM `o`.`OrderDate`) AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task Select_collection_of_scalar_before_GroupBy_aggregate(bool async) + { + await base.Select_collection_of_scalar_before_GroupBy_aggregate(async); + + AssertSql( +""" +SELECT `c`.`City` AS `Key`, COUNT(*) AS `Count` +FROM `Customers` AS `c` +GROUP BY `c`.`City` +"""); + } + + public override async Task GroupBy_OrderBy_key(bool async) + { + await base.GroupBy_OrderBy_key(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, COUNT(*) AS `c` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +ORDER BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_OrderBy_count(bool async) + { + await base.GroupBy_OrderBy_count(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, COUNT(*) AS `Count` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +ORDER BY COUNT(*), `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_OrderBy_count_Select_sum(bool async) + { + await base.GroupBy_OrderBy_count_Select_sum(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +ORDER BY COUNT(*), `o`.`CustomerID` +"""); + } + + [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore")] + public override async Task GroupBy_aggregate_Contains(bool async) + { + await base.GroupBy_aggregate_Contains(async); + + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM `Orders` AS `o` +WHERE EXISTS ( + SELECT 1 + FROM `Orders` AS `o0` + GROUP BY `o0`.`CustomerID` + HAVING (COUNT(*) > 30) AND ((`o0`.`CustomerID` = `o`.`CustomerID`) OR (`o0`.`CustomerID` IS NULL AND (`o`.`CustomerID` IS NULL)))) +"""); + } + + public override async Task GroupBy_aggregate_Pushdown(bool async) + { + await base.GroupBy_aggregate_Pushdown(async); + + AssertSql( +""" +@__p_0='20' +@__p_1='4' + +SELECT `o0`.`CustomerID` +FROM ( + SELECT `o`.`CustomerID` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) > 10 + ORDER BY `o`.`CustomerID` + LIMIT @__p_0 +) AS `o0` +ORDER BY `o0`.`CustomerID` +LIMIT 18446744073709551610 OFFSET @__p_1 +"""); + } + + public override async Task GroupBy_aggregate_using_grouping_key_Pushdown(bool async) + { + await base.GroupBy_aggregate_using_grouping_key_Pushdown(async); + + AssertSql( +""" +@__p_0='20' +@__p_1='4' + +SELECT `o0`.`Key`, `o0`.`Max` +FROM ( + SELECT `o`.`CustomerID` AS `Key`, MAX(`o`.`CustomerID`) AS `Max` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) > 10 + ORDER BY `o`.`CustomerID` + LIMIT @__p_0 +) AS `o0` +ORDER BY `o0`.`Key` +LIMIT 18446744073709551610 OFFSET @__p_1 +"""); + } + + public override async Task GroupBy_aggregate_Pushdown_followed_by_projecting_Length(bool async) + { + await base.GroupBy_aggregate_Pushdown_followed_by_projecting_Length(async); + + AssertSql( +""" +@__p_0='20' +@__p_1='4' + +SELECT CHAR_LENGTH(`o0`.`CustomerID`) +FROM ( + SELECT `o`.`CustomerID` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) > 10 + ORDER BY `o`.`CustomerID` + LIMIT @__p_0 +) AS `o0` +ORDER BY `o0`.`CustomerID` +LIMIT 18446744073709551610 OFFSET @__p_1 +"""); + } + + public override async Task GroupBy_aggregate_Pushdown_followed_by_projecting_constant(bool async) + { + await base.GroupBy_aggregate_Pushdown_followed_by_projecting_constant(async); + + AssertSql( +""" +@__p_0='20' +@__p_1='4' + +SELECT 5 +FROM ( + SELECT `o`.`CustomerID` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) > 10 + ORDER BY `o`.`CustomerID` + LIMIT @__p_0 +) AS `o0` +ORDER BY `o0`.`CustomerID` +LIMIT 18446744073709551610 OFFSET @__p_1 +"""); + } + + public override async Task GroupBy_filter_key(bool async) + { + await base.GroupBy_filter_key(async); + + AssertSql( +""" +SELECT `o0`.`Key`, `o0`.`c` +FROM ( + SELECT `o`.`CustomerID` AS `Key`, COUNT(*) AS `c`, (`o`.`CustomerID` = 'ALFKI') AND `o`.`CustomerID` IS NOT NULL AS `c0` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID`, `c0` + HAVING `c0` +) AS `o0` +"""); + } + + public override async Task GroupBy_filter_count(bool async) + { + await base.GroupBy_filter_count(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, COUNT(*) AS `Count` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +HAVING COUNT(*) > 4 +"""); + } + + public override async Task GroupBy_count_filter(bool async) + { + await base.GroupBy_count_filter(async); + + AssertSql( +""" +SELECT `o0`.`Key` AS `Name`, COUNT(*) AS `Count` +FROM ( + SELECT 'Order' AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +HAVING COUNT(*) > 0 +"""); + } + + public override async Task GroupBy_filter_count_OrderBy_count_Select_sum(bool async) + { + await base.GroupBy_filter_count_OrderBy_count_Select_sum(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, COUNT(*) AS `Count`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +HAVING COUNT(*) > 4 +ORDER BY COUNT(*), `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Aggregate_Join(bool async) + { + await base.GroupBy_Aggregate_Join(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate` +FROM ( + SELECT `o`.`CustomerID`, MAX(`o`.`OrderID`) AS `LastOrderID` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) > 5 +) AS `o0` +INNER JOIN `Customers` AS `c` ON `o0`.`CustomerID` = `c`.`CustomerID` +INNER JOIN `Orders` AS `o1` ON `o0`.`LastOrderID` = `o1`.`OrderID` +"""); + } + + public override async Task GroupBy_Aggregate_Join_converted_from_SelectMany(bool async) + { + await base.GroupBy_Aggregate_Join_converted_from_SelectMany(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +INNER JOIN ( + SELECT `o`.`CustomerID` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) > 5 +) AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` +"""); + } + + public override async Task GroupBy_Aggregate_LeftJoin_converted_from_SelectMany(bool async) + { + await base.GroupBy_Aggregate_LeftJoin_converted_from_SelectMany(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +LEFT JOIN ( + SELECT `o`.`CustomerID` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) > 5 +) AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` +"""); + } + + public override async Task Join_GroupBy_Aggregate_multijoins(bool async) + { + await base.Join_GroupBy_Aggregate_multijoins(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate` +FROM `Customers` AS `c` +INNER JOIN ( + SELECT `o`.`CustomerID`, MAX(`o`.`OrderID`) AS `LastOrderID` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) > 5 +) AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` +INNER JOIN `Orders` AS `o1` ON `o0`.`LastOrderID` = `o1`.`OrderID` +"""); + } + + public override async Task Join_GroupBy_Aggregate_single_join(bool async) + { + await base.Join_GroupBy_Aggregate_single_join(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o0`.`LastOrderID` +FROM `Customers` AS `c` +INNER JOIN ( + SELECT `o`.`CustomerID`, MAX(`o`.`OrderID`) AS `LastOrderID` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) > 5 +) AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` +"""); + } + + public override async Task Join_GroupBy_Aggregate_with_another_join(bool async) + { + await base.Join_GroupBy_Aggregate_with_another_join(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o0`.`LastOrderID`, `o1`.`OrderID` +FROM `Customers` AS `c` +INNER JOIN ( + SELECT `o`.`CustomerID`, MAX(`o`.`OrderID`) AS `LastOrderID` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) > 5 +) AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` +INNER JOIN `Orders` AS `o1` ON `c`.`CustomerID` = `o1`.`CustomerID` +"""); + } + + public override async Task Join_GroupBy_Aggregate_distinct_single_join(bool async) + { + await base.Join_GroupBy_Aggregate_distinct_single_join(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o1`.`LastOrderID` +FROM `Customers` AS `c` +INNER JOIN ( + SELECT DISTINCT `o0`.`CustomerID`, MAX(`o0`.`OrderID`) AS `LastOrderID` + FROM ( + SELECT `o`.`OrderID`, `o`.`CustomerID`, EXTRACT(year FROM `o`.`OrderDate`) AS `Year` + FROM `Orders` AS `o` + ) AS `o0` + GROUP BY `o0`.`CustomerID`, `o0`.`Year` + HAVING COUNT(*) > 5 +) AS `o1` ON `c`.`CustomerID` = `o1`.`CustomerID` +"""); + } + + public override async Task Join_GroupBy_Aggregate_with_left_join(bool async) + { + await base.Join_GroupBy_Aggregate_with_left_join(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o0`.`LastOrderID` +FROM `Customers` AS `c` +LEFT JOIN ( + SELECT `o`.`CustomerID`, MAX(`o`.`OrderID`) AS `LastOrderID` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) > 5 +) AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` +WHERE `c`.`CustomerID` LIKE 'A%' +"""); + } + + public override async Task Join_GroupBy_Aggregate_in_subquery(bool async) + { + await base.Join_GroupBy_Aggregate_in_subquery(async); + + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, `s`.`CustomerID`, `s`.`Address`, `s`.`City`, `s`.`CompanyName`, `s`.`ContactName`, `s`.`ContactTitle`, `s`.`Country`, `s`.`Fax`, `s`.`Phone`, `s`.`PostalCode`, `s`.`Region` +FROM `Orders` AS `o` +INNER JOIN ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Customers` AS `c` + INNER JOIN ( + SELECT `o0`.`CustomerID` + FROM `Orders` AS `o0` + GROUP BY `o0`.`CustomerID` + HAVING COUNT(*) > 5 + ) AS `o1` ON `c`.`CustomerID` = `o1`.`CustomerID` +) AS `s` ON `o`.`CustomerID` = `s`.`CustomerID` +WHERE `o`.`OrderID` < 10400 +"""); + } + + public override async Task Join_GroupBy_Aggregate_on_key(bool async) + { + await base.Join_GroupBy_Aggregate_on_key(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o0`.`LastOrderID` +FROM `Customers` AS `c` +INNER JOIN ( + SELECT `o`.`CustomerID` AS `Key`, MAX(`o`.`OrderID`) AS `LastOrderID` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) > 5 +) AS `o0` ON `c`.`CustomerID` = `o0`.`Key` +"""); + } + + public override async Task GroupBy_with_result_selector(bool async) + { + await base.GroupBy_with_result_selector(async); + + AssertSql( +""" +SELECT COALESCE(SUM(`o`.`OrderID`), 0) AS `Sum`, MIN(`o`.`OrderID`) AS `Min`, MAX(`o`.`OrderID`) AS `Max`, AVG((`o`.`OrderID` :> double)) AS `Avg` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Sum_constant(bool async) + { + await base.GroupBy_Sum_constant(async); + + AssertSql( +""" +SELECT COALESCE(SUM(1), 0) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Sum_constant_cast(bool async) + { + await base.GroupBy_Sum_constant_cast(async); + + AssertSql( +""" +SELECT COALESCE(SUM(1), 0) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task Distinct_GroupBy_OrderBy_key(bool async) + { + await base.Distinct_GroupBy_OrderBy_key(async); + + AssertSql( +""" +SELECT `o0`.`CustomerID` AS `Key`, COUNT(*) AS `c` +FROM ( + SELECT DISTINCT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`CustomerID` +ORDER BY `o0`.`CustomerID` +"""); + } + + public override async Task Select_uncorrelated_collection_with_groupby_works(bool async) + { + await base.Select_uncorrelated_collection_with_groupby_works(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `o0`.`OrderID` +FROM `Customers` AS `c` +LEFT JOIN LATERAL ( + SELECT `o`.`OrderID` + FROM `Orders` AS `o` + GROUP BY `o`.`OrderID` +) AS `o0` ON TRUE +WHERE `c`.`CustomerID` LIKE 'A%' +ORDER BY `c`.`CustomerID` +"""); + } + + public override async Task Select_uncorrelated_collection_with_groupby_multiple_collections_work(bool async) + { + await base.Select_uncorrelated_collection_with_groupby_multiple_collections_work(async); + + AssertSql( +""" +SELECT `o`.`OrderID`, `p1`.`ProductID`, `p2`.`c`, `p2`.`ProductID` +FROM `Orders` AS `o` +LEFT JOIN LATERAL ( + SELECT `p`.`ProductID` + FROM `Products` AS `p` + GROUP BY `p`.`ProductID` +) AS `p1` ON TRUE +LEFT JOIN LATERAL ( + SELECT COUNT(*) AS `c`, `p0`.`ProductID` + FROM `Products` AS `p0` + GROUP BY `p0`.`ProductID` +) AS `p2` ON TRUE +WHERE `o`.`CustomerID` LIKE 'A%' +ORDER BY `o`.`OrderID`, `p1`.`ProductID` +"""); + } + + public override async Task Select_GroupBy_All(bool async) + { + await base.Select_GroupBy_All(async); + + AssertSql( +""" +SELECT NOT EXISTS ( + SELECT 1 + FROM ( + SELECT (`o`.`CustomerID` <> 'ALFKI') OR `o`.`CustomerID` IS NULL AS `c` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID`, `c` + HAVING `c` + ) AS `o0`) +"""); + } + + public override async Task GroupBy_multiple_Count_with_predicate(bool async) + { + await base.GroupBy_multiple_Count_with_predicate(async); + + AssertSql( +""" +SELECT `o`.`CustomerID`, COUNT(*) AS `All`, COUNT(CASE + WHEN `o`.`OrderID` < 11000 THEN 1 +END) AS `TenK`, COUNT(CASE + WHEN `o`.`OrderID` < 12000 THEN 1 +END) AS `EleventK` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_multiple_Sum_with_conditional_projection(bool async) + { + await base.GroupBy_multiple_Sum_with_conditional_projection(async); + + AssertSql( +""" +SELECT `o`.`CustomerID`, COALESCE(SUM(CASE + WHEN `o`.`OrderID` < 11000 THEN `o`.`OrderID` + ELSE 0 +END), 0) AS `TenK`, COALESCE(SUM(CASE + WHEN `o`.`OrderID` >= 11000 THEN `o`.`OrderID` + ELSE 0 +END), 0) AS `EleventK` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Key_as_part_of_element_selector(bool async) + { + await base.GroupBy_Key_as_part_of_element_selector(async); + + AssertSql( +""" +SELECT `o`.`OrderID` AS `Key`, AVG((`o`.`OrderID` :> double)) AS `Avg`, MAX(`o`.`OrderDate`) AS `Max` +FROM `Orders` AS `o` +GROUP BY `o`.`OrderID` +"""); + } + + public override async Task GroupBy_composite_Key_as_part_of_element_selector(bool async) + { + await base.GroupBy_composite_Key_as_part_of_element_selector(async); + + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`CustomerID`, AVG((`o`.`OrderID` :> double)) AS `Avg`, MAX(`o`.`OrderDate`) AS `Max` +FROM `Orders` AS `o` +GROUP BY `o`.`OrderID`, `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_with_order_by_skip_and_another_order_by(bool async) + { + await base.GroupBy_with_order_by_skip_and_another_order_by(async); + + AssertSql( +""" +@__p_0='80' + +SELECT COALESCE(SUM(`o0`.`OrderID`), 0) +FROM ( + SELECT `o`.`OrderID`, `o`.`CustomerID` + FROM `Orders` AS `o` + ORDER BY `o`.`CustomerID`, `o`.`OrderID` + LIMIT 18446744073709551610 OFFSET @__p_0 +) AS `o0` +GROUP BY `o0`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_Count_with_predicate(bool async) + { + await base.GroupBy_Property_Select_Count_with_predicate(async); + + AssertSql( +""" +SELECT COUNT(CASE + WHEN `o`.`OrderID` < 10300 THEN 1 +END) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Property_Select_LongCount_with_predicate(bool async) + { + await base.GroupBy_Property_Select_LongCount_with_predicate(async); + + AssertSql( +""" +SELECT COUNT(CASE + WHEN `o`.`OrderID` < 10300 THEN 1 +END) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_orderby_projection_with_coalesce_operation(bool async) + { + await base.GroupBy_orderby_projection_with_coalesce_operation(async); + + AssertSql( +""" +SELECT COALESCE(`c`.`City`, 'Unknown') AS `Locality`, COUNT(*) AS `Count` +FROM `Customers` AS `c` +GROUP BY `c`.`City` +ORDER BY COUNT(*) DESC, `c`.`City` +"""); + } + + public override async Task GroupBy_let_orderby_projection_with_coalesce_operation(bool async) + { + await base.GroupBy_let_orderby_projection_with_coalesce_operation(async); + + AssertSql(); + } + + public override async Task GroupBy_Min_Where_optional_relationship(bool async) + { + await base.GroupBy_Min_Where_optional_relationship(async); + + AssertSql( +""" +SELECT `c`.`CustomerID` AS `Key`, COUNT(*) AS `Count` +FROM `Orders` AS `o` +LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` +GROUP BY `c`.`CustomerID` +HAVING COUNT(*) <> 2 +"""); + } + + public override async Task GroupBy_Min_Where_optional_relationship_2(bool async) + { + await base.GroupBy_Min_Where_optional_relationship_2(async); + + AssertSql( +""" +SELECT `c`.`CustomerID` AS `Key`, COUNT(*) AS `Count` +FROM `Orders` AS `o` +LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` +GROUP BY `c`.`CustomerID` +HAVING (COUNT(*) < 2) OR (COUNT(*) > 2) +"""); + } + + public override async Task GroupBy_aggregate_over_a_subquery(bool async) + { + await base.GroupBy_aggregate_over_a_subquery(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, ( + SELECT COUNT(*) + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` = `o`.`CustomerID`) AS `Count` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_aggregate_join_with_grouping_key(bool async) + { + await base.GroupBy_aggregate_join_with_grouping_key(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o0`.`Count` +FROM ( + SELECT `o`.`CustomerID` AS `Key`, COUNT(*) AS `Count` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` +) AS `o0` +INNER JOIN `Customers` AS `c` ON `o0`.`Key` = `c`.`CustomerID` +"""); + } + + public override async Task GroupBy_aggregate_join_with_group_result(bool async) + { + await base.GroupBy_aggregate_join_with_group_result(async); + + AssertSql( +""" +SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` +FROM ( + SELECT `o`.`CustomerID` AS `Key`, MAX(`o`.`OrderDate`) AS `LastOrderDate` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` +) AS `o1` +INNER JOIN `Orders` AS `o0` ON ((`o1`.`Key` = `o0`.`CustomerID`) OR (`o1`.`Key` IS NULL AND (`o0`.`CustomerID` IS NULL))) AND ((`o1`.`LastOrderDate` = `o0`.`OrderDate`) OR (`o1`.`LastOrderDate` IS NULL AND (`o0`.`OrderDate` IS NULL))) +"""); + } + + public override async Task GroupBy_aggregate_from_right_side_of_join(bool async) + { + await base.GroupBy_aggregate_from_right_side_of_join(async); + + AssertSql( +""" +@__p_0='10' + +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o0`.`Max` +FROM `Customers` AS `c` +INNER JOIN ( + SELECT `o`.`CustomerID` AS `Key`, MAX(`o`.`OrderDate`) AS `Max` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` +) AS `o0` ON `c`.`CustomerID` = `o0`.`Key` +ORDER BY `o0`.`Max`, `c`.`CustomerID` +LIMIT @__p_0 OFFSET @__p_0 +"""); + } + + public override async Task GroupBy_aggregate_join_another_GroupBy_aggregate(bool async) + { + await base.GroupBy_aggregate_join_another_GroupBy_aggregate(async); + + AssertSql( +""" +SELECT `o1`.`Key`, `o1`.`Total`, `o2`.`ThatYear` +FROM ( + SELECT `o`.`CustomerID` AS `Key`, COUNT(*) AS `Total` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` +) AS `o1` +INNER JOIN ( + SELECT `o0`.`CustomerID` AS `Key`, COUNT(*) AS `ThatYear` + FROM `Orders` AS `o0` + WHERE EXTRACT(year FROM `o0`.`OrderDate`) = 1997 + GROUP BY `o0`.`CustomerID` +) AS `o2` ON `o1`.`Key` = `o2`.`Key` +"""); + } + + public override async Task GroupBy_aggregate_after_skip_0_take_0(bool async) + { + await base.GroupBy_aggregate_after_skip_0_take_0(async); + + AssertSql( + AppConfig.ServerVersion.Supports.SingleStoreBugLimit0Offset0ExistsWorkaround + ? """ +SELECT `o0`.`CustomerID` AS `Key`, COUNT(*) AS `Total` +FROM ( + SELECT `o`.`CustomerID` + FROM `Orders` AS `o` + WHERE FALSE +) AS `o0` +GROUP BY `o0`.`CustomerID` +""" + : """ +@__p_0='0' + +SELECT `o0`.`CustomerID` AS `Key`, COUNT(*) AS `Total` +FROM ( + SELECT `o`.`CustomerID` + FROM `Orders` AS `o` + LIMIT @__p_0 OFFSET @__p_0 +) AS `o0` +GROUP BY `o0`.`CustomerID` +"""); + } + + public override async Task GroupBy_skip_0_take_0_aggregate(bool async) + { + await base.GroupBy_skip_0_take_0_aggregate(async); + + AssertSql( + AppConfig.ServerVersion.Supports.SingleStoreBugLimit0Offset0ExistsWorkaround + ? """ +SELECT `o`.`CustomerID` AS `Key`, COUNT(*) AS `Total` +FROM `Orders` AS `o` +WHERE `o`.`OrderID` > 10500 +GROUP BY `o`.`CustomerID` +HAVING FALSE +""" + : """ +@__p_0='0' + +SELECT `o`.`CustomerID` AS `Key`, COUNT(*) AS `Total` +FROM `Orders` AS `o` +WHERE `o`.`OrderID` > 10500 +GROUP BY `o`.`CustomerID` +LIMIT @__p_0 OFFSET @__p_0 +"""); + } + + public override async Task GroupBy_aggregate_followed_another_GroupBy_aggregate(bool async) + { + await base.GroupBy_aggregate_followed_another_GroupBy_aggregate(async); + + AssertSql( +""" +SELECT `o1`.`CustomerID` AS `Key`, COUNT(*) AS `Count` +FROM ( + SELECT `o0`.`CustomerID` + FROM ( + SELECT `o`.`CustomerID`, EXTRACT(year FROM `o`.`OrderDate`) AS `Year` + FROM `Orders` AS `o` + ) AS `o0` + GROUP BY `o0`.`CustomerID`, `o0`.`Year` +) AS `o1` +GROUP BY `o1`.`CustomerID` +"""); + } + + public override async Task GroupBy_aggregate_SelectMany(bool async) + { + await base.GroupBy_aggregate_SelectMany(async); + + AssertSql(); + } + + public override async Task GroupBy_aggregate_without_selectMany_selecting_first(bool async) + { + await base.GroupBy_aggregate_without_selectMany_selecting_first(async); + + AssertSql( +""" +SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` +FROM ( + SELECT MIN(`o`.`OrderID`) AS `c` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` +) AS `o1` +CROSS JOIN `Orders` AS `o0` +WHERE `o0`.`OrderID` = `o1`.`c` +"""); + } + + public override async Task GroupBy_aggregate_left_join_GroupBy_aggregate_left_join(bool async) + { + await base.GroupBy_aggregate_left_join_GroupBy_aggregate_left_join(async); + + AssertSql(); + } + + public override async Task GroupBy_Where_Average(bool async) + { + await base.GroupBy_Where_Average(async); + + AssertSql( +""" +SELECT AVG(CASE + WHEN `o`.`OrderID` < 10300 THEN (`o`.`OrderID` :> double) +END) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Where_Count(bool async) + { + await base.GroupBy_Where_Count(async); + + AssertSql( +""" +SELECT COUNT(CASE + WHEN `o`.`OrderID` < 10300 THEN 1 +END) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Where_LongCount(bool async) + { + await base.GroupBy_Where_LongCount(async); + + AssertSql( +""" +SELECT COUNT(CASE + WHEN `o`.`OrderID` < 10300 THEN 1 +END) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Where_Max(bool async) + { + await base.GroupBy_Where_Max(async); + + AssertSql( +""" +SELECT MAX(CASE + WHEN `o`.`OrderID` < 10300 THEN `o`.`OrderID` +END) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Where_Min(bool async) + { + await base.GroupBy_Where_Min(async); + + AssertSql( +""" +SELECT MIN(CASE + WHEN `o`.`OrderID` < 10300 THEN `o`.`OrderID` +END) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Where_Sum(bool async) + { + await base.GroupBy_Where_Sum(async); + + AssertSql( +""" +SELECT COALESCE(SUM(CASE + WHEN `o`.`OrderID` < 10300 THEN `o`.`OrderID` +END), 0) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Where_Count_with_predicate(bool async) + { + await base.GroupBy_Where_Count_with_predicate(async); + + AssertSql( +""" +SELECT COUNT(CASE + WHEN (`o`.`OrderID` < 10300) AND (`o`.`OrderDate` IS NOT NULL AND (EXTRACT(year FROM `o`.`OrderDate`) = 1997)) THEN 1 +END) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Where_Where_Count(bool async) + { + await base.GroupBy_Where_Where_Count(async); + + AssertSql( +""" +SELECT COUNT(CASE + WHEN (`o`.`OrderID` < 10300) AND (`o`.`OrderDate` IS NOT NULL AND (EXTRACT(year FROM `o`.`OrderDate`) = 1997)) THEN 1 +END) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Where_Select_Where_Count(bool async) + { + await base.GroupBy_Where_Select_Where_Count(async); + + AssertSql( +""" +SELECT COUNT(CASE + WHEN (`o`.`OrderID` < 10300) AND (`o`.`OrderDate` IS NOT NULL AND (EXTRACT(year FROM `o`.`OrderDate`) = 1997)) THEN 1 +END) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_Where_Select_Where_Select_Min(bool async) + { + await base.GroupBy_Where_Select_Where_Select_Min(async); + + AssertSql( +""" +SELECT MIN(CASE + WHEN (`o`.`OrderID` < 10300) AND (`o`.`OrderDate` IS NOT NULL AND (EXTRACT(year FROM `o`.`OrderDate`) = 1997)) THEN `o`.`OrderID` +END) +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_multiple_Sum_with_Select_conditional_projection(bool async) + { + await base.GroupBy_multiple_Sum_with_Select_conditional_projection(async); + + AssertSql( +""" +SELECT `o`.`CustomerID`, COALESCE(SUM(CASE + WHEN `o`.`OrderID` < 11000 THEN `o`.`OrderID` + ELSE 0 +END), 0) AS `TenK`, COALESCE(SUM(CASE + WHEN `o`.`OrderID` >= 11000 THEN `o`.`OrderID` + ELSE 0 +END), 0) AS `EleventK` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task LongCount_after_GroupBy_aggregate(bool async) + { + await base.LongCount_after_GroupBy_aggregate(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM ( + SELECT 1 + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` +) AS `o0` +"""); + } + + public override async Task GroupBy_Select_Distinct_aggregate(bool async) + { + await base.GroupBy_Select_Distinct_aggregate(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, AVG(DISTINCT ((`o`.`OrderID` :> double))) AS `Average`, COUNT(DISTINCT (`o`.`EmployeeID`)) AS `Count`, COUNT(DISTINCT (`o`.`EmployeeID`)) AS `LongCount`, MAX(DISTINCT (`o`.`OrderDate`)) AS `Max`, MIN(DISTINCT (`o`.`OrderDate`)) AS `Min`, COALESCE(SUM(DISTINCT (`o`.`OrderID`)), 0) AS `Sum` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task Final_GroupBy_property_entity(bool async) + { + await base.Final_GroupBy_property_entity(async); + + AssertSql( +""" +SELECT `c`.`City`, `c`.`CustomerID`, `c`.`Address`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +ORDER BY `c`.`City` +"""); + } + + public override async Task Final_GroupBy_entity(bool async) + { + await base.Final_GroupBy_entity(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM `Orders` AS `o` +LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` +WHERE `o`.`OrderID` < 10500 +ORDER BY `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +"""); + } + + public override async Task Final_GroupBy_property_entity_non_nullable(bool async) + { + await base.Final_GroupBy_property_entity_non_nullable(async); + + AssertSql( +""" +SELECT `o`.`OrderID`, `o`.`ProductID`, `o`.`Discount`, `o`.`Quantity`, `o`.`UnitPrice` +FROM `Order Details` AS `o` +WHERE `o`.`OrderID` < 10500 +ORDER BY `o`.`OrderID` +"""); + } + + public override async Task Final_GroupBy_property_anonymous_type(bool async) + { + await base.Final_GroupBy_property_anonymous_type(async); + + AssertSql( +""" +SELECT `c`.`City`, `c`.`ContactName`, `c`.`ContactTitle` +FROM `Customers` AS `c` +ORDER BY `c`.`City` +"""); + } + + public override async Task Final_GroupBy_multiple_properties_entity(bool async) + { + await base.Final_GroupBy_multiple_properties_entity(async); + + AssertSql( +""" +SELECT `c`.`City`, `c`.`Region`, `c`.`CustomerID`, `c`.`Address`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode` +FROM `Customers` AS `c` +ORDER BY `c`.`City`, `c`.`Region` +"""); + } + + public override async Task Final_GroupBy_complex_key_entity(bool async) + { + await base.Final_GroupBy_complex_key_entity(async); + + AssertSql( +""" +SELECT `c0`.`City`, `c0`.`Region`, `c0`.`Constant`, `c0`.`CustomerID`, `c0`.`Address`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode` +FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, 1 AS `Constant` + FROM `Customers` AS `c` +) AS `c0` +ORDER BY `c0`.`City`, `c0`.`Region`, `c0`.`Constant` +"""); + } + + public override async Task Final_GroupBy_nominal_type_entity(bool async) + { + await base.Final_GroupBy_nominal_type_entity(async); + + AssertSql( +""" +SELECT `c0`.`City`, `c0`.`Constant`, `c0`.`CustomerID`, `c0`.`Address`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` +FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, 1 AS `Constant` + FROM `Customers` AS `c` +) AS `c0` +ORDER BY `c0`.`City`, `c0`.`Constant` +"""); + } + + public override async Task Final_GroupBy_property_anonymous_type_element_selector(bool async) + { + await base.Final_GroupBy_property_anonymous_type_element_selector(async); + + AssertSql( +""" +SELECT `c`.`City`, `c`.`ContactName`, `c`.`ContactTitle` +FROM `Customers` AS `c` +ORDER BY `c`.`City` +"""); + } + + public override async Task Final_GroupBy_property_entity_Include_collection(bool async) + { + await base.Final_GroupBy_property_entity_Include_collection(async); + + AssertSql( +""" +SELECT `c`.`City`, `c`.`CustomerID`, `c`.`Address`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM `Customers` AS `c` +LEFT JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID` +WHERE `c`.`Country` = 'USA' +ORDER BY `c`.`City`, `c`.`CustomerID` +"""); + } + + public override async Task Final_GroupBy_property_entity_projecting_collection(bool async) + { + await base.Final_GroupBy_property_entity_projecting_collection(async); + + AssertSql( +""" +SELECT `c`.`City`, `c`.`CustomerID`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM `Customers` AS `c` +LEFT JOIN `Orders` AS `o` ON `c`.`CustomerID` = `o`.`CustomerID` +WHERE `c`.`Country` = 'USA' +ORDER BY `c`.`City`, `c`.`CustomerID` +"""); + } + + public override async Task Final_GroupBy_property_entity_projecting_collection_composed(bool async) + { + await base.Final_GroupBy_property_entity_projecting_collection_composed(async); + + AssertSql( +""" +SELECT `c`.`City`, `c`.`CustomerID`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` +FROM `Customers` AS `c` +LEFT JOIN ( + SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + FROM `Orders` AS `o` + WHERE `o`.`OrderID` < 11000 +) AS `o0` ON `c`.`CustomerID` = `o0`.`CustomerID` +WHERE `c`.`Country` = 'USA' +ORDER BY `c`.`City`, `c`.`CustomerID` +"""); + } + + public override async Task Final_GroupBy_property_entity_projecting_collection_and_single_result(bool async) + { + await base.Final_GroupBy_property_entity_projecting_collection_and_single_result(async); + + AssertSql( +""" +SELECT `c`.`City`, `c`.`CustomerID`, `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate`, `o3`.`OrderID`, `o3`.`CustomerID`, `o3`.`EmployeeID`, `o3`.`OrderDate` +FROM `Customers` AS `c` +LEFT JOIN ( + SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` + FROM `Orders` AS `o` + WHERE `o`.`OrderID` < 11000 +) AS `o1` ON `c`.`CustomerID` = `o1`.`CustomerID` +LEFT JOIN ( + SELECT `o2`.`OrderID`, `o2`.`CustomerID`, `o2`.`EmployeeID`, `o2`.`OrderDate` + FROM ( + SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate`, ROW_NUMBER() OVER(PARTITION BY `o0`.`CustomerID` ORDER BY `o0`.`OrderDate` DESC) AS `row` + FROM `Orders` AS `o0` + ) AS `o2` + WHERE `o2`.`row` <= 1 +) AS `o3` ON `c`.`CustomerID` = `o3`.`CustomerID` +WHERE `c`.`Country` = 'USA' +ORDER BY `c`.`City`, `c`.`CustomerID` +"""); + } + + public override async Task GroupBy_Where_with_grouping_result(bool async) + { + await base.GroupBy_Where_with_grouping_result(async); + + AssertSql(); + } + + public override async Task GroupBy_OrderBy_with_grouping_result(bool async) + { + await base.GroupBy_OrderBy_with_grouping_result(async); + + AssertSql(); + } + + public override async Task GroupBy_SelectMany(bool async) + { + await base.GroupBy_SelectMany(async); + + AssertSql(); + } + + public override async Task OrderBy_GroupBy_SelectMany(bool async) + { + await base.OrderBy_GroupBy_SelectMany(async); + + AssertSql(); + } + + public override async Task OrderBy_GroupBy_SelectMany_shadow(bool async) + { + await base.OrderBy_GroupBy_SelectMany_shadow(async); + + AssertSql(); + } + + public override async Task GroupBy_with_orderby_take_skip_distinct_followed_by_group_key_projection(bool async) + { + await base.GroupBy_with_orderby_take_skip_distinct_followed_by_group_key_projection(async); + + AssertSql(); + } + + public override async Task GroupBy_Distinct(bool async) + { + await base.GroupBy_Distinct(async); + + AssertSql(); + } + + public override async Task GroupBy_complex_key_without_aggregate(bool async) + { + await base.GroupBy_complex_key_without_aggregate(async); + + AssertSql( +""" +SELECT `s1`.`Key`, `s3`.`OrderID`, `s3`.`CustomerID`, `s3`.`EmployeeID`, `s3`.`OrderDate`, `s3`.`CustomerID0` +FROM ( + SELECT `s`.`Key` + FROM ( + SELECT SUBSTRING(`c`.`CustomerID`, 0 + 1, 1) AS `Key` + FROM `Orders` AS `o` + LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` + ) AS `s` + GROUP BY `s`.`Key` +) AS `s1` +LEFT JOIN ( + SELECT `s2`.`OrderID`, `s2`.`CustomerID`, `s2`.`EmployeeID`, `s2`.`OrderDate`, `s2`.`CustomerID0`, `s2`.`Key` + FROM ( + SELECT `s0`.`OrderID`, `s0`.`CustomerID`, `s0`.`EmployeeID`, `s0`.`OrderDate`, `s0`.`CustomerID0`, `s0`.`Key`, ROW_NUMBER() OVER(PARTITION BY `s0`.`Key` ORDER BY `s0`.`OrderID`, `s0`.`CustomerID0`) AS `row` + FROM ( + SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate`, `c0`.`CustomerID` AS `CustomerID0`, SUBSTRING(`c0`.`CustomerID`, 0 + 1, 1) AS `Key` + FROM `Orders` AS `o0` + LEFT JOIN `Customers` AS `c0` ON `o0`.`CustomerID` = `c0`.`CustomerID` + ) AS `s0` + ) AS `s2` + WHERE (1 < `s2`.`row`) AND (`s2`.`row` <= 3) +) AS `s3` ON `s1`.`Key` = `s3`.`Key` +ORDER BY `s1`.`Key`, `s3`.`OrderID` +"""); + } + + public override async Task GroupBy_selecting_grouping_key_list(bool async) + { + await base.GroupBy_selecting_grouping_key_list(async); + + AssertSql( +""" +SELECT `o1`.`CustomerID`, `o0`.`CustomerID`, `o0`.`OrderID` +FROM ( + SELECT `o`.`CustomerID` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` +) AS `o1` +LEFT JOIN `Orders` AS `o0` ON `o1`.`CustomerID` = `o0`.`CustomerID` +ORDER BY `o1`.`CustomerID` +"""); + } + + public override async Task Select_GroupBy_SelectMany(bool async) + { + await base.Select_GroupBy_SelectMany(async); + + AssertSql(); + } + + [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore")] + public override async Task GroupBy_Shadow(bool async) + { + await base.GroupBy_Shadow(async); + + AssertSql( +""" +SELECT ( + SELECT `e0`.`Title` + FROM `Employees` AS `e0` + WHERE ((`e0`.`Title` = 'Sales Representative') AND (`e0`.`EmployeeID` = 1)) AND ((`e`.`Title` = `e0`.`Title`) OR (`e`.`Title` IS NULL AND (`e0`.`Title` IS NULL))) + LIMIT 1) +FROM `Employees` AS `e` +WHERE (`e`.`Title` = 'Sales Representative') AND (`e`.`EmployeeID` = 1) +GROUP BY `e`.`Title` +"""); + } + + public override async Task GroupBy_Shadow2(bool async) + { + await base.GroupBy_Shadow2(async); + + AssertSql( +""" +SELECT `e3`.`EmployeeID`, `e3`.`City`, `e3`.`Country`, `e3`.`FirstName`, `e3`.`ReportsTo`, `e3`.`Title` +FROM ( + SELECT `e`.`Title` + FROM `Employees` AS `e` + WHERE (`e`.`Title` = 'Sales Representative') AND (`e`.`EmployeeID` = 1) + GROUP BY `e`.`Title` +) AS `e1` +LEFT JOIN ( + SELECT `e2`.`EmployeeID`, `e2`.`City`, `e2`.`Country`, `e2`.`FirstName`, `e2`.`ReportsTo`, `e2`.`Title` + FROM ( + SELECT `e0`.`EmployeeID`, `e0`.`City`, `e0`.`Country`, `e0`.`FirstName`, `e0`.`ReportsTo`, `e0`.`Title`, ROW_NUMBER() OVER(PARTITION BY `e0`.`Title` ORDER BY `e0`.`EmployeeID`) AS `row` + FROM `Employees` AS `e0` + WHERE (`e0`.`Title` = 'Sales Representative') AND (`e0`.`EmployeeID` = 1) + ) AS `e2` + WHERE `e2`.`row` <= 1 +) AS `e3` ON `e1`.`Title` = `e3`.`Title` +"""); + } + + public override async Task GroupBy_Shadow3(bool async) + { + await base.GroupBy_Shadow3(async); + + AssertSql( +""" +SELECT ( + SELECT `e0`.`Title` + FROM `Employees` AS `e0` + WHERE (`e0`.`EmployeeID` = 1) AND (`e`.`EmployeeID` = `e0`.`EmployeeID`) + LIMIT 1) +FROM `Employees` AS `e` +WHERE `e`.`EmployeeID` = 1 +GROUP BY `e`.`EmployeeID` +"""); + } + + public override async Task GroupBy_select_grouping_list(bool async) + { + await base.GroupBy_select_grouping_list(async); + + AssertSql( +""" +SELECT `c1`.`City`, `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` +FROM ( + SELECT `c`.`City` + FROM `Customers` AS `c` + GROUP BY `c`.`City` +) AS `c1` +LEFT JOIN `Customers` AS `c0` ON `c1`.`City` = `c0`.`City` +ORDER BY `c1`.`City` +"""); + } + + public override async Task GroupBy_select_grouping_array(bool async) + { + await base.GroupBy_select_grouping_array(async); + + AssertSql( +""" +SELECT `c1`.`City`, `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` +FROM ( + SELECT `c`.`City` + FROM `Customers` AS `c` + GROUP BY `c`.`City` +) AS `c1` +LEFT JOIN `Customers` AS `c0` ON `c1`.`City` = `c0`.`City` +ORDER BY `c1`.`City` +"""); + } + + public override async Task GroupBy_select_grouping_composed_list(bool async) + { + await base.GroupBy_select_grouping_composed_list(async); + + AssertSql( +""" +SELECT `c1`.`City`, `c2`.`CustomerID`, `c2`.`Address`, `c2`.`City`, `c2`.`CompanyName`, `c2`.`ContactName`, `c2`.`ContactTitle`, `c2`.`Country`, `c2`.`Fax`, `c2`.`Phone`, `c2`.`PostalCode`, `c2`.`Region` +FROM ( + SELECT `c`.`City` + FROM `Customers` AS `c` + GROUP BY `c`.`City` +) AS `c1` +LEFT JOIN ( + SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` + FROM `Customers` AS `c0` + WHERE `c0`.`CustomerID` LIKE 'A%' +) AS `c2` ON `c1`.`City` = `c2`.`City` +ORDER BY `c1`.`City` +"""); + } + + public override async Task GroupBy_select_grouping_composed_list_2(bool async) + { + await base.GroupBy_select_grouping_composed_list_2(async); + + AssertSql( +""" +SELECT `c1`.`City`, `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` +FROM ( + SELECT `c`.`City` + FROM `Customers` AS `c` + GROUP BY `c`.`City` +) AS `c1` +LEFT JOIN `Customers` AS `c0` ON `c1`.`City` = `c0`.`City` +ORDER BY `c1`.`City`, `c0`.`CustomerID` +"""); + } + + public override async Task GroupBy_with_group_key_being_navigation(bool async) + { + await base.GroupBy_with_group_key_being_navigation(async); + + AssertSql( +""" +SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Aggregate` +FROM `Order Details` AS `o` +INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` +GROUP BY `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` +"""); + } + + public override async Task GroupBy_with_group_key_being_nested_navigation(bool async) + { + await base.GroupBy_with_group_key_being_nested_navigation(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, COALESCE(SUM(`o`.`OrderID`), 0) AS `Aggregate` +FROM `Order Details` AS `o` +INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` +LEFT JOIN `Customers` AS `c` ON `o0`.`CustomerID` = `c`.`CustomerID` +GROUP BY `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +"""); + } + + public override async Task GroupBy_with_group_key_being_navigation_with_entity_key_projection(bool async) + { + await base.GroupBy_with_group_key_being_navigation_with_entity_key_projection(async); + + AssertSql( +""" +SELECT `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` +FROM `Order Details` AS `o` +INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` +GROUP BY `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` +"""); + } + + public override async Task GroupBy_with_group_key_being_navigation_with_complex_projection(bool async) + { + await base.GroupBy_with_group_key_being_navigation_with_complex_projection(async); + + AssertSql(); + } + + public override async Task Count_after_GroupBy_aggregate(bool async) + { + await base.Count_after_GroupBy_aggregate(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM ( + SELECT 1 + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` +) AS `o0` +"""); + } + + public override async Task MinMax_after_GroupBy_aggregate(bool async) + { + await base.MinMax_after_GroupBy_aggregate(async); + + AssertSql( +""" +SELECT MIN(`o0`.`c`) +FROM ( + SELECT COALESCE(SUM(`o`.`OrderID`), 0) AS `c` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` +) AS `o0` +""", + // + """ +SELECT MAX(`o0`.`c`) +FROM ( + SELECT COALESCE(SUM(`o`.`OrderID`), 0) AS `c` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` +) AS `o0` +"""); + } + + public override async Task All_after_GroupBy_aggregate(bool async) + { + await base.All_after_GroupBy_aggregate(async); + + AssertSql( +""" +SELECT NOT EXISTS ( + SELECT 1 + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING FALSE) +"""); + } + + public override async Task All_after_GroupBy_aggregate2(bool async) + { + await base.All_after_GroupBy_aggregate2(async); + + AssertSql( +""" +SELECT NOT EXISTS ( + SELECT 1 + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COALESCE(SUM(`o`.`OrderID`), 0) < 0) +"""); + } + + public override async Task Any_after_GroupBy_aggregate(bool async) + { + await base.Any_after_GroupBy_aggregate(async); + + AssertSql( +""" +SELECT EXISTS ( + SELECT 1 + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID`) +"""); + } + + public override async Task Count_after_GroupBy_without_aggregate(bool async) + { + await base.Count_after_GroupBy_without_aggregate(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM ( + SELECT 1 + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` +) AS `o0` +"""); + } + + public override async Task Count_with_predicate_after_GroupBy_without_aggregate(bool async) + { + await base.Count_with_predicate_after_GroupBy_without_aggregate(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM ( + SELECT 1 + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) > 1 +) AS `o0` +"""); + } + + public override async Task LongCount_after_GroupBy_without_aggregate(bool async) + { + await base.LongCount_after_GroupBy_without_aggregate(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM ( + SELECT 1 + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` +) AS `o0` +"""); + } + + public override async Task LongCount_with_predicate_after_GroupBy_without_aggregate(bool async) + { + await base.LongCount_with_predicate_after_GroupBy_without_aggregate(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM ( + SELECT 1 + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) > 1 +) AS `o0` +"""); + } + + public override async Task Any_after_GroupBy_without_aggregate(bool async) + { + await base.Any_after_GroupBy_without_aggregate(async); + + AssertSql( +""" +SELECT EXISTS ( + SELECT 1 + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID`) +"""); + } + + public override async Task Any_with_predicate_after_GroupBy_without_aggregate(bool async) + { + await base.Any_with_predicate_after_GroupBy_without_aggregate(async); + + AssertSql( +""" +SELECT EXISTS ( + SELECT 1 + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) > 1) +"""); + } + + public override async Task All_with_predicate_after_GroupBy_without_aggregate(bool async) + { + await base.All_with_predicate_after_GroupBy_without_aggregate(async); + + AssertSql( +""" +SELECT NOT EXISTS ( + SELECT 1 + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + HAVING COUNT(*) <= 1) +"""); + } + + public override async Task GroupBy_aggregate_followed_by_another_GroupBy_aggregate(bool async) + { + await base.GroupBy_aggregate_followed_by_another_GroupBy_aggregate(async); + + AssertSql( +""" +SELECT `o1`.`Key0` AS `Key`, COALESCE(SUM(`o1`.`Count`), 0) AS `Count` +FROM ( + SELECT `o0`.`Count`, 1 AS `Key0` + FROM ( + SELECT COUNT(*) AS `Count` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` + ) AS `o0` +) AS `o1` +GROUP BY `o1`.`Key0` +"""); + } + + public override async Task GroupBy_nominal_type_count(bool async) + { + await base.GroupBy_nominal_type_count(async); + + AssertSql( +""" +SELECT COUNT(*) +FROM ( + SELECT 1 + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID` +) AS `o0` +"""); + } + + public override async Task Complex_query_with_groupBy_in_subquery4(bool async) + { + await base.Complex_query_with_groupBy_in_subquery4(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, `s1`.`Sum`, `s1`.`Count`, `s1`.`Key` +FROM `Customers` AS `c` +LEFT JOIN LATERAL ( + SELECT COALESCE(SUM(`s`.`OrderID`), 0) AS `Sum`, ( + SELECT COUNT(*) + FROM ( + SELECT `o0`.`CustomerID`, CONCAT(COALESCE(`c1`.`City`, ''), COALESCE(`o0`.`CustomerID`, '')) AS `Key` + FROM `Orders` AS `o0` + LEFT JOIN `Customers` AS `c1` ON `o0`.`CustomerID` = `c1`.`CustomerID` + WHERE `c`.`CustomerID` = `o0`.`CustomerID` + ) AS `s0` + LEFT JOIN `Customers` AS `c2` ON `s0`.`CustomerID` = `c2`.`CustomerID` + WHERE ((`s`.`Key` = `s0`.`Key`) OR (`s`.`Key` IS NULL AND (`s0`.`Key` IS NULL))) AND (CONCAT(COALESCE(`c2`.`City`, ''), COALESCE(`s0`.`CustomerID`, '')) LIKE 'Lon%')) AS `Count`, `s`.`Key` + FROM ( + SELECT `o`.`OrderID`, CONCAT(COALESCE(`c0`.`City`, ''), COALESCE(`o`.`CustomerID`, '')) AS `Key` + FROM `Orders` AS `o` + LEFT JOIN `Customers` AS `c0` ON `o`.`CustomerID` = `c0`.`CustomerID` + WHERE `c`.`CustomerID` = `o`.`CustomerID` + ) AS `s` + GROUP BY `s`.`Key` +) AS `s1` ON TRUE +ORDER BY `c`.`CustomerID` +"""); + } + + public override async Task Complex_query_with_group_by_in_subquery5(bool async) + { + await base.Complex_query_with_group_by_in_subquery5(async); + + AssertSql( +""" +SELECT `s`.`c`, `s`.`ProductID`, `c1`.`CustomerID`, `c1`.`City` +FROM ( + SELECT COALESCE(SUM(`o`.`ProductID` + (`o`.`OrderID` * 1000)), 0) AS `c`, `o`.`ProductID`, MIN(`o`.`OrderID` / 100) AS `c0` + FROM `Order Details` AS `o` + INNER JOIN `Orders` AS `o0` ON `o`.`OrderID` = `o0`.`OrderID` + LEFT JOIN `Customers` AS `c` ON `o0`.`CustomerID` = `c`.`CustomerID` + WHERE `c`.`CustomerID` = 'ALFKI' + GROUP BY `o`.`ProductID` +) AS `s` +LEFT JOIN LATERAL ( + SELECT `c0`.`CustomerID`, `c0`.`City` + FROM `Customers` AS `c0` + WHERE CHAR_LENGTH(`c0`.`CustomerID`) < `s`.`c0` +) AS `c1` ON TRUE +ORDER BY `s`.`ProductID`, `c1`.`CustomerID` +"""); + } + + [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore")] + public override async Task GroupBy_scalar_subquery(bool async) + { + await base.GroupBy_scalar_subquery(async); + + AssertSql( +""" +SELECT `o0`.`Key`, COUNT(*) AS `Count` +FROM ( + SELECT ( + SELECT `c`.`ContactName` + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` = `o`.`CustomerID` + LIMIT 1) AS `Key` + FROM `Orders` AS `o` +) AS `o0` +GROUP BY `o0`.`Key` +"""); + } + + public override async Task GroupBy_scalar_aggregate_in_set_operation(bool async) + { + await base.GroupBy_scalar_aggregate_in_set_operation(async); + + AssertSql( +""" +SELECT `c`.`CustomerID`, 0 AS `Sequence` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` LIKE 'F%' +UNION +SELECT `o`.`CustomerID`, 1 AS `Sequence` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + public override async Task GroupBy_aggregate_from_multiple_query_in_same_projection(bool async) + { + await base.GroupBy_aggregate_from_multiple_query_in_same_projection(async); + + AssertSql(); + } + + [ConditionalTheory(Skip = "Feature 'Dependent aggregate inside subselect' is not supported by SingleStore.")] + public override async Task GroupBy_aggregate_from_multiple_query_in_same_projection_2(bool async) + { + await base.GroupBy_aggregate_from_multiple_query_in_same_projection_2(async); + + AssertSql( +""" +SELECT `o`.`CustomerID` AS `Key`, COALESCE(( + SELECT COUNT(*) + MIN(`o`.`OrderID`) + FROM `Employees` AS `e` + WHERE `e`.`City` = 'Seattle' + GROUP BY `e`.`City` + ORDER BY (SELECT 1) + LIMIT 1), 0) AS `A` +FROM `Orders` AS `o` +GROUP BY `o`.`CustomerID` +"""); + } + + [ConditionalTheory(Skip = "SingleStore does not support this type of query: scalar subselect references field belonging to outer select that is more than one level up")] + public override async Task GroupBy_aggregate_from_multiple_query_in_same_projection_3(bool async) + { + await base.GroupBy_aggregate_from_multiple_query_in_same_projection_3(async); + + AssertSql(); + } + + public override async Task Select_uncorrelated_collection_with_groupby_when_outer_is_distinct(bool async) + { + await base.Select_uncorrelated_collection_with_groupby_when_outer_is_distinct(async); + + AssertSql( +""" +SELECT `s`.`City`, `p1`.`ProductID`, `p2`.`c`, `p2`.`ProductID` +FROM ( + SELECT DISTINCT `c`.`City` + FROM `Orders` AS `o` + LEFT JOIN `Customers` AS `c` ON `o`.`CustomerID` = `c`.`CustomerID` + WHERE `o`.`CustomerID` LIKE 'A%' +) AS `s` +LEFT JOIN LATERAL ( + SELECT `p`.`ProductID` + FROM `Products` AS `p` + GROUP BY `p`.`ProductID` +) AS `p1` ON TRUE +LEFT JOIN LATERAL ( + SELECT COUNT(*) AS `c`, `p0`.`ProductID` + FROM `Products` AS `p0` + GROUP BY `p0`.`ProductID` +) AS `p2` ON TRUE +ORDER BY `s`.`City`, `p1`.`ProductID` +"""); + } + + public override async Task Select_correlated_collection_after_GroupBy_aggregate_when_identifier_does_not_change(bool async) + { + await base.Select_correlated_collection_after_GroupBy_aggregate_when_identifier_does_not_change(async); + + AssertSql( +""" +SELECT `c0`.`CustomerID`, `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +FROM ( + SELECT `c`.`CustomerID`, `c`.`CustomerID` LIKE 'F%' AS `c` + FROM `Customers` AS `c` + GROUP BY `c`.`CustomerID`, `c` + HAVING `c` +) AS `c0` +LEFT JOIN `Orders` AS `o` ON `c0`.`CustomerID` = `o`.`CustomerID` +ORDER BY `c0`.`CustomerID` +"""); + } + + public override async Task Select_correlated_collection_after_GroupBy_aggregate_when_identifier_changes(bool async) + { + await base.Select_correlated_collection_after_GroupBy_aggregate_when_identifier_changes(async); + + AssertSql( +""" +SELECT `o1`.`CustomerID`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` +FROM ( + SELECT `o`.`CustomerID`, (`o`.`CustomerID` LIKE 'F%') AND `o`.`CustomerID` IS NOT NULL AS `c` + FROM `Orders` AS `o` + GROUP BY `o`.`CustomerID`, `c` + HAVING `c` +) AS `o1` +LEFT JOIN `Orders` AS `o0` ON `o1`.`CustomerID` = `o0`.`CustomerID` +ORDER BY `o1`.`CustomerID` +"""); + } + + public override async Task Select_correlated_collection_after_GroupBy_aggregate_when_identifier_changes_to_complex(bool async) + { + await base.Select_correlated_collection_after_GroupBy_aggregate_when_identifier_changes_to_complex(async); + + AssertSql( +""" +SELECT `o2`.`Key`, `o3`.`OrderID`, `o3`.`CustomerID`, `o3`.`EmployeeID`, `o3`.`OrderDate` +FROM ( + SELECT `o0`.`Key`, (`o0`.`Key` LIKE 'F%') AND `o0`.`Key` IS NOT NULL AS `c` + FROM ( + SELECT CONCAT(COALESCE(`o`.`CustomerID`, ''), 'A') AS `Key` + FROM `Orders` AS `o` + ) AS `o0` + GROUP BY `o0`.`Key`, `c` + HAVING `c` +) AS `o2` +LEFT JOIN LATERAL ( + SELECT `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate` + FROM `Orders` AS `o1` + WHERE (CONCAT(COALESCE(`o1`.`CustomerID`, ''), 'A')) = `o2`.`Key` +) AS `o3` ON TRUE +ORDER BY `o2`.`Key` +"""); + } + + [SupportedServerVersionCondition(nameof(ServerVersionSupport.OuterReferenceInMultiLevelSubquery))] + public override Task GroupBy_Count_in_projection(bool async) + { + return base.GroupBy_Count_in_projection(async); + } + + [SupportedServerVersionCondition("8.0.22-mysql", "0.0.0-mariadb")] + public override Task GroupBy_group_Where_Select_Distinct_aggregate(bool async) + { + // See https://github.com/mysql-net/MySqlConnector/issues/898. + return base.GroupBy_group_Where_Select_Distinct_aggregate(async); + } + + [SupportedServerVersionCondition("8.0.0-mysql", "0.0.0-mariadb")] // Is an issue issue in MySQL 5.7.34, but not in 8.0.25. + public override Task GroupBy_constant_with_where_on_grouping_with_aggregate_operators(bool async) + { + // See https://github.com/mysql-net/MySqlConnector/issues/980. + return base.GroupBy_constant_with_where_on_grouping_with_aggregate_operators(async); + } + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindIncludeQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindIncludeQuerySingleStoreTest.cs index 931a23422..2b9ecc17d 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindIncludeQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindIncludeQuerySingleStoreTest.cs @@ -22,9 +22,6 @@ public NorthwindIncludeQuerySingleStoreTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - [ConditionalTheory] public override Task Include_duplicate_collection(bool async) { diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindJoinQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindJoinQuerySingleStoreTest.cs index 75fbaaf99..a52ea92aa 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindJoinQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindJoinQuerySingleStoreTest.cs @@ -17,9 +17,6 @@ public NorthwindJoinQuerySingleStoreTest(NorthwindQuerySingleStoreFixture true; - /// /// Needs explicit ordering of views to work consistently with MySQL and MariaDB. /// But since CustomerViewModel is private, we can't even override the test case properly. diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySingleStoreTest.cs index fd1fc00a1..5fe6f65b1 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindKeylessEntitiesQuerySingleStoreTest.cs @@ -16,9 +16,6 @@ public NorthwindKeylessEntitiesQuerySingleStoreTest(NorthwindQuerySingleStoreFix //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - public override async Task KeylessEntity_with_nav_defining_query(bool async) { // FromSql mapping. Issue #21627. diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindMiscellaneousQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindMiscellaneousQuerySingleStoreTest.cs index d8072a924..0d5774411 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindMiscellaneousQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindMiscellaneousQuerySingleStoreTest.cs @@ -30,87 +30,100 @@ public NorthwindMiscellaneousQuerySingleStoreTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - public override async Task Select_bitwise_or(bool async) { await base.Select_bitwise_or(async); AssertSql( - @"SELECT `c`.`CustomerID`, (`c`.`CustomerID` = 'ALFKI') | (`c`.`CustomerID` = 'ANATR') AS `Value` -FROM `Customers` AS `c` -ORDER BY `c`.`CustomerID`"); + """ + SELECT `c`.`CustomerID`, `c`.`CustomerID` IN ('ALFKI', 'ANATR') AS `Value` + FROM `Customers` AS `c` + ORDER BY `c`.`CustomerID` + """); } public override async Task Select_bitwise_or_multiple(bool async) { await base.Select_bitwise_or_multiple(async); - AssertSql( - @"SELECT `c`.`CustomerID`, ((`c`.`CustomerID` = 'ALFKI') | (`c`.`CustomerID` = 'ANATR')) | (`c`.`CustomerID` = 'ANTON') AS `Value` + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`CustomerID` IN ('ALFKI', 'ANATR', 'ANTON') AS `Value` FROM `Customers` AS `c` -ORDER BY `c`.`CustomerID`"); +ORDER BY `c`.`CustomerID` +"""); } public override async Task Select_bitwise_and(bool async) { await base.Select_bitwise_and(async); - AssertSql( - @"SELECT `c`.`CustomerID`, (`c`.`CustomerID` = 'ALFKI') & (`c`.`CustomerID` = 'ANATR') AS `Value` + AssertSql( +""" +SELECT `c`.`CustomerID`, FALSE AS `Value` FROM `Customers` AS `c` -ORDER BY `c`.`CustomerID`"); +ORDER BY `c`.`CustomerID` +"""); } public override async Task Select_bitwise_and_or(bool async) { await base.Select_bitwise_and_or(async); - AssertSql( - @"SELECT `c`.`CustomerID`, ((`c`.`CustomerID` = 'ALFKI') & (`c`.`CustomerID` = 'ANATR')) | (`c`.`CustomerID` = 'ANTON') AS `Value` + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`CustomerID` = 'ANTON' AS `Value` FROM `Customers` AS `c` -ORDER BY `c`.`CustomerID`"); +ORDER BY `c`.`CustomerID` +"""); } public override async Task Where_bitwise_or_with_logical_or(bool async) { await base.Where_bitwise_or_with_logical_or(async); - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` -WHERE ((`c`.`CustomerID` = 'ALFKI') | (`c`.`CustomerID` = 'ANATR')) OR (`c`.`CustomerID` = 'ANTON')"); +WHERE `c`.`CustomerID` IN ('ALFKI', 'ANATR', 'ANTON') +"""); } public override async Task Where_bitwise_and_with_logical_and(bool async) { await base.Where_bitwise_and_with_logical_and(async); - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` -WHERE ((`c`.`CustomerID` = 'ALFKI') & (`c`.`CustomerID` = 'ANATR')) AND (`c`.`CustomerID` = 'ANTON')"); +WHERE FALSE +"""); } public override async Task Where_bitwise_or_with_logical_and(bool async) { await base.Where_bitwise_or_with_logical_and(async); - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` -WHERE ((`c`.`CustomerID` = 'ALFKI') | (`c`.`CustomerID` = 'ANATR')) AND (`c`.`Country` = 'Germany')"); +WHERE `c`.`CustomerID` IN ('ALFKI', 'ANATR') AND (`c`.`Country` = 'Germany') +"""); } public override async Task Where_bitwise_and_with_logical_or(bool async) { await base.Where_bitwise_and_with_logical_or(async); - AssertSql( - @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` -WHERE ((`c`.`CustomerID` = 'ALFKI') & (`c`.`CustomerID` = 'ANATR')) OR (`c`.`CustomerID` = 'ANTON')"); +WHERE `c`.`CustomerID` = 'ANTON' +"""); } public override async Task Where_bitwise_binary_not(bool async) @@ -130,9 +143,11 @@ public override async Task Where_bitwise_binary_and(bool async) await base.Where_bitwise_binary_and(async); AssertSql( - @"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +""" +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`OrderID` & 10248) = 10248"); +WHERE CAST(`o`.`OrderID` & 10248 AS signed) = 10248 +"""); } public override async Task Where_bitwise_binary_or(bool async) @@ -140,29 +155,35 @@ public override async Task Where_bitwise_binary_or(bool async) await base.Where_bitwise_binary_or(async); AssertSql( - @"SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` +""" +SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` -WHERE (`o`.`OrderID` | 10248) = 10248"); +WHERE CAST(`o`.`OrderID` | 10248 AS signed) = 10248 +"""); } public override async Task Select_bitwise_or_with_logical_or(bool async) { await base.Select_bitwise_or_with_logical_or(async); - AssertSql( - @"SELECT `c`.`CustomerID`, ((`c`.`CustomerID` = 'ALFKI') | (`c`.`CustomerID` = 'ANATR')) OR (`c`.`CustomerID` = 'ANTON') AS `Value` + AssertSql( +""" +SELECT `c`.`CustomerID`, `c`.`CustomerID` IN ('ALFKI', 'ANATR', 'ANTON') AS `Value` FROM `Customers` AS `c` -ORDER BY `c`.`CustomerID`"); +ORDER BY `c`.`CustomerID` +"""); } public override async Task Select_bitwise_and_with_logical_and(bool async) { await base.Select_bitwise_and_with_logical_and(async); - AssertSql( - @"SELECT `c`.`CustomerID`, ((`c`.`CustomerID` = 'ALFKI') & (`c`.`CustomerID` = 'ANATR')) AND (`c`.`CustomerID` = 'ANTON') AS `Value` + AssertSql( +""" +SELECT `c`.`CustomerID`, FALSE AS `Value` FROM `Customers` AS `c` -ORDER BY `c`.`CustomerID`"); +ORDER BY `c`.`CustomerID` +"""); } [ConditionalTheory] @@ -170,19 +191,21 @@ public override async Task Take_Skip(bool async) { await base.Take_Skip(async); - AssertSql( - @"@__p_0='10' + AssertSql( +""" +@__p_0='10' @__p_1='5' -SELECT `t`.`CustomerID`, `t`.`Address`, `t`.`City`, `t`.`CompanyName`, `t`.`ContactName`, `t`.`ContactTitle`, `t`.`Country`, `t`.`Fax`, `t`.`Phone`, `t`.`PostalCode`, `t`.`Region` +SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` FROM ( SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` ORDER BY `c`.`ContactName` LIMIT @__p_0 -) AS `t` -ORDER BY `t`.`ContactName` -LIMIT 18446744073709551610 OFFSET @__p_1"); +) AS `c0` +ORDER BY `c0`.`ContactName` +LIMIT 18446744073709551610 OFFSET @__p_1 +"""); } [ConditionalTheory] @@ -506,18 +529,20 @@ await AssertQuery( }); AssertSql( - @"@__p_0='5' - -SELECT `t`.`OrderID`, `o0`.`ProductID`, `o0`.`OrderID` -FROM ( - SELECT `o`.`OrderID` - FROM `Orders` AS `o` - WHERE `o`.`OrderID` < 10300 - ORDER BY `o`.`OrderID` - LIMIT 18446744073709551610 OFFSET @__p_0 -) AS `t` -LEFT JOIN `Order Details` AS `o0` ON `t`.`OrderID` = `o0`.`OrderID` -ORDER BY `t`.`OrderID`, `o0`.`ProductID`"); + """ + @__p_0='5' + + SELECT `o1`.`OrderID`, `o0`.`ProductID`, `o0`.`OrderID` + FROM ( + SELECT `o`.`OrderID` + FROM `Orders` AS `o` + WHERE `o`.`OrderID` < 10300 + ORDER BY `o`.`OrderID` + LIMIT 18446744073709551610 OFFSET @__p_0 + ) AS `o1` + LEFT JOIN `Order Details` AS `o0` ON `o1`.`OrderID` = `o0`.`OrderID` + ORDER BY `o1`.`OrderID`, `o0`.`ProductID` + """); } /// @@ -543,19 +568,21 @@ await AssertQuery( }); AssertSql( - @"@__p_1='10' -@__p_0='5' - -SELECT `t`.`OrderID`, `o0`.`ProductID`, `o0`.`OrderID` -FROM ( - SELECT `o`.`OrderID` - FROM `Orders` AS `o` - WHERE `o`.`OrderID` < 10300 - ORDER BY `o`.`OrderID` - LIMIT @__p_1 OFFSET @__p_0 -) AS `t` -LEFT JOIN `Order Details` AS `o0` ON `t`.`OrderID` = `o0`.`OrderID` -ORDER BY `t`.`OrderID`, `o0`.`ProductID`"); + """ + @__p_1='10' + @__p_0='5' + + SELECT `o1`.`OrderID`, `o0`.`ProductID`, `o0`.`OrderID` + FROM ( + SELECT `o`.`OrderID` + FROM `Orders` AS `o` + WHERE `o`.`OrderID` < 10300 + ORDER BY `o`.`OrderID` + LIMIT @__p_1 OFFSET @__p_0 + ) AS `o1` + LEFT JOIN `Order Details` AS `o0` ON `o1`.`OrderID` = `o0`.`OrderID` + ORDER BY `o1`.`OrderID`, `o0`.`ProductID` + """); } /// @@ -580,18 +607,20 @@ await AssertQuery( }); AssertSql( - @"@__p_0='10' - -SELECT `t`.`OrderID`, `o0`.`ProductID`, `o0`.`OrderID` -FROM ( - SELECT `o`.`OrderID` - FROM `Orders` AS `o` - WHERE `o`.`OrderID` < 10300 - ORDER BY `o`.`OrderID` - LIMIT @__p_0 -) AS `t` -LEFT JOIN `Order Details` AS `o0` ON `t`.`OrderID` = `o0`.`OrderID` -ORDER BY `t`.`OrderID`, `o0`.`ProductID`"); + """ + @__p_0='10' + + SELECT `o1`.`OrderID`, `o0`.`ProductID`, `o0`.`OrderID` + FROM ( + SELECT `o`.`OrderID` + FROM `Orders` AS `o` + WHERE `o`.`OrderID` < 10300 + ORDER BY `o`.`OrderID` + LIMIT @__p_0 + ) AS `o1` + LEFT JOIN `Order Details` AS `o0` ON `o1`.`OrderID` = `o0`.`OrderID` + ORDER BY `o1`.`OrderID`, `o0`.`ProductID` + """); } public override Task Complex_nested_query_doesnt_try_binding_to_grandparent_when_parent_returns_complex_result(bool async) @@ -695,6 +724,7 @@ public override async Task var actual = async ? (await actualQuery.ToListAsync()).OrderBy(e => e.A.Id).ToList() : actualQuery.ToList().OrderBy(e => e.A.Id).ToList(); + var expected = Fixture.GetExpectedData().Set() .Where(o => o.OrderID < 10300) .Select(o => new { A = new OrderCountDTO(o.CustomerID), o.CustomerID }) @@ -712,16 +742,16 @@ public override async Task } AssertSql( -""" -SELECT `t`.`CustomerID`, `o0`.`OrderID`, `o0`.`CustomerID`, `o0`.`EmployeeID`, `o0`.`OrderDate` -FROM ( - SELECT DISTINCT `o`.`CustomerID` - FROM `Orders` AS `o` - WHERE `o`.`OrderID` < 10300 -) AS `t` -LEFT JOIN `Orders` AS `o0` ON `t`.`CustomerID` = `o0`.`CustomerID` -ORDER BY `t`.`CustomerID`, `o0`.`OrderID` -"""); + """ + SELECT `o0`.`CustomerID`, `o1`.`OrderID`, `o1`.`CustomerID`, `o1`.`EmployeeID`, `o1`.`OrderDate` + FROM ( + SELECT DISTINCT `o`.`CustomerID` + FROM `Orders` AS `o` + WHERE `o`.`OrderID` < 10300 + ) AS `o0` + LEFT JOIN `Orders` AS `o1` ON `o0`.`CustomerID` = `o1`.`CustomerID` + ORDER BY `o0`.`CustomerID`, `o1`.`OrderID` + """); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.OuterReferenceInMultiLevelSubquery))] @@ -761,6 +791,12 @@ SELECT MAX(`o3`.`OrderDate`) #endif } + [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed")] + public override Task All_on_distinct(bool async) + { + return base.All_on_distinct(async); + } + [SupportedServerVersionCondition(nameof(ServerVersionSupport.WhereSubqueryReferencesOuterQuery))] public override async Task Subquery_with_navigation_inside_inline_collection(bool async) { diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindQuerySingleStoreFixture.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindQuerySingleStoreFixture.cs index 01395f8c5..e373bd3f6 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindQuerySingleStoreFixture.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindQuerySingleStoreFixture.cs @@ -10,7 +10,7 @@ namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query { public class NorthwindQuerySingleStoreFixture : NorthwindQueryRelationalFixture - where TModelCustomizer : IModelCustomizer, new() + where TModelCustomizer : ITestModelCustomizer, new() { protected override ITestStoreFactory TestStoreFactory => SingleStoreNorthwindTestStoreFactory.Instance; protected override Type ContextType => typeof(NorthwindSingleStoreContext); diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSelectQuerySingleStoreTest.SingleStore.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSelectQuerySingleStoreTest.SingleStore.cs index d692365f7..4e7fbe158 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSelectQuerySingleStoreTest.SingleStore.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSelectQuerySingleStoreTest.SingleStore.cs @@ -33,26 +33,26 @@ await AssertQuery( ss => ss.Set() .Where(o => o.CustomerID == "ALFKI" && o.OrderDate != null) - .GroupBy(o => new {o.CustomerID, o.OrderDate.Value.Year}) - .Select(g => new {g.Key.Year, Count = g.Count()}) + .GroupBy(o => new {o.CustomerID, o.OrderDate.Value.Date}) + .Select(g => new {g.Key.Date.Year, Count = g.Count()}) .Where(k => k.Year == 1995) .OrderBy(k => k.Year), assertOrder: true, assertEmpty: true); // TODO: Use a linq query that does not return an empty result. AssertSql( - @"SELECT `t`.`Year`, `t`.`Count` + @"SELECT `o1`.`Year`, `o1`.`Count` FROM ( - SELECT `t`.`Year`, COUNT(*) AS `Count`, `t`.`CustomerID`, `t`.`Year` = 1995 AS `c` + SELECT EXTRACT(year FROM `o0`.`Date`) AS `Year`, COUNT(*) AS `Count`, (EXTRACT(year FROM `o0`.`Date`) = 1995) AND EXTRACT(year FROM `o0`.`Date`) IS NOT NULL AS `c` FROM ( - SELECT `o`.`CustomerID`, EXTRACT(year FROM `o`.`OrderDate`) AS `Year` + SELECT `o`.`CustomerID`, CONVERT(`o`.`OrderDate`, date) AS `Date` FROM `Orders` AS `o` WHERE (`o`.`CustomerID` = 'ALFKI') AND `o`.`OrderDate` IS NOT NULL - ) AS `t` - GROUP BY `t`.`CustomerID`, `t`.`Year`, `c` + ) AS `o0` + GROUP BY `o0`.`CustomerID`, `o0`.`Date`, `c` HAVING `c` -) AS `t` -ORDER BY `t`.`Year`"); +) AS `o1` +ORDER BY `o1`.`Year`"); } [ConditionalTheory] @@ -76,26 +76,28 @@ await AssertQueryScalar( .Select(k => k.Year))); AssertSql( - @"SELECT `t`.`Year` -FROM ( - SELECT `t`.`Year`, `t`.`CustomerID`, `t`.`Year` = 1995 AS `c` - FROM ( - SELECT `o`.`CustomerID`, EXTRACT(year FROM `o`.`OrderDate`) AS `Year` - FROM `Orders` AS `o` - WHERE (`o`.`CustomerID` = 'ALFKI') AND `o`.`OrderDate` IS NOT NULL - ) AS `t` - GROUP BY `t`.`CustomerID`, `t`.`Year`, `c` - HAVING `c` -) AS `t` -UNION ALL -SELECT `t1`.`Key` AS `Year` -FROM ( - SELECT EXTRACT(year FROM `o0`.`OrderDate`) AS `Key` - FROM `Orders` AS `o0` - WHERE `o0`.`OrderDate` IS NOT NULL -) AS `t1` -GROUP BY `t1`.`Key` -HAVING COUNT(*) > 0"); + """ + SELECT `o3`.`Year` + FROM ( + SELECT `o0`.`Year`, (`o0`.`Year` = 1995) AND `o0`.`Year` IS NOT NULL AS `c` + FROM ( + SELECT `o`.`CustomerID`, EXTRACT(year FROM `o`.`OrderDate`) AS `Year` + FROM `Orders` AS `o` + WHERE (`o`.`CustomerID` = 'ALFKI') AND `o`.`OrderDate` IS NOT NULL + ) AS `o0` + GROUP BY `o0`.`CustomerID`, `o0`.`Year`, `c` + HAVING `c` + ) AS `o3` + UNION ALL + SELECT `o2`.`Key` AS `Year` + FROM ( + SELECT EXTRACT(year FROM `o1`.`OrderDate`) AS `Key` + FROM `Orders` AS `o1` + WHERE `o1`.`OrderDate` IS NOT NULL + ) AS `o2` + GROUP BY `o2`.`Key` + HAVING COUNT(*) > 0 + """); } } } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSelectQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSelectQuerySingleStoreTest.cs index ddf82b711..6b07776de 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSelectQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSelectQuerySingleStoreTest.cs @@ -1,9 +1,13 @@ using System; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using EntityFrameworkCore.SingleStore.Infrastructure; +using EntityFrameworkCore.SingleStore.Tests; using EntityFrameworkCore.SingleStore.Tests.TestUtilities.Attributes; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Xunit; @@ -23,9 +27,6 @@ public NorthwindSelectQuerySingleStoreTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed")] public override Task Client_projection_with_string_initialization_with_scalar_subquery(bool async) { @@ -132,8 +133,10 @@ public override async Task Select_datetime_month_component(bool async) await base.Select_datetime_month_component(async); AssertSql( - @"SELECT EXTRACT(month FROM `o`.`OrderDate`) -FROM `Orders` AS `o`"); +""" +SELECT EXTRACT(month FROM `o`.`OrderDate`) +FROM `Orders` AS `o` +"""); } [ConditionalTheory] @@ -261,7 +264,14 @@ public override async Task Correlated_collection_after_distinct_with_complex_pro () => base.Correlated_collection_after_distinct_with_complex_projection_not_containing_original_identifier(async))) .Message; - Assert.Equal(RelationalStrings.InsufficientInformationToIdentifyElementOfCollectionJoin, message); + if (SingleStoreTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) + { + Assert.Equal(RelationalStrings.InsufficientInformationToIdentifyElementOfCollectionJoin, message); + } + else + { + Assert.Contains("Primitive collections support has not been enabled.", message); + } AssertSql(); } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSetOperationsQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSetOperationsQuerySingleStoreTest.cs index a94b38aa3..feac24d70 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSetOperationsQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSetOperationsQuerySingleStoreTest.cs @@ -22,9 +22,6 @@ public NorthwindSetOperationsQuerySingleStoreTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - public override async Task Client_eval_Union_FirstOrDefault(bool async) { // Client evaluation in projection. Issue #16243. @@ -127,14 +124,16 @@ public override async Task Except_simple_followed_by_projecting_constant(bool as await base.Except_simple_followed_by_projecting_constant(async); AssertSql( - @"SELECT 1 -FROM ( - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` - FROM `Customers` AS `c` - EXCEPT - SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` - FROM `Customers` AS `c0` -) AS `t`"); + """ + SELECT 1 + FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Customers` AS `c` + EXCEPT + SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` + FROM `Customers` AS `c0` + ) AS `e` + """); } [SupportedServerVersionCondition(nameof(ServerVersionSupport.ExceptIntercept))] @@ -202,16 +201,16 @@ public override async Task Union_Select_scalar(bool async) await base.Union_Select_scalar(async); AssertSql( -""" -SELECT 1 -FROM ( - SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` - FROM `Customers` AS `c` - UNION - SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` - FROM `Customers` AS `c0` -) AS `t` -"""); + """ + SELECT 1 + FROM ( + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Customers` AS `c` + UNION + SELECT `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region` + FROM `Customers` AS `c0` + ) AS `u` + """); } private void AssertSql(params string[] expected) diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSqlQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSqlQuerySingleStoreTest.cs index 28792a8dc..26961bd18 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSqlQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindSqlQuerySingleStoreTest.cs @@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; using SingleStoreConnector; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using Xunit; using Xunit.Abstractions; @@ -18,7 +19,7 @@ public NorthwindSqlQuerySingleStoreTest(NorthwindQuerySingleStoreFixture TestHelpers.AssertAllMethodsOverridden(GetType()); + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); public override async Task SqlQueryRaw_over_int(bool async) { @@ -39,10 +40,10 @@ public override async Task SqlQuery_composed_Contains(bool async) SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate` FROM `Orders` AS `o` WHERE `o`.`OrderID` IN ( - SELECT `t`.`Value` + SELECT `s`.`Value` FROM ( SELECT `ProductID` AS `Value` FROM `Products` - ) AS `t` + ) AS `s` ) """); } @@ -53,11 +54,11 @@ public override async Task SqlQuery_composed_Join(bool async) AssertSql( """ - SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, CAST(`t`.`Value` AS signed) AS `p` + SELECT `o`.`OrderID`, `o`.`CustomerID`, `o`.`EmployeeID`, `o`.`OrderDate`, CAST(`s`.`Value` AS signed) AS `p` FROM `Orders` AS `o` INNER JOIN ( SELECT `ProductID` AS `Value` FROM `Products` - ) AS `t` ON `o`.`OrderID` = CAST(`t`.`Value` AS signed) + ) AS `s` ON `o`.`OrderID` = CAST(`s`.`Value` AS signed) """); } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindStringComparisonFunctionsQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindStringComparisonFunctionsQuerySingleStoreTest.cs new file mode 100644 index 000000000..1c5a1e4e0 --- /dev/null +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindStringComparisonFunctionsQuerySingleStoreTest.cs @@ -0,0 +1,769 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using JetBrains.Annotations; +using Microsoft.EntityFrameworkCore.Query; +using Microsoft.EntityFrameworkCore.TestModels.Northwind; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Xunit; +using Xunit.Abstractions; + +namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query +{ + public class NorthwindStringComparisonFunctionsQuerySingleStoreTest : QueryTestBase> + { + public NorthwindStringComparisonFunctionsQuerySingleStoreTest( + [NotNull] CaseSensitiveWithStringComparisonNorthwindQuerySingleStoreFixture fixture, + ITestOutputHelper testOutputHelper) + : base(fixture) + { + ClearLog(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + [ConditionalTheory] + [InlineData(StringComparison.OrdinalIgnoreCase, 1, false)] + [InlineData(StringComparison.OrdinalIgnoreCase, 1, true)] + [InlineData(StringComparison.CurrentCultureIgnoreCase, 1, false)] + [InlineData(StringComparison.CurrentCultureIgnoreCase, 1, true)] + [InlineData(StringComparison.InvariantCultureIgnoreCase, 1, false)] + [InlineData(StringComparison.InvariantCultureIgnoreCase, 1, true)] + [InlineData(StringComparison.Ordinal, 0, false)] + [InlineData(StringComparison.Ordinal, 0, true)] + [InlineData(StringComparison.CurrentCulture, 0, false)] + [InlineData(StringComparison.CurrentCulture, 0, true)] + [InlineData(StringComparison.InvariantCulture, 0, false)] + [InlineData(StringComparison.InvariantCulture, 0, true)] + public async Task StringEquals_with_comparison_parameter(StringComparison comparison, int expected, bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.Equals("anton", comparison)), + assertEmpty: expected == 0); + + // When the comparison parameter is not a constant, we have to use a case + // statement + AssertSql( + $@"@__comparison_0='{comparison:D}' + +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE CASE + WHEN @__comparison_0 IN (4, 0, 2) THEN `c`.`CustomerID` = ('anton' :> VARCHAR(255) COLLATE utf8mb4_bin) + ELSE LCASE(`c`.`CustomerID`) = (LCASE('anton') :> VARCHAR(255) COLLATE utf8mb4_bin) +END"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringEquals_ordinal(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.Equals("anton", StringComparison.Ordinal)), + assertEmpty: true); + + AssertSql(@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` = ('anton' :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringEquals_invariant(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.Equals("anton", StringComparison.CurrentCulture)), + assertEmpty: true); + + AssertSql(@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` = ('anton' :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringEquals_current(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.Equals("anton", StringComparison.InvariantCulture)), + assertEmpty: true); + + AssertSql(@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` = ('anton' :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringEquals_ordinal_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.Equals("anton", StringComparison.OrdinalIgnoreCase))); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE LCASE(`c`.`CustomerID`) = (LCASE('anton') :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringEquals_current_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.Equals("anton", StringComparison.CurrentCultureIgnoreCase))); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE LCASE(`c`.`CustomerID`) = (LCASE('anton') :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringEquals_invariant_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.Equals("anton", StringComparison.InvariantCultureIgnoreCase))); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE LCASE(`c`.`CustomerID`) = (LCASE('anton') :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [InlineData(StringComparison.OrdinalIgnoreCase, 1, false)] + [InlineData(StringComparison.OrdinalIgnoreCase, 1, true)] + [InlineData(StringComparison.CurrentCultureIgnoreCase, 1, false)] + [InlineData(StringComparison.CurrentCultureIgnoreCase, 1, true)] + [InlineData(StringComparison.InvariantCultureIgnoreCase, 1, false)] + [InlineData(StringComparison.InvariantCultureIgnoreCase, 1, true)] + [InlineData(StringComparison.Ordinal, 0, false)] + [InlineData(StringComparison.Ordinal, 0, true)] + [InlineData(StringComparison.CurrentCulture, 0, false)] + [InlineData(StringComparison.CurrentCulture, 0, true)] + [InlineData(StringComparison.InvariantCulture, 0, false)] + [InlineData(StringComparison.InvariantCulture, 0, true)] + public async Task StaticStringEquals_with_comparison(StringComparison comparison, int expected, bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Equals(c.CustomerID, "anton", comparison)), + assertEmpty: expected == 0); + + // When the comparison parameter is not a constant, we have to use a case + // statement + AssertSql( + $@"@__comparison_0='{comparison:D}' + +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE CASE + WHEN @__comparison_0 IN (4, 0, 2) THEN `c`.`CustomerID` = ('anton' :> VARCHAR(255) COLLATE utf8mb4_bin) + ELSE LCASE(`c`.`CustomerID`) = (LCASE('anton') :> VARCHAR(255) COLLATE utf8mb4_bin) +END"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StaticStringEquals_ordinal(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Equals(c.CustomerID, "anton", StringComparison.Ordinal)), + assertEmpty: true); + + AssertSql(@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` = ('anton' :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StaticStringEquals_invariant(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Equals(c.CustomerID, "anton", StringComparison.CurrentCulture)), + assertEmpty: true); + + AssertSql(@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` = ('anton' :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StaticStringEquals_current(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Equals(c.CustomerID, "anton", StringComparison.InvariantCulture)), + assertEmpty: true); + + AssertSql(@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` = ('anton' :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StaticStringEquals_ordinal_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Equals(c.CustomerID, "anton", StringComparison.OrdinalIgnoreCase))); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE LCASE(`c`.`CustomerID`) = (LCASE('anton') :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StaticStringEquals_current_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Equals(c.CustomerID, "anton", StringComparison.CurrentCultureIgnoreCase))); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE LCASE(`c`.`CustomerID`) = (LCASE('anton') :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StaticStringEquals_invariant_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Equals(c.CustomerID, "anton", StringComparison.InvariantCultureIgnoreCase))); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE LCASE(`c`.`CustomerID`) = (LCASE('anton') :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [InlineData(StringComparison.OrdinalIgnoreCase, 1, false)] + [InlineData(StringComparison.OrdinalIgnoreCase, 1, true)] + [InlineData(StringComparison.CurrentCultureIgnoreCase, 1, false)] + [InlineData(StringComparison.CurrentCultureIgnoreCase, 1, true)] + [InlineData(StringComparison.InvariantCultureIgnoreCase, 1, false)] + [InlineData(StringComparison.InvariantCultureIgnoreCase, 1, true)] + [InlineData(StringComparison.Ordinal, 0, false)] + [InlineData(StringComparison.Ordinal, 0, true)] + [InlineData(StringComparison.CurrentCulture, 0, false)] + [InlineData(StringComparison.CurrentCulture, 0, true)] + [InlineData(StringComparison.InvariantCulture, 0, false)] + [InlineData(StringComparison.InvariantCulture, 0, true)] + public async Task StringContains_with_comparison(StringComparison comparison, int expected, bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.Contains("nto", comparison)), + assertEmpty: expected == 0); + + // When the comparison parameter is not a constant, we have to use a case + // statement + AssertSql( + $@"@__comparison_0='{comparison:D}' + +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE CASE + WHEN @__comparison_0 IN (4, 0, 2) THEN `c`.`CustomerID` LIKE ('%nto%' :> VARCHAR(255) COLLATE utf8mb4_bin) + ELSE LCASE(`c`.`CustomerID`) LIKE (LCASE('%nto%') :> VARCHAR(255) COLLATE utf8mb4_bin) +END"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringContains_ordinal(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.Contains("nto", StringComparison.Ordinal)), + assertEmpty: true); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` LIKE ('%nto%' :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringContains_invariant(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.Contains("nto", StringComparison.CurrentCulture)), + assertEmpty: true); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` LIKE ('%nto%' :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringContains_current(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.Contains("nto", StringComparison.InvariantCulture)), + assertEmpty: true); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` LIKE ('%nto%' :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringContains_ordinal_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.Contains("nto", StringComparison.OrdinalIgnoreCase))); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE LCASE(`c`.`CustomerID`) LIKE (LCASE('%nto%') :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringContains_current_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.Contains("nto", StringComparison.CurrentCultureIgnoreCase))); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE LCASE(`c`.`CustomerID`) LIKE (LCASE('%nto%') :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringContains_invariant_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.Contains("nto", StringComparison.InvariantCultureIgnoreCase))); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE LCASE(`c`.`CustomerID`) LIKE (LCASE('%nto%') :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [InlineData(StringComparison.OrdinalIgnoreCase, 1, false)] + [InlineData(StringComparison.OrdinalIgnoreCase, 1, true)] + [InlineData(StringComparison.CurrentCultureIgnoreCase, 1, false)] + [InlineData(StringComparison.CurrentCultureIgnoreCase, 1, true)] + [InlineData(StringComparison.InvariantCultureIgnoreCase, 1, false)] + [InlineData(StringComparison.InvariantCultureIgnoreCase, 1, true)] + [InlineData(StringComparison.Ordinal, 0, false)] + [InlineData(StringComparison.Ordinal, 0, true)] + [InlineData(StringComparison.CurrentCulture, 0, false)] + [InlineData(StringComparison.CurrentCulture, 0, true)] + [InlineData(StringComparison.InvariantCulture, 0, false)] + [InlineData(StringComparison.InvariantCulture, 0, true)] + public async Task StringStartsWith_with_comparison(StringComparison comparison, int expected, bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.StartsWith("anto", comparison)), + assertEmpty: expected == 0); + + // When the comparison parameter is not a constant, we have to use a case + // statement + AssertSql( + $@"@__comparison_0='{comparison:D}' + +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE CASE + WHEN @__comparison_0 IN (4, 0, 2) THEN `c`.`CustomerID` LIKE ('anto' :> VARCHAR(255) COLLATE utf8mb4_bin) + ELSE LCASE(`c`.`CustomerID`) LIKE (LCASE('anto%') :> VARCHAR(255) COLLATE utf8mb4_bin) +END"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringStartsWith_ordinal(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.StartsWith("anto", StringComparison.Ordinal)), + assertEmpty: true); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` LIKE ('anto%' :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringStartsWith_invariant(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.StartsWith("anto", StringComparison.CurrentCulture)), + assertEmpty: true); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` LIKE ('anto%' :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringStartsWith_current(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.StartsWith("anto", StringComparison.InvariantCulture)), + assertEmpty: true); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` LIKE ('anto%' :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringStartsWith_ordinal_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.StartsWith("anto", StringComparison.OrdinalIgnoreCase))); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE LCASE(LCASE(`c`.`CustomerID`)) LIKE (LCASE('anto%') :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringStartsWith_current_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.StartsWith("anto", StringComparison.CurrentCultureIgnoreCase))); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE LCASE(LCASE(`c`.`CustomerID`)) LIKE (LCASE('anto%') :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringStartsWith_invariant_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.StartsWith("anto", StringComparison.InvariantCultureIgnoreCase))); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE LCASE(LCASE(`c`.`CustomerID`)) LIKE (LCASE('anto%') :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [InlineData(StringComparison.OrdinalIgnoreCase, 1, false)] + [InlineData(StringComparison.OrdinalIgnoreCase, 1, true)] + [InlineData(StringComparison.CurrentCultureIgnoreCase, 1, false)] + [InlineData(StringComparison.CurrentCultureIgnoreCase, 1, true)] + [InlineData(StringComparison.InvariantCultureIgnoreCase, 1, false)] + [InlineData(StringComparison.InvariantCultureIgnoreCase, 1, true)] + [InlineData(StringComparison.Ordinal, 0, false)] + [InlineData(StringComparison.Ordinal, 0, true)] + [InlineData(StringComparison.CurrentCulture, 0, false)] + [InlineData(StringComparison.CurrentCulture, 0, true)] + [InlineData(StringComparison.InvariantCulture, 0, false)] + [InlineData(StringComparison.InvariantCulture, 0, true)] + public async Task StringEndsWith_with_comparison(StringComparison comparison, int expected, bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.EndsWith("nton", comparison)), + assertEmpty: expected == 0); + + AssertSql( + $@"@__comparison_0='{comparison:D}' + +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE CASE + WHEN @__comparison_0 IN (4, 0, 2) THEN `c`.`CustomerID` LIKE ('%nton' :> VARCHAR(255) COLLATE utf8mb4_bin) + ELSE LCASE(`c`.`CustomerID`) LIKE (LCASE('%nton') :> VARCHAR(255) COLLATE utf8mb4_bin) +END"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringEndsWith_ordinal(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.EndsWith("nton", StringComparison.Ordinal)), + assertEmpty: true); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` LIKE ('%nton' :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringEndsWith_invariant(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.EndsWith("nton", StringComparison.CurrentCulture)), + assertEmpty: true); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` LIKE ('%nton' :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringEndsWith_current(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.EndsWith("nton", StringComparison.InvariantCulture)), + assertEmpty: true); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE `c`.`CustomerID` LIKE ('%nton' :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringEndsWith_ordinal_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.EndsWith("nton", StringComparison.OrdinalIgnoreCase))); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE LCASE(`c`.`CustomerID`) LIKE (LCASE('%nton') :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringEndsWith_current_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.EndsWith("nton", StringComparison.CurrentCultureIgnoreCase))); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE LCASE(`c`.`CustomerID`) LIKE (LCASE('%nton') :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringEndsWith_invariant_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.EndsWith("nton", StringComparison.InvariantCultureIgnoreCase))); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE LCASE(`c`.`CustomerID`) LIKE (LCASE('%nton') :> VARCHAR(255) COLLATE utf8mb4_bin)"); + } + + [ConditionalTheory] + [InlineData(StringComparison.OrdinalIgnoreCase, 1, false)] + [InlineData(StringComparison.OrdinalIgnoreCase, 1, true)] + [InlineData(StringComparison.CurrentCultureIgnoreCase, 1, false)] + [InlineData(StringComparison.CurrentCultureIgnoreCase, 1, true)] + [InlineData(StringComparison.InvariantCultureIgnoreCase, 1, false)] + [InlineData(StringComparison.InvariantCultureIgnoreCase, 1, true)] + [InlineData(StringComparison.Ordinal, 0, false)] + [InlineData(StringComparison.Ordinal, 0, true)] + [InlineData(StringComparison.CurrentCulture, 0, false)] + [InlineData(StringComparison.CurrentCulture, 0, true)] + [InlineData(StringComparison.InvariantCulture, 0, false)] + [InlineData(StringComparison.InvariantCulture, 0, true)] + public async Task StringIndexOf_with_comparison(StringComparison comparison, int expected, bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.IndexOf("nt", comparison) == 1), + assertEmpty: expected == 0); + + // When the comparison parameter is not a constant, we have to use a case + // statement + AssertSql($"@__comparison_0='{comparison:D}'" + @" + +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE CASE + WHEN @__comparison_0 IN (4, 0, 2) THEN LOCATE(('nt' :> VARCHAR(255) COLLATE utf8mb4_bin), `c`.`CustomerID`) - 1 + ELSE LOCATE((LCASE('nt') :> VARCHAR(255) COLLATE utf8mb4_bin), LCASE(`c`.`CustomerID`)) - 1 +END = 1"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringIndexOf_with_constant_start_index(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.IndexOf("nt", 0, StringComparison.OrdinalIgnoreCase) == 1)); + + AssertSql( + @"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE (LOCATE((LCASE('nt') :> VARCHAR(255) COLLATE utf8mb4_bin), LCASE(`c`.`CustomerID`), 1) - 1) = 1"); + } + + [ConditionalTheory] + [InlineData(0, 1, false)] + [InlineData(2, 0, false)] + [InlineData(0, 1, true)] + [InlineData(2, 0, true)] + public async Task StringIndexOf_with_parameter_start_index(int startIndex, int expected, bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.IndexOf("nt", startIndex, StringComparison.OrdinalIgnoreCase) == 1), + assertEmpty: expected == 0); + + AssertSql( + @$"@__startIndex_0='{startIndex}' + +SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE (LOCATE((LCASE('nt') :> VARCHAR(255) COLLATE utf8mb4_bin), LCASE(`c`.`CustomerID`), @__startIndex_0 + 1) - 1) = 1"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringIndexOf_ordinal(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.IndexOf("nt", StringComparison.Ordinal) == 1), + assertEmpty: true); + + AssertSql(@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE (LOCATE(('nt' :> VARCHAR(255) COLLATE utf8mb4_bin), `c`.`CustomerID`) - 1) = 1"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringIndexOf_invariant(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.IndexOf("nt", StringComparison.InvariantCulture) == 1), + assertEmpty: true); + + AssertSql(@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE (LOCATE(('nt' :> VARCHAR(255) COLLATE utf8mb4_bin), `c`.`CustomerID`) - 1) = 1"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringIndexOf_current(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.IndexOf("nt", StringComparison.CurrentCulture) == 1), + assertEmpty: true); + + AssertSql(@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE (LOCATE(('nt' :> VARCHAR(255) COLLATE utf8mb4_bin), `c`.`CustomerID`) - 1) = 1"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringIndexOf_ordinal_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.IndexOf("nt", StringComparison.OrdinalIgnoreCase) == 1)); + + AssertSql(@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE (LOCATE((LCASE('nt') :> VARCHAR(255) COLLATE utf8mb4_bin), LCASE(`c`.`CustomerID`)) - 1) = 1"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringIndexOf_current_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.IndexOf("nt", StringComparison.CurrentCultureIgnoreCase) == 1)); + + AssertSql(@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE (LOCATE((LCASE('nt') :> VARCHAR(255) COLLATE utf8mb4_bin), LCASE(`c`.`CustomerID`)) - 1) = 1"); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task StringIndexOf_invariant_ignore_case(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.CustomerID.IndexOf("nt", StringComparison.InvariantCultureIgnoreCase) == 1)); + + AssertSql(@"SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` +FROM `Customers` AS `c` +WHERE (LOCATE((LCASE('nt') :> VARCHAR(255) COLLATE utf8mb4_bin), LCASE(`c`.`CustomerID`)) - 1) = 1"); + } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + private void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); + } +} diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindWhereQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindWhereQuerySingleStoreTest.cs index d65df05ed..ef08f790a 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindWhereQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NorthwindWhereQuerySingleStoreTest.cs @@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestModels.Northwind; using Microsoft.EntityFrameworkCore.TestUtilities; +using EntityFrameworkCore.SingleStore.Tests.TestUtilities.Attributes; using Xunit; using Xunit.Abstractions; @@ -22,9 +23,6 @@ public NorthwindWhereQuerySingleStoreTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - [ConditionalTheory(Skip = "SingleStore does not support this type of query: scalar subselect references field belonging to outer select that is more than one level up")] public override Task Where_contains_on_navigation(bool async) { @@ -53,7 +51,7 @@ public override async Task Where_datetime_now(bool async) SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` -WHERE CURRENT_TIMESTAMP() <> @__myDatetime_0"); +WHERE CURRENT_TIMESTAMP(6) <> @__myDatetime_0"); } [ConditionalTheory] @@ -66,7 +64,7 @@ public override async Task Where_datetime_utcnow(bool async) SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` FROM `Customers` AS `c` -WHERE UTC_TIMESTAMP() <> @__myDatetime_0"); +WHERE UTC_TIMESTAMP(6) <> @__myDatetime_0"); } [ConditionalTheory] @@ -77,7 +75,7 @@ public override async Task Where_datetime_today(bool async) AssertSql( @"SELECT `e`.`EmployeeID`, `e`.`City`, `e`.`Country`, `e`.`FirstName`, `e`.`ReportsTo`, `e`.`Title` FROM `Employees` AS `e` -WHERE CONVERT(CURRENT_TIMESTAMP(), date) = CURDATE()"); +WHERE CONVERT(CURRENT_TIMESTAMP(6), date) = CURDATE()"); } [ConditionalTheory] @@ -399,7 +397,7 @@ public virtual async Task Where_string_concat_method_comparison_object_3(bool as await AssertQuery( async, - ss => ss.Set().Where(c => string.Concat(i, j, k, c.CustomerID) == c.CompanyName).Select(c => c.CustomerID), + ss => ss.Set().Where(c => string.Concat(new[] {i, j, k, c.CustomerID}) == c.CompanyName).Select(c => c.CustomerID), assertEmpty: true); AssertSql( @@ -425,7 +423,7 @@ public virtual async Task Where_string_concat_method_comparison_params_string_ar await AssertQuery( async, - ss => ss.Set().Where(c => string.Concat(i, j, k, m, c.CustomerID) == c.CompanyName).Select(c => c.CustomerID), + ss => ss.Set().Where(c => string.Concat(new[] {i, j, k, m, c.CustomerID}) == c.CompanyName).Select(c => c.CustomerID), assertEmpty: true); AssertSql( @@ -494,7 +492,7 @@ public virtual async Task Where_string_concat_method_comparison_params_object_ar await AssertQuery( async, - ss => ss.Set().Where(c => string.Concat(i, j, k, m, c.CustomerID) == c.CompanyName).Select(c => c.CustomerID), + ss => ss.Set().Where(c => string.Concat(new[]{i, j, k, m, c.CustomerID}) == c.CompanyName).Select(c => c.CustomerID), assertEmpty: true); AssertSql( @@ -664,10 +662,14 @@ public override Task ElementAtOrDefault_over_custom_projection_compared_to_null( public override async Task Where_bitwise_xor(bool async) { - // Cannot eval 'where (([c].CustomerID == \"ALFKI\") ^ True)'. Issue #16645. - await AssertTranslationFailed(() => base.Where_bitwise_xor(async)); + await base.Where_bitwise_xor(async); - AssertSql(); + AssertSql( + """ + SELECT `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region` + FROM `Customers` AS `c` + WHERE (`c`.`CustomerID` = 'ALFKI') ^ TRUE + """); } public override async Task Where_compare_constructed_equal(bool async) diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/NullSemanticsQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/NullSemanticsQuerySingleStoreTest.cs index 4ce3c30e1..ceac2ba56 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/NullSemanticsQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/NullSemanticsQuerySingleStoreTest.cs @@ -59,6 +59,20 @@ await AssertQueryScalar( WHERE @__prm_0 = (`e`.`NullableBoolC` IS NOT NULL)"); } + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override Task CaseOpWhen_predicate(bool async) + => AssertQuery( + async, + ss => ss.Set() + .Where( + x => NullSemanticsQueryFixtureBase.BoolSwitch( + x.StringA == "Foo", 3, 2 + ) + == 2), + assertOrder: false + ); + [ConditionalTheory(Skip = "LIKE ... ESCAPE is not supported by SingleStore Distributed.")] public override async Task Like_with_escape_char(bool async) { diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/OperatorsQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/OperatorsQuerySingleStoreTest.cs index 24544e428..0fba3ac3c 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/OperatorsQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/OperatorsQuerySingleStoreTest.cs @@ -21,21 +21,45 @@ public override async Task Bitwise_and_on_expression_with_like_and_null_check_be { await base.Bitwise_and_on_expression_with_like_and_null_check_being_compared_to_false(); - AssertSql(""); + AssertSql( + """ + SELECT `o`.`Value` AS `Value1`, `o0`.`Value` AS `Value2`, `o1`.`Value` AS `Value3` + FROM `OperatorEntityString` AS `o` + CROSS JOIN `OperatorEntityString` AS `o0` + CROSS JOIN `OperatorEntityBool` AS `o1` + WHERE (((`o0`.`Value` LIKE 'B') AND `o0`.`Value` IS NOT NULL) OR `o1`.`Value`) AND `o`.`Value` IS NOT NULL + ORDER BY `o`.`Id`, `o0`.`Id`, `o1`.`Id` + """); } public override async Task Complex_predicate_with_bitwise_and_modulo_and_negation() { await base.Complex_predicate_with_bitwise_and_modulo_and_negation(); - AssertSql(""); + AssertSql( + """ + SELECT `o`.`Value` AS `Value0`, `o0`.`Value` AS `Value1`, `o1`.`Value` AS `Value2`, `o2`.`Value` AS `Value3` + FROM `OperatorEntityLong` AS `o` + CROSS JOIN `OperatorEntityLong` AS `o0` + CROSS JOIN `OperatorEntityLong` AS `o1` + CROSS JOIN `OperatorEntityLong` AS `o2` + WHERE CAST(((`o0`.`Value` % 2) / `o`.`Value`) & ((CAST(`o2`.`Value` | `o1`.`Value` AS signed) - `o`.`Value`) - (`o1`.`Value` * `o1`.`Value`)) AS signed) >= (((`o0`.`Value` / CAST(~`o2`.`Value` AS signed)) % 2) % (CAST(~`o`.`Value` AS signed) + 1)) + ORDER BY `o`.`Id`, `o0`.`Id`, `o1`.`Id`, `o2`.`Id` + """); } public override async Task Complex_predicate_with_bitwise_and_arithmetic_operations() { await base.Complex_predicate_with_bitwise_and_arithmetic_operations(); - AssertSql(""); + AssertSql(""" + SELECT `o`.`Value` AS `Value0`, `o0`.`Value` AS `Value1`, `o1`.`Value` AS `Value2` + FROM `OperatorEntityInt` AS `o` + CROSS JOIN `OperatorEntityInt` AS `o0` + CROSS JOIN `OperatorEntityBool` AS `o1` + WHERE ((CAST(CAST(`o0`.`Value` & (`o`.`Value` + `o`.`Value`) AS signed) & `o`.`Value` AS signed) / 1) > CAST(`o0`.`Value` & 10 AS signed)) AND `o1`.`Value` + ORDER BY `o`.`Id`, `o0`.`Id`, `o1`.`Id` + """); } public override async Task Or_on_two_nested_binaries_and_another_simple_comparison() @@ -50,7 +74,7 @@ CROSS JOIN `OperatorEntityString` AS `o0` CROSS JOIN `OperatorEntityString` AS `o1` CROSS JOIN `OperatorEntityString` AS `o2` CROSS JOIN `OperatorEntityInt` AS `o3` -WHERE ((((`o`.`Value` = 'A') AND `o`.`Value` IS NOT NULL) AND ((`o0`.`Value` = 'A') AND `o0`.`Value` IS NOT NULL)) | (((`o1`.`Value` = 'B') AND `o1`.`Value` IS NOT NULL) AND ((`o2`.`Value` = 'B') AND `o2`.`Value` IS NOT NULL))) AND (`o3`.`Value` = 2) +WHERE (((`o`.`Value` = 'A') AND (`o0`.`Value` = 'A')) OR ((`o1`.`Value` = 'B') AND (`o2`.`Value` = 'B'))) AND (`o3`.`Value` = 2) ORDER BY `o`.`Id`, `o0`.`Id`, `o1`.`Id`, `o2`.`Id`, `o3`.`Id` """); } @@ -139,7 +163,7 @@ public override async Task Negate_on_like_expression(bool async) public override Task Concat_and_json_scalar(bool async) => Assert.ThrowsAsync(() => base.Concat_and_json_scalar(async)); - protected override void Seed(OperatorsContext ctx) + protected override async Task Seed(OperatorsContext ctx) { ctx.Set().AddRange(ExpectedData.OperatorEntitiesString); ctx.Set().AddRange(ExpectedData.OperatorEntitiesInt); @@ -149,6 +173,6 @@ protected override void Seed(OperatorsContext ctx) ctx.Set().AddRange(ExpectedData.OperatorEntitiesNullableBool); // ctx.Set().AddRange(ExpectedData.OperatorEntitiesDateTimeOffset); - ctx.SaveChanges(); + await ctx.SaveChangesAsync(); } } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/OwnedEntityQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/OwnedEntityQuerySingleStoreTest.cs index e8bad8d63..7e537170c 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/OwnedEntityQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/OwnedEntityQuerySingleStoreTest.cs @@ -1,13 +1,10 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Linq.Expressions; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; -using EntityFrameworkCore.SingleStore.Tests; using Xunit; namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query @@ -21,139 +18,257 @@ public override async Task Multiple_single_result_in_projection_containing_owned await base.Multiple_single_result_in_projection_containing_owned_types(async); AssertSql( - @"SELECT `e`.`Id`, `t0`.`Id`, `t0`.`Entity20277Id`, `t0`.`Owned_IsDeleted`, `t0`.`Owned_Value`, `t0`.`Type`, `t0`.`c`, `t1`.`Id`, `t1`.`Entity20277Id`, `t1`.`Owned_IsDeleted`, `t1`.`Owned_Value`, `t1`.`Type`, `t1`.`c` -FROM `Entities` AS `e` -LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Entity20277Id`, `t`.`Owned_IsDeleted`, `t`.`Owned_Value`, `t`.`Type`, `t`.`c` - FROM ( - SELECT `c`.`Id`, `c`.`Entity20277Id`, `c`.`Owned_IsDeleted`, `c`.`Owned_Value`, `c`.`Type`, 1 AS `c`, ROW_NUMBER() OVER(PARTITION BY `c`.`Entity20277Id` ORDER BY `c`.`Entity20277Id`, `c`.`Id`) AS `row` - FROM `Child20277` AS `c` - WHERE `c`.`Type` = 1 - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `e`.`Id` = `t0`.`Entity20277Id` -LEFT JOIN ( - SELECT `t2`.`Id`, `t2`.`Entity20277Id`, `t2`.`Owned_IsDeleted`, `t2`.`Owned_Value`, `t2`.`Type`, `t2`.`c` - FROM ( - SELECT `c0`.`Id`, `c0`.`Entity20277Id`, `c0`.`Owned_IsDeleted`, `c0`.`Owned_Value`, `c0`.`Type`, 1 AS `c`, ROW_NUMBER() OVER(PARTITION BY `c0`.`Entity20277Id` ORDER BY `c0`.`Entity20277Id`, `c0`.`Id`) AS `row` - FROM `Child20277` AS `c0` - WHERE `c0`.`Type` = 2 - ) AS `t2` - WHERE `t2`.`row` <= 1 -) AS `t1` ON `e`.`Id` = `t1`.`Entity20277Id`"); + """ + SELECT `e`.`Id`, `c2`.`Id`, `c2`.`EntityId`, `c2`.`Owned_IsDeleted`, `c2`.`Owned_Value`, `c2`.`Type`, `c2`.`c`, `c4`.`Id`, `c4`.`EntityId`, `c4`.`Owned_IsDeleted`, `c4`.`Owned_Value`, `c4`.`Type`, `c4`.`c` + FROM `Entities` AS `e` + LEFT JOIN ( + SELECT `c1`.`Id`, `c1`.`EntityId`, `c1`.`Owned_IsDeleted`, `c1`.`Owned_Value`, `c1`.`Type`, `c1`.`c` + FROM ( + SELECT `c`.`Id`, `c`.`EntityId`, `c`.`Owned_IsDeleted`, `c`.`Owned_Value`, `c`.`Type`, 1 AS `c`, ROW_NUMBER() OVER(PARTITION BY `c`.`EntityId` ORDER BY `c`.`EntityId`, `c`.`Id`) AS `row` + FROM `Child` AS `c` + WHERE `c`.`Type` = 1 + ) AS `c1` + WHERE `c1`.`row` <= 1 + ) AS `c2` ON `e`.`Id` = `c2`.`EntityId` + LEFT JOIN ( + SELECT `c3`.`Id`, `c3`.`EntityId`, `c3`.`Owned_IsDeleted`, `c3`.`Owned_Value`, `c3`.`Type`, `c3`.`c` + FROM ( + SELECT `c0`.`Id`, `c0`.`EntityId`, `c0`.`Owned_IsDeleted`, `c0`.`Owned_Value`, `c0`.`Type`, 1 AS `c`, ROW_NUMBER() OVER(PARTITION BY `c0`.`EntityId` ORDER BY `c0`.`EntityId`, `c0`.`Id`) AS `row` + FROM `Child` AS `c0` + WHERE `c0`.`Type` = 2 + ) AS `c3` + WHERE `c3`.`row` <= 1 + ) AS `c4` ON `e`.`Id` = `c4`.`EntityId` + """); } [ConditionalTheory] public override async Task Owned_entity_with_all_null_properties_entity_equality_when_not_containing_another_owned_entity( bool async) { - var contextFactory = (await this.InitializeAsync(seed: c => c.Seed(), onModelCreating: modelBuilder => + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => { // We're changing the data type of the fields from INT to BIGINT, because in SingleStore // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column - modelBuilder.Entity() + modelBuilder.Entity() .Property(e => e.Id) .HasColumnType("bigint"); - })); + }); - using (MyContext28247 context = contextFactory.CreateContext()) - { - IQueryable source = context.RotRutCases.AsNoTracking().Select((Expression>) (e => e.Rot)).Where((Expression>) (e => e != default (object))); - - List collection; - if (async) - collection = await source.ToListAsync(); - else - collection = source.ToList(); - Assert.Collection((IEnumerable) collection, (Action) (t => + using var context = contextFactory.CreateContext(); + var query = context.RotRutCases.AsNoTracking().Select(e => e.Rot).Where(e => e != null); + + var result = async + ? await query.ToListAsync() + : query.ToList(); + + Assert.Collection( + result, + t => { - Assert.Equal(new int?(1), t.ServiceType); + Assert.Equal(1, t.ServiceType); Assert.Equal("1", t.ApartmentNo); - })); - } + }); } - [ConditionalTheory] - public override async Task Owned_entity_with_all_null_properties_property_access_when_not_containing_another_owned_entity( - bool async) + public override async Task Owned_collection_basic_split_query(bool async) + { + // Use custom context to set prefix length, so we don't exhaust the max. key length. + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + modelBuilder.Entity().OwnsMany(e => e.PublishTokenTypes, + b => + { + b.WithOwner(e => e.Location).HasForeignKey(e => e.LocationId); + b.HasKey(e => new { e.LocationId, e.ExternalId, e.VisualNumber, e.TokenGroupId }) + .HasPrefixLength(0, 128, 128, 128); // <-- set prefix length, so we don't exhaust the max. key length + }); + }); + + using var context = contextFactory.CreateContext(); + + var id = new Guid("6c1ae3e5-30b9-4c77-8d98-f02075974a0a"); + var query = context.Set().Where(e => e.Id == id).AsSplitQuery(); + var result = async + ? await query.FirstOrDefaultAsync() + : query.FirstOrDefault(); + } + + public override async Task Projecting_correlated_collection_property_for_owned_entity(bool async) { - var contextFactory = (await this.InitializeAsync(seed: c => c.Seed(), onModelCreating: modelBuilder => + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => { // We're changing the data type of the fields from INT to BIGINT, because in SingleStore // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column - modelBuilder.Entity() + modelBuilder.Entity() .Property(e => e.Id) .HasColumnType("bigint"); - })); + modelBuilder.Entity().OwnsMany( + e => e.DestinationCountries, + b => + { + b.Property("Id") + .HasConversion() + .HasColumnType("bigint"); + }); + }); + + using var context = contextFactory.CreateContext(); + var query = context.Warehouses.Select( + x => new Context18582.WarehouseModel + { + WarehouseCode = x.WarehouseCode, + DestinationCountryCodes = x.DestinationCountries.OrderBy(c => c.CountryCode).Select(c => c.CountryCode).ToArray() + }).AsNoTracking(); - using (MyContext28247 context = contextFactory.CreateContext()) + var result = async + ? await query.ToListAsync() + : query.ToList(); + + var warehouseModel = Assert.Single(result); + Assert.Equal("W001", warehouseModel.WarehouseCode); + Assert.True(new[] { "CA", "US" }.SequenceEqual(warehouseModel.DestinationCountryCodes)); + } + + // Use base implementation once https://github.com/dotnet/efcore/pull/32509#issuecomment-1948812777 is fixed and the base + // implementation has been fixed to use a deterministic order. + public override async Task Correlated_subquery_with_owned_navigation_being_compared_to_null_works() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => { - IQueryable source = context.RotRutCases.AsNoTracking().OrderBy(e => e.Id).Select((Expression>) (e => e.Rot.ApartmentNo)); - List collection; - if (async) - collection = await source.ToListAsync(); - else - collection = source.ToList(); - Assert.Collection((IEnumerable) collection, (Action) (t => Assert.Equal("1", t)), (Action) (t => Assert.Null((object) t))); + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using (var context = contextFactory.CreateContext()) + { + var partners = context.Partners + .Select( + x => new + { + Addresses = x.Addresses.Select( + y => new + { + Turnovers = y.Turnovers == null + ? null + : new { y.Turnovers.AmountIn } + }) + .ToList() + }).ToList(); + + Assert.Single(partners); + Assert.Collection( + partners[0].Addresses + .OrderBy(a => a.Turnovers is null), // <-- explicitly order to make deterministic + t => + { + Assert.NotNull(t.Turnovers); + Assert.Equal(10, t.Turnovers.AmountIn); + }, + t => + { + Assert.Null(t.Turnovers); + }); } + + AssertSql( + """ + SELECT `p`.`Id`, `a`.`Turnovers_AmountIn` IS NULL, `a`.`Turnovers_AmountIn`, `a`.`Id` + FROM `Partners` AS `p` + LEFT JOIN `Address` AS `a` ON `p`.`Id` = `a`.`PartnerId` + ORDER BY `p`.`Id` + """); } [ConditionalTheory] - public override async Task Owned_entity_with_all_null_properties_materializes_when_not_containing_another_owned_entity( - bool async) + [MemberData(nameof(IsAsyncData))] + public override async Task Owned_entity_with_all_null_properties_materializes_when_not_containing_another_owned_entity(bool async) { - var contextFactory = await this.InitializeAsync(seed: c => c.Seed(), onModelCreating: modelBuilder => + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => { // We're changing the data type of the fields from INT to BIGINT, because in SingleStore // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column - modelBuilder.Entity() + modelBuilder.Entity() .Property(e => e.Id) .HasColumnType("bigint"); }); - using (MyContext28247 context = contextFactory.CreateContext()) - { - IOrderedQueryable source = context.RotRutCases.OrderBy((Expression>) (e => e.Buyer)); - List collection; - if (async) - collection = await source.ToListAsync(); - else - collection = source.ToList(); - Assert.Collection((IEnumerable) collection, (Action) (t => + using var context = contextFactory.CreateContext(); + var query = context.RotRutCases.OrderBy(e => e.Buyer); + + var result = async + ? await query.ToListAsync() + : query.ToList(); + + Assert.Collection( + result, + t => { Assert.Equal("Buyer1", t.Buyer); - Assert.NotNull((object) t.Rot); - Assert.Equal(new int?(1), t.Rot.ServiceType); + Assert.NotNull(t.Rot); + Assert.Equal(1, t.Rot.ServiceType); Assert.Equal("1", t.Rot.ApartmentNo); - Assert.NotNull((object) t.Rut); - Assert.Equal(new int?(1), t.Rut.Value); - }), (Action) (t => + Assert.NotNull(t.Rut); + Assert.Equal(1, t.Rut.Value); + }, + t => { Assert.Equal("Buyer2", t.Buyer); - Assert.Null((object) t.Rot); - Assert.Null((object) t.Rut); - })); - } + Assert.Null(t.Rot); + Assert.Null(t.Rut); + }); } [ConditionalTheory] - public override async Task Owned_reference_mapped_to_different_table_nested_updated_correctly_after_subquery_pushdown(bool async) + [MemberData(nameof(IsAsyncData))] + public override async Task Owned_entity_with_all_null_properties_property_access_when_not_containing_another_owned_entity(bool async) { - // We're skipping this test when we're running tests on Managed Service due to the specifics of - // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) - if (AppConfig.ManagedService) + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => { - return; - } + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + + using var context = contextFactory.CreateContext(); + var query = context.RotRutCases.AsNoTracking().OrderBy(e => e.Buyer).Select(e => e.Rot.ApartmentNo); + + var result = async + ? await query.ToListAsync() + : query.ToList(); - var contextFactory = await InitializeAsync(seed: c => c.Seed(), onModelCreating: modelBuilder => + Assert.Collection( + result, + t => + { + Assert.Equal("1", t); + }, + t => + { + Assert.Null(t); + }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public override async Task Owned_reference_mapped_to_different_table_nested_updated_correctly_after_subquery_pushdown(bool async) + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => { // We're changing the data type of the fields from INT to BIGINT, because in SingleStore // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column - modelBuilder.Entity() + modelBuilder.Entity() .Property(e => e.Id) .HasColumnType("bigint"); - modelBuilder.Entity() + modelBuilder.Entity() .Property(e => e.Id) .HasColumnType("bigint"); }); @@ -163,81 +278,143 @@ public override async Task Owned_reference_mapped_to_different_table_nested_upda } [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] public override async Task Owned_reference_mapped_to_different_table_updated_correctly_after_subquery_pushdown(bool async) { - // We're skipping this test when we're running tests on Managed Service due to the specifics of - // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) - if (AppConfig.ManagedService) + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => { - return; - } + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); - var contextFactory = await InitializeAsync(seed: c => c.Seed(), onModelCreating: modelBuilder => + await base.Owned_references_on_same_level_expanded_at_different_times_around_take_helper(context, async); + } + + [ConditionalFact] + public override async Task Accessing_scalar_property_in_derived_type_projection_does_not_load_owned_navigations() + { + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => { // We're changing the data type of the fields from INT to BIGINT, because in SingleStore // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column - modelBuilder.Entity() + modelBuilder.Entity() .Property(e => e.Id) .HasColumnType("bigint"); - modelBuilder.Entity() + modelBuilder.Entity() .Property(e => e.Id) .HasColumnType("bigint"); }); using var context = contextFactory.CreateContext(); + var result = context.BaseEntities + .Select(b => context.OtherEntities.Where(o => o.OtherEntityData == ((Context19138.SubEntity)b).Data).FirstOrDefault()) + .ToList(); - await base.Owned_references_on_same_level_expanded_at_different_times_around_take_helper(context, async); + Assert.Equal("A", Assert.Single(result).OtherEntityData); } - public override async Task Owned_collection_basic_split_query(bool async) + [ConditionalFact] + public override async Task Can_auto_include_navigation_from_model() { - // Use custom context to set prefix length, so we don't exhaust the max. key length. - var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => { - modelBuilder.Entity().OwnsMany(e => e.PublishTokenTypes, - b => - { - b.WithOwner(e => e.Location).HasForeignKey(e => e.LocationId); - b.HasKey(e => new { e.LocationId, e.ExternalId, e.VisualNumber, e.TokenGroupId }) - .HasPrefixLength(0, 128, 128, 128); // <-- set prefix length, so we don't exhaust the max. key length - }); + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); }); - using var context = contextFactory.CreateContext(); + using (var context = contextFactory.CreateContext()) + { + var query = context.Parents.AsNoTracking().ToList(); + var result = Assert.Single(query); + Assert.NotNull(result.OwnedReference); + Assert.NotNull(result.Reference); + Assert.NotNull(result.Collection); + Assert.Equal(2, result.Collection.Count); + Assert.NotNull(result.SkipOtherSide); + Assert.Single(result.SkipOtherSide); + } - var id = new Guid("6c1ae3e5-30b9-4c77-8d98-f02075974a0a"); - var query = context.Set().Where(e => e.Id == id).AsSplitQuery(); - var result = async - ? await query.FirstOrDefaultAsync() - : query.FirstOrDefault(); + using (var context = contextFactory.CreateContext()) + { + var query = context.Parents.AsNoTracking().IgnoreAutoIncludes().ToList(); + var result = Assert.Single(query); + Assert.NotNull(result.OwnedReference); + Assert.Null(result.Reference); + Assert.Null(result.Collection); + Assert.Null(result.SkipOtherSide); + } } - public override async Task Projecting_correlated_collection_property_for_owned_entity(bool async) + [ConditionalFact] + public override async Task Include_collection_for_entity_with_owned_type_works() { - var contextFactory = await InitializeAsync(seed: c => c.Seed(), onModelCreating: modelBuilder => + var contextFactory = await InitializeAsync(seed: c => c.SeedAsync(), onModelCreating: modelBuilder => { // We're changing the data type of the fields from INT to BIGINT, because in SingleStore // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column - modelBuilder.Entity() + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + modelBuilder.Entity() .Property(e => e.Id) .HasColumnType("bigint"); }); - using var context = contextFactory.CreateContext(); - var query = context.Warehouses.Select(x => new WarehouseModel + using (var context = contextFactory.CreateContext()) { - WarehouseCode = x.WarehouseCode, - DestinationCountryCodes = x.DestinationCountries.Select(c => c.CountryCode) - .OrderByDescending(c => c) // <-- explicitly order - .ToArray() - }).AsNoTracking(); + var query = context.Movies.Include(m => m.Cast); + var result = query.ToList(); - var result = async - ? await query.ToListAsync() - : query.ToList(); + Assert.Single(result); + Assert.Equal(3, result[0].Cast.Count); + Assert.NotNull(result[0].Details); + Assert.True(result[0].Cast.All(a => a.Details != null)); + } - var warehouseModel = Assert.Single(result); - Assert.Equal("W001", warehouseModel.WarehouseCode); - Assert.True(new[] { "US", "CA" }.SequenceEqual(warehouseModel.DestinationCountryCodes)); + using (var context = contextFactory.CreateContext()) + { + var query = context.Movies.Include("Cast"); + var result = query.ToList(); + + Assert.Single(result); + Assert.Equal(3, result[0].Cast.Count); + Assert.NotNull(result[0].Details); + Assert.True(result[0].Cast.All(a => a.Details != null)); + } + } + + [ConditionalFact] + public override async Task Multilevel_owned_entities_determine_correct_nullability() + { + var contextFactory = await InitializeAsync(onModelCreating: modelBuilder => + { + // We're changing the data type of the fields from INT to BIGINT, because in SingleStore + // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column + modelBuilder.Entity() + .Property(e => e.Id) + .HasColumnType("bigint"); + }); + using var context = contextFactory.CreateContext(); + await context.AddAsync(new Context13079.BaseEntity()); + await context.SaveChangesAsync(); } [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed")] @@ -270,5 +447,11 @@ public override async Task Owned_entity_with_all_null_properties_in_compared_to_ { await base.Owned_entity_with_all_null_properties_in_compared_to_null_in_conditional_projection(async); } + + [ConditionalTheory(Skip = "It's impossible to override this test so it could be run against SingleStore")] + public override async Task Owned_entity_multiple_level_in_aggregate() + { + await base.Owned_entity_multiple_level_in_aggregate(); + } } } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/OwnedQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/OwnedQuerySingleStoreTest.cs index c5320dd70..75353018e 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/OwnedQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/OwnedQuerySingleStoreTest.cs @@ -2,6 +2,8 @@ using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; +using EntityFrameworkCore.SingleStore.Infrastructure; +using EntityFrameworkCore.SingleStore.Tests.TestUtilities.Attributes; using Xunit; using Xunit.Abstractions; @@ -15,15 +17,24 @@ public OwnedQuerySingleStoreTest(OwnedQuerySingleStoreFixture fixture, ITestOutp //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - public class OwnedQuerySingleStoreFixture : RelationalOwnedQueryFixture { protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; } + [SupportedServerVersionCondition(nameof(ServerVersionSupport.WhereSubqueryReferencesOuterQuery))] + public override Task Union_over_owned_collection(bool async) + { + return base.Union_over_owned_collection(async); + } + + [SupportedServerVersionCondition(nameof(ServerVersionSupport.WhereSubqueryReferencesOuterQuery))] + public override Task Distinct_over_owned_collection(bool async) + { + return base.Distinct_over_owned_collection(async); + } + [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore")] public override Task Navigation_rewrite_on_owned_collection_with_composition(bool async) { diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/PrimitiveCollectionsQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/PrimitiveCollectionsQuerySingleStoreTest.cs index 2f9ef57a3..6f0637205 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/PrimitiveCollectionsQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/PrimitiveCollectionsQuerySingleStoreTest.cs @@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; +using SingleStoreConnector; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using EntityFrameworkCore.SingleStore.Infrastructure; using EntityFrameworkCore.SingleStore.Tests; @@ -155,11 +156,11 @@ public override async Task Inline_collection_Contains_with_zero_values(bool asyn await base.Inline_collection_Contains_with_zero_values(async); AssertSql( - """ - SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` - FROM `PrimitiveCollectionsEntity` AS `p` - WHERE FALSE - """); +""" +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE FALSE +"""); } public override async Task Inline_collection_Contains_with_one_value(bool async) @@ -206,6 +207,7 @@ public override async Task Inline_collection_Contains_with_all_parameters(bool a """ @__i_0='2' @__j_1='999' + SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` FROM `PrimitiveCollectionsEntity` AS `p` WHERE `p`.`Id` IN (@__i_0, @__j_1) @@ -219,6 +221,7 @@ public override async Task Inline_collection_Contains_with_constant_and_paramete AssertSql( """ @__j_0='999' + SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` FROM `PrimitiveCollectionsEntity` AS `p` WHERE `p`.`Id` IN (2, @__j_0) @@ -232,6 +235,7 @@ public override async Task Inline_collection_Contains_with_mixed_value_types(boo AssertSql( """ @__i_0='11' + SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` FROM `PrimitiveCollectionsEntity` AS `p` WHERE `p`.`Int` IN (999, @__i_0, `p`.`Id`, `p`.`Id` + `p`.`Int`) @@ -268,78 +272,6 @@ FROM JSON_TABLE('[2,999]', '$[*]' COLUMNS ( """); } - public override async Task Parameter_collection_of_ints_Contains_int(bool async) - { - await base.Parameter_collection_of_ints_Contains_int(async); - - if (SingleStoreTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) - { - AssertSql( -""" -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` -FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Int` IN ( - SELECT `i`.`value` - FROM JSON_TABLE('[10,999]', '$[*]' COLUMNS ( - `key` FOR ORDINALITY, - `value` int PATH '$[0]' - )) AS `i` -) -"""); - } - else - { - AssertSql( -""" -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` -FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Int` IN (10, 999) -""", - // - """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` -FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Int` NOT IN (10, 999) -"""); - } - } - - public override async Task Parameter_collection_of_ints_Contains_nullable_int(bool async) - { - await base.Parameter_collection_of_ints_Contains_nullable_int(async); - - if (SingleStoreTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) - { - AssertSql( -""" -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` -FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`Int` IN ( - SELECT `n`.`value` - FROM JSON_TABLE('[10,999]', '$[*]' COLUMNS ( - `key` FOR ORDINALITY, - `value` int PATH '$[0]' - )) AS `n` -) -"""); - } - else - { - AssertSql( -""" -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` -FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`NullableInt` IN (10, 999) -""", - // - """ -SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` -FROM `PrimitiveCollectionsEntity` AS `p` -WHERE `p`.`NullableInt` NOT IN (10, 999) OR (`p`.`NullableInt` IS NULL) -"""); - } - } - public override async Task Parameter_collection_of_nullable_ints_Contains_int(bool async) { await base.Parameter_collection_of_nullable_ints_Contains_int(async); @@ -361,7 +293,7 @@ FROM JSON_TABLE('[10,999]', '$[*]' COLUMNS ( } else { - AssertSql( + AssertSql( """ SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` FROM `PrimitiveCollectionsEntity` AS `p` @@ -397,7 +329,7 @@ FROM JSON_TABLE('[null,999]', '$[*]' COLUMNS ( } else { - AssertSql( + AssertSql( """ SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` FROM `PrimitiveCollectionsEntity` AS `p` @@ -428,12 +360,12 @@ FROM JSON_TABLE('["999",null]', '$[*]' COLUMNS ( `key` FOR ORDINALITY, `value` longtext PATH '$[0]' )) AS `s` -WHERE (`s`.`value` = `p`.`NullableString`) OR (`s`.`value` IS NULL AND (`p`.`NullableString` IS NULL))) + WHERE (`s`.`value` = `p`.`NullableString`) OR (`s`.`value` IS NULL AND (`p`.`NullableString` IS NULL))) """); } else { - AssertSql( + AssertSql( """ SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` FROM `PrimitiveCollectionsEntity` AS `p` @@ -854,6 +786,7 @@ public override async Task Parameter_collection_index_Column_equal_Column(bool a AssertSql( """ @__ints_0='[0,2,3]' (Size = 4000) + SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` FROM `PrimitiveCollectionsEntity` AS `p` WHERE CAST(JSON_UNQUOTE(JSON_EXTRACT(@__ints_0, CONCAT('$[', CAST(`p`.`Int` AS char), ']'))) AS signed) = `p`.`Int` @@ -867,6 +800,7 @@ public override async Task Parameter_collection_index_Column_equal_constant(bool AssertSql( """ @__ints_0='[1,2,3]' (Size = 4000) + SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` FROM `PrimitiveCollectionsEntity` AS `p` WHERE CAST(JSON_UNQUOTE(JSON_EXTRACT(@__ints_0, CONCAT('$[', CAST(`p`.`Int` AS char), ']'))) AS signed) = 1 @@ -1146,6 +1080,7 @@ public override async Task Column_collection_equality_parameter_collection(bool AssertSql( """ @__ints_0='[1,10]' (Size = 4000) + SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` FROM `PrimitiveCollectionsEntity` AS `p` WHERE `p`.`Ints` = @__ints_0 @@ -1696,14 +1631,14 @@ public override async Task Nested_contains_with_Lists_and_no_inferred_type_mappi await base.Nested_contains_with_Lists_and_no_inferred_type_mapping(async); AssertSql( - """ - SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` - FROM `PrimitiveCollectionsEntity` AS `p` - WHERE CASE - WHEN `p`.`Int` IN (1, 2, 3) THEN 'one' - ELSE 'two' - END IN ('one', 'two', 'three') - """); +""" +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE CASE + WHEN `p`.`Int` IN (1, 2, 3) THEN 'one' + ELSE 'two' +END IN ('one', 'two', 'three') +"""); } public override async Task Nested_contains_with_arrays_and_no_inferred_type_mapping(bool async) @@ -1711,19 +1646,50 @@ public override async Task Nested_contains_with_arrays_and_no_inferred_type_mapp await base.Nested_contains_with_arrays_and_no_inferred_type_mapping(async); AssertSql( - """ - SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` - FROM `PrimitiveCollectionsEntity` AS `p` - WHERE CASE - WHEN `p`.`Int` IN (1, 2, 3) THEN 'one' - ELSE 'two' - END IN ('one', 'two', 'three') - """); +""" +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE CASE + WHEN `p`.`Int` IN (1, 2, 3) THEN 'one' + ELSE 'two' +END IN ('one', 'two', 'three') +"""); } - public override async Task Inline_collection_Contains_with_EF_Constant(bool async) + public override async Task Inline_collection_with_single_parameter_element_Contains(bool async) { - await base.Inline_collection_Contains_with_EF_Constant(async); + await base.Inline_collection_with_single_parameter_element_Contains(async); + + AssertSql( +""" +@__i_0='2' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE `p`.`Id` = @__i_0 +"""); + } + + public override async Task Inline_collection_with_single_parameter_element_Count(bool async) + { + await base.Inline_collection_with_single_parameter_element_Count(async); + + AssertSql( +""" +@__i_0='2' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE ( + SELECT COUNT(*) + FROM (SELECT CAST(@__i_0 AS signed) AS `Value`) AS `v` + WHERE `v`.`Value` > `p`.`Id`) = 1 +"""); + } + + public override async Task Parameter_collection_Contains_with_EF_Constant(bool async) + { + await base.Parameter_collection_Contains_with_EF_Constant(async); AssertSql( """ @@ -1733,6 +1699,128 @@ public override async Task Inline_collection_Contains_with_EF_Constant(bool asyn """); } + public override async Task Parameter_collection_Where_with_EF_Constant_Where_Any(bool async) + { + await base.Parameter_collection_Where_with_EF_Constant_Where_Any(async); + + var rowSql = AppConfig.ServerVersion.Supports.ValuesWithRows ? "ROW" : string.Empty; + + AssertSql( +$""" +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE EXISTS ( + SELECT 1 + FROM (SELECT 2 AS `Value` UNION ALL VALUES {rowSql}(999), {rowSql}(1000)) AS `i` + WHERE `i`.`Value` > 0) +"""); + } + + public override async Task Parameter_collection_Count_with_column_predicate_with_EF_Constant(bool async) + { + await base.Parameter_collection_Count_with_column_predicate_with_EF_Constant(async); + + var rowSql = AppConfig.ServerVersion.Supports.ValuesWithRows ? "ROW" : string.Empty; + + AssertSql( +$""" +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE ( + SELECT COUNT(*) + FROM (SELECT 2 AS `Value` UNION ALL VALUES {rowSql}(999), {rowSql}(1000)) AS `i` + WHERE `i`.`Value` > `p`.`Id`) = 2 +"""); + } + + public override async Task Inline_collection_Min_with_two_values(bool async) + { + await base.Inline_collection_Min_with_two_values(async); + + AssertSql( +""" +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE LEAST(30, `p`.`Int`) = 30 +"""); + } + + public override async Task Inline_collection_Max_with_two_values(bool async) + { + await base.Inline_collection_Max_with_two_values(async); + + AssertSql( +""" +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE GREATEST(30, `p`.`Int`) = 30 +"""); + } + + public override async Task Inline_collection_Min_with_three_values(bool async) + { + await base.Inline_collection_Min_with_three_values(async); + + AssertSql( +""" +@__i_0='25' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE LEAST(30, `p`.`Int`, @__i_0) = 25 +"""); + } + + public override async Task Inline_collection_Max_with_three_values(bool async) + { + await base.Inline_collection_Max_with_three_values(async); + + AssertSql( +""" +@__i_0='35' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE GREATEST(30, `p`.`Int`, @__i_0) = 35 +"""); + } + + public override async Task Parameter_collection_of_ints_Contains_int(bool async) + { + await base.Parameter_collection_of_ints_Contains_int(async); + + AssertSql( +""" +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE `p`.`Int` IN (10, 999) +""", + // + """ +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE `p`.`Int` NOT IN (10, 999) +"""); + } + + public override async Task Parameter_collection_of_ints_Contains_nullable_int(bool async) + { + await base.Parameter_collection_of_ints_Contains_nullable_int(async); + + AssertSql( +""" +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE `p`.`NullableInt` IN (10, 999) +""", + // + """ +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE `p`.`NullableInt` NOT IN (10, 999) OR (`p`.`NullableInt` IS NULL) +"""); + } + public override async Task Parameter_collection_of_strings_Contains_string(bool async) { await base.Parameter_collection_of_strings_Contains_string(async); @@ -1787,23 +1875,376 @@ public override async Task Parameter_collection_of_nullable_strings_Contains_nul """); } + public override async Task Column_collection_SelectMany(bool async) + { + await base.Column_collection_SelectMany(async); + + AssertSql(""); + } + + public override async Task Project_collection_of_ints_with_ToList_and_FirstOrDefault(bool async) + { + await base.Project_collection_of_ints_with_ToList_and_FirstOrDefault(async); + + AssertSql( +""" +SELECT `p`.`Ints` +FROM `PrimitiveCollectionsEntity` AS `p` +ORDER BY `p`.`Id` +LIMIT 1 +"""); + } + + public override async Task Project_inline_collection_with_Concat(bool async) + { + await base.Project_inline_collection_with_Concat(async); + + AssertSql(); + } + + public override async Task Column_collection_Where_equality_inline_collection(bool async) + { + await base.Column_collection_Where_equality_inline_collection(async); + + AssertSql(); + } + + public override async Task Inline_collection_List_Contains_with_mixed_value_types(bool async) + { + await base.Inline_collection_List_Contains_with_mixed_value_types(async); + + AssertSql( +""" +@__i_0='11' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE `p`.`Int` IN (999, @__i_0, `p`.`Id`, `p`.`Id` + `p`.`Int`) +"""); + } + + public override async Task Inline_collection_List_Min_with_two_values(bool async) + { + await base.Inline_collection_List_Min_with_two_values(async); + + AssertSql( +""" +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE LEAST(30, `p`.`Int`) = 30 +"""); + } + + public override async Task Inline_collection_List_Max_with_two_values(bool async) + { + await base.Inline_collection_List_Max_with_two_values(async); + + AssertSql( +""" +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE GREATEST(30, `p`.`Int`) = 30 +"""); + } + + public override async Task Inline_collection_List_Min_with_three_values(bool async) + { + await base.Inline_collection_List_Min_with_three_values(async); + + AssertSql( +""" +@__i_0='25' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE LEAST(30, `p`.`Int`, @__i_0) = 25 +"""); + } + + public override async Task Inline_collection_List_Max_with_three_values(bool async) + { + await base.Inline_collection_List_Max_with_three_values(async); + + AssertSql( +""" +@__i_0='35' + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE GREATEST(30, `p`.`Int`, @__i_0) = 35 +"""); + } + + public override async Task Inline_collection_of_nullable_value_type_Min(bool async) + { + if (AppConfig.ServerVersion.Supports.FieldReferenceInTableValueConstructor) + { + await base.Inline_collection_of_nullable_value_type_Min(async); + + AssertSql( +""" +@__i_0='25' (Nullable = true) + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE ( + SELECT MIN(`v`.`Value`) + FROM (SELECT CAST(30 AS signed) AS `Value` UNION ALL VALUES ROW(`p`.`Int`), ROW(@__i_0)) AS `v`) = 25 +"""); + } + else + { + var exception = await Assert.ThrowsAsync(() => base.Inline_collection_of_nullable_value_type_Min(async)); + Assert.True(exception.Message is "Field reference 'p.Int' can't be used in table value constructor" + or "Unknown table 'p' in order clause"); + } + } + + public override async Task Inline_collection_of_nullable_value_type_Max(bool async) + { + if (AppConfig.ServerVersion.Supports.FieldReferenceInTableValueConstructor) + { + await base.Inline_collection_of_nullable_value_type_Max(async); + + AssertSql( +""" +@__i_0='35' (Nullable = true) + +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE ( + SELECT MAX(`v`.`Value`) + FROM (SELECT CAST(30 AS signed) AS `Value` UNION ALL VALUES ROW(`p`.`Int`), ROW(@__i_0)) AS `v`) = 35 +"""); + } + else + { + var exception = await Assert.ThrowsAsync(() => base.Inline_collection_of_nullable_value_type_Max(async)); + Assert.True(exception.Message is "Field reference 'p.Int' can't be used in table value constructor" + or "Unknown table 'p' in order clause"); + } + } + + public override async Task Inline_collection_of_nullable_value_type_with_null_Min(bool async) + { + if (AppConfig.ServerVersion.Supports.FieldReferenceInTableValueConstructor) + { + await base.Inline_collection_of_nullable_value_type_with_null_Min(async); + + AssertSql( +""" +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE ( + SELECT MIN(`v`.`Value`) + FROM (SELECT CAST(30 AS signed) AS `Value` UNION ALL VALUES ROW(`p`.`NullableInt`), ROW(NULL)) AS `v`) = 30 +"""); + } + else + { + var exception = await Assert.ThrowsAsync(() => base.Inline_collection_of_nullable_value_type_with_null_Min(async)); + Assert.True(exception.Message is "Field reference 'p.NullableInt' can't be used in table value constructor" + or "Unknown table 'p' in order clause"); + } + } + + public override async Task Inline_collection_of_nullable_value_type_with_null_Max(bool async) + { + if (AppConfig.ServerVersion.Supports.FieldReferenceInTableValueConstructor) + { + await base.Inline_collection_of_nullable_value_type_with_null_Max(async); + + AssertSql( +""" +SELECT `p`.`Id`, `p`.`Bool`, `p`.`Bools`, `p`.`DateTime`, `p`.`DateTimes`, `p`.`Enum`, `p`.`Enums`, `p`.`Int`, `p`.`Ints`, `p`.`NullableInt`, `p`.`NullableInts`, `p`.`NullableString`, `p`.`NullableStrings`, `p`.`String`, `p`.`Strings` +FROM `PrimitiveCollectionsEntity` AS `p` +WHERE ( + SELECT MAX(`v`.`Value`) + FROM (SELECT CAST(30 AS signed) AS `Value` UNION ALL VALUES ROW(`p`.`NullableInt`), ROW(NULL)) AS `v`) = 30 +"""); + } + else + { + var exception = await Assert.ThrowsAsync(() => base.Inline_collection_of_nullable_value_type_with_null_Max(async)); + Assert.True(exception.Message is "Field reference 'p.NullableInt' can't be used in table value constructor" + or "Unknown table 'p' in order clause"); + } + } + + public override async Task Inline_collection_Contains_with_EF_Parameter(bool async) + { + await base.Inline_collection_Contains_with_EF_Parameter(async); + + AssertSql(); + } + + public override async Task Inline_collection_Count_with_column_predicate_with_EF_Parameter(bool async) + { + await base.Inline_collection_Count_with_column_predicate_with_EF_Parameter(async); + + AssertSql(); + } + + public override async Task Parameter_collection_HashSet_of_ints_Contains_int(bool async) + { + await base.Parameter_collection_HashSet_of_ints_Contains_int(async); + + AssertSql(); + } + public override async Task Column_collection_Count_with_predicate(bool async) { await base.Column_collection_Count_with_predicate(async); - AssertSql(""); + AssertSql(); } public override async Task Column_collection_Where_Count(bool async) { await base.Column_collection_Where_Count(async); - AssertSql(""); + AssertSql(); + } + + [SupportedServerVersionCondition(nameof(ServerVersionSupport.WhereSubqueryReferencesOuterQuery))] + public override async Task Inline_collection_value_index_Column(bool async) + { + await base.Inline_collection_value_index_Column(async); + + AssertSql(); + } + + [SupportedServerVersionCondition(nameof(ServerVersionSupport.WhereSubqueryReferencesOuterQuery))] + public override async Task Inline_collection_List_value_index_Column(bool async) + { + await base.Inline_collection_List_value_index_Column(async); + + AssertSql(); + } + + public override async Task Column_collection_First(bool async) + { + await base.Column_collection_First(async); + + AssertSql(); + } + + public override async Task Column_collection_FirstOrDefault(bool async) + { + await base.Column_collection_FirstOrDefault(async); + + AssertSql(); + } + + public override async Task Column_collection_Single(bool async) + { + await base.Column_collection_Single(async); + + AssertSql(); + } + + public override async Task Column_collection_SingleOrDefault(bool async) + { + await base.Column_collection_SingleOrDefault(async); + + AssertSql(); + } + + public override async Task Column_collection_Where_Skip(bool async) + { + await base.Column_collection_Where_Skip(async); + + AssertSql(); + } + + public override async Task Column_collection_Where_Take(bool async) + { + await base.Column_collection_Where_Take(async); + + AssertSql(); + } + + public override async Task Column_collection_Where_Skip_Take(bool async) + { + await base.Column_collection_Where_Skip_Take(async); + + AssertSql(); + } + + public override async Task Column_collection_Contains_over_subquery(bool async) + { + await base.Column_collection_Contains_over_subquery(async); + + AssertSql(); + } + + public override async Task Column_collection_Where_ElementAt(bool async) + { + await base.Column_collection_Where_ElementAt(async); + + AssertSql(); + } + + public override async Task Column_collection_SelectMany_with_filter(bool async) + { + await base.Column_collection_SelectMany_with_filter(async); + + AssertSql(); + } + + public override async Task Column_collection_SelectMany_with_Select_to_anonymous_type(bool async) + { + await base.Column_collection_SelectMany_with_Select_to_anonymous_type(async); + + AssertSql(); + } + + public override async Task Parameter_collection_with_type_inference_for_JsonScalarExpression(bool async) + { + await base.Parameter_collection_with_type_inference_for_JsonScalarExpression(async); + + AssertSql(); + } + + public override async Task Column_collection_Where_Union(bool async) + { + await base.Column_collection_Where_Union(async); + + AssertSql(); + } + + public override async Task Project_inline_collection(bool async) + { + await base.Project_inline_collection(async); + + AssertSql( +""" +SELECT `p`.`String` +FROM `PrimitiveCollectionsEntity` AS `p` +"""); + } + + public override async Task Project_inline_collection_with_Union(bool async) + { + await base.Project_inline_collection_with_Union(async); + + AssertSql( +""" +SELECT `p`.`Id`, `u`.`Value` +FROM `PrimitiveCollectionsEntity` AS `p` +LEFT JOIN LATERAL ( + SELECT `p`.`String` AS `Value` + UNION + SELECT `p0`.`String` AS `Value` + FROM `PrimitiveCollectionsEntity` AS `p0` +) AS `u` ON TRUE +ORDER BY `p`.`Id` +"""); } [ConditionalFact] public virtual void Check_all_tests_overridden() - => TestHelpers.AssertAllMethodsOverridden(GetType()); + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); @@ -1811,7 +2252,7 @@ private void AssertSql(params string[] expected) private PrimitiveCollectionsContext CreateContext() => Fixture.CreateContext(); - public class PrimitiveCollectionsQuerySingleStoreFixture : PrimitiveCollectionsQueryFixtureBase + public class PrimitiveCollectionsQuerySingleStoreFixture : PrimitiveCollectionsQueryFixtureBase, ITestSqlLoggerFactory { public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/QueryNavigationsSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/QueryNavigationsSingleStoreTest.cs index fd4873234..2bf048c4d 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/QueryNavigationsSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/QueryNavigationsSingleStoreTest.cs @@ -20,9 +20,6 @@ public NorthwindNavigationsQuerySingleStoreTest( //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - [ConditionalTheory(Skip = "SingleStore does not support this type of query: correlated subselect in ORDER BY")] public override Task Collection_orderby_nav_prop_count(bool async) { diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/SharedTypeQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/SharedTypeQuerySingleStoreTest.cs index eaa7d3d58..9b46abd46 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/SharedTypeQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/SharedTypeQuerySingleStoreTest.cs @@ -21,7 +21,7 @@ public class SharedTypeQuerySingleStoreTest : SharedTypeQueryRelationalTestBase public override async Task Can_use_shared_type_entity_type_in_query_filter(bool async) { var contextFactory = await InitializeAsync( - seed: c => c.Seed(), onModelCreating: modelBuilder => + seed: c => c.SeedAsync(), onModelCreating: modelBuilder => { modelBuilder.SharedTypeEntity>("STET", b => @@ -52,7 +52,7 @@ SELECT 1 public override async Task Can_use_shared_type_entity_type_in_query_filter_with_from_sql(bool async) { var contextFactory = await InitializeAsync( - seed: c => c.Seed(), onModelCreating: modelBuilder => + seed: c => c.SeedAsync(), onModelCreating: modelBuilder => { modelBuilder.SharedTypeEntity>("STET", b => @@ -64,7 +64,7 @@ public override async Task Can_use_shared_type_entity_type_in_query_filter_with_ }); }); - using var context = contextFactory.CreateContext(); + await using var context = contextFactory.CreateContext(); var query = context.Set(); var result = async ? await query.ToListAsync() @@ -84,10 +84,10 @@ SELECT 1 } [ConditionalFact] - public override void Ad_hoc_query_for_shared_type_entity_type_works() + public override async Task Ad_hoc_query_for_shared_type_entity_type_works() { - var contextFactory = Initialize( - seed: c => c.Seed(), onModelCreating: modelBuilder => + var contextFactory = await InitializeAsync( + seed: c => c.SeedAsync(), onModelCreating: modelBuilder => { modelBuilder.SharedTypeEntity>("STET", b => @@ -99,19 +99,19 @@ public override void Ad_hoc_query_for_shared_type_entity_type_works() }); }); - using var context = contextFactory.CreateContext(); + await using var context = contextFactory.CreateContext(); var result = context.Database.SqlQueryRaw( - ((RelationalTestStore)TestStore).NormalizeDelimitersInRawString(@"SELECT * FROM [ViewQuery24601]")); + ((RelationalTestStore)TestStore).NormalizeDelimitersInRawString(@"SELECT * FROM `ViewQuery24601`")); Assert.Empty(result); } [ConditionalFact] - public override void Ad_hoc_query_for_default_shared_type_entity_type_throws() + public override async Task Ad_hoc_query_for_default_shared_type_entity_type_throws() { - var contextFactory = Initialize( - seed: c => c.Seed(), onModelCreating: modelBuilder => + var contextFactory = await InitializeAsync( + seed: c => c.SeedAsync(), onModelCreating: modelBuilder => { modelBuilder.SharedTypeEntity>("STET", b => @@ -123,7 +123,7 @@ public override void Ad_hoc_query_for_default_shared_type_entity_type_throws() }); }); - using var context = contextFactory.CreateContext(); + await using var context = contextFactory.CreateContext(); Assert.Equal( CoreStrings.ClashingSharedType("Dictionary"), diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/SimpleQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/SimpleQuerySingleStoreTest.cs deleted file mode 100644 index 419e976b0..000000000 --- a/test/EFCore.SingleStore.FunctionalTests/Query/SimpleQuerySingleStoreTest.cs +++ /dev/null @@ -1,425 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.TestUtilities; -using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; -using EntityFrameworkCore.SingleStore.Tests; -using EntityFrameworkCore.SingleStore.Infrastructure; -using EntityFrameworkCore.SingleStore.Tests.TestUtilities.Attributes; -using Xunit; - -// ReSharper disable InconsistentNaming -namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query -{ - public class SimpleQuerySingleStoreTest : SimpleQueryRelationalTestBase - { - protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; - - public override async Task Multiple_nested_reference_navigations(bool async) - { - await base.Multiple_nested_reference_navigations(async); - - AssertSql( - @"@__p_0='3' - -SELECT `s`.`Id`, `s`.`Email`, `s`.`Logon`, `s`.`ManagerId`, `s`.`Name`, `s`.`SecondaryManagerId` -FROM `Staff` AS `s` -WHERE `s`.`Id` = @__p_0 -LIMIT 1", - // - @"@__id_0='1' - -SELECT `a`.`Id`, `a`.`Complete`, `a`.`Deleted`, `a`.`PeriodEnd`, `a`.`PeriodStart`, `a`.`StaffId`, `s`.`Id`, `s`.`Email`, `s`.`Logon`, `s`.`ManagerId`, `s`.`Name`, `s`.`SecondaryManagerId`, `s0`.`Id`, `s0`.`Email`, `s0`.`Logon`, `s0`.`ManagerId`, `s0`.`Name`, `s0`.`SecondaryManagerId`, `s1`.`Id`, `s1`.`Email`, `s1`.`Logon`, `s1`.`ManagerId`, `s1`.`Name`, `s1`.`SecondaryManagerId` -FROM `Appraisals` AS `a` -INNER JOIN `Staff` AS `s` ON `a`.`StaffId` = `s`.`Id` -LEFT JOIN `Staff` AS `s0` ON `s`.`ManagerId` = `s0`.`Id` -LEFT JOIN `Staff` AS `s1` ON `s`.`SecondaryManagerId` = `s1`.`Id` -WHERE `a`.`Id` = @__id_0 -LIMIT 2"); - } - - public override async Task Multiple_different_entity_type_from_different_namespaces(bool async) - { - var contextFactory = await InitializeAsync(); - using var context = contextFactory.CreateContext(); - var bad = context.Set().FromSqlRaw(@"SELECT cast(null as signed) AS MyValue").ToList(); // <-- MySQL uses `signed` instead of `int` in CAST() expressions - } - - [SupportedServerVersionCondition(nameof(ServerVersionSupport.OuterReferenceInMultiLevelSubquery))] - public override Task Group_by_multiple_aggregate_joining_different_tables(bool async) - { - return base.Group_by_multiple_aggregate_joining_different_tables(async); - } - - [SupportedServerVersionCondition(nameof(ServerVersionSupport.OuterReferenceInMultiLevelSubquery))] - public override Task Group_by_multiple_aggregate_joining_different_tables_with_query_filter(bool async) - { - return base.Group_by_multiple_aggregate_joining_different_tables_with_query_filter(async); - } - - [ConditionalTheory(Skip = "SingleStore does not support this type of query: scalar subselect references field belonging to outer select that is more than one level up")] - public override Task Aggregate_over_subquery_in_group_by_projection(bool async) - { - return base.Aggregate_over_subquery_in_group_by_projection(async); - } - - [ConditionalTheory(Skip = "SingleStore does not support this type of query: scalar subselect references field belonging to outer select that is more than one level up")] - public override Task Aggregate_over_subquery_in_group_by_projection_2(bool async) - { - return base.Aggregate_over_subquery_in_group_by_projection_2(async); - } - - [ConditionalTheory(Skip = "SingleStore does not support this type of query: scalar subselect references field belonging to outer select that is more than one level up")] - public override Task Group_by_aggregate_in_subquery_projection_after_group_by(bool async) - { - return base.Group_by_aggregate_in_subquery_projection_after_group_by(async); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public override async Task Bool_discriminator_column_works(bool async) - { - var contextFactory = await InitializeAsync(seed: c => c.Seed(), onModelCreating: modelBuilder => - { - // We're changing the data type of the fields from INT to BIGINT, because in SingleStore - // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - }); - - using var context = contextFactory.CreateContext(); - - var query = context.Authors.Include(e => e.Blog); - - var authors = async - ? await query.ToListAsync() - : query.ToList(); - - Assert.Equal(2, authors.Count); - } - - [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore")] - [MemberData(nameof(IsAsyncData))] - public override async Task GroupBy_Aggregate_over_navigations_repeated(bool async) - { - // We're skipping this test when we're running tests on Managed Service due to the specifics of - // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) - if (AppConfig.ManagedService) - { - return; - } - - var contextFactory = await InitializeAsync(seed: c => c.Seed(), onModelCreating: modelBuilder => - { - // We're changing the data type of the fields from INT to BIGINT, because in SingleStore - // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - }); - using var context = contextFactory.CreateContext(); - - var query = context - .Set() - .Where(x => x.OrderId != null) - .GroupBy(x => x.OrderId) - .Select(x => new - { - HourlyRate = x.Min(f => f.Order.HourlyRate), - CustomerId = x.Min(f => f.Project.Customer.Id), - CustomerName = x.Min(f => f.Project.Customer.Name), - }); - - var timeSheets = async - ? await query.ToListAsync() - : query.ToList(); - - Assert.Equal(2, timeSheets.Count); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public override async Task Unwrap_convert_node_over_projection_when_translating_contains_over_subquery(bool async) - { - var contextFactory = await InitializeAsync(seed: c => c.Seed(), onModelCreating: modelBuilder => - { - // We're changing the data type of the fields from INT to BIGINT, because in SingleStore - // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - }); - using var context = contextFactory.CreateContext(); - - var currentUserId = 1; - - var currentUserGroupIds = context.Memberships - .Where(m => m.UserId == currentUserId) - .Select(m => m.GroupId); - - var hasMembership = context.Memberships - .Where(m => currentUserGroupIds.Contains(m.GroupId)) - .Select(m => m.User); - - var query = context.Users - .Select(u => new - { - HasAccess = hasMembership.Contains(u) - }); - - var users = async - ? await query.ToListAsync() - : query.ToList(); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public override async Task Unwrap_convert_node_over_projection_when_translating_contains_over_subquery_2(bool async) - { - var contextFactory = await InitializeAsync(seed: c => c.Seed(), onModelCreating: modelBuilder => - { - // We're changing the data type of the fields from INT to BIGINT, because in SingleStore - // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - }); - using var context = contextFactory.CreateContext(); - - var currentUserId = 1; - - var currentUserGroupIds = context.Memberships - .Where(m => m.UserId == currentUserId) - .Select(m => m.Group); - - var hasMembership = context.Memberships - .Where(m => currentUserGroupIds.Contains(m.Group)) - .Select(m => m.User); - - var query = context.Users - .Select(u => new - { - HasAccess = hasMembership.Contains(u) - }); - - var users = async - ? await query.ToListAsync() - : query.ToList(); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public override async Task Unwrap_convert_node_over_projection_when_translating_contains_over_subquery_3(bool async) - { - var contextFactory = await InitializeAsync(seed: c => c.Seed(), onModelCreating: modelBuilder => - { - // We're changing the data type of the fields from INT to BIGINT, because in SingleStore - // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - }); - using var context = contextFactory.CreateContext(); - - var currentUserId = 1; - - var currentUserGroupIds = context.Memberships - .Where(m => m.UserId == currentUserId) - .Select(m => m.GroupId); - - var hasMembership = context.Memberships - .Where(m => currentUserGroupIds.Contains(m.GroupId)) - .Select(m => m.User); - - var query = context.Users - .Select(u => new - { - HasAccess = hasMembership.Any(e => e == u) - }); - - var users = async - ? await query.ToListAsync() - : query.ToList(); - } - - [ConditionalTheory] - [MemberData("IsAsyncData", new object[] {})] - public override async Task SelectMany_where_Select(bool async) - { - // We're skipping this test when we're running tests on Managed Service due to the specifics of - // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) - if (AppConfig.ManagedService) - { - return; - } - - var contextFactory = await this.InitializeAsync( - seed: (Action)(c => c.Seed()), - onModelCreating: modelBuilder => - { - // We're changing the data type of the fields from INT to BIGINT, because in SingleStore - // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - }); - - - using (Context26744 context = contextFactory.CreateContext()) - { - IQueryable source = context.Parents - .SelectMany(p => p.Children - .AsQueryable() - .Where(c => c.SomeNullableDateTime == null) - .OrderBy(c => c.SomeInteger) - .Take(1) - ) - .Where(c => c.SomeOtherNullableDateTime != null) - .Select(c => c.SomeNullableDateTime); - - List collection; - if (async) - collection = await source.ToListAsync(); - else - collection = source.ToList(); - - Assert.Single(collection); - } - } - - [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore")] - [MemberData("IsAsyncData", new object[] {})] - public override async Task Subquery_first_member_compared_to_null(bool async) - { - var contextFactory = await this.InitializeAsync( - seed: (Action)(c => c.Seed()), - onModelCreating: modelBuilder => - { - // We're changing the data type of the fields from INT to BIGINT, because in SingleStore - // on a sharded (distributed) table, AUTO_INCREMENT can only be used on a BIGINT column - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - - modelBuilder.Entity() - .Property(e => e.Id) - .HasColumnType("bigint"); - }); - - - using (Context26744 context = contextFactory.CreateContext()) - { - IQueryable source = context.Parents - .Where(p => p.Children - .Any(c => c.SomeNullableDateTime == null) && - p.Children - .Where(c => c.SomeNullableDateTime == null) - .OrderBy(c => c.SomeInteger) - .FirstOrDefault().SomeOtherNullableDateTime != null) - .Select(p => p.Children - .Where(c => c.SomeNullableDateTime == null) - .OrderBy(c => c.SomeInteger) - .FirstOrDefault().SomeOtherNullableDateTime); - - List collection; - if (async) - collection = await source.ToListAsync(); - else - collection = source.ToList(); - - Assert.Single(collection); - } - } - - [ConditionalTheory(Skip = "Can't access internal class to make changes in the contextFactory to be able to run this test")] - public override async Task Count_member_over_IReadOnlyCollection_works(bool async) - { - await base.Count_member_over_IReadOnlyCollection_works(async); - } - - [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore")] - public override async Task Enum_with_value_converter_matching_take_value(bool async) - { - await base.Enum_with_value_converter_matching_take_value(async); - } - } -} diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/SpatialGeographyQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/SpatialGeographyQuerySingleStoreTest.cs index a1cb81c47..19477419d 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/SpatialGeographyQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/SpatialGeographyQuerySingleStoreTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Query; @@ -156,10 +157,10 @@ public SpatialGeographyContext(DbContextOptions options) { } - public static void Seed(SpatialGeographyContext context, GeometryFactory factory) + public static async Task SeedAsync(SpatialGeographyContext context, GeometryFactory factory) { context.AddRange(SpatialGeographyData.CreateCities(factory)); - context.SaveChanges(); + await context.SaveChangesAsync(); } public class City @@ -201,7 +202,7 @@ public virtual IQueryable Set() } } - public class SpatialGeographyQuerySingleStoreFixture : SharedStoreFixtureBase, IQueryFixtureBase + public class SpatialGeographyQuerySingleStoreFixture : SharedStoreFixtureBase, IQueryFixtureBase, ITestSqlLoggerFactory { private GeometryFactory _geometryFactory; @@ -246,8 +247,8 @@ public override SpatialGeographyContext CreateContext() return context; } - protected override void Seed(SpatialGeographyContext context) - => SpatialGeographyContext.Seed(context, GeometryFactory); + protected override Task SeedAsync(SpatialGeographyContext context) + => SpatialGeographyContext.SeedAsync(context, GeometryFactory); public Func GetContextCreator() => CreateContext; diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/SpatialQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/SpatialQuerySingleStoreTest.cs index 1ca63e9f1..694ce8b39 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/SpatialQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/SpatialQuerySingleStoreTest.cs @@ -4,7 +4,9 @@ using Microsoft.EntityFrameworkCore.TestModels.SpatialModel; using NetTopologySuite.Geometries; using NetTopologySuite.Geometries.Utilities; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using EntityFrameworkCore.SingleStore.Infrastructure; +using EntityFrameworkCore.SingleStore.Tests; using EntityFrameworkCore.SingleStore.Tests.TestUtilities.Attributes; using Xunit; using Xunit.Abstractions; @@ -76,6 +78,981 @@ public override Task Combine_aggregate(bool async) Assert.Equal(eCollection.Geometries, aCollection.Geometries); }); + public override async Task SimpleSelect(bool async) + { + await base.SimpleSelect(async); + + AssertSql( +""" +SELECT `p`.`Id`, `p`.`Geometry`, `p`.`Group`, `p`.`Point`, `p`.`PointM`, `p`.`PointZ`, `p`.`PointZM` +FROM `PointEntity` AS `p` +""", + // + """ +SELECT `l`.`Id`, `l`.`LineString` +FROM `LineStringEntity` AS `l` +""", + // + """ +SELECT `p`.`Id`, `p`.`Polygon` +FROM `PolygonEntity` AS `p` +""", + // + """ +SELECT `m`.`Id`, `m`.`MultiLineString` +FROM `MultiLineStringEntity` AS `m` +"""); + } + + public override async Task WithConversion(bool async) + { + await base.WithConversion(async); + + AssertSql( +""" +SELECT `g`.`Id`, `g`.`Location` +FROM `GeoPointEntity` AS `g` +"""); + } + + public override async Task Area(bool async) + { + await base.Area(async); + + AssertSql( +""" +SELECT `p`.`Id`, ST_Area(`p`.`Polygon`) AS `Area` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task AsBinary(bool async) + { + await base.AsBinary(async); + + AssertSql( +""" +SELECT `p`.`Id`, ST_AsBinary(`p`.`Point`) AS `Binary` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task AsBinary_with_null_check(bool async) + { + await base.AsBinary_with_null_check(async); + + AssertSql( +""" +SELECT `p`.`Id`, CASE + WHEN `p`.`Point` IS NULL THEN NULL + ELSE ST_AsBinary(`p`.`Point`) +END AS `Binary` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task AsText(bool async) + { + await base.AsText(async); + + AssertSql( +""" +SELECT `p`.`Id`, ST_AsText(`p`.`Point`) AS `Text` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task Buffer(bool async) + { + await base.Buffer(async); + + AssertSql( +""" +SELECT `p`.`Id`, ST_Buffer(`p`.`Polygon`, 1.0) AS `Buffer` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task Centroid(bool async) + { + await base.Centroid(async); + + AssertSql( +""" +SELECT `p`.`Id`, ST_Centroid(`p`.`Polygon`) AS `Centroid` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task EnvelopeCombine_aggregate(bool async) + { + await base.EnvelopeCombine_aggregate(async); + + AssertSql( +""" +SELECT `p1`.`Group`, `p2`.`Point`, `p2`.`Id` +FROM ( + SELECT `p`.`Group` + FROM `PointEntity` AS `p` + WHERE `p`.`Point` IS NOT NULL + GROUP BY `p`.`Group` +) AS `p1` +LEFT JOIN ( + SELECT `p0`.`Point`, `p0`.`Id`, `p0`.`Group` + FROM `PointEntity` AS `p0` + WHERE `p0`.`Point` IS NOT NULL +) AS `p2` ON `p1`.`Group` = `p2`.`Group` +ORDER BY `p1`.`Group` +"""); + } + + public override async Task Contains(bool async) + { + await base.Contains(async); + + AssertSql( +""" +@__point_0='0x000000000101000000000000000000D03F000000000000D03F' (DbType = Binary) +SELECT `p`.`Id`, ST_Contains(`p`.`Polygon`, @__point_0) AS `Contains` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task ConvexHull_aggregate(bool async) + { + await base.ConvexHull_aggregate(async); + + AssertSql( +""" +SELECT `p1`.`Group`, `p2`.`Point`, `p2`.`Id` +FROM ( + SELECT `p`.`Group` + FROM `PointEntity` AS `p` + WHERE `p`.`Point` IS NOT NULL + GROUP BY `p`.`Group` +) AS `p1` +LEFT JOIN ( + SELECT `p0`.`Point`, `p0`.`Id`, `p0`.`Group` + FROM `PointEntity` AS `p0` + WHERE `p0`.`Point` IS NOT NULL +) AS `p2` ON `p1`.`Group` = `p2`.`Group` +ORDER BY `p1`.`Group` +"""); + } + + public override async Task IGeometryCollection_Count(bool async) + { + await base.IGeometryCollection_Count(async); + + AssertSql( +""" +SELECT `m`.`Id`, ST_NumGeometries(`m`.`MultiLineString`) AS `Count` +FROM `MultiLineStringEntity` AS `m` +"""); + } + + public override async Task LineString_Count(bool async) + { + await base.LineString_Count(async); + + AssertSql( +""" +SELECT `l`.`Id`, ST_NumPoints(`l`.`LineString`) AS `Count` +FROM `LineStringEntity` AS `l` +"""); + } + + public override async Task Crosses(bool async) + { + await base.Crosses(async); + + AssertSql( +""" +@__lineString_0='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) +SELECT `l`.`Id`, ST_Crosses(`l`.`LineString`, @__lineString_0) AS `Crosses` +FROM `LineStringEntity` AS `l` +"""); + } + + public override async Task Difference(bool async) + { + await base.Difference(async); + + AssertSql( +""" +@__polygon_0='0x0000000001030000000100000004000000000000000000000000000000000000...' (DbType = Binary) +SELECT `p`.`Id`, ST_Difference(`p`.`Polygon`, @__polygon_0) AS `Difference` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task Dimension(bool async) + { + await base.Dimension(async); + + AssertSql( +""" +SELECT `p`.`Id`, ST_Dimension(`p`.`Point`) AS `Dimension` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task Disjoint_with_cast_to_nullable(bool async) + { + await base.Disjoint_with_cast_to_nullable(async); + + AssertSql( +""" +@__point_0='0x000000000101000000000000000000F03F000000000000F03F' (DbType = Binary) +SELECT `p`.`Id`, ST_Disjoint(`p`.`Polygon`, @__point_0) AS `Disjoint` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task Disjoint_with_null_check(bool async) + { + await base.Disjoint_with_null_check(async); + + AssertSql( +""" +@__point_0='0x000000000101000000000000000000F03F000000000000F03F' (DbType = Binary) +SELECT `p`.`Id`, CASE + WHEN `p`.`Polygon` IS NULL THEN NULL + ELSE ST_Disjoint(`p`.`Polygon`, @__point_0) +END AS `Disjoint` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task Distance_with_null_check(bool async) + { + await base.Distance_with_null_check(async); + + AssertSql( + AppConfig.ServerVersion.Supports.SpatialDistanceSphereFunction + ? """ +@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +SELECT `p`.`Id`, CASE + WHEN ST_SRID(`p`.`Point`) = 4326 THEN ST_Distance_Sphere(`p`.`Point`, @__point_0) + ELSE ST_Distance(`p`.`Point`, @__point_0) +END AS `Distance` +FROM `PointEntity` AS `p` +""" + : """ +@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +SELECT `p`.`Id`, CASE + WHEN ST_SRID(`p`.`Point`) = 4326 THEN CASE + WHEN (((((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0) AND (((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0)) OR (((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0)) OR (((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0) THEN 0.0 + ELSE ((2.0 * ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) * 6378137.0) * (1.0 + (((6378137.0 - 6356752.3142451793) / 6378137.0) * (((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) - 1.0) / (2.0 * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) - ((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) + 1.0) / (2.0 * ((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) + END + ELSE ST_Distance(`p`.`Point`, @__point_0) +END AS `Distance` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task Distance_with_cast_to_nullable(bool async) + { + await base.Distance_with_cast_to_nullable(async); + + AssertSql( + AppConfig.ServerVersion.Supports.SpatialDistanceSphereFunction + ? """ +@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +SELECT `p`.`Id`, CASE + WHEN ST_SRID(`p`.`Point`) = 4326 THEN ST_Distance_Sphere(`p`.`Point`, @__point_0) + ELSE ST_Distance(`p`.`Point`, @__point_0) +END AS `Distance` +FROM `PointEntity` AS `p` +""" + : """ +@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +SELECT `p`.`Id`, CASE + WHEN ST_SRID(`p`.`Point`) = 4326 THEN CASE + WHEN (((((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0) AND (((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0)) OR (((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0)) OR (((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0) THEN 0.0 + ELSE ((2.0 * ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) * 6378137.0) * (1.0 + (((6378137.0 - 6356752.3142451793) / 6378137.0) * (((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) - 1.0) / (2.0 * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) - ((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) + 1.0) / (2.0 * ((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) + END + ELSE ST_Distance(`p`.`Point`, @__point_0) +END AS `Distance` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task Distance_geometry(bool async) + { + await base.Distance_geometry(async); + + AssertSql( + AppConfig.ServerVersion.Supports.SpatialDistanceSphereFunction + ? """ +@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +SELECT `p`.`Id`, CASE + WHEN ST_SRID(`p`.`Geometry`) = 4326 THEN ST_Distance_Sphere(`p`.`Geometry`, @__point_0) + ELSE ST_Distance(`p`.`Geometry`, @__point_0) +END AS `Distance` +FROM `PointEntity` AS `p` +""" + : """ +@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +SELECT `p`.`Id`, CASE + WHEN ST_SRID(`p`.`Geometry`) = 4326 THEN CASE + WHEN (((((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0) AND (((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0)) OR (((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0)) OR (((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0) THEN 0.0 + ELSE ((2.0 * ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) * 6378137.0) * (1.0 + (((6378137.0 - 6356752.3142451793) / 6378137.0) * (((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) - 1.0) / (2.0 * ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) - ((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) + 1.0) / (2.0 * ((POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Geometry`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(COS((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(SIN((((ST_Y(`p`.`Geometry`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) + END + ELSE ST_Distance(`p`.`Geometry`, @__point_0) +END AS `Distance` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task Distance_constant(bool async) + { + await base.Distance_constant(async); + + AssertSql( + AppConfig.ServerVersion.Supports.SpatialDistanceSphereFunction + ? """ +SELECT `p`.`Id`, CASE + WHEN ST_SRID(`p`.`Point`) = 4326 THEN ST_Distance_Sphere(`p`.`Point`, X'0000000001010000000000000000000000000000000000F03F') + ELSE ST_Distance(`p`.`Point`, X'0000000001010000000000000000000000000000000000F03F') +END AS `Distance` +FROM `PointEntity` AS `p` +""" + : """ +SELECT `p`.`Id`, CASE + WHEN ST_SRID(`p`.`Point`) = 4326 THEN CASE + WHEN (((((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0) = 0.0) AND (((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0) = 0.0)) OR (((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2))) = 0.0)) OR (((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2))) = 0.0) THEN 0.0 + ELSE ((2.0 * ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)))))) * 6378137.0) * (1.0 + (((6378137.0 - 6356752.3142451793) / 6378137.0) * (((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)))))) - 1.0) / (2.0 * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2))))) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) - ((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)))))) + 1.0) / (2.0 * ((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2))))) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2)) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0)) / 2.0), 2))))) + END + ELSE ST_Distance(`p`.`Point`, X'0000000001010000000000000000000000000000000000F03F') +END AS `Distance` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task Distance_constant_lhs(bool async) + { + await base.Distance_constant_lhs(async); + + AssertSql( + AppConfig.ServerVersion.Supports.SpatialDistanceSphereFunction + ? """ +SELECT `p`.`Id`, CASE + WHEN ST_SRID(X'0000000001010000000000000000000000000000000000F03F') = 4326 THEN ST_Distance_Sphere(X'0000000001010000000000000000000000000000000000F03F', `p`.`Point`) + ELSE ST_Distance(X'0000000001010000000000000000000000000000000000F03F', `p`.`Point`) +END AS `Distance` +FROM `PointEntity` AS `p` +""" + : """ +SELECT `p`.`Id`, CASE + WHEN ST_SRID(X'0000000001010000000000000000000000000000000000F03F') = 4326 THEN CASE + WHEN (((((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0) = 0.0) AND (((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0) = 0.0)) OR (((POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2))) = 0.0)) OR (((POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2))) = 0.0) THEN 0.0 + ELSE ((2.0 * ATAN(SQRT(((POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)))))) * 6378137.0) * (1.0 + (((6378137.0 - 6356752.3142451793) / 6378137.0) * (((((((3.0 * SQRT(((POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)))))) - 1.0) / (2.0 * ((POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2))))) * POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) * POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) - ((((((3.0 * SQRT(((POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)))))) + 1.0) / (2.0 * ((POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_X(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2))))) * POWER(COS((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) + ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2)) * POWER(SIN((((ST_Y(X'0000000001010000000000000000000000000000000000F03F') * PI()) / 180.0) - ((ST_Y(`p`.`Point`) * PI()) / 180.0)) / 2.0), 2))))) + END + ELSE ST_Distance(X'0000000001010000000000000000000000000000000000F03F', `p`.`Point`) +END AS `Distance` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task Distance_on_converted_geometry_type(bool async) + { + await base.Distance_on_converted_geometry_type(async); + + AssertSql( +""" +SELECT `g`.`Id`, `g`.`Location` +FROM `GeoPointEntity` AS `g` +"""); + } + + public override async Task Distance_on_converted_geometry_type_lhs(bool async) + { + await base.Distance_on_converted_geometry_type_lhs(async); + + AssertSql( +""" +SELECT `g`.`Id`, `g`.`Location` +FROM `GeoPointEntity` AS `g` +"""); + } + + public override async Task Distance_on_converted_geometry_type_constant(bool async) + { + await base.Distance_on_converted_geometry_type_constant(async); + + AssertSql( +""" +SELECT `g`.`Id`, `g`.`Location` +FROM `GeoPointEntity` AS `g` +"""); + } + + public override async Task Distance_on_converted_geometry_type_constant_lhs(bool async) + { + await base.Distance_on_converted_geometry_type_constant_lhs(async); + + AssertSql( +""" +SELECT `g`.`Id`, `g`.`Location` +FROM `GeoPointEntity` AS `g` +"""); + } + + public override async Task EndPoint(bool async) + { + await base.EndPoint(async); + + AssertSql( +""" +SELECT `l`.`Id`, ST_EndPoint(`l`.`LineString`) AS `EndPoint` +FROM `LineStringEntity` AS `l` +"""); + } + + public override async Task Envelope(bool async) + { + await base.Envelope(async); + + AssertSql( +""" +SELECT `p`.`Id`, ST_Envelope(`p`.`Polygon`) AS `Envelope` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task EqualsTopologically(bool async) + { + await base.EqualsTopologically(async); + + AssertSql( +""" +@__point_0='0x00000000010100000000000000000000000000000000000000' (DbType = Binary) +SELECT `p`.`Id`, ST_Equals(`p`.`Point`, @__point_0) AS `EqualsTopologically` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task ExteriorRing(bool async) + { + await base.ExteriorRing(async); + + AssertSql( +""" +SELECT `p`.`Id`, ST_ExteriorRing(`p`.`Polygon`) AS `ExteriorRing` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task GetGeometryN(bool async) + { + await base.GetGeometryN(async); + + AssertSql( +""" +SELECT `m`.`Id`, ST_GeometryN(`m`.`MultiLineString`, 0 + 1) AS `Geometry0` +FROM `MultiLineStringEntity` AS `m` +"""); + } + + public override async Task GetGeometryN_with_null_argument(bool async) + { + await base.GetGeometryN_with_null_argument(async); + + AssertSql( +""" +SELECT `m`.`Id`, ST_GeometryN(`m`.`MultiLineString`, ( + SELECT MAX(`m0`.`Id`) + FROM `MultiLineStringEntity` AS `m0` + WHERE FALSE) + 1) AS `Geometry0` +FROM `MultiLineStringEntity` AS `m` +"""); + } + + public override async Task GetInteriorRingN(bool async) + { + await base.GetInteriorRingN(async); + + AssertSql( +""" +SELECT `p`.`Id`, CASE + WHEN ST_NumInteriorRings(`p`.`Polygon`) = 0 THEN NULL + ELSE ST_InteriorRingN(`p`.`Polygon`, 0 + 1) +END AS `InteriorRing0` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task GetPointN(bool async) + { + await base.GetPointN(async); + + AssertSql( +""" +SELECT `l`.`Id`, ST_PointN(`l`.`LineString`, 0 + 1) AS `Point0` +FROM `LineStringEntity` AS `l` +"""); + } + + public override async Task Intersection(bool async) + { + await base.Intersection(async); + + AssertSql( +""" +@__polygon_0='0x0000000001030000000100000004000000000000000000000000000000000000...' (DbType = Binary) +SELECT `p`.`Id`, ST_Intersection(`p`.`Polygon`, @__polygon_0) AS `Intersection` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task Intersects(bool async) + { + await base.Intersects(async); + + AssertSql( +""" +@__lineString_0='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) +SELECT `l`.`Id`, ST_Intersects(`l`.`LineString`, @__lineString_0) AS `Intersects` +FROM `LineStringEntity` AS `l` +"""); + } + + public override async Task ICurve_IsClosed(bool async) + { + await base.ICurve_IsClosed(async); + + AssertSql( +""" +SELECT `l`.`Id`, CASE + WHEN `l`.`LineString` IS NULL THEN NULL + ELSE ST_IsClosed(`l`.`LineString`) +END AS `IsClosed` +FROM `LineStringEntity` AS `l` +"""); + } + + public override async Task IMultiCurve_IsClosed(bool async) + { + await base.IMultiCurve_IsClosed(async); + + AssertSql( +""" +SELECT `m`.`Id`, CASE + WHEN `m`.`MultiLineString` IS NULL THEN NULL + ELSE ST_IsClosed(`m`.`MultiLineString`) +END AS `IsClosed` +FROM `MultiLineStringEntity` AS `m` +"""); + } + + public override async Task IsEmpty(bool async) + { + await base.IsEmpty(async); + + AssertSql( +""" +SELECT `m`.`Id`, CASE + WHEN `m`.`MultiLineString` IS NULL THEN NULL + ELSE ST_IsEmpty(`m`.`MultiLineString`) +END AS `IsEmpty` +FROM `MultiLineStringEntity` AS `m` +"""); + } + + public override async Task IsRing(bool async) + { + await base.IsRing(async); + + AssertSql( + AppConfig.ServerVersion.Supports.SpatialFunctionAdditions + ? """ +SELECT `l`.`Id`, CASE + WHEN `l`.`LineString` IS NULL THEN NULL + ELSE ST_IsRing(`l`.`LineString`) +END AS `IsRing` +FROM `LineStringEntity` AS `l` +""" + : """ +SELECT `l`.`Id`, CASE + WHEN `l`.`LineString` IS NULL THEN NULL + ELSE ST_IsClosed(`l`.`LineString`) AND ST_IsSimple(`l`.`LineString`) +END AS `IsRing` +FROM `LineStringEntity` AS `l` +"""); + } + + public override async Task IsSimple(bool async) + { + await base.IsSimple(async); + + AssertSql( +""" +SELECT `l`.`Id`, CASE + WHEN `l`.`LineString` IS NULL THEN NULL + ELSE ST_IsSimple(`l`.`LineString`) +END AS `IsSimple` +FROM `LineStringEntity` AS `l` +"""); + } + + public override async Task IsWithinDistance(bool async) + { + await base.IsWithinDistance(async); + + AssertSql( + AppConfig.ServerVersion.Supports.SpatialDistanceSphereFunction + ? """ +@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +SELECT `p`.`Id`, CASE + WHEN CASE + WHEN ST_SRID(`p`.`Point`) = 4326 THEN ST_Distance_Sphere(`p`.`Point`, @__point_0) + ELSE ST_Distance(`p`.`Point`, @__point_0) + END <= 1.0 THEN TRUE + ELSE FALSE +END AS `IsWithinDistance` +FROM `PointEntity` AS `p` +""" + : """ +@__point_0='0x0000000001010000000000000000000000000000000000F03F' (DbType = Binary) +SELECT `p`.`Id`, CASE + WHEN CASE + WHEN ST_SRID(`p`.`Point`) = 4326 THEN CASE + WHEN (((((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0) AND (((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0) = 0.0)) OR (((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0)) OR (((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) = 0.0) THEN 0.0 + ELSE ((2.0 * ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) * 6378137.0) * (1.0 + (((6378137.0 - 6356752.3142451793) / 6378137.0) * (((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) - 1.0) / (2.0 * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) - ((((((3.0 * SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) * ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) / ATAN(SQRT(((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))) / ((POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)))))) + 1.0) / (2.0 * ((POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(COS((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2)) + (POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2) * POWER(SIN((((ST_X(`p`.`Point`) * PI()) / 180.0) - ((ST_X(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) * POWER(COS((((ST_Y(`p`.`Point`) * PI()) / 180.0) + ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2)) * POWER(SIN((((ST_Y(`p`.`Point`) * PI()) / 180.0) - ((ST_Y(@__point_0) * PI()) / 180.0)) / 2.0), 2))))) + END + ELSE ST_Distance(`p`.`Point`, @__point_0) + END <= 1.0 THEN TRUE + ELSE FALSE +END AS `IsWithinDistance` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task Item(bool async) + { + await base.Item(async); + + AssertSql( +""" +SELECT `m`.`Id`, ST_GeometryN(`m`.`MultiLineString`, 0 + 1) AS `Item0` +FROM `MultiLineStringEntity` AS `m` +"""); + } + + public override async Task Length(bool async) + { + await base.Length(async); + + AssertSql( +""" +SELECT `l`.`Id`, ST_Length(`l`.`LineString`) AS `Length` +FROM `LineStringEntity` AS `l` +"""); + } + + public override async Task NumGeometries(bool async) + { + await base.NumGeometries(async); + + AssertSql( +""" +SELECT `m`.`Id`, ST_NumGeometries(`m`.`MultiLineString`) AS `NumGeometries` +FROM `MultiLineStringEntity` AS `m` +"""); + } + + public override async Task NumInteriorRings(bool async) + { + await base.NumInteriorRings(async); + + AssertSql( +""" +SELECT `p`.`Id`, ST_NumInteriorRings(`p`.`Polygon`) AS `NumInteriorRings` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task NumPoints(bool async) + { + await base.NumPoints(async); + + AssertSql( +""" +SELECT `l`.`Id`, ST_NumPoints(`l`.`LineString`) AS `NumPoints` +FROM `LineStringEntity` AS `l` +"""); + } + + public override async Task OgcGeometryType(bool async) + { + await base.OgcGeometryType(async); + + AssertSql( +""" +SELECT `p`.`Id`, CASE ST_GeometryType(`p`.`Point`) + WHEN 'Point' THEN 1 + WHEN 'LineString' THEN 2 + WHEN 'Polygon' THEN 3 + WHEN 'MultiPoint' THEN 4 + WHEN 'MultiLineString' THEN 5 + WHEN 'MultiPolygon' THEN 6 + WHEN 'GeometryCollection' THEN 7 + WHEN 'CircularString' THEN 8 + WHEN 'CompoundCurve' THEN 9 + WHEN 'CurvePolygon' THEN 10 +END AS `OgcGeometryType` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task Overlaps(bool async) + { + await base.Overlaps(async); + + AssertSql( +""" +@__polygon_0='0x0000000001030000000100000004000000000000000000000000000000000000...' (DbType = Binary) +SELECT `p`.`Id`, ST_Overlaps(`p`.`Polygon`, @__polygon_0) AS `Overlaps` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task SRID(bool async) + { + await base.SRID(async); + + AssertSql( +""" +SELECT `p`.`Id`, ST_SRID(`p`.`Point`) AS `SRID` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task SRID_geometry(bool async) + { + await base.SRID_geometry(async); + + AssertSql( +""" +SELECT `p`.`Id`, ST_SRID(`p`.`Geometry`) AS `SRID` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task StartPoint(bool async) + { + await base.StartPoint(async); + + AssertSql( +""" +SELECT `l`.`Id`, ST_StartPoint(`l`.`LineString`) AS `StartPoint` +FROM `LineStringEntity` AS `l` +"""); + } + + public override async Task SymmetricDifference(bool async) + { + await base.SymmetricDifference(async); + + AssertSql( +""" +@__polygon_0='0x0000000001030000000100000004000000000000000000000000000000000000...' (DbType = Binary) +SELECT `p`.`Id`, ST_SymDifference(`p`.`Polygon`, @__polygon_0) AS `SymmetricDifference` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task ToBinary(bool async) + { + await base.ToBinary(async); + + AssertSql( +""" +SELECT `p`.`Id`, ST_AsBinary(`p`.`Point`) AS `Binary` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task ToText(bool async) + { + await base.ToText(async); + + AssertSql( +""" +SELECT `p`.`Id`, ST_AsText(`p`.`Point`) AS `Text` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task Touches(bool async) + { + await base.Touches(async); + + AssertSql( +""" +@__polygon_0='0x00000000010300000001000000040000000000000000000000000000000000F0...' (DbType = Binary) +SELECT `p`.`Id`, ST_Touches(`p`.`Polygon`, @__polygon_0) AS `Touches` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task Union(bool async) + { + await base.Union(async); + + AssertSql( +""" +@__polygon_0='0x0000000001030000000100000004000000000000000000000000000000000000...' (DbType = Binary) +SELECT `p`.`Id`, ST_Union(`p`.`Polygon`, @__polygon_0) AS `Union` +FROM `PolygonEntity` AS `p` +"""); + } + + public override async Task Union_aggregate(bool async) + { + await base.Union_aggregate(async); + + AssertSql( +""" +SELECT `p1`.`Group`, `p2`.`Point`, `p2`.`Id` +FROM ( + SELECT `p`.`Group` + FROM `PointEntity` AS `p` + WHERE `p`.`Point` IS NOT NULL + GROUP BY `p`.`Group` +) AS `p1` +LEFT JOIN ( + SELECT `p0`.`Point`, `p0`.`Id`, `p0`.`Group` + FROM `PointEntity` AS `p0` + WHERE `p0`.`Point` IS NOT NULL +) AS `p2` ON `p1`.`Group` = `p2`.`Group` +ORDER BY `p1`.`Group` +"""); + } + + public override async Task Within(bool async) + { + await base.Within(async); + + AssertSql( +""" +@__polygon_0='0x0000000001030000000100000005000000000000000000F0BF000000000000F0...' (DbType = Binary) +SELECT `p`.`Id`, ST_Within(`p`.`Point`, @__polygon_0) AS `Within` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task X(bool async) + { + await base.X(async); + + AssertSql( +""" +SELECT `p`.`Id`, ST_X(`p`.`Point`) AS `X` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task Y(bool async) + { + await base.Y(async); + + AssertSql( +""" +SELECT `p`.`Id`, ST_Y(`p`.`Point`) AS `Y` +FROM `PointEntity` AS `p` +"""); + } + + public override async Task XY_with_collection_join(bool async) + { + await base.XY_with_collection_join(async); + + AssertSql( +""" +SELECT `p1`.`Id`, `p1`.`c`, `p1`.`c0`, `p0`.`Id`, `p0`.`Geometry`, `p0`.`Group`, `p0`.`Point`, `p0`.`PointM`, `p0`.`PointZ`, `p0`.`PointZM` +FROM ( + SELECT `p`.`Id`, ST_X(`p`.`Point`) AS `c`, ST_Y(`p`.`Point`) AS `c0` + FROM `PointEntity` AS `p` + ORDER BY `p`.`Id` + LIMIT 1 +) AS `p1` +LEFT JOIN `PointEntity` AS `p0` ON `p1`.`Id` = `p0`.`Id` +ORDER BY `p1`.`Id` +"""); + } + + public override async Task IsEmpty_equal_to_null(bool async) + { + await base.IsEmpty_equal_to_null(async); + + AssertSql( +""" +SELECT `p`.`Id` +FROM `PointEntity` AS `p` +WHERE CASE + WHEN `p`.`Point` IS NULL THEN NULL + ELSE ST_IsEmpty(`p`.`Point`) +END IS NULL +"""); + } + + public override async Task IsEmpty_not_equal_to_null(bool async) + { + await base.IsEmpty_not_equal_to_null(async); + + AssertSql( +""" +SELECT `p`.`Id` +FROM `PointEntity` AS `p` +WHERE CASE + WHEN `p`.`Point` IS NULL THEN NULL + ELSE ST_IsEmpty(`p`.`Point`) +END IS NOT NULL +"""); + } + + public override async Task Intersects_equal_to_null(bool async) + { + await base.Intersects_equal_to_null(async); + + AssertSql( +""" +@__lineString_0='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) +SELECT `l`.`Id` +FROM `LineStringEntity` AS `l` +WHERE ST_Intersects(`l`.`LineString`, @__lineString_0) IS NULL +""", + // + """ +@__lineString_0='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) +SELECT `l`.`Id` +FROM `LineStringEntity` AS `l` +WHERE ST_Intersects(@__lineString_0, `l`.`LineString`) IS NULL +"""); + } + + public override async Task Intersects_not_equal_to_null(bool async) + { + await base.Intersects_not_equal_to_null(async); + + AssertSql( +""" +@__lineString_0='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) +SELECT `l`.`Id` +FROM `LineStringEntity` AS `l` +WHERE ST_Intersects(`l`.`LineString`, @__lineString_0) IS NOT NULL +""", + // + """ +@__lineString_0='0x00000000010200000002000000000000000000E03F000000000000E0BF000000...' (DbType = Binary) +SELECT `l`.`Id` +FROM `LineStringEntity` AS `l` +WHERE ST_Intersects(@__lineString_0, `l`.`LineString`) IS NOT NULL +"""); + } + #region Not supported by MySQL and MariaDB public override Task Buffer_quadrantSegments(bool async) => Task.CompletedTask; @@ -89,6 +1066,10 @@ public override Task Combine_aggregate(bool async) #endregion + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/SqlExecutorSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/SqlExecutorSingleStoreTest.cs index 27a72c26b..86301e055 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/SqlExecutorSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/SqlExecutorSingleStoreTest.cs @@ -2,16 +2,16 @@ using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.TestUtilities; +using Microsoft.EntityFrameworkCore.TestModels.ConcurrencyModel; using SingleStoreConnector; using Xunit; using Xunit.Abstractions; namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query { - public class SqlExecutorSingleStoreTest : SqlExecutorTestBase> + public class SqlExecutorSingleStoreTest : SqlExecutorTestBase> { - public SqlExecutorSingleStoreTest(NorthwindQuerySingleStoreFixture fixture, ITestOutputHelper testOutputHelper) + public SqlExecutorSingleStoreTest(NorthwindQuerySingleStoreFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); @@ -222,6 +222,25 @@ public override async Task Query_with_DbParameters_interpolated(bool async) Assert.Equal(DefaultSqlResult, actual); } + public override async Task Query_with_parameters_custom_converter(bool async) + { + // We have to reimplement the base method, because it uses double-quote delimiters, while MySQL uses ticks. + // await base.Query_with_parameters_custom_converter(async); + + var city = new City { Name = "London" }; + var contactTitle = "Sales Representative"; + + using var context = CreateContext(); + + var actual = async + ? await context.Database.ExecuteSqlAsync( + $@"SELECT COUNT(*) FROM `Customers` WHERE `City` = {city} AND `ContactTitle` = {contactTitle}") + : context.Database.ExecuteSql( + $@"SELECT COUNT(*) FROM `Customers` WHERE `City` = {city} AND `ContactTitle` = {contactTitle}"); + + Assert.Equal(-1, actual); + } + protected override DbParameter CreateDbParameter(string name, object value) => new SingleStoreParameter { diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/SqlQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/SqlQuerySingleStoreTest.cs index b9f9511d2..f43ef4442 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/SqlQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/SqlQuerySingleStoreTest.cs @@ -3,8 +3,10 @@ using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; using SingleStoreConnector; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using EntityFrameworkCore.SingleStore.Infrastructure; using EntityFrameworkCore.SingleStore.Tests.TestUtilities.Attributes; +using Xunit; using Xunit.Abstractions; namespace EntityFrameworkCore.SingleStore.FunctionalTests.Query; @@ -693,6 +695,181 @@ public override async Task Multiple_occurrences_of_SqlQuery_with_db_parameter_ad """); } + public override async Task Bad_data_error_handling_invalid_cast_key(bool async) + { + await base.Bad_data_error_handling_invalid_cast_key(async); + + AssertSql( +""" +SELECT `ProductName` AS `ProductID`, `ProductID` AS `ProductName`, `SupplierID`, `UnitPrice`, `UnitsInStock`, `Discontinued` + FROM `Products` +"""); + } + + public override async Task Bad_data_error_handling_invalid_cast(bool async) + { + await base.Bad_data_error_handling_invalid_cast(async); + + AssertSql( +""" +SELECT `ProductID`, `ProductName` AS `UnitPrice`, `ProductName`, `SupplierID`, `UnitsInStock`, `Discontinued` + FROM `Products` +"""); + } + + public override async Task Bad_data_error_handling_invalid_cast_projection(bool async) + { + await base.Bad_data_error_handling_invalid_cast_projection(async); + + AssertSql( +""" +SELECT `m`.`UnitPrice` +FROM ( + SELECT `ProductID`, `ProductName` AS `UnitPrice`, `ProductName`, `UnitsInStock`, `Discontinued` + FROM `Products` +) AS `m` +"""); + } + + public override async Task Bad_data_error_handling_invalid_cast_no_tracking(bool async) + { + await base.Bad_data_error_handling_invalid_cast_no_tracking(async); + + AssertSql( +""" +SELECT `ProductName` AS `ProductID`, `ProductID` AS `ProductName`, `SupplierID`, `UnitPrice`, `UnitsInStock`, `Discontinued` + FROM `Products` +"""); + } + + public override async Task Bad_data_error_handling_null(bool async) + { + await base.Bad_data_error_handling_null(async); + + AssertSql( +""" +SELECT `ProductID`, `ProductName`, `SupplierID`, `UnitPrice`, `UnitsInStock`, NULL AS `Discontinued` + FROM `Products` +"""); + } + + public override async Task Bad_data_error_handling_null_projection(bool async) + { + await base.Bad_data_error_handling_null_projection(async); + + AssertSql( +""" +SELECT `m`.`Discontinued` +FROM ( + SELECT `ProductID`, `ProductName`, `SupplierID`, `UnitPrice`, `UnitsInStock`, NULL AS `Discontinued` + FROM `Products` +) AS `m` +"""); + } + + public override async Task Bad_data_error_handling_null_no_tracking(bool async) + { + await base.Bad_data_error_handling_null_no_tracking(async); + + AssertSql( +""" +SELECT `ProductID`, `ProductName`, `SupplierID`, `UnitPrice`, `UnitsInStock`, NULL AS `Discontinued` + FROM `Products` +"""); + } + + public override async Task SqlQueryRaw_queryable_simple_mapped_type(bool async) + { + await base.SqlQueryRaw_queryable_simple_mapped_type(async); + + AssertSql( +""" +SELECT * FROM `Customers` WHERE `ContactName` LIKE '%z%' +"""); + } + + public override async Task SqlQueryRaw_queryable_simple_columns_out_of_order_and_not_enough_columns_throws(bool async) + { + await base.SqlQueryRaw_queryable_simple_columns_out_of_order_and_not_enough_columns_throws(async); + + AssertSql( +""" +SELECT `PostalCode`, `Phone`, `Fax`, `CustomerID`, `Country`, `ContactTitle`, `ContactName`, `CompanyName`, `City`, `Address` FROM `Customers` +"""); + } + + public override async Task SqlQueryRaw_queryable_simple_different_cased_columns_and_not_enough_columns_throws(bool async) + { + await base.SqlQueryRaw_queryable_simple_different_cased_columns_and_not_enough_columns_throws(async); + + AssertSql( +""" +SELECT `PostalCODE`, `Phone`, `Fax`, `CustomerID`, `Country`, `ContactTitle`, `ContactName`, `CompanyName`, `City`, `Address` FROM `Customers` +"""); + } + + public override async Task SqlQueryRaw_queryable_simple_projection_not_composed(bool async) + { + await base.SqlQueryRaw_queryable_simple_projection_not_composed(async); + + AssertSql( +""" +SELECT `m`.`CustomerID`, `m`.`City` +FROM ( + SELECT * FROM `Customers` +) AS `m` +"""); + } + + public override void Ad_hoc_type_with_reference_navigation_throws() + { + base.Ad_hoc_type_with_reference_navigation_throws(); + + AssertSql(); + } + + public override void Ad_hoc_type_with_collection_navigation_throws() + { + base.Ad_hoc_type_with_collection_navigation_throws(); + + AssertSql(); + } + + public override void Ad_hoc_type_with_unmapped_property_throws() + { + base.Ad_hoc_type_with_unmapped_property_throws(); + + AssertSql(); + } + + public override async Task SqlQueryRaw_then_String_Length(bool async) + { + await base.SqlQueryRaw_then_String_Length(async); + + AssertSql( +""" +SELECT `s`.`Value` +FROM ( + SELECT 'x' AS `Value` FROM `Customers` +) AS `s` +WHERE CHAR_LENGTH(`s`.`Value`) = 0 +"""); + } + + public override async Task SqlQueryRaw_then_String_ToUpper_String_Length(bool async) + { + await base.SqlQueryRaw_then_String_ToUpper_String_Length(async); + + AssertSql( +""" +SELECT `s`.`Value` +FROM ( + SELECT 'x' AS `Value` FROM `Customers` +) AS `s` +WHERE CHAR_LENGTH(UPPER(`s`.`Value`)) = 0 +"""); + } + [SupportedServerVersionCondition(nameof(ServerVersionSupport.CommonTableExpressions))] public override async Task SqlQueryRaw_composed_with_common_table_expression(bool async) { @@ -714,6 +891,10 @@ public override async Task SqlQueryRaw_composed_with_common_table_expression(boo protected override DbParameter CreateDbParameter(string name, object value) => new SingleStoreParameter { ParameterName = name, Value = value }; + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/TPCFiltersInheritanceQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/TPCFiltersInheritanceQuerySingleStoreTest.cs index d01c91691..362c5be86 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/TPCFiltersInheritanceQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/TPCFiltersInheritanceQuerySingleStoreTest.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.TestUtilities; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using Xunit; using Xunit.Abstractions; @@ -19,7 +20,7 @@ public TPCFiltersInheritanceQuerySingleStoreTest( [ConditionalFact] public virtual void Check_all_tests_overridden() - => TestHelpers.AssertAllMethodsOverridden(GetType()); + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); public override async Task Can_use_of_type_animal(bool async) { @@ -27,16 +28,16 @@ public override async Task Can_use_of_type_animal(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`CountryId`, `t`.`Name`, `t`.`Species`, `t`.`EagleId`, `t`.`IsFlightless`, `t`.`Group`, `t`.`FoundOn`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`CountryId`, `u`.`Name`, `u`.`Species`, `u`.`EagleId`, `u`.`IsFlightless`, `u`.`Group`, `u`.`FoundOn`, `u`.`Discriminator` FROM ( SELECT `e`.`Id`, `e`.`CountryId`, `e`.`Name`, `e`.`Species`, `e`.`EagleId`, `e`.`IsFlightless`, `e`.`Group`, NULL AS `FoundOn`, 'Eagle' AS `Discriminator` FROM `Eagle` AS `e` UNION ALL SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` FROM `Kiwi` AS `k` -) AS `t` -WHERE `t`.`CountryId` = 1 -ORDER BY `t`.`Species` +) AS `u` +WHERE `u`.`CountryId` = 1 +ORDER BY `u`.`Species` """); } @@ -46,12 +47,12 @@ public override async Task Can_use_is_kiwi(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`CountryId`, `t`.`Name`, `t`.`Species`, `t`.`EagleId`, `t`.`IsFlightless`, `t`.`Group`, `t`.`FoundOn`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`CountryId`, `u`.`Name`, `u`.`Species`, `u`.`EagleId`, `u`.`IsFlightless`, `u`.`Group`, `u`.`FoundOn`, `u`.`Discriminator` FROM ( SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` FROM `Kiwi` AS `k` -) AS `t` -WHERE `t`.`CountryId` = 1 +) AS `u` +WHERE `u`.`CountryId` = 1 """); } @@ -61,15 +62,15 @@ public override async Task Can_use_is_kiwi_with_other_predicate(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`CountryId`, `t`.`Name`, `t`.`Species`, `t`.`EagleId`, `t`.`IsFlightless`, `t`.`Group`, `t`.`FoundOn`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`CountryId`, `u`.`Name`, `u`.`Species`, `u`.`EagleId`, `u`.`IsFlightless`, `u`.`Group`, `u`.`FoundOn`, `u`.`Discriminator` FROM ( SELECT `e`.`Id`, `e`.`CountryId`, `e`.`Name`, `e`.`Species`, `e`.`EagleId`, `e`.`IsFlightless`, `e`.`Group`, NULL AS `FoundOn`, 'Eagle' AS `Discriminator` FROM `Eagle` AS `e` UNION ALL SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` FROM `Kiwi` AS `k` -) AS `t` -WHERE (`t`.`CountryId` = 1) AND ((`t`.`Discriminator` = 'Kiwi') AND (`t`.`CountryId` = 1)) +) AS `u` +WHERE (`u`.`CountryId` = 1) AND ((`u`.`Discriminator` = 'Kiwi') AND (`u`.`CountryId` = 1)) """); } @@ -79,15 +80,15 @@ public override async Task Can_use_is_kiwi_in_projection(bool async) AssertSql( """ -SELECT `t`.`Discriminator` = 'Kiwi' +SELECT `u`.`Discriminator` = 'Kiwi' FROM ( SELECT `e`.`CountryId`, 'Eagle' AS `Discriminator` FROM `Eagle` AS `e` UNION ALL SELECT `k`.`CountryId`, 'Kiwi' AS `Discriminator` FROM `Kiwi` AS `k` -) AS `t` -WHERE `t`.`CountryId` = 1 +) AS `u` +WHERE `u`.`CountryId` = 1 """); } @@ -97,16 +98,16 @@ public override async Task Can_use_of_type_bird(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`CountryId`, `t`.`Name`, `t`.`Species`, `t`.`EagleId`, `t`.`IsFlightless`, `t`.`Group`, `t`.`FoundOn`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`CountryId`, `u`.`Name`, `u`.`Species`, `u`.`EagleId`, `u`.`IsFlightless`, `u`.`Group`, `u`.`FoundOn`, `u`.`Discriminator` FROM ( SELECT `e`.`Id`, `e`.`CountryId`, `e`.`Name`, `e`.`Species`, `e`.`EagleId`, `e`.`IsFlightless`, `e`.`Group`, NULL AS `FoundOn`, 'Eagle' AS `Discriminator` FROM `Eagle` AS `e` UNION ALL SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` FROM `Kiwi` AS `k` -) AS `t` -WHERE `t`.`CountryId` = 1 -ORDER BY `t`.`Species` +) AS `u` +WHERE `u`.`CountryId` = 1 +ORDER BY `u`.`Species` """); } @@ -116,16 +117,16 @@ public override async Task Can_use_of_type_bird_predicate(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`CountryId`, `t`.`Name`, `t`.`Species`, `t`.`EagleId`, `t`.`IsFlightless`, `t`.`Group`, `t`.`FoundOn`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`CountryId`, `u`.`Name`, `u`.`Species`, `u`.`EagleId`, `u`.`IsFlightless`, `u`.`Group`, `u`.`FoundOn`, `u`.`Discriminator` FROM ( SELECT `e`.`Id`, `e`.`CountryId`, `e`.`Name`, `e`.`Species`, `e`.`EagleId`, `e`.`IsFlightless`, `e`.`Group`, NULL AS `FoundOn`, 'Eagle' AS `Discriminator` FROM `Eagle` AS `e` UNION ALL SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` FROM `Kiwi` AS `k` -) AS `t` -WHERE `t`.`CountryId` = 1 -ORDER BY `t`.`Species` +) AS `u` +WHERE `u`.`CountryId` = 1 +ORDER BY `u`.`Species` """); } @@ -135,15 +136,15 @@ public override async Task Can_use_of_type_bird_with_projection(bool async) AssertSql( """ -SELECT `t`.`Name` +SELECT `u`.`Name` FROM ( SELECT `e`.`CountryId`, `e`.`Name` FROM `Eagle` AS `e` UNION ALL SELECT `k`.`CountryId`, `k`.`Name` FROM `Kiwi` AS `k` -) AS `t` -WHERE `t`.`CountryId` = 1 +) AS `u` +WHERE `u`.`CountryId` = 1 """); } @@ -153,16 +154,16 @@ public override async Task Can_use_of_type_bird_first(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`CountryId`, `t`.`Name`, `t`.`Species`, `t`.`EagleId`, `t`.`IsFlightless`, `t`.`Group`, `t`.`FoundOn`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`CountryId`, `u`.`Name`, `u`.`Species`, `u`.`EagleId`, `u`.`IsFlightless`, `u`.`Group`, `u`.`FoundOn`, `u`.`Discriminator` FROM ( SELECT `e`.`Id`, `e`.`CountryId`, `e`.`Name`, `e`.`Species`, `e`.`EagleId`, `e`.`IsFlightless`, `e`.`Group`, NULL AS `FoundOn`, 'Eagle' AS `Discriminator` FROM `Eagle` AS `e` UNION ALL SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, NULL AS `Group`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` FROM `Kiwi` AS `k` -) AS `t` -WHERE `t`.`CountryId` = 1 -ORDER BY `t`.`Species` +) AS `u` +WHERE `u`.`CountryId` = 1 +ORDER BY `u`.`Species` LIMIT 1 """); } @@ -173,12 +174,12 @@ public override async Task Can_use_of_type_kiwi(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`CountryId`, `t`.`Name`, `t`.`Species`, `t`.`EagleId`, `t`.`IsFlightless`, `t`.`FoundOn`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`CountryId`, `u`.`Name`, `u`.`Species`, `u`.`EagleId`, `u`.`IsFlightless`, `u`.`FoundOn`, `u`.`Discriminator` FROM ( SELECT `k`.`Id`, `k`.`CountryId`, `k`.`Name`, `k`.`Species`, `k`.`EagleId`, `k`.`IsFlightless`, `k`.`FoundOn`, 'Kiwi' AS `Discriminator` FROM `Kiwi` AS `k` -) AS `t` -WHERE `t`.`CountryId` = 1 +) AS `u` +WHERE `u`.`CountryId` = 1 """); } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/TPCGearsOfWarQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/TPCGearsOfWarQuerySingleStoreTest.cs index eb0e034f3..e00843ec4 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/TPCGearsOfWarQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/TPCGearsOfWarQuerySingleStoreTest.cs @@ -24,8 +24,9 @@ public TPCGearsOfWarQuerySingleStoreTest(TPCGearsOfWarQuerySingleStoreFixture fi //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); public override async Task Entity_equality_empty(bool async) { @@ -33,14 +34,14 @@ public override async Task Entity_equality_empty(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE FALSE """); } @@ -51,7 +52,7 @@ public override async Task Include_multiple_one_to_one_and_one_to_many(bool asyn AssertSql( """ -SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -59,9 +60,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -LEFT JOIN `Weapons` AS `w` ON `t0`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId` +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `t`.`Id`, `u`.`Nickname`, `u`.`SquadId` """); } @@ -71,7 +72,7 @@ public override async Task Include_multiple_one_to_one_optional_and_one_to_one_r AssertSql( """ -SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` +SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -79,8 +80,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -LEFT JOIN `Squads` AS `s` ON `t0`.`SquadId` = `s`.`Id` +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +LEFT JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` """); } @@ -90,23 +91,23 @@ public override async Task Include_multiple_circular(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Cities` AS `c` ON `t`.`CityOfBirthName` = `c`.`Name` +) AS `u` +INNER JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON `c`.`Name` = `t0`.`AssignedCityName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `c`.`Name`, `t0`.`Nickname` +) AS `u0` ON `c`.`Name` = `u0`.`AssignedCityName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `c`.`Name`, `u0`.`Nickname` """); } @@ -116,24 +117,24 @@ public override async Task Include_multiple_circular_with_filter(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Cities` AS `c` ON `t`.`CityOfBirthName` = `c`.`Name` +) AS `u` +INNER JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON `c`.`Name` = `t0`.`AssignedCityName` -WHERE `t`.`Nickname` = 'Marcus' -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `c`.`Name`, `t0`.`Nickname` +) AS `u0` ON `c`.`Name` = `u0`.`AssignedCityName` +WHERE `u`.`Nickname` = 'Marcus' +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `c`.`Name`, `u0`.`Nickname` """); } @@ -143,17 +144,17 @@ public override async Task Include_using_alternate_key(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` -WHERE `t`.`Nickname` = 'Marcus' -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `u` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +WHERE `u`.`Nickname` = 'Marcus' +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -163,19 +164,19 @@ public override async Task Include_navigation_on_derived_type(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON (`t`.`Nickname` = `t0`.`LeaderNickname`) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` +) AS `u0` ON (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -185,19 +186,19 @@ public override async Task String_based_Include_navigation_on_derived_type(bool AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON (`t`.`Nickname` = `t0`.`LeaderNickname`) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` +) AS `u0` ON (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -207,7 +208,7 @@ public override async Task Select_Where_Navigation_Included(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -215,8 +216,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -WHERE `t0`.`Nickname` = 'Marcus' +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE `u`.`Nickname` = 'Marcus' """); } @@ -226,16 +227,16 @@ public override async Task Include_with_join_reference1(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Tags` AS `t0` ON (`t`.`SquadId` = `t0`.`GearSquadId`) AND (`t`.`Nickname` = `t0`.`GearNickName`) -INNER JOIN `Cities` AS `c` ON `t`.`CityOfBirthName` = `c`.`Name` +) AS `u` +INNER JOIN `Tags` AS `t` ON (`u`.`SquadId` = `t`.`GearSquadId`) AND (`u`.`Nickname` = `t`.`GearNickName`) +INNER JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` """); } @@ -245,7 +246,7 @@ public override async Task Include_with_join_reference2(bool async) AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation` FROM `Tags` AS `t` INNER JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -253,8 +254,8 @@ INNER JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearSquadId` = `t0`.`SquadId`) AND (`t`.`GearNickName` = `t0`.`Nickname`) -INNER JOIN `Cities` AS `c` ON `t0`.`CityOfBirthName` = `c`.`Name` +) AS `u` ON (`t`.`GearSquadId` = `u`.`SquadId`) AND (`t`.`GearNickName` = `u`.`Nickname`) +INNER JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` """); } @@ -264,17 +265,17 @@ public override async Task Include_with_join_collection1(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Id`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t`.`Id`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Tags` AS `t0` ON (`t`.`SquadId` = `t0`.`GearSquadId`) AND (`t`.`Nickname` = `t0`.`GearNickName`) -LEFT JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id` +) AS `u` +INNER JOIN `Tags` AS `t` ON (`u`.`SquadId` = `t`.`GearSquadId`) AND (`u`.`Nickname` = `t`.`GearNickName`) +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `t`.`Id` """); } @@ -284,7 +285,7 @@ public override async Task Include_with_join_collection2(bool async) AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `t`.`Id`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t`.`Id`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Tags` AS `t` INNER JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -292,19 +293,80 @@ INNER JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearSquadId` = `t0`.`SquadId`) AND (`t`.`GearNickName` = `t0`.`Nickname`) -LEFT JOIN `Weapons` AS `w` ON `t0`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId` +) AS `u` ON (`t`.`GearSquadId` = `u`.`SquadId`) AND (`t`.`GearNickName` = `u`.`Nickname`) +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `t`.`Id`, `u`.`Nickname`, `u`.`SquadId` """); } - public override async Task Include_with_join_multi_level(bool async) + public override async Task Include_where_list_contains_navigation(bool async) { - await base.Include_with_join_multi_level(async); + await base.Include_where_list_contains_navigation(async); + if (SingleStoreTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) + { + AssertSql( +""" +SELECT `t`.`Id` +FROM `Tags` AS `t` +""", + // + """ +SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`GearNickName`, `t0`.`GearSquadId`, `t0`.`IssueDate`, `t0`.`Note` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `t` +LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) +WHERE `t0`.`Id` IS NOT NULL AND EXISTS ( + SELECT 1 + FROM JSON_TABLE('["b39a6fba-9026-4d69-828e-fd7068673e57","70534e05-782c-4052-8720-c2c54481ce5f","a8ad98f9-e023-4e2a-9a70-c2728455bd34","df36f493-463f-4123-83f9-6b135deeb7ba","34c8d86e-a4ac-4be5-827f-584dda348a07","a7be028a-0cf2-448f-ab55-ce8bc5d8cf69"]', '$[*]' COLUMNS ( + `key` FOR ORDINALITY, + `value` char(36) PATH '$[0]' + )) AS `t1` + WHERE (`t1`.`value` = `t0`.`Id`) OR (`t1`.`value` IS NULL AND (`t0`.`Id` IS NULL))) +"""); + } + else + { AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation`, `t0`.`Id`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` +SELECT `t`.`Id` +FROM `Tags` AS `t` +""", + // + """ +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) +WHERE `t`.`Id` IS NOT NULL AND `t`.`Id` IN ('b39a6fba-9026-4d69-828e-fd7068673e57', '70534e05-782c-4052-8720-c2c54481ce5f', 'a8ad98f9-e023-4e2a-9a70-c2728455bd34', 'df36f493-463f-4123-83f9-6b135deeb7ba', '34c8d86e-a4ac-4be5-827f-584dda348a07', 'a7be028a-0cf2-448f-ab55-ce8bc5d8cf69') +"""); + } + } + + public override async Task Include_where_list_contains_navigation2(bool async) + { + await base.Include_where_list_contains_navigation2(async); + + if (SingleStoreTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) + { + AssertSql( +""" +SELECT `t`.`Id` +FROM `Tags` AS `t` +""", + // + """ +SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`GearNickName`, `t0`.`GearSquadId`, `t0`.`IssueDate`, `t0`.`Note` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` @@ -312,16 +374,119 @@ UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` ) AS `t` -INNER JOIN `Tags` AS `t0` ON (`t`.`SquadId` = `t0`.`GearSquadId`) AND (`t`.`Nickname` = `t0`.`GearNickName`) INNER JOIN `Cities` AS `c` ON `t`.`CityOfBirthName` = `c`.`Name` +LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) +WHERE `c`.`Location` IS NOT NULL AND EXISTS ( + SELECT 1 + FROM JSON_TABLE('["b39a6fba-9026-4d69-828e-fd7068673e57","70534e05-782c-4052-8720-c2c54481ce5f","a8ad98f9-e023-4e2a-9a70-c2728455bd34","df36f493-463f-4123-83f9-6b135deeb7ba","34c8d86e-a4ac-4be5-827f-584dda348a07","a7be028a-0cf2-448f-ab55-ce8bc5d8cf69"]', '$[*]' COLUMNS ( + `key` FOR ORDINALITY, + `value` char(36) PATH '$[0]' + )) AS `t1` + WHERE (`t1`.`value` = `t0`.`Id`) OR (`t1`.`value` IS NULL AND (`t0`.`Id` IS NULL))) +"""); + } + else + { + AssertSql( +""" +SELECT `t`.`Id` +FROM `Tags` AS `t` +""", + // + """ +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +INNER JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) +WHERE `c`.`Location` IS NOT NULL AND `t`.`Id` IN ('b39a6fba-9026-4d69-828e-fd7068673e57', '70534e05-782c-4052-8720-c2c54481ce5f', 'a8ad98f9-e023-4e2a-9a70-c2728455bd34', 'df36f493-463f-4123-83f9-6b135deeb7ba', '34c8d86e-a4ac-4be5-827f-584dda348a07', 'a7be028a-0cf2-448f-ab55-ce8bc5d8cf69') +"""); + } + } + + public override async Task Navigation_accessed_twice_outside_and_inside_subquery(bool async) + { + await base.Navigation_accessed_twice_outside_and_inside_subquery(async); + + if (SingleStoreTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) + { + AssertSql( +""" +SELECT `t`.`Id` +FROM `Tags` AS `t` +""", + // + """ +SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `t` +LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) +WHERE `t0`.`Id` IS NOT NULL AND EXISTS ( + SELECT 1 + FROM JSON_TABLE('["b39a6fba-9026-4d69-828e-fd7068673e57","70534e05-782c-4052-8720-c2c54481ce5f","a8ad98f9-e023-4e2a-9a70-c2728455bd34","df36f493-463f-4123-83f9-6b135deeb7ba","34c8d86e-a4ac-4be5-827f-584dda348a07","a7be028a-0cf2-448f-ab55-ce8bc5d8cf69"]', '$[*]' COLUMNS ( + `key` FOR ORDINALITY, + `value` char(36) PATH '$[0]' + )) AS `t1` + WHERE (`t1`.`value` = `t0`.`Id`) OR (`t1`.`value` IS NULL AND (`t0`.`Id` IS NULL))) +"""); + } + else + { + AssertSql( +""" +SELECT `t`.`Id` +FROM `Tags` AS `t` +""", + // + """ +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) +WHERE `t`.`Id` IS NOT NULL AND `t`.`Id` IN ('b39a6fba-9026-4d69-828e-fd7068673e57', '70534e05-782c-4052-8720-c2c54481ce5f', 'a8ad98f9-e023-4e2a-9a70-c2728455bd34', 'df36f493-463f-4123-83f9-6b135deeb7ba', '34c8d86e-a4ac-4be5-827f-584dda348a07', 'a7be028a-0cf2-448f-ab55-ce8bc5d8cf69') +"""); + } + } + + public override async Task Include_with_join_multi_level(bool async) + { + await base.Include_with_join_multi_level(async); + + AssertSql( +""" +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation`, `t`.`Id`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +INNER JOIN `Tags` AS `t` ON (`u`.`SquadId` = `t`.`GearSquadId`) AND (`u`.`Nickname` = `t`.`GearNickName`) +INNER JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t1` ON `c`.`Name` = `t1`.`AssignedCityName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `c`.`Name`, `t1`.`Nickname` +) AS `u0` ON `c`.`Name` = `u0`.`AssignedCityName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `t`.`Id`, `c`.`Name`, `u0`.`Nickname` """); } @@ -331,13 +496,13 @@ public override async Task Include_with_join_and_inheritance1(bool async) AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation` FROM `Tags` AS `t` INNER JOIN ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearSquadId` = `t0`.`SquadId`) AND (`t`.`GearNickName` = `t0`.`Nickname`) -INNER JOIN `Cities` AS `c` ON `t0`.`CityOfBirthName` = `c`.`Name` +) AS `u` ON (`t`.`GearSquadId` = `u`.`SquadId`) AND (`t`.`GearNickName` = `u`.`Nickname`) +INNER JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` """); } @@ -347,20 +512,20 @@ public override async Task Include_with_join_and_inheritance_with_orderby_before AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `t`.`Id`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t`.`Id`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM `Tags` AS `t` INNER JOIN ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearSquadId` = `t0`.`SquadId`) AND (`t`.`GearNickName` = `t0`.`Nickname`) +) AS `u` ON (`t`.`GearSquadId` = `u`.`SquadId`) AND (`t`.`GearNickName` = `u`.`Nickname`) LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t1` ON (`t0`.`Nickname` = `t1`.`LeaderNickname`) AND (`t0`.`SquadId` = `t1`.`LeaderSquadId`) -ORDER BY `t0`.`HasSoulPatch`, `t0`.`Nickname` DESC, `t`.`Id`, `t0`.`SquadId`, `t1`.`Nickname` +) AS `u0` ON (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `u`.`HasSoulPatch`, `u`.`Nickname` DESC, `t`.`Id`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -370,14 +535,14 @@ public override async Task Include_with_join_and_inheritance2(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Id`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t`.`Id`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Tags` AS `t0` ON (`t`.`SquadId` = `t0`.`GearSquadId`) AND (`t`.`Nickname` = `t0`.`GearNickName`) -LEFT JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id` +) AS `u` +INNER JOIN `Tags` AS `t` ON (`u`.`SquadId` = `t`.`GearSquadId`) AND (`u`.`Nickname` = `t`.`GearNickName`) +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `t`.`Id` """); } @@ -387,20 +552,20 @@ public override async Task Include_with_join_and_inheritance3(bool async) AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `t`.`Id`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t`.`Id`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM `Tags` AS `t` INNER JOIN ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearSquadId` = `t0`.`SquadId`) AND (`t`.`GearNickName` = `t0`.`Nickname`) +) AS `u` ON (`t`.`GearSquadId` = `u`.`SquadId`) AND (`t`.`GearNickName` = `u`.`Nickname`) LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t1` ON (`t0`.`Nickname` = `t1`.`LeaderNickname`) AND (`t0`.`SquadId` = `t1`.`LeaderSquadId`) -ORDER BY `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `t1`.`Nickname` +) AS `u0` ON (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `t`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -410,7 +575,7 @@ public override async Task Include_with_nested_navigation_in_order_by(bool async AssertSql( """ -SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM `Weapons` AS `w` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -418,9 +583,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` ON `w`.`OwnerFullName` = `t`.`FullName` -LEFT JOIN `Cities` AS `c` ON `t`.`CityOfBirthName` = `c`.`Name` -WHERE (`t`.`Nickname` <> 'Paduk') OR `t`.`Nickname` IS NULL +) AS `u` ON `w`.`OwnerFullName` = `u`.`FullName` +LEFT JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` +WHERE (`u`.`Nickname` <> 'Paduk') OR `u`.`Nickname` IS NULL ORDER BY `c`.`Name`, `w`.`Id` """); } @@ -431,15 +596,15 @@ public override async Task Where_enum(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`Rank` = 4 +) AS `u` +WHERE `u`.`Rank` = 4 """); } @@ -507,27 +672,27 @@ public override async Task Where_bitwise_and_enum(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` & 2) > 0 +) AS `u` +WHERE CAST(`u`.`Rank` & 2 AS signed) > 0 """, // """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` & 2) = 2 +) AS `u` +WHERE CAST(`u`.`Rank` & 2 AS signed) = 2 """); } @@ -537,39 +702,39 @@ public override async Task Where_bitwise_and_integral(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` & 1) = 1 +) AS `u` +WHERE CAST(`u`.`Rank` & 1 AS signed) = 1 """, // """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (CAST(`t`.`Rank` AS signed) & 1) = 1 +) AS `u` +WHERE CAST(CAST(`u`.`Rank` AS signed) & 1 AS signed) = 1 """, // """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (CAST(`t`.`Rank` AS signed) & 1) = 1 +) AS `u` +WHERE CAST(CAST(`u`.`Rank` AS signed) & 1 AS signed) = 1 """); } @@ -581,7 +746,7 @@ public override async Task Where_bitwise_and_nullable_enum_with_constant(bool as """ SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` -WHERE (`w`.`AmmunitionType` & 1) > 0 +WHERE CAST(`w`.`AmmunitionType` & 1 AS signed) > 0 """); } @@ -593,7 +758,7 @@ public override async Task Where_bitwise_and_nullable_enum_with_null_constant(bo """ SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` -WHERE (`w`.`AmmunitionType` & NULL) > 0 +WHERE CAST(`w`.`AmmunitionType` & NULL AS signed) > 0 """); } @@ -607,7 +772,7 @@ public override async Task Where_bitwise_and_nullable_enum_with_non_nullable_par SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` -WHERE (`w`.`AmmunitionType` & @__ammunitionType_0) > 0 +WHERE CAST(`w`.`AmmunitionType` & @__ammunitionType_0 AS signed) > 0 """); } @@ -621,13 +786,13 @@ public override async Task Where_bitwise_and_nullable_enum_with_nullable_paramet SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` -WHERE (`w`.`AmmunitionType` & @__ammunitionType_0) > 0 +WHERE CAST(`w`.`AmmunitionType` & @__ammunitionType_0 AS signed) > 0 """, // """ SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` -WHERE (`w`.`AmmunitionType` & NULL) > 0 +WHERE CAST(`w`.`AmmunitionType` & NULL AS signed) > 0 """); } @@ -637,15 +802,15 @@ public override async Task Where_bitwise_or_enum(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` | 2) > 0 +) AS `u` +WHERE CAST(`u`.`Rank` | 2 AS signed) > 0 """); } @@ -655,15 +820,15 @@ public override async Task Bitwise_projects_values_in_select(bool async) AssertSql( """ -SELECT (`t`.`Rank` & 2) = 2 AS `BitwiseTrue`, (`t`.`Rank` & 2) = 4 AS `BitwiseFalse`, `t`.`Rank` & 2 AS `BitwiseValue` +SELECT CAST(`u`.`Rank` & 2 AS signed) = 2 AS `BitwiseTrue`, CAST(`u`.`Rank` & 2 AS signed) = 4 AS `BitwiseFalse`, CAST(`u`.`Rank` & 2 AS signed) AS `BitwiseValue` FROM ( SELECT `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Rank` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` & 2) = 2 +) AS `u` +WHERE CAST(`u`.`Rank` & 2 AS signed) = 2 LIMIT 1 """); } @@ -674,63 +839,63 @@ public override async Task Where_enum_has_flag(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` & 2) = 2 +) AS `u` +WHERE CAST(`u`.`Rank` & 2 AS signed) = 2 """, // """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` & 18) = 18 +) AS `u` +WHERE CAST(`u`.`Rank` & 18 AS signed) = 18 """, // """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` & 1) = 1 +) AS `u` +WHERE CAST(`u`.`Rank` & 1 AS signed) = 1 """, // """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` & 1) = 1 +) AS `u` +WHERE CAST(`u`.`Rank` & 1 AS signed) = 1 """, // """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (2 & `t`.`Rank`) = `t`.`Rank` +) AS `u` +WHERE CAST(2 & `u`.`Rank` AS signed) = `u`.`Rank` """); } @@ -740,66 +905,66 @@ public override async Task Where_enum_has_flag_subquery(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` & COALESCE(( - SELECT `t0`.`Rank` +) AS `u` +WHERE CAST(`u`.`Rank` & COALESCE(( + SELECT `u0`.`Rank` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` FROM `Officers` AS `o0` - ) AS `t0` - ORDER BY `t0`.`Nickname`, `t0`.`SquadId` - LIMIT 1), 0)) = COALESCE(( - SELECT `t0`.`Rank` + ) AS `u0` + ORDER BY `u0`.`Nickname`, `u0`.`SquadId` + LIMIT 1), 0) AS signed) = COALESCE(( + SELECT `u0`.`Rank` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` FROM `Officers` AS `o0` - ) AS `t0` - ORDER BY `t0`.`Nickname`, `t0`.`SquadId` + ) AS `u0` + ORDER BY `u0`.`Nickname`, `u0`.`SquadId` LIMIT 1), 0) """, // """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (2 & COALESCE(( - SELECT `t0`.`Rank` +) AS `u` +WHERE CAST(2 & COALESCE(( + SELECT `u0`.`Rank` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` FROM `Officers` AS `o0` - ) AS `t0` - ORDER BY `t0`.`Nickname`, `t0`.`SquadId` - LIMIT 1), 0)) = COALESCE(( - SELECT `t0`.`Rank` + ) AS `u0` + ORDER BY `u0`.`Nickname`, `u0`.`SquadId` + LIMIT 1), 0) AS signed) = COALESCE(( + SELECT `u0`.`Rank` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` FROM `Officers` AS `o0` - ) AS `t0` - ORDER BY `t0`.`Nickname`, `t0`.`SquadId` + ) AS `u0` + ORDER BY `u0`.`Nickname`, `u0`.`SquadId` LIMIT 1), 0) """); } @@ -810,86 +975,86 @@ public override async Task Where_enum_has_flag_subquery_with_pushdown(bool async AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE ((`t`.`Rank` & ( - SELECT `t0`.`Rank` +) AS `u` +WHERE (CAST(`u`.`Rank` & ( + SELECT `u0`.`Rank` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` FROM `Officers` AS `o0` - ) AS `t0` - ORDER BY `t0`.`Nickname`, `t0`.`SquadId` - LIMIT 1)) = ( - SELECT `t0`.`Rank` + ) AS `u0` + ORDER BY `u0`.`Nickname`, `u0`.`SquadId` + LIMIT 1) AS signed) = ( + SELECT `u0`.`Rank` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` FROM `Officers` AS `o0` - ) AS `t0` - ORDER BY `t0`.`Nickname`, `t0`.`SquadId` + ) AS `u0` + ORDER BY `u0`.`Nickname`, `u0`.`SquadId` LIMIT 1)) OR ( - SELECT `t0`.`Rank` + SELECT `u0`.`Rank` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` FROM `Officers` AS `o0` - ) AS `t0` - ORDER BY `t0`.`Nickname`, `t0`.`SquadId` + ) AS `u0` + ORDER BY `u0`.`Nickname`, `u0`.`SquadId` LIMIT 1) IS NULL """, // """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE ((2 & ( - SELECT `t0`.`Rank` +) AS `u` +WHERE (CAST(2 & ( + SELECT `u0`.`Rank` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` FROM `Officers` AS `o0` - ) AS `t0` - ORDER BY `t0`.`Nickname`, `t0`.`SquadId` - LIMIT 1)) = ( - SELECT `t0`.`Rank` + ) AS `u0` + ORDER BY `u0`.`Nickname`, `u0`.`SquadId` + LIMIT 1) AS signed) = ( + SELECT `u0`.`Rank` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` FROM `Officers` AS `o0` - ) AS `t0` - ORDER BY `t0`.`Nickname`, `t0`.`SquadId` + ) AS `u0` + ORDER BY `u0`.`Nickname`, `u0`.`SquadId` LIMIT 1)) OR ( - SELECT `t0`.`Rank` + SELECT `u0`.`Rank` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` FROM `Officers` AS `o0` - ) AS `t0` - ORDER BY `t0`.`Nickname`, `t0`.`SquadId` + ) AS `u0` + ORDER BY `u0`.`Nickname`, `u0`.`SquadId` LIMIT 1) IS NULL """); } @@ -900,44 +1065,44 @@ public override async Task Where_enum_has_flag_subquery_client_eval(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE ((`t`.`Rank` & ( - SELECT `t0`.`Rank` +) AS `u` +WHERE (CAST(`u`.`Rank` & ( + SELECT `u0`.`Rank` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` FROM `Officers` AS `o0` - ) AS `t0` - ORDER BY `t0`.`Nickname`, `t0`.`SquadId` - LIMIT 1)) = ( - SELECT `t0`.`Rank` + ) AS `u0` + ORDER BY `u0`.`Nickname`, `u0`.`SquadId` + LIMIT 1) AS signed) = ( + SELECT `u0`.`Rank` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` FROM `Officers` AS `o0` - ) AS `t0` - ORDER BY `t0`.`Nickname`, `t0`.`SquadId` + ) AS `u0` + ORDER BY `u0`.`Nickname`, `u0`.`SquadId` LIMIT 1)) OR ( - SELECT `t0`.`Rank` + SELECT `u0`.`Rank` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`Rank` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`Rank` FROM `Officers` AS `o0` - ) AS `t0` - ORDER BY `t0`.`Nickname`, `t0`.`SquadId` + ) AS `u0` + ORDER BY `u0`.`Nickname`, `u0`.`SquadId` LIMIT 1) IS NULL """); } @@ -950,15 +1115,15 @@ public override async Task Where_enum_has_flag_with_non_nullable_parameter(bool """ @__parameter_0='2' -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` & @__parameter_0) = @__parameter_0 +) AS `u` +WHERE CAST(`u`.`Rank` & @__parameter_0 AS signed) = @__parameter_0 """); } @@ -970,15 +1135,15 @@ public override async Task Where_has_flag_with_nullable_parameter(bool async) """ @__parameter_0='2' (Nullable = true) -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` & @__parameter_0) = @__parameter_0 +) AS `u` +WHERE CAST(`u`.`Rank` & @__parameter_0 AS signed) = @__parameter_0 """); } @@ -988,15 +1153,15 @@ public override async Task Select_enum_has_flag(bool async) AssertSql( """ -SELECT (`t`.`Rank` & 2) = 2 AS `hasFlagTrue`, (`t`.`Rank` & 4) = 4 AS `hasFlagFalse` +SELECT CAST(`u`.`Rank` & 2 AS signed) = 2 AS `hasFlagTrue`, CAST(`u`.`Rank` & 4 AS signed) = 4 AS `hasFlagFalse` FROM ( SELECT `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Rank` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` & 2) = 2 +) AS `u` +WHERE CAST(`u`.`Rank` & 2 AS signed) = 2 LIMIT 1 """); } @@ -1007,18 +1172,18 @@ public override async Task Where_count_subquery_without_collision(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE ( SELECT COUNT(*) FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName`) = 2 + WHERE `u`.`FullName` = `w`.`OwnerFullName`) = 2 """); } @@ -1028,18 +1193,18 @@ public override async Task Where_any_subquery_without_collision(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE EXISTS ( SELECT 1 FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName`) + WHERE `u`.`FullName` = `w`.`OwnerFullName`) """); } @@ -1210,15 +1375,15 @@ public override async Task Null_propagation_optimization1(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`LeaderNickname` = 'Marcus') AND `t`.`LeaderNickname` IS NOT NULL +) AS `u` +WHERE `u`.`LeaderNickname` = 'Marcus' """); } @@ -1229,18 +1394,18 @@ public override async Task Null_propagation_optimization2(bool async) // issue #16050 AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE CASE - WHEN `t`.`LeaderNickname` IS NULL THEN NULL - ELSE (`t`.`LeaderNickname` LIKE '%us') AND `t`.`LeaderNickname` IS NOT NULL -END = TRUE + WHEN `u`.`LeaderNickname` IS NULL THEN NULL + ELSE `u`.`LeaderNickname` LIKE '%us' +END """); } @@ -1251,18 +1416,17 @@ public override async Task Null_propagation_optimization3(bool async) // issue #16050 AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE CASE - WHEN `t`.`LeaderNickname` IS NOT NULL THEN `t`.`LeaderNickname` LIKE '%us' - ELSE NULL -END = TRUE + WHEN `u`.`LeaderNickname` IS NOT NULL THEN `u`.`LeaderNickname` LIKE '%us' +END """); } @@ -1273,21 +1437,18 @@ public override async Task Null_propagation_optimization4(bool async) // issue #16050 AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (CASE - WHEN `t`.`LeaderNickname` IS NULL THEN NULL - ELSE CHAR_LENGTH(`t`.`LeaderNickname`) -END = 5) AND CASE - WHEN `t`.`LeaderNickname` IS NULL THEN NULL - ELSE CHAR_LENGTH(`t`.`LeaderNickname`) -END IS NOT NULL +) AS `u` +WHERE CASE + WHEN `u`.`LeaderNickname` IS NULL THEN NULL + ELSE CHAR_LENGTH(`u`.`LeaderNickname`) +END = 5 """); } @@ -1298,21 +1459,17 @@ public override async Task Null_propagation_optimization5(bool async) // issue #16050 AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (CASE - WHEN `t`.`LeaderNickname` IS NOT NULL THEN CHAR_LENGTH(`t`.`LeaderNickname`) - ELSE NULL -END = 5) AND CASE - WHEN `t`.`LeaderNickname` IS NOT NULL THEN CHAR_LENGTH(`t`.`LeaderNickname`) - ELSE NULL -END IS NOT NULL +) AS `u` +WHERE CASE + WHEN `u`.`LeaderNickname` IS NOT NULL THEN CHAR_LENGTH(`u`.`LeaderNickname`) +END = 5 """); } @@ -1323,21 +1480,17 @@ public override async Task Null_propagation_optimization6(bool async) // issue #16050 AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (CASE - WHEN `t`.`LeaderNickname` IS NOT NULL THEN CHAR_LENGTH(`t`.`LeaderNickname`) - ELSE NULL -END = 5) AND CASE - WHEN `t`.`LeaderNickname` IS NOT NULL THEN CHAR_LENGTH(`t`.`LeaderNickname`) - ELSE NULL -END IS NOT NULL +) AS `u` +WHERE CASE + WHEN `u`.`LeaderNickname` IS NOT NULL THEN CHAR_LENGTH(`u`.`LeaderNickname`) +END = 5 """); } @@ -1349,8 +1502,7 @@ public override async Task Select_null_propagation_optimization7(bool async) AssertSql( """ SELECT CASE - WHEN `t`.`LeaderNickname` IS NOT NULL THEN CONCAT(`t`.`LeaderNickname`, `t`.`LeaderNickname`) - ELSE NULL + WHEN `u`.`LeaderNickname` IS NOT NULL THEN CONCAT(`u`.`LeaderNickname`, `u`.`LeaderNickname`) END FROM ( SELECT `g`.`LeaderNickname` @@ -1358,7 +1510,7 @@ ELSE NULL UNION ALL SELECT `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -1368,14 +1520,14 @@ public override async Task Select_null_propagation_optimization8(bool async) AssertSql( """ -SELECT CONCAT(COALESCE(`t`.`LeaderNickname`, ''), COALESCE(`t`.`LeaderNickname`, '')) +SELECT CONCAT(COALESCE(`u`.`LeaderNickname`, ''), COALESCE(`u`.`LeaderNickname`, '')) FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`LeaderNickname` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -1385,14 +1537,14 @@ public override async Task Select_null_propagation_optimization9(bool async) AssertSql( """ -SELECT CHAR_LENGTH(`t`.`FullName`) +SELECT CHAR_LENGTH(`u`.`FullName`) FROM ( SELECT `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -1403,8 +1555,7 @@ public override async Task Select_null_propagation_negative1(bool async) AssertSql( """ SELECT CASE - WHEN `t`.`LeaderNickname` IS NOT NULL THEN CHAR_LENGTH(`t`.`Nickname`) = 5 - ELSE NULL + WHEN `u`.`LeaderNickname` IS NOT NULL THEN CHAR_LENGTH(`u`.`Nickname`) = 5 END FROM ( SELECT `g`.`Nickname`, `g`.`LeaderNickname` @@ -1412,7 +1563,7 @@ ELSE NULL UNION ALL SELECT `o`.`Nickname`, `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -1423,8 +1574,7 @@ public override async Task Select_null_propagation_negative2(bool async) AssertSql( """ SELECT CASE - WHEN `t`.`LeaderNickname` IS NOT NULL THEN `t0`.`LeaderNickname` - ELSE NULL + WHEN `u`.`LeaderNickname` IS NOT NULL THEN `u0`.`LeaderNickname` END FROM ( SELECT `g`.`LeaderNickname` @@ -1432,14 +1582,14 @@ ELSE NULL UNION ALL SELECT `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` +) AS `u` CROSS JOIN ( SELECT `g0`.`LeaderNickname` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`LeaderNickname` FROM `Officers` AS `o0` -) AS `t0` +) AS `u0` """); } @@ -1449,9 +1599,8 @@ public override async Task Select_null_propagation_negative3(bool async) AssertSql( """ -SELECT `t0`.`Nickname`, CASE - WHEN `t0`.`Nickname` IS NOT NULL AND (`t0`.`SquadId` IS NOT NULL) THEN `t0`.`LeaderNickname` IS NOT NULL - ELSE NULL +SELECT `u0`.`Nickname`, CASE + WHEN `u0`.`Nickname` IS NOT NULL AND (`u0`.`SquadId` IS NOT NULL) THEN `u0`.`LeaderNickname` IS NOT NULL END AS `Condition` FROM ( SELECT `g`.`HasSoulPatch` @@ -1459,15 +1608,15 @@ END AS `Condition` UNION ALL SELECT `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`LeaderNickname` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`LeaderNickname` FROM `Officers` AS `o0` -) AS `t0` ON `t`.`HasSoulPatch` = TRUE -ORDER BY `t0`.`Nickname` +) AS `u0` ON `u`.`HasSoulPatch` = TRUE +ORDER BY `u0`.`Nickname` """); } @@ -1477,22 +1626,22 @@ public override async Task Select_null_propagation_negative4(bool async) AssertSql( """ -SELECT `t0`.`Nickname` IS NOT NULL AND (`t0`.`SquadId` IS NOT NULL), `t0`.`Nickname` +SELECT `u0`.`Nickname` IS NOT NULL AND (`u0`.`SquadId` IS NOT NULL), `u0`.`Nickname` FROM ( SELECT `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId` FROM `Officers` AS `o0` -) AS `t0` ON `t`.`HasSoulPatch` = TRUE -ORDER BY `t0`.`Nickname` +) AS `u0` ON `u`.`HasSoulPatch` = TRUE +ORDER BY `u0`.`Nickname` """); } @@ -1502,22 +1651,22 @@ public override async Task Select_null_propagation_negative5(bool async) AssertSql( """ -SELECT `t0`.`Nickname` IS NOT NULL AND (`t0`.`SquadId` IS NOT NULL), `t0`.`Nickname` +SELECT `u0`.`Nickname` IS NOT NULL AND (`u0`.`SquadId` IS NOT NULL), `u0`.`Nickname` FROM ( SELECT `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId` FROM `Officers` AS `o0` -) AS `t0` ON `t`.`HasSoulPatch` = TRUE -ORDER BY `t0`.`Nickname` +) AS `u0` ON `u`.`HasSoulPatch` = TRUE +ORDER BY `u0`.`Nickname` """); } @@ -1528,8 +1677,7 @@ public override async Task Select_null_propagation_negative6(bool async) AssertSql( """ SELECT CASE - WHEN `t`.`LeaderNickname` IS NOT NULL THEN CHAR_LENGTH(`t`.`LeaderNickname`) <> CHAR_LENGTH(`t`.`LeaderNickname`) - ELSE NULL + WHEN `u`.`LeaderNickname` IS NOT NULL THEN FALSE END FROM ( SELECT `g`.`LeaderNickname` @@ -1537,7 +1685,7 @@ ELSE NULL UNION ALL SELECT `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -1548,8 +1696,7 @@ public override async Task Select_null_propagation_negative7(bool async) AssertSql( """ SELECT CASE - WHEN `t`.`LeaderNickname` IS NOT NULL THEN TRUE - ELSE NULL + WHEN `u`.`LeaderNickname` IS NOT NULL THEN TRUE END FROM ( SELECT `g`.`LeaderNickname` @@ -1557,7 +1704,7 @@ ELSE NULL UNION ALL SELECT `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -1569,7 +1716,6 @@ public override async Task Select_null_propagation_negative8(bool async) """ SELECT CASE WHEN `s`.`Id` IS NOT NULL THEN `c`.`Name` - ELSE NULL END FROM `Tags` AS `t` LEFT JOIN ( @@ -1578,9 +1724,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -LEFT JOIN `Squads` AS `s` ON `t0`.`SquadId` = `s`.`Id` -LEFT JOIN `Cities` AS `c` ON `t0`.`AssignedCityName` = `c`.`Name` +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +LEFT JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` +LEFT JOIN `Cities` AS `c` ON `u`.`AssignedCityName` = `c`.`Name` """); } @@ -1591,8 +1737,7 @@ public override async Task Select_null_propagation_negative9(bool async) AssertSql( """ SELECT CASE - WHEN `t`.`LeaderNickname` IS NOT NULL THEN COALESCE(CHAR_LENGTH(`t`.`Nickname`) = 5, FALSE) - ELSE NULL + WHEN `u`.`LeaderNickname` IS NOT NULL THEN CHAR_LENGTH(`u`.`Nickname`) = 5 END FROM ( SELECT `g`.`Nickname`, `g`.`LeaderNickname` @@ -1600,7 +1745,7 @@ ELSE NULL UNION ALL SELECT `o`.`Nickname`, `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -1610,7 +1755,7 @@ public override async Task Select_null_propagation_works_for_navigations_with_co AssertSql( """ -SELECT `t0`.`Nickname` +SELECT `u`.`Nickname` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId` @@ -1618,7 +1763,7 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) """); } @@ -1630,7 +1775,6 @@ public override async Task Select_null_propagation_works_for_multiple_navigation """ SELECT CASE WHEN `c`.`Name` IS NOT NULL THEN `c`.`Name` - ELSE NULL END FROM `Tags` AS `t` LEFT JOIN ( @@ -1639,16 +1783,16 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -LEFT JOIN `Tags` AS `t1` ON ((`t0`.`Nickname` = `t1`.`GearNickName`) OR (`t0`.`Nickname` IS NULL AND (`t1`.`GearNickName` IS NULL))) AND ((`t0`.`SquadId` = `t1`.`GearSquadId`) OR (`t0`.`SquadId` IS NULL AND (`t1`.`GearSquadId` IS NULL))) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +LEFT JOIN `Tags` AS `t0` ON ((`u`.`Nickname` = `t0`.`GearNickName`) OR (`u`.`Nickname` IS NULL AND (`t0`.`GearNickName` IS NULL))) AND ((`u`.`SquadId` = `t0`.`GearSquadId`) OR (`u`.`SquadId` IS NULL AND (`t0`.`GearSquadId` IS NULL))) LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName` FROM `Officers` AS `o0` -) AS `t2` ON (`t1`.`GearNickName` = `t2`.`Nickname`) AND (`t1`.`GearSquadId` = `t2`.`SquadId`) -LEFT JOIN `Cities` AS `c` ON `t2`.`AssignedCityName` = `c`.`Name` +) AS `u0` ON (`t0`.`GearNickName` = `u0`.`Nickname`) AND (`t0`.`GearSquadId` = `u0`.`SquadId`) +LEFT JOIN `Cities` AS `c` ON `u0`.`AssignedCityName` = `c`.`Name` """); } @@ -1658,15 +1802,15 @@ public override async Task Select_conditional_with_anonymous_type_and_null_const AssertSql( """ -SELECT `t`.`LeaderNickname` IS NOT NULL, `t`.`HasSoulPatch` +SELECT `u`.`LeaderNickname` IS NOT NULL, `u`.`HasSoulPatch` FROM ( SELECT `g`.`Nickname`, `g`.`HasSoulPatch`, `g`.`LeaderNickname` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`HasSoulPatch`, `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` -ORDER BY `t`.`Nickname` +) AS `u` +ORDER BY `u`.`Nickname` """); } @@ -1676,15 +1820,15 @@ public override async Task Select_conditional_with_anonymous_types(bool async) AssertSql( """ -SELECT `t`.`LeaderNickname` IS NOT NULL, `t`.`Nickname`, `t`.`FullName` +SELECT `u`.`LeaderNickname` IS NOT NULL, `u`.`Nickname`, `u`.`FullName` FROM ( SELECT `g`.`Nickname`, `g`.`FullName`, `g`.`LeaderNickname` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`FullName`, `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` -ORDER BY `t`.`Nickname` +) AS `u` +ORDER BY `u`.`Nickname` """); } @@ -1694,16 +1838,16 @@ public override async Task Where_conditional_equality_1(bool async) AssertSql( """ -SELECT `t`.`Nickname` +SELECT `u`.`Nickname` FROM ( SELECT `g`.`Nickname`, `g`.`HasSoulPatch`, `g`.`LeaderNickname` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`HasSoulPatch`, `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`LeaderNickname` IS NULL -ORDER BY `t`.`Nickname` +) AS `u` +WHERE `u`.`LeaderNickname` IS NULL +ORDER BY `u`.`Nickname` """); } @@ -1713,16 +1857,16 @@ public override async Task Where_conditional_equality_2(bool async) AssertSql( """ -SELECT `t`.`Nickname` +SELECT `u`.`Nickname` FROM ( SELECT `g`.`Nickname`, `g`.`HasSoulPatch`, `g`.`LeaderNickname` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`HasSoulPatch`, `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`LeaderNickname` IS NULL -ORDER BY `t`.`Nickname` +) AS `u` +WHERE `u`.`LeaderNickname` IS NULL +ORDER BY `u`.`Nickname` """); } @@ -1732,15 +1876,15 @@ public override async Task Where_conditional_equality_3(bool async) AssertSql( """ -SELECT `t`.`Nickname` +SELECT `u`.`Nickname` FROM ( SELECT `g`.`Nickname`, `g`.`LeaderNickname` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` -ORDER BY `t`.`Nickname` +) AS `u` +ORDER BY `u`.`Nickname` """); } @@ -1750,15 +1894,15 @@ public override async Task Select_coalesce_with_anonymous_types(bool async) AssertSql( """ -SELECT `t`.`LeaderNickname`, `t`.`FullName` +SELECT `u`.`LeaderNickname`, `u`.`FullName` FROM ( SELECT `g`.`Nickname`, `g`.`FullName`, `g`.`LeaderNickname` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`FullName`, `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` -ORDER BY `t`.`Nickname` +) AS `u` +ORDER BY `u`.`Nickname` """); } @@ -1775,32 +1919,31 @@ public override async Task Where_member_access_on_anonymous_type(bool async) AssertSql( """ -SELECT `t`.`Nickname` +SELECT `u`.`Nickname` FROM ( SELECT `g`.`Nickname`, `g`.`LeaderNickname` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`LeaderNickname` = 'Marcus' +) AS `u` +WHERE `u`.`LeaderNickname` = 'Marcus' """); } public override async Task Where_compare_anonymous_types_with_uncorrelated_members(bool async) { await base.Where_compare_anonymous_types_with_uncorrelated_members(async); - AssertSql( """ -SELECT `t`.`Nickname` +SELECT `u`.`Nickname` FROM ( SELECT `g`.`Nickname` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE FALSE """); } @@ -1820,15 +1963,15 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t1` ON (`t`.`GearNickName` = `t1`.`Nickname`) AND (`t`.`GearSquadId` = `t1`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId` FROM `Officers` AS `o0` -) AS `t2` ON (`t0`.`GearNickName` = `t2`.`Nickname`) AND (`t0`.`GearSquadId` = `t2`.`SquadId`) -WHERE (`t1`.`Nickname` = `t2`.`Nickname`) OR (`t1`.`Nickname` IS NULL AND (`t2`.`Nickname` IS NULL)) +) AS `u0` ON (`t0`.`GearNickName` = `u0`.`Nickname`) AND (`t0`.`GearSquadId` = `u0`.`SquadId`) +WHERE (`u`.`Nickname` = `u0`.`Nickname`) OR (`u`.`Nickname` IS NULL AND (`u0`.`Nickname` IS NULL)) """); } @@ -1838,7 +1981,7 @@ public override async Task Select_Singleton_Navigation_With_Member_Access(bool a AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -1846,8 +1989,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -WHERE (`t0`.`Nickname` = 'Marcus') AND ((`t0`.`CityOfBirthName` <> 'Ephyra') OR `t0`.`CityOfBirthName` IS NULL) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE (`u`.`Nickname` = 'Marcus') AND ((`u`.`CityOfBirthName` <> 'Ephyra') OR `u`.`CityOfBirthName` IS NULL) """); } @@ -1865,8 +2008,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -WHERE `t0`.`Nickname` = 'Marcus' +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE `u`.`Nickname` = 'Marcus' """); } @@ -1885,15 +2028,15 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t1` ON (`t`.`GearNickName` = `t1`.`Nickname`) AND (`t`.`GearSquadId` = `t1`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId` FROM `Officers` AS `o0` -) AS `t2` ON (`t0`.`GearNickName` = `t2`.`Nickname`) AND (`t0`.`GearSquadId` = `t2`.`SquadId`) -WHERE ((`t1`.`Nickname` = `t2`.`Nickname`) OR (`t1`.`Nickname` IS NULL AND (`t2`.`Nickname` IS NULL))) AND ((`t1`.`SquadId` = `t2`.`SquadId`) OR (`t1`.`SquadId` IS NULL AND (`t2`.`SquadId` IS NULL))) +) AS `u0` ON (`t0`.`GearNickName` = `u0`.`Nickname`) AND (`t0`.`GearSquadId` = `u0`.`SquadId`) +WHERE ((`u`.`Nickname` = `u0`.`Nickname`) OR (`u`.`Nickname` IS NULL AND (`u0`.`Nickname` IS NULL))) AND ((`u`.`SquadId` = `u0`.`SquadId`) OR (`u`.`SquadId` IS NULL AND (`u0`.`SquadId` IS NULL))) """); } @@ -1911,8 +2054,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -WHERE `t0`.`Nickname` IS NULL OR (`t0`.`SquadId` IS NULL) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE `u`.`Nickname` IS NULL OR (`u`.`SquadId` IS NULL) """); } @@ -1930,8 +2073,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -WHERE `t0`.`Nickname` IS NULL OR (`t0`.`SquadId` IS NULL) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE `u`.`Nickname` IS NULL OR (`u`.`SquadId` IS NULL) """); } @@ -1950,15 +2093,15 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t1` ON (`t`.`GearNickName` = `t1`.`Nickname`) AND (`t`.`GearSquadId` = `t1`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId` FROM `Officers` AS `o0` -) AS `t2` ON (`t0`.`GearNickName` = `t2`.`Nickname`) AND (`t0`.`GearSquadId` = `t2`.`SquadId`) -WHERE (`t1`.`Nickname` = `t2`.`Nickname`) OR (`t1`.`Nickname` IS NULL AND (`t2`.`Nickname` IS NULL)) +) AS `u0` ON (`t0`.`GearNickName` = `u0`.`Nickname`) AND (`t0`.`GearSquadId` = `u0`.`SquadId`) +WHERE (`u`.`Nickname` = `u0`.`Nickname`) OR (`u`.`Nickname` IS NULL AND (`u0`.`Nickname` IS NULL)) """); } @@ -1983,18 +2126,18 @@ public override async Task Where_subquery_boolean(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE COALESCE(( SELECT `w`.`IsAutomatic` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` ORDER BY `w`.`Id` LIMIT 1), FALSE) """); @@ -2007,18 +2150,18 @@ public override async Task Where_subquery_boolean_with_pushdown(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE ( SELECT `w`.`IsAutomatic` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` ORDER BY `w`.`Id` LIMIT 1) """); @@ -2031,22 +2174,22 @@ public override async Task Where_subquery_distinct_firstordefault_boolean(bool a AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`HasSoulPatch` = TRUE) AND COALESCE(( - SELECT `t0`.`IsAutomatic` +) AS `u` +WHERE (`u`.`HasSoulPatch` = TRUE) AND COALESCE(( + SELECT `w0`.`IsAutomatic` FROM ( SELECT DISTINCT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` - ) AS `t0` - ORDER BY `t0`.`Id` + WHERE `u`.`FullName` = `w`.`OwnerFullName` + ) AS `w0` + ORDER BY `w0`.`Id` LIMIT 1), FALSE) """); } @@ -2058,22 +2201,22 @@ public override async Task Where_subquery_distinct_firstordefault_boolean_with_p AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`HasSoulPatch` = TRUE) AND ( - SELECT `t0`.`IsAutomatic` +) AS `u` +WHERE (`u`.`HasSoulPatch` = TRUE) AND ( + SELECT `w0`.`IsAutomatic` FROM ( SELECT DISTINCT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` - ) AS `t0` - ORDER BY `t0`.`Id` + WHERE `u`.`FullName` = `w`.`OwnerFullName` + ) AS `w0` + ORDER BY `w0`.`Id` LIMIT 1) """); } @@ -2085,24 +2228,24 @@ public override async Task Where_subquery_distinct_first_boolean(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`HasSoulPatch` = TRUE) AND ( - SELECT `t0`.`IsAutomatic` +) AS `u` +WHERE (`u`.`HasSoulPatch` = TRUE) AND ( + SELECT `w0`.`IsAutomatic` FROM ( SELECT DISTINCT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` - ) AS `t0` - ORDER BY `t0`.`Id` + WHERE `u`.`FullName` = `w`.`OwnerFullName` + ) AS `w0` + ORDER BY `w0`.`Id` LIMIT 1) -ORDER BY `t`.`Nickname` +ORDER BY `u`.`Nickname` """); } @@ -2113,23 +2256,23 @@ public override async Task Where_subquery_distinct_singleordefault_boolean1(bool AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`HasSoulPatch` = TRUE) AND COALESCE(( - SELECT `t0`.`IsAutomatic` +) AS `u` +WHERE (`u`.`HasSoulPatch` = TRUE) AND COALESCE(( + SELECT `w0`.`IsAutomatic` FROM ( SELECT DISTINCT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Lancer%') - ) AS `t0` + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Lancer%') + ) AS `w0` LIMIT 1), FALSE) -ORDER BY `t`.`Nickname` +ORDER BY `u`.`Nickname` """); } @@ -2140,20 +2283,20 @@ public override async Task Where_subquery_distinct_singleordefault_boolean2(bool AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`HasSoulPatch` = TRUE) AND COALESCE(( +) AS `u` +WHERE (`u`.`HasSoulPatch` = TRUE) AND COALESCE(( SELECT DISTINCT `w`.`IsAutomatic` FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Lancer%') + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Lancer%') LIMIT 1), FALSE) -ORDER BY `t`.`Nickname` +ORDER BY `u`.`Nickname` """); } @@ -2164,23 +2307,23 @@ public override async Task Where_subquery_distinct_singleordefault_boolean_with_ AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`HasSoulPatch` = TRUE) AND ( - SELECT `t0`.`IsAutomatic` +) AS `u` +WHERE (`u`.`HasSoulPatch` = TRUE) AND ( + SELECT `w0`.`IsAutomatic` FROM ( SELECT DISTINCT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Lancer%') - ) AS `t0` + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Lancer%') + ) AS `w0` LIMIT 1) -ORDER BY `t`.`Nickname` +ORDER BY `u`.`Nickname` """); } @@ -2191,24 +2334,24 @@ public override async Task Where_subquery_distinct_lastordefault_boolean(bool as AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE NOT (( - SELECT `t0`.`IsAutomatic` + SELECT `w0`.`IsAutomatic` FROM ( SELECT DISTINCT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` - ) AS `t0` - ORDER BY `t0`.`Id` DESC + WHERE `u`.`FullName` = `w`.`OwnerFullName` + ) AS `w0` + ORDER BY `w0`.`Id` DESC LIMIT 1)) -ORDER BY `t`.`Nickname` +ORDER BY `u`.`Nickname` """); } @@ -2219,24 +2362,24 @@ public override async Task Where_subquery_distinct_last_boolean(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`HasSoulPatch` = FALSE) AND ( - SELECT `t0`.`IsAutomatic` +) AS `u` +WHERE (`u`.`HasSoulPatch` = FALSE) AND ( + SELECT `w0`.`IsAutomatic` FROM ( SELECT DISTINCT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` - ) AS `t0` - ORDER BY `t0`.`Id` DESC + WHERE `u`.`FullName` = `w`.`OwnerFullName` + ) AS `w0` + ORDER BY `w0`.`Id` DESC LIMIT 1) -ORDER BY `t`.`Nickname` +ORDER BY `u`.`Nickname` """); } @@ -2247,22 +2390,22 @@ public override async Task Where_subquery_distinct_orderby_firstordefault_boolea AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`HasSoulPatch` = TRUE) AND COALESCE(( - SELECT `t0`.`IsAutomatic` +) AS `u` +WHERE (`u`.`HasSoulPatch` = TRUE) AND COALESCE(( + SELECT `w0`.`IsAutomatic` FROM ( SELECT DISTINCT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` - ) AS `t0` - ORDER BY `t0`.`Id` + WHERE `u`.`FullName` = `w`.`OwnerFullName` + ) AS `w0` + ORDER BY `w0`.`Id` LIMIT 1), FALSE) """); } @@ -2274,22 +2417,22 @@ public override async Task Where_subquery_distinct_orderby_firstordefault_boolea AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`HasSoulPatch` = TRUE) AND ( - SELECT `t0`.`IsAutomatic` +) AS `u` +WHERE (`u`.`HasSoulPatch` = TRUE) AND ( + SELECT `w0`.`IsAutomatic` FROM ( SELECT DISTINCT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` - ) AS `t0` - ORDER BY `t0`.`Id` + WHERE `u`.`FullName` = `w`.`OwnerFullName` + ) AS `w0` + ORDER BY `w0`.`Id` LIMIT 1) """); } @@ -2301,26 +2444,26 @@ public override async Task Where_subquery_union_firstordefault_boolean(bool asyn AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`HasSoulPatch` = TRUE) AND ( - SELECT `t0`.`IsAutomatic` +) AS `u` +WHERE (`u`.`HasSoulPatch` = TRUE) AND ( + SELECT `u0`.`IsAutomatic` FROM ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` UNION SELECT `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM `Weapons` AS `w0` - WHERE `t`.`FullName` = `w0`.`OwnerFullName` - ) AS `t0` - ORDER BY `t0`.`Id` + WHERE `u`.`FullName` = `w0`.`OwnerFullName` + ) AS `u0` + ORDER BY `u0`.`Id` LIMIT 1) """); } @@ -2332,23 +2475,23 @@ public override async Task Where_subquery_join_firstordefault_boolean(bool async AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`HasSoulPatch` = TRUE) AND ( +) AS `u` +WHERE (`u`.`HasSoulPatch` = TRUE) AND ( SELECT `w`.`IsAutomatic` FROM `Weapons` AS `w` INNER JOIN ( - SELECT `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` + SELECT `w0`.`Id` FROM `Weapons` AS `w0` - WHERE `t`.`FullName` = `w0`.`OwnerFullName` - ) AS `t0` ON `w`.`Id` = `t0`.`Id` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w0`.`OwnerFullName` + ) AS `w1` ON `w`.`Id` = `w1`.`Id` + WHERE `u`.`FullName` = `w`.`OwnerFullName` ORDER BY `w`.`Id` LIMIT 1) """); @@ -2361,23 +2504,23 @@ public override async Task Where_subquery_left_join_firstordefault_boolean(bool AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`HasSoulPatch` = TRUE) AND ( +) AS `u` +WHERE (`u`.`HasSoulPatch` = TRUE) AND ( SELECT `w`.`IsAutomatic` FROM `Weapons` AS `w` LEFT JOIN ( - SELECT `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` + SELECT `w0`.`Id` FROM `Weapons` AS `w0` - WHERE `t`.`FullName` = `w0`.`OwnerFullName` - ) AS `t0` ON `w`.`Id` = `t0`.`Id` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w0`.`OwnerFullName` + ) AS `w1` ON `w`.`Id` = `w1`.`Id` + WHERE `u`.`FullName` = `w`.`OwnerFullName` ORDER BY `w`.`Id` LIMIT 1) """); @@ -2390,26 +2533,26 @@ public override async Task Where_subquery_concat_firstordefault_boolean(bool asy AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`HasSoulPatch` = TRUE) AND ( - SELECT `t0`.`IsAutomatic` +) AS `u` +WHERE (`u`.`HasSoulPatch` = TRUE) AND ( + SELECT `u0`.`IsAutomatic` FROM ( - SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` + SELECT `w`.`Id`, `w`.`IsAutomatic` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` UNION ALL - SELECT `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` + SELECT `w0`.`Id`, `w0`.`IsAutomatic` FROM `Weapons` AS `w0` - WHERE `t`.`FullName` = `w0`.`OwnerFullName` - ) AS `t0` - ORDER BY `t0`.`Id` + WHERE `u`.`FullName` = `w0`.`OwnerFullName` + ) AS `u0` + ORDER BY `u0`.`Id` LIMIT 1) """); } @@ -2422,18 +2565,18 @@ public override async Task Concat_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT 1 FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT 1 FROM `Officers` AS `o` UNION ALL - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT 1 FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT 1 FROM `Officers` AS `o0` -) AS `t0` +) AS `u1` """); } @@ -2445,18 +2588,18 @@ public override async Task Concat_scalars_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT 1 FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT 1 FROM `Officers` AS `o` UNION ALL - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT 1 FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT 1 FROM `Officers` AS `o0` -) AS `t0` +) AS `u1` """); } @@ -2468,24 +2611,24 @@ public override async Task Concat_anonymous_with_count(bool async) """ SELECT COUNT(*) FROM ( - SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t`.`Nickname` AS `Name` + SELECT 1 FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT 1 FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT 1 FROM `Officers` AS `o` - ) AS `t` + ) AS `u` UNION ALL - SELECT `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator`, `t1`.`FullName` AS `Name` + SELECT 1 FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT 1 FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT 1 FROM `Officers` AS `o0` - ) AS `t1` -) AS `t0` + ) AS `u0` +) AS `u1` """); } @@ -2519,22 +2662,22 @@ public override async Task Select_navigation_with_concat_and_count(bool async) SELECT ( SELECT COUNT(*) FROM ( - SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` + SELECT 1 FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` UNION ALL - SELECT `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` + SELECT 1 FROM `Weapons` AS `w0` - WHERE `t`.`FullName` = `w0`.`OwnerFullName` - ) AS `t0`) + WHERE `u`.`FullName` = `w0`.`OwnerFullName` + ) AS `u0`) FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`HasSoulPatch` = FALSE +) AS `u` +WHERE `u`.`HasSoulPatch` = FALSE """); } @@ -2550,20 +2693,20 @@ SELECT COUNT(*) FROM ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` UNION SELECT `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM `Weapons` AS `w0` - WHERE `t`.`FullName` = `w0`.`OwnerFullName` - ) AS `t0`) + WHERE `u`.`FullName` = `w0`.`OwnerFullName` + ) AS `u0`) FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`HasSoulPatch` = TRUE +) AS `u` +WHERE `u`.`HasSoulPatch` = TRUE """); } @@ -2577,30 +2720,30 @@ public override async Task Union_with_collection_navigations(bool async) SELECT ( SELECT COUNT(*) FROM ( - SELECT `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` - ) AS `t1` - WHERE (`t`.`Nickname` = `t1`.`LeaderNickname`) AND (`t`.`SquadId` = `t1`.`LeaderSquadId`) + ) AS `u0` + WHERE (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) UNION - SELECT `t2`.`Nickname`, `t2`.`SquadId`, `t2`.`AssignedCityName`, `t2`.`CityOfBirthName`, `t2`.`FullName`, `t2`.`HasSoulPatch`, `t2`.`LeaderNickname`, `t2`.`LeaderSquadId`, `t2`.`Rank`, `t2`.`Discriminator` + SELECT `u1`.`Nickname`, `u1`.`SquadId`, `u1`.`AssignedCityName`, `u1`.`CityOfBirthName`, `u1`.`FullName`, `u1`.`HasSoulPatch`, `u1`.`LeaderNickname`, `u1`.`LeaderSquadId`, `u1`.`Rank`, `u1`.`Discriminator` FROM ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`AssignedCityName`, `o1`.`CityOfBirthName`, `o1`.`FullName`, `o1`.`HasSoulPatch`, `o1`.`LeaderNickname`, `o1`.`LeaderSquadId`, `o1`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o1` - ) AS `t2` - WHERE (`t`.`Nickname` = `t2`.`LeaderNickname`) AND (`t`.`SquadId` = `t2`.`LeaderSquadId`) - ) AS `t0`) + ) AS `u1` + WHERE (`u`.`Nickname` = `u1`.`LeaderNickname`) AND (`u`.`SquadId` = `u1`.`LeaderSquadId`) + ) AS `u2`) FROM ( SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -2612,13 +2755,13 @@ public override async Task Select_subquery_distinct_firstordefault(bool async) AssertSql( """ SELECT ( - SELECT `t0`.`Name` + SELECT `w0`.`Name` FROM ( SELECT DISTINCT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` - ) AS `t0` - ORDER BY `t0`.`Id` + WHERE `u`.`FullName` = `w`.`OwnerFullName` + ) AS `w0` + ORDER BY `w0`.`Id` LIMIT 1) FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch` @@ -2626,8 +2769,8 @@ ORDER BY `t0`.`Id` UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`HasSoulPatch` = TRUE +) AS `u` +WHERE `u`.`HasSoulPatch` = TRUE """); } @@ -2637,7 +2780,7 @@ public override async Task Singleton_Navigation_With_Member_Access(bool async) AssertSql( """ -SELECT `t0`.`CityOfBirthName` AS `B` +SELECT `u`.`CityOfBirthName` AS `B` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`CityOfBirthName` @@ -2645,8 +2788,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`CityOfBirthName` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -WHERE (`t0`.`Nickname` = 'Marcus') AND ((`t0`.`CityOfBirthName` <> 'Ephyra') OR `t0`.`CityOfBirthName` IS NULL) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE (`u`.`Nickname` = 'Marcus') AND ((`u`.`CityOfBirthName` <> 'Ephyra') OR `u`.`CityOfBirthName` IS NULL) """); } @@ -2656,7 +2799,7 @@ public override async Task GroupJoin_Composite_Key(bool async) AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM `Tags` AS `t` INNER JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -2664,7 +2807,7 @@ INNER JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) """); } @@ -2674,25 +2817,25 @@ public override async Task Join_navigation_translated_to_subquery_composite_key( AssertSql( """ -SELECT `t`.`FullName`, `t1`.`Note` +SELECT `u`.`FullName`, `s`.`Note` FROM ( SELECT `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` INNER JOIN ( - SELECT `t0`.`Note`, `t2`.`FullName` - FROM `Tags` AS `t0` + SELECT `t`.`Note`, `u0`.`FullName` + FROM `Tags` AS `t` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName` FROM `Officers` AS `o0` - ) AS `t2` ON (`t0`.`GearNickName` = `t2`.`Nickname`) AND (`t0`.`GearSquadId` = `t2`.`SquadId`) -) AS `t1` ON `t`.`FullName` = `t1`.`FullName` + ) AS `u0` ON (`t`.`GearNickName` = `u0`.`Nickname`) AND (`t`.`GearSquadId` = `u0`.`SquadId`) +) AS `s` ON `u`.`FullName` = `s`.`FullName` """); } @@ -2702,25 +2845,25 @@ public override async Task Join_with_order_by_on_inner_sequence_navigation_trans AssertSql( """ -SELECT `t`.`FullName`, `t1`.`Note` +SELECT `u`.`FullName`, `s`.`Note` FROM ( SELECT `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` INNER JOIN ( - SELECT `t0`.`Note`, `t2`.`FullName` - FROM `Tags` AS `t0` + SELECT `t`.`Note`, `u0`.`FullName` + FROM `Tags` AS `t` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName` FROM `Officers` AS `o0` - ) AS `t2` ON (`t0`.`GearNickName` = `t2`.`Nickname`) AND (`t0`.`GearSquadId` = `t2`.`SquadId`) -) AS `t1` ON `t`.`FullName` = `t1`.`FullName` + ) AS `u0` ON (`t`.`GearNickName` = `u0`.`Nickname`) AND (`t`.`GearSquadId` = `u0`.`SquadId`) +) AS `s` ON `u`.`FullName` = `s`.`FullName` """); } @@ -2730,15 +2873,15 @@ public override async Task Join_with_order_by_without_skip_or_take(bool async) AssertSql( """ -SELECT `w`.`Name`, `t`.`FullName` +SELECT `w`.`Name`, `u`.`FullName` FROM ( SELECT `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` +) AS `u` +INNER JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` """); } @@ -2748,7 +2891,7 @@ public override async Task Join_with_order_by_without_skip_or_take_nested(bool a AssertSql( """ -SELECT `w`.`Name`, `t`.`FullName` +SELECT `w`.`Name`, `u`.`FullName` FROM `Squads` AS `s` INNER JOIN ( SELECT `g`.`SquadId`, `g`.`FullName` @@ -2756,8 +2899,8 @@ INNER JOIN ( UNION ALL SELECT `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` ON `s`.`Id` = `t`.`SquadId` -INNER JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` +) AS `u` ON `s`.`Id` = `u`.`SquadId` +INNER JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` """); } @@ -2767,13 +2910,13 @@ public override async Task Collection_with_inheritance_and_join_include_joined(b AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `t1`.`Id`, `t1`.`GearNickName`, `t1`.`GearSquadId`, `t1`.`IssueDate`, `t1`.`Note` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t0`.`Id`, `t0`.`GearNickName`, `t0`.`GearSquadId`, `t0`.`IssueDate`, `t0`.`Note` FROM `Tags` AS `t` INNER JOIN ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearSquadId` = `t0`.`SquadId`) AND (`t`.`GearNickName` = `t0`.`Nickname`) -LEFT JOIN `Tags` AS `t1` ON (`t0`.`Nickname` = `t1`.`GearNickName`) AND (`t0`.`SquadId` = `t1`.`GearSquadId`) +) AS `u` ON (`t`.`GearSquadId` = `u`.`SquadId`) AND (`t`.`GearNickName` = `u`.`Nickname`) +LEFT JOIN `Tags` AS `t0` ON (`u`.`Nickname` = `t0`.`GearNickName`) AND (`u`.`SquadId` = `t0`.`GearSquadId`) """); } @@ -2783,13 +2926,13 @@ public override async Task Collection_with_inheritance_and_join_include_source(b AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t1`.`Id`, `t1`.`GearNickName`, `t1`.`GearSquadId`, `t1`.`IssueDate`, `t1`.`Note` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t0`.`Id`, `t0`.`GearNickName`, `t0`.`GearSquadId`, `t0`.`IssueDate`, `t0`.`Note` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Tags` AS `t0` ON (`t`.`SquadId` = `t0`.`GearSquadId`) AND (`t`.`Nickname` = `t0`.`GearNickName`) -LEFT JOIN `Tags` AS `t1` ON (`t`.`Nickname` = `t1`.`GearNickName`) AND (`t`.`SquadId` = `t1`.`GearSquadId`) +) AS `u` +INNER JOIN `Tags` AS `t` ON (`u`.`SquadId` = `t`.`GearSquadId`) AND (`u`.`Nickname` = `t`.`GearNickName`) +LEFT JOIN `Tags` AS `t0` ON (`u`.`Nickname` = `t0`.`GearNickName`) AND (`u`.`SquadId` = `t0`.`GearSquadId`) """); } @@ -2872,13 +3015,13 @@ public override async Task Non_unicode_string_literals_is_used_for_non_unicode_c WHERE (`c`.`Location` = 'Unknown') AND (( SELECT COUNT(*) FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`Nickname`, `g`.`CityOfBirthName` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`Nickname`, `o`.`CityOfBirthName` FROM `Officers` AS `o` - ) AS `t` - WHERE (`c`.`Name` = `t`.`CityOfBirthName`) AND (`t`.`Nickname` = 'Paduk')) = 1) + ) AS `u` + WHERE (`c`.`Name` = `u`.`CityOfBirthName`) AND (`u`.`Nickname` = 'Paduk')) = 1) """); } @@ -2888,16 +3031,16 @@ public override async Task Non_unicode_string_literals_is_used_for_non_unicode_c AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Cities` AS `c` ON `t`.`CityOfBirthName` = `c`.`Name` -WHERE (`t`.`Nickname` = 'Marcus') AND (`c`.`Location` = 'Jacinto''s location') +) AS `u` +INNER JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` +WHERE (`u`.`Nickname` = 'Marcus') AND (`c`.`Location` = 'Jacinto''s location') """); } @@ -2913,18 +3056,6 @@ public override async Task Non_unicode_string_literals_is_used_for_non_unicode_c """); } - public override async Task Unicode_string_literals_is_used_for_non_unicode_column_with_concat(bool async) - { - await base.Unicode_string_literals_is_used_for_non_unicode_column_with_concat(async); - - AssertSql( -""" -SELECT `c`.`Name`, `c`.`Location`, `c`.`Nation` -FROM `Cities` AS `c` -WHERE CONCAT(COALESCE(`c`.`Location`, ''), 'Added') LIKE '%Add%' -"""); - } - public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1() { base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1(); @@ -2932,23 +3063,23 @@ public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesc // Issue#16897 AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON `t`.`LeaderNickname` = `t0`.`Nickname` -LEFT JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname`, `t0`.`SquadId` +) AS `u0` ON `u`.`LeaderNickname` = `u0`.`Nickname` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId` """); } @@ -2959,23 +3090,23 @@ public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesc // Issue#16897 AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `t`.`Nickname`, `t`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u`.`Nickname`, `u`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON `t`.`LeaderNickname` = `t0`.`Nickname` -LEFT JOIN `Weapons` AS `w` ON `t0`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname`, `t0`.`SquadId` +) AS `u0` ON `u`.`LeaderNickname` = `u0`.`Nickname` +LEFT JOIN `Weapons` AS `w` ON `u0`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId` """); } @@ -2986,24 +3117,24 @@ public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_c // Issue#16897 AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `t`.`Nickname`, `t`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` +SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u`.`Nickname`, `u`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON `t`.`LeaderNickname` = `t0`.`Nickname` -LEFT JOIN `Weapons` AS `w` ON `t0`.`FullName` = `w`.`OwnerFullName` -LEFT JOIN `Weapons` AS `w0` ON `t`.`FullName` = `w0`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname`, `t0`.`SquadId`, `w`.`Id` +) AS `u0` ON `u`.`LeaderNickname` = `u0`.`Nickname` +LEFT JOIN `Weapons` AS `w` ON `u0`.`FullName` = `w`.`OwnerFullName` +LEFT JOIN `Weapons` AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId`, `w`.`Id` """); } @@ -3014,26 +3145,26 @@ public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_c // Issue#16897 AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId`, `w1`.`Id`, `w1`.`AmmunitionType`, `w1`.`IsAutomatic`, `w1`.`Name`, `w1`.`OwnerFullName`, `w1`.`SynergyWithId`, `w2`.`Id`, `w2`.`AmmunitionType`, `w2`.`IsAutomatic`, `w2`.`Name`, `w2`.`OwnerFullName`, `w2`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId`, `w1`.`Id`, `w1`.`AmmunitionType`, `w1`.`IsAutomatic`, `w1`.`Name`, `w1`.`OwnerFullName`, `w1`.`SynergyWithId`, `w2`.`Id`, `w2`.`AmmunitionType`, `w2`.`IsAutomatic`, `w2`.`Name`, `w2`.`OwnerFullName`, `w2`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON `t`.`LeaderNickname` = `t0`.`Nickname` -LEFT JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` -LEFT JOIN `Weapons` AS `w0` ON `t0`.`FullName` = `w0`.`OwnerFullName` -LEFT JOIN `Weapons` AS `w1` ON `t0`.`FullName` = `w1`.`OwnerFullName` -LEFT JOIN `Weapons` AS `w2` ON `t`.`FullName` = `w2`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname`, `t0`.`SquadId`, `w`.`Id`, `w0`.`Id`, `w1`.`Id` +) AS `u0` ON `u`.`LeaderNickname` = `u0`.`Nickname` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +LEFT JOIN `Weapons` AS `w0` ON `u0`.`FullName` = `w0`.`OwnerFullName` +LEFT JOIN `Weapons` AS `w1` ON `u0`.`FullName` = `w1`.`OwnerFullName` +LEFT JOIN `Weapons` AS `w2` ON `u`.`FullName` = `w2`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId`, `w`.`Id`, `w0`.`Id`, `w1`.`Id` """); } @@ -3043,22 +3174,22 @@ public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_i // Issue#16897 AssertSql( -$""" -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `t`.`Nickname`, `t`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` +""" +SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u`.`Nickname`, `u`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Officer'")} AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON `t`.`LeaderNickname` = `t0`.`Nickname` -LEFT JOIN `Weapons` AS `w` ON `t0`.`FullName` = `w`.`OwnerFullName` -LEFT JOIN `Weapons` AS `w0` ON `t`.`FullName` = `w0`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname`, `t0`.`SquadId`, `w`.`Id` +) AS `u0` ON `u`.`LeaderNickname` = `u0`.`Nickname` +LEFT JOIN `Weapons` AS `w` ON `u0`.`FullName` = `w`.`OwnerFullName` +LEFT JOIN `Weapons` AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId`, `w`.`Id` """); } @@ -3069,24 +3200,24 @@ public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_c // Issue#16897 AssertSql( """ -SELECT `t0`.`Nickname` IS NOT NULL AND (`t0`.`SquadId` IS NOT NULL), `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `t`.`Nickname`, `t`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` +SELECT `u0`.`Nickname` IS NOT NULL AND (`u0`.`SquadId` IS NOT NULL), `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u`.`Nickname`, `u`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON `t`.`LeaderNickname` = `t0`.`Nickname` -LEFT JOIN `Weapons` AS `w` ON `t0`.`FullName` = `w`.`OwnerFullName` -LEFT JOIN `Weapons` AS `w0` ON `t`.`FullName` = `w0`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname`, `t0`.`SquadId`, `w`.`Id` +) AS `u0` ON `u`.`LeaderNickname` = `u0`.`Nickname` +LEFT JOIN `Weapons` AS `w` ON `u0`.`FullName` = `w`.`OwnerFullName` +LEFT JOIN `Weapons` AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId`, `w`.`Id` """); } @@ -3096,28 +3227,28 @@ public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_c AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId`, `w1`.`Id`, `w1`.`AmmunitionType`, `w1`.`IsAutomatic`, `w1`.`Name`, `w1`.`OwnerFullName`, `w1`.`SynergyWithId`, `w2`.`Id`, `w2`.`AmmunitionType`, `w2`.`IsAutomatic`, `w2`.`Name`, `w2`.`OwnerFullName`, `w2`.`SynergyWithId`, `t0`.`Nickname` IS NOT NULL AND (`t0`.`SquadId` IS NOT NULL), `w3`.`Id`, `w3`.`AmmunitionType`, `w3`.`IsAutomatic`, `w3`.`Name`, `w3`.`OwnerFullName`, `w3`.`SynergyWithId`, `w4`.`Id`, `w4`.`AmmunitionType`, `w4`.`IsAutomatic`, `w4`.`Name`, `w4`.`OwnerFullName`, `w4`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId`, `w1`.`Id`, `w1`.`AmmunitionType`, `w1`.`IsAutomatic`, `w1`.`Name`, `w1`.`OwnerFullName`, `w1`.`SynergyWithId`, `w2`.`Id`, `w2`.`AmmunitionType`, `w2`.`IsAutomatic`, `w2`.`Name`, `w2`.`OwnerFullName`, `w2`.`SynergyWithId`, `u0`.`Nickname` IS NOT NULL AND (`u0`.`SquadId` IS NOT NULL), `w3`.`Id`, `w3`.`AmmunitionType`, `w3`.`IsAutomatic`, `w3`.`Name`, `w3`.`OwnerFullName`, `w3`.`SynergyWithId`, `w4`.`Id`, `w4`.`AmmunitionType`, `w4`.`IsAutomatic`, `w4`.`Name`, `w4`.`OwnerFullName`, `w4`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON `t`.`LeaderNickname` = `t0`.`Nickname` -LEFT JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` -LEFT JOIN `Weapons` AS `w0` ON `t0`.`FullName` = `w0`.`OwnerFullName` -LEFT JOIN `Weapons` AS `w1` ON `t0`.`FullName` = `w1`.`OwnerFullName` -LEFT JOIN `Weapons` AS `w2` ON `t`.`FullName` = `w2`.`OwnerFullName` -LEFT JOIN `Weapons` AS `w3` ON `t0`.`FullName` = `w3`.`OwnerFullName` -LEFT JOIN `Weapons` AS `w4` ON `t`.`FullName` = `w4`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname`, `t0`.`SquadId`, `w`.`Id`, `w0`.`Id`, `w1`.`Id`, `w2`.`Id`, `w3`.`Id` +) AS `u0` ON `u`.`LeaderNickname` = `u0`.`Nickname` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +LEFT JOIN `Weapons` AS `w0` ON `u0`.`FullName` = `w0`.`OwnerFullName` +LEFT JOIN `Weapons` AS `w1` ON `u0`.`FullName` = `w1`.`OwnerFullName` +LEFT JOIN `Weapons` AS `w2` ON `u`.`FullName` = `w2`.`OwnerFullName` +LEFT JOIN `Weapons` AS `w3` ON `u0`.`FullName` = `w3`.`OwnerFullName` +LEFT JOIN `Weapons` AS `w4` ON `u`.`FullName` = `w4`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId`, `w`.`Id`, `w0`.`Id`, `w1`.`Id`, `w2`.`Id`, `w3`.`Id` """); } @@ -3127,9 +3258,16 @@ public override async Task Coalesce_operator_in_predicate(bool async) AssertSql( """ -SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` -FROM `Weapons` AS `w` -WHERE COALESCE(`w`.`IsAutomatic`, FALSE) +SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` +FROM `Tags` AS `t` +LEFT JOIN ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` + FROM `Officers` AS `o` +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE COALESCE(`u`.`HasSoulPatch`, FALSE) """); } @@ -3139,9 +3277,16 @@ public override async Task Coalesce_operator_in_predicate_with_other_conditions( AssertSql( """ -SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` -FROM `Weapons` AS `w` -WHERE (`w`.`AmmunitionType` = 1) AND COALESCE(`w`.`IsAutomatic`, FALSE) +SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` +FROM `Tags` AS `t` +LEFT JOIN ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` + FROM `Officers` AS `o` +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE ((`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL) AND COALESCE(`u`.`HasSoulPatch`, FALSE) """); } @@ -3151,8 +3296,15 @@ public override async Task Coalesce_operator_in_projection_with_other_conditions AssertSql( """ -SELECT ((`w`.`AmmunitionType` = 1) AND `w`.`AmmunitionType` IS NOT NULL) AND COALESCE(`w`.`IsAutomatic`, FALSE) -FROM `Weapons` AS `w` +SELECT ((`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL) AND COALESCE(`u`.`HasSoulPatch`, FALSE) +FROM `Tags` AS `t` +LEFT JOIN ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` + FROM `Officers` AS `o` +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) """); } @@ -3170,8 +3322,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -WHERE ((`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL) AND (`t0`.`HasSoulPatch` = TRUE) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE ((`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL) AND (`u`.`HasSoulPatch` = TRUE) """); } @@ -3189,8 +3341,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -WHERE `t0`.`HasSoulPatch` = TRUE +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE `u`.`HasSoulPatch` = TRUE """); } @@ -3208,8 +3360,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -WHERE `t0`.`HasSoulPatch` = FALSE +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE `u`.`HasSoulPatch` = FALSE """); } @@ -3227,10 +3379,10 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE NOT (CASE - WHEN `t0`.`HasSoulPatch` = TRUE THEN TRUE - ELSE `t0`.`HasSoulPatch` + WHEN `u`.`HasSoulPatch` = TRUE THEN TRUE + ELSE `u`.`HasSoulPatch` END) """); } @@ -3249,10 +3401,10 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE NOT (CASE - WHEN `t0`.`HasSoulPatch` = FALSE THEN FALSE - ELSE `t0`.`HasSoulPatch` + WHEN `u`.`HasSoulPatch` = FALSE THEN FALSE + ELSE `u`.`HasSoulPatch` END) """); } @@ -3271,9 +3423,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE CASE - WHEN `t0`.`HasSoulPatch` = TRUE THEN TRUE + WHEN `u`.`HasSoulPatch` = TRUE THEN TRUE ELSE FALSE END """); @@ -3293,8 +3445,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -WHERE (`t0`.`HasSoulPatch` = TRUE) OR (`t`.`Note` LIKE '%Cole%') +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE (`u`.`HasSoulPatch` = TRUE) OR (`t`.`Note` LIKE '%Cole%') """); } @@ -3304,7 +3456,7 @@ public override async Task Optional_navigation_type_compensation_works_with_bina AssertSql( """ -SELECT (`t0`.`HasSoulPatch` = TRUE) AND ((`t`.`Note` LIKE '%Cole%') AND `t`.`Note` IS NOT NULL) +SELECT (`u`.`HasSoulPatch` = TRUE) AND ((`t`.`Note` LIKE '%Cole%') AND `t`.`Note` IS NOT NULL) FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` @@ -3312,7 +3464,7 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) """); } @@ -3322,7 +3474,7 @@ public override async Task Optional_navigation_type_compensation_works_with_proj AssertSql( """ -SELECT `t0`.`SquadId` +SELECT `u`.`SquadId` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId` @@ -3330,7 +3482,7 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE (`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL """); } @@ -3341,7 +3493,7 @@ public override async Task Optional_navigation_type_compensation_works_with_proj AssertSql( """ -SELECT `t0`.`SquadId` +SELECT `u`.`SquadId` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId` @@ -3349,7 +3501,7 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE (`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL """); } @@ -3360,7 +3512,7 @@ public override async Task Optional_navigation_type_compensation_works_with_DTOs AssertSql( """ -SELECT `t0`.`SquadId` AS `Id` +SELECT `u`.`SquadId` AS `Id` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId` @@ -3368,7 +3520,7 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE (`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL """); } @@ -3379,7 +3531,7 @@ public override async Task Optional_navigation_type_compensation_works_with_list AssertSql( """ -SELECT `t0`.`SquadId`, `t0`.`SquadId` + 1 +SELECT `u`.`SquadId`, `u`.`SquadId` + 1 FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId` @@ -3387,7 +3539,7 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE (`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL ORDER BY `t`.`Note` """); @@ -3399,7 +3551,7 @@ public override async Task Optional_navigation_type_compensation_works_with_arra AssertSql( """ -SELECT `t0`.`SquadId` +SELECT `u`.`SquadId` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId` @@ -3407,7 +3559,7 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE (`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL """); } @@ -3426,9 +3578,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE (`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL -ORDER BY `t0`.`SquadId` +ORDER BY `u`.`SquadId` """); } @@ -3442,13 +3594,13 @@ SELECT NOT EXISTS ( SELECT 1 FROM `Tags` AS `t` LEFT JOIN ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) - WHERE ((`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL) AND (`t0`.`HasSoulPatch` = FALSE)) + ) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) + WHERE ((`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL) AND (`u`.`HasSoulPatch` = FALSE)) """); } @@ -3466,8 +3618,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -WHERE ((`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL) AND (`t0`.`HasSoulPatch` = FALSE) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE ((`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL) AND (`u`.`HasSoulPatch` = FALSE) """); } @@ -3485,8 +3637,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -WHERE ((`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL) AND `t0`.`SquadId` IN ( +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE ((`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL) AND `u`.`SquadId` IN ( SELECT `g0`.`SquadId` FROM `Gears` AS `g0` UNION ALL @@ -3516,22 +3668,22 @@ public override async Task Select_correlated_filtered_collection(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `c`.`Name`, `t0`.`Id`, `t0`.`AmmunitionType`, `t0`.`IsAutomatic`, `t0`.`Name`, `t0`.`OwnerFullName`, `t0`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `c`.`Name`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`CityOfBirthName`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`CityOfBirthName`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Cities` AS `c` ON `t`.`CityOfBirthName` = `c`.`Name` +) AS `u` +INNER JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` LEFT JOIN ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` WHERE (`w`.`Name` <> 'Lancer') OR `w`.`Name` IS NULL -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` +) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` WHERE `c`.`Name` IN ('Ephyra', 'Hanover') -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `c`.`Name` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `c`.`Name` """); } @@ -3540,24 +3692,24 @@ public override async Task Select_correlated_filtered_collection_with_composite_ await base.Select_correlated_filtered_collection_with_composite_key(async); AssertSql( -$""" -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +""" +SELECT `u`.`Nickname`, `u`.`SquadId`, `u1`.`Nickname`, `u1`.`SquadId`, `u1`.`AssignedCityName`, `u1`.`CityOfBirthName`, `u1`.`FullName`, `u1`.`HasSoulPatch`, `u1`.`LeaderNickname`, `u1`.`LeaderSquadId`, `u1`.`Rank`, `u1`.`Discriminator` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Gear'")} AS `Discriminator` + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Officer'")} AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` - ) AS `t1` - WHERE `t1`.`Nickname` <> 'Dom' -) AS `t0` ON (`t`.`Nickname` = `t0`.`LeaderNickname`) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` + ) AS `u0` + WHERE `u0`.`Nickname` <> 'Dom' +) AS `u1` ON (`u`.`Nickname` = `u1`.`LeaderNickname`) AND (`u`.`SquadId` = `u1`.`LeaderSquadId`) +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u1`.`Nickname` """); } @@ -3567,7 +3719,7 @@ public override async Task Select_correlated_filtered_collection_works_with_cach AssertSql( """ -SELECT `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `t`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -3575,8 +3727,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON `t`.`GearNickName` = `t0`.`Nickname` -ORDER BY `t`.`Note`, `t`.`Id`, `t0`.`Nickname` +) AS `u` ON `t`.`GearNickName` = `u`.`Nickname` +ORDER BY `t`.`Note`, `t`.`Id`, `u`.`Nickname` """); } @@ -3586,14 +3738,14 @@ public override async Task Join_predicate_value_equals_condition(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` INNER JOIN `Weapons` AS `w` ON `w`.`SynergyWithId` IS NOT NULL """); } @@ -3604,15 +3756,15 @@ public override async Task Join_predicate_value(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Weapons` AS `w` ON `t`.`HasSoulPatch` = TRUE +) AS `u` +INNER JOIN `Weapons` AS `w` ON `u`.`HasSoulPatch` = TRUE """); } @@ -3622,14 +3774,14 @@ public override async Task Join_predicate_condition_equals_condition(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` INNER JOIN `Weapons` AS `w` ON `w`.`SynergyWithId` IS NOT NULL """); } @@ -3640,14 +3792,14 @@ public override async Task Left_join_predicate_value_equals_condition(bool async AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN `Weapons` AS `w` ON `w`.`SynergyWithId` IS NOT NULL """); } @@ -3658,15 +3810,15 @@ public override async Task Left_join_predicate_value(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Weapons` AS `w` ON `t`.`HasSoulPatch` = TRUE +) AS `u` +LEFT JOIN `Weapons` AS `w` ON `u`.`HasSoulPatch` = TRUE """); } @@ -3676,14 +3828,14 @@ public override async Task Left_join_predicate_condition_equals_condition(bool a AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN `Weapons` AS `w` ON `w`.`SynergyWithId` IS NOT NULL """); } @@ -3694,9 +3846,9 @@ public override async Task Where_datetimeoffset_now(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` -WHERE `m`.`Timeline` <> UTC_TIMESTAMP() +WHERE `m`.`Timeline` <> UTC_TIMESTAMP(6) """); } @@ -3706,9 +3858,9 @@ public override async Task Where_datetimeoffset_utcnow(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` -WHERE `m`.`Timeline` <> UTC_TIMESTAMP() +WHERE `m`.`Timeline` <> UTC_TIMESTAMP(6) """); } @@ -3720,7 +3872,7 @@ public override async Task Where_datetimeoffset_date_component(bool async) """ @__Date_0='0001-01-01T00:00:00.0000000' (DbType = DateTime) -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE CONVERT(`m`.`Timeline`, date) > @__Date_0 """); @@ -3732,7 +3884,7 @@ public override async Task Where_datetimeoffset_year_component(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(year FROM `m`.`Timeline`) = 2 """); @@ -3744,7 +3896,7 @@ public override async Task Where_datetimeoffset_month_component(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(month FROM `m`.`Timeline`) = 1 """); @@ -3756,7 +3908,7 @@ public override async Task Where_datetimeoffset_dayofyear_component(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE DAYOFYEAR(`m`.`Timeline`) = 2 """); @@ -3768,7 +3920,7 @@ public override async Task Where_datetimeoffset_day_component(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(day FROM `m`.`Timeline`) = 2 """); @@ -3784,7 +3936,7 @@ await AssertQuery( AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(hour FROM `m`.`Timeline`) = 8 """); @@ -3796,7 +3948,7 @@ public override async Task Where_datetimeoffset_minute_component(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(minute FROM `m`.`Timeline`) = 0 """); @@ -3808,7 +3960,7 @@ public override async Task Where_datetimeoffset_second_component(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(second FROM `m`.`Timeline`) = 0 """); @@ -3820,7 +3972,7 @@ public override async Task Where_datetimeoffset_millisecond_component(bool async AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE (EXTRACT(microsecond FROM `m`.`Timeline`)) DIV (1000) = 0 """); @@ -3939,8 +4091,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` ON `w`.`OwnerFullName` = `t`.`FullName` -WHERE (`w`.`Id` <> 50) AND (`t`.`HasSoulPatch` = FALSE) +) AS `u` ON `w`.`OwnerFullName` = `u`.`FullName` +WHERE (`w`.`Id` <> 50) AND (`u`.`HasSoulPatch` = FALSE) """); } @@ -3950,16 +4102,16 @@ public override async Task Distinct_with_optional_navigation_is_translated_to_sq AssertSql( """ -SELECT DISTINCT `t`.`HasSoulPatch` +SELECT DISTINCT `u`.`HasSoulPatch` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) -WHERE (`t0`.`Note` <> 'Foo') OR `t0`.`Note` IS NULL +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) +WHERE (`t`.`Note` <> 'Foo') OR `t`.`Note` IS NULL """); } @@ -3969,16 +4121,16 @@ public override async Task Sum_with_optional_navigation_is_translated_to_sql(boo AssertSql( """ -SELECT COALESCE(SUM(`t`.`SquadId`), 0) +SELECT COALESCE(SUM(`u`.`SquadId`), 0) FROM ( SELECT `g`.`Nickname`, `g`.`SquadId` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) -WHERE (`t0`.`Note` <> 'Foo') OR `t0`.`Note` IS NULL +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) +WHERE (`t`.`Note` <> 'Foo') OR `t`.`Note` IS NULL """); } @@ -3995,9 +4147,9 @@ SELECT COUNT(*) UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) -WHERE (`t0`.`Note` <> 'Foo') OR `t0`.`Note` IS NULL +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) +WHERE (`t`.`Note` <> 'Foo') OR `t`.`Note` IS NULL """); } @@ -4010,12 +4162,12 @@ public override async Task FirstOrDefault_with_manually_created_groupjoin_is_tra SELECT `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` FROM `Squads` AS `s` LEFT JOIN ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`SquadId` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`SquadId` FROM `Officers` AS `o` -) AS `t` ON `s`.`Id` = `t`.`SquadId` +) AS `u` ON `s`.`Id` = `u`.`SquadId` WHERE `s`.`Name` = 'Kilo' LIMIT 1 """); @@ -4032,14 +4184,14 @@ public override async Task Any_with_optional_navigation_as_subquery_predicate_is WHERE NOT EXISTS ( SELECT 1 FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`Nickname`, `g`.`SquadId` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` - ) AS `t` - LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) - WHERE (`s`.`Id` = `t`.`SquadId`) AND (`t0`.`Note` = 'Dom''s Tag')) + ) AS `u` + LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) + WHERE (`s`.`Id` = `u`.`SquadId`) AND (`t`.`Note` = 'Dom''s Tag')) """); } @@ -4052,14 +4204,14 @@ public override async Task All_with_optional_navigation_is_translated_to_sql(boo SELECT NOT EXISTS ( SELECT 1 FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`Nickname`, `g`.`SquadId` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` - ) AS `t` - LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) - WHERE (`t0`.`Note` = 'Foo') AND `t0`.`Note` IS NOT NULL) + ) AS `u` + LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) + WHERE `t`.`Note` = 'Foo') """); } @@ -4099,16 +4251,16 @@ public override async Task Unnecessary_include_doesnt_get_added_complex_when_pro AssertSql( """ -SELECT `t`.`FullName` +SELECT `u`.`FullName` FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`Rank` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`HasSoulPatch` = TRUE -ORDER BY `t`.`Rank` +) AS `u` +WHERE `u`.`HasSoulPatch` = TRUE +ORDER BY `u`.`Rank` """); } @@ -4118,16 +4270,16 @@ public override async Task Multiple_order_bys_are_properly_lifted_from_subquery_ AssertSql( """ -SELECT `t`.`FullName` +SELECT `u`.`FullName` FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`HasSoulPatch` = FALSE -ORDER BY `t`.`FullName` +) AS `u` +WHERE `u`.`HasSoulPatch` = FALSE +ORDER BY `u`.`FullName` """); } @@ -4137,16 +4289,16 @@ public override async Task Order_by_is_properly_lifted_from_subquery_with_same_o AssertSql( """ -SELECT `t`.`FullName` +SELECT `u`.`FullName` FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`HasSoulPatch` = FALSE -ORDER BY `t`.`FullName` +) AS `u` +WHERE `u`.`HasSoulPatch` = FALSE +ORDER BY `u`.`FullName` """); } @@ -4156,17 +4308,17 @@ public override async Task Where_is_properly_lifted_from_subquery_created_by_inc AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`GearNickName`, `t0`.`GearSquadId`, `t0`.`IssueDate`, `t0`.`Note` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) -WHERE (`t`.`FullName` <> 'Augustus Cole') AND (`t`.`HasSoulPatch` = FALSE) -ORDER BY `t`.`FullName` +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) +WHERE (`u`.`FullName` <> 'Augustus Cole') AND (`u`.`HasSoulPatch` = FALSE) +ORDER BY `u`.`FullName` """); } @@ -4176,23 +4328,23 @@ public override async Task Subquery_is_lifted_from_main_from_clause_of_SelectMan AssertSql( """ -SELECT `t`.`FullName` AS `Name1`, `t0`.`FullName` AS `Name2` +SELECT `u`.`FullName` AS `Name1`, `u0`.`FullName` AS `Name2` FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` +) AS `u` CROSS JOIN ( SELECT `g0`.`FullName`, `g0`.`HasSoulPatch` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`FullName`, `o0`.`HasSoulPatch` FROM `Officers` AS `o0` -) AS `t0` -WHERE (`t`.`HasSoulPatch` = TRUE) AND (`t0`.`HasSoulPatch` = FALSE) -ORDER BY `t`.`FullName` +) AS `u0` +WHERE (`u`.`HasSoulPatch` = TRUE) AND (`u0`.`HasSoulPatch` = FALSE) +ORDER BY `u`.`FullName` """); } @@ -4202,17 +4354,17 @@ public override async Task Subquery_containing_SelectMany_projecting_main_from_c AssertSql( """ -SELECT `t`.`FullName` +SELECT `u`.`FullName` FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -CROSS JOIN `Tags` AS `t0` -WHERE `t`.`HasSoulPatch` = TRUE -ORDER BY `t`.`FullName` +) AS `u` +CROSS JOIN `Tags` AS `t` +WHERE `u`.`HasSoulPatch` = TRUE +ORDER BY `u`.`FullName` """); } @@ -4222,16 +4374,16 @@ public override async Task Subquery_containing_join_projecting_main_from_clause_ AssertSql( """ -SELECT `t`.`Nickname` +SELECT `u`.`Nickname` FROM ( SELECT `g`.`Nickname` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Tags` AS `t0` ON `t`.`Nickname` = `t0`.`GearNickName` -ORDER BY `t`.`Nickname` +) AS `u` +INNER JOIN `Tags` AS `t` ON `u`.`Nickname` = `t`.`GearNickName` +ORDER BY `u`.`Nickname` """); } @@ -4241,16 +4393,16 @@ public override async Task Subquery_containing_left_join_projecting_main_from_cl AssertSql( """ -SELECT `t`.`Nickname` +SELECT `u`.`Nickname` FROM ( SELECT `g`.`Nickname` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON `t`.`Nickname` = `t0`.`GearNickName` -ORDER BY `t`.`Nickname` +) AS `u` +LEFT JOIN `Tags` AS `t` ON `u`.`Nickname` = `t`.`GearNickName` +ORDER BY `u`.`Nickname` """); } @@ -4260,18 +4412,18 @@ public override async Task Subquery_containing_join_gets_lifted_clashing_names(b AssertSql( """ -SELECT `t`.`Nickname` +SELECT `u`.`Nickname` FROM ( SELECT `g`.`Nickname` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Tags` AS `t0` ON `t`.`Nickname` = `t0`.`GearNickName` -INNER JOIN `Tags` AS `t1` ON `t`.`Nickname` = `t1`.`GearNickName` -WHERE (`t0`.`GearNickName` <> 'Cole Train') OR `t0`.`GearNickName` IS NULL -ORDER BY `t`.`Nickname`, `t1`.`Id` +) AS `u` +INNER JOIN `Tags` AS `t` ON `u`.`Nickname` = `t`.`GearNickName` +INNER JOIN `Tags` AS `t0` ON `u`.`Nickname` = `t0`.`GearNickName` +WHERE (`t`.`GearNickName` <> 'Cole Train') OR `t`.`GearNickName` IS NULL +ORDER BY `u`.`Nickname`, `t0`.`Id` """); } @@ -4281,20 +4433,20 @@ public override async Task Subquery_created_by_include_gets_lifted_nested(bool a AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Cities` AS `c` ON `t`.`CityOfBirthName` = `c`.`Name` +) AS `u` +INNER JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` WHERE EXISTS ( SELECT 1 FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName`) AND (`t`.`HasSoulPatch` = FALSE) -ORDER BY `t`.`Nickname` + WHERE `u`.`FullName` = `w`.`OwnerFullName`) AND (`u`.`HasSoulPatch` = FALSE) +ORDER BY `u`.`Nickname` """); } @@ -4304,23 +4456,23 @@ public override async Task Subquery_is_lifted_from_additional_from_clause(bool a AssertSql( """ -SELECT `t`.`FullName` AS `Name1`, `t0`.`FullName` AS `Name2` +SELECT `u`.`FullName` AS `Name1`, `u0`.`FullName` AS `Name2` FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` +) AS `u` CROSS JOIN ( SELECT `g0`.`FullName`, `g0`.`HasSoulPatch` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`FullName`, `o0`.`HasSoulPatch` FROM `Officers` AS `o0` -) AS `t0` -WHERE (`t`.`HasSoulPatch` = TRUE) AND (`t0`.`HasSoulPatch` = FALSE) -ORDER BY `t`.`FullName` +) AS `u0` +WHERE (`u`.`HasSoulPatch` = TRUE) AND (`u0`.`HasSoulPatch` = FALSE) +ORDER BY `u`.`FullName` """); } @@ -4332,21 +4484,21 @@ public override async Task Subquery_with_result_operator_is_not_lifted(bool asyn """ @__p_0='2' -SELECT `t0`.`FullName` +SELECT `u0`.`FullName` FROM ( - SELECT `t`.`FullName`, `t`.`Rank` + SELECT `u`.`FullName`, `u`.`Rank` FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`Rank` FROM `Officers` AS `o` - ) AS `t` - WHERE `t`.`HasSoulPatch` = FALSE - ORDER BY `t`.`FullName` + ) AS `u` + WHERE `u`.`HasSoulPatch` = FALSE + ORDER BY `u`.`FullName` LIMIT @__p_0 -) AS `t0` -ORDER BY `t0`.`Rank` +) AS `u0` +ORDER BY `u0`.`Rank` """); } @@ -4358,25 +4510,25 @@ public override async Task Skip_with_orderby_followed_by_orderBy_is_pushed_down( """ @__p_0='1' -SELECT `t0`.`FullName` +SELECT `u0`.`FullName` FROM ( - SELECT `t`.`FullName`, `t`.`Rank` + SELECT `u`.`FullName`, `u`.`Rank` FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`Rank` FROM `Officers` AS `o` - ) AS `t` - WHERE `t`.`HasSoulPatch` = FALSE - ORDER BY `t`.`FullName` + ) AS `u` + WHERE `u`.`HasSoulPatch` = FALSE + ORDER BY `u`.`FullName` LIMIT 18446744073709551610 OFFSET @__p_0 -) AS `t0` -ORDER BY `t0`.`Rank` +) AS `u0` +ORDER BY `u0`.`Rank` """); } - [ConditionalTheory(Skip = "MySQL does not support LIMIT with a parameterized argument, unless the statement was prepared. The argument needs to be a numeric constant.")] + [ConditionalTheory(Skip = "SingleStore does not support LIMIT with a parameterized argument, unless the statement was prepared. The argument needs to be a numeric constant.")] public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down1(bool async) { await base.Take_without_orderby_followed_by_orderBy_is_pushed_down1(async); @@ -4402,7 +4554,7 @@ ORDER BY `t0`.`Rank` """); } - [ConditionalTheory(Skip = "MySQL does not support LIMIT with a parameterized argument, unless the statement was prepared. The argument needs to be a numeric constant.")] + [ConditionalTheory(Skip = "SingleStore does not support LIMIT with a parameterized argument, unless the statement was prepared. The argument needs to be a numeric constant.")] public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down2(bool async) { await base.Take_without_orderby_followed_by_orderBy_is_pushed_down2(async); @@ -4428,7 +4580,7 @@ ORDER BY `t0`.`Rank` """); } - [ConditionalTheory(Skip = "MySQL does not support LIMIT with a parameterized argument, unless the statement was prepared. The argument needs to be a numeric constant.")] + [ConditionalTheory(Skip = "SingleStore does not support LIMIT with a parameterized argument, unless the statement was prepared. The argument needs to be a numeric constant.")] public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down3(bool async) { await base.Take_without_orderby_followed_by_orderBy_is_pushed_down3(async); @@ -4581,13 +4733,13 @@ public override async Task Collection_navigation_access_on_derived_entity_using_ SELECT `l`.`Name`, ( SELECT COUNT(*) FROM ( - SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` + SELECT `l0`.`LocustHordeId` FROM `LocustLeaders` AS `l0` UNION ALL - SELECT `l1`.`Name`, `l1`.`LocustHordeId`, `l1`.`ThreatLevel`, `l1`.`ThreatLevelByte`, `l1`.`ThreatLevelNullableByte`, `l1`.`DefeatedByNickname`, `l1`.`DefeatedBySquadId`, `l1`.`HighCommandId`, 'LocustCommander' AS `Discriminator` + SELECT `l1`.`LocustHordeId` FROM `LocustCommanders` AS `l1` - ) AS `t` - WHERE `l`.`Id` = `t`.`LocustHordeId`) AS `LeadersCount` + ) AS `u` + WHERE `l`.`Id` = `u`.`LocustHordeId`) AS `LeadersCount` FROM `LocustHordes` AS `l` ORDER BY `l`.`Name` """); @@ -4599,7 +4751,7 @@ public override async Task Collection_navigation_access_on_derived_entity_using_ AssertSql( """ -SELECT `l`.`Name`, `t`.`Name` AS `LeaderName` +SELECT `l`.`Name`, `u`.`Name` AS `LeaderName` FROM `LocustHordes` AS `l` INNER JOIN ( SELECT `l0`.`Name`, `l0`.`LocustHordeId` @@ -4607,8 +4759,8 @@ INNER JOIN ( UNION ALL SELECT `l1`.`Name`, `l1`.`LocustHordeId` FROM `LocustCommanders` AS `l1` -) AS `t` ON `l`.`Id` = `t`.`LocustHordeId` -ORDER BY `t`.`Name` +) AS `u` ON `l`.`Id` = `u`.`LocustHordeId` +ORDER BY `u`.`Name` """); } @@ -4618,7 +4770,7 @@ public override async Task Include_on_derived_entity_using_OfType(bool async) AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM `LocustHordes` AS `l` LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` LEFT JOIN ( @@ -4627,7 +4779,7 @@ LEFT JOIN ( UNION ALL SELECT `l2`.`Name`, `l2`.`LocustHordeId`, `l2`.`ThreatLevel`, `l2`.`ThreatLevelByte`, `l2`.`ThreatLevelNullableByte`, `l2`.`DefeatedByNickname`, `l2`.`DefeatedBySquadId`, `l2`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l2` -) AS `t` ON `l`.`Id` = `t`.`LocustHordeId` +) AS `u` ON `l`.`Id` = `u`.`LocustHordeId` ORDER BY `l`.`Name`, `l`.`Id`, `l0`.`Name` """); } @@ -4638,17 +4790,17 @@ public override async Task Distinct_on_subquery_doesnt_get_lifted(bool async) AssertSql( """ -SELECT `t0`.`HasSoulPatch` +SELECT `u0`.`HasSoulPatch` FROM ( - SELECT DISTINCT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` + SELECT DISTINCT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` - ) AS `t` -) AS `t0` + ) AS `u` +) AS `u0` """); } @@ -4669,23 +4821,23 @@ public override async Task Comparing_two_collection_navigations_composite_key(bo AssertSql( """ -SELECT `t`.`Nickname` AS `Nickname1`, `t0`.`Nickname` AS `Nickname2` +SELECT `u`.`Nickname` AS `Nickname1`, `u0`.`Nickname` AS `Nickname2` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t` +) AS `u` CROSS JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId` FROM `Officers` AS `o0` -) AS `t0` -WHERE (`t`.`Nickname` = `t0`.`Nickname`) AND (`t`.`SquadId` = `t0`.`SquadId`) -ORDER BY `t`.`Nickname` +) AS `u0` +WHERE (`u`.`Nickname` = `u0`.`Nickname`) AND (`u`.`SquadId` = `u0`.`SquadId`) +ORDER BY `u`.`Nickname` """); } @@ -4695,12 +4847,12 @@ public override async Task Comparing_two_collection_navigations_inheritance(bool AssertSql( """ -SELECT `l`.`Name`, `t`.`Nickname` +SELECT `l`.`Name`, `u`.`Nickname` FROM `LocustHordes` AS `l` CROSS JOIN ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId` @@ -4708,8 +4860,8 @@ LEFT JOIN ( UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId` FROM `Officers` AS `o0` -) AS `t0` ON (`l0`.`DefeatedByNickname` = `t0`.`Nickname`) AND (`l0`.`DefeatedBySquadId` = `t0`.`SquadId`) -WHERE (`t`.`HasSoulPatch` = TRUE) AND ((`t0`.`Nickname` = `t`.`Nickname`) AND (`t0`.`SquadId` = `t`.`SquadId`)) +) AS `u0` ON (`l0`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`l0`.`DefeatedBySquadId` = `u0`.`SquadId`) +WHERE (`u`.`HasSoulPatch` = TRUE) AND ((`u0`.`Nickname` = `u`.`Nickname`) AND (`u0`.`SquadId` = `u`.`SquadId`)) """); } @@ -4719,20 +4871,20 @@ public override async Task Comparing_entities_using_Equals_inheritance(bool asyn AssertSql( """ -SELECT `t`.`Nickname` AS `Nickname1`, `t0`.`Nickname` AS `Nickname2` +SELECT `u`.`Nickname` AS `Nickname1`, `u0`.`Nickname` AS `Nickname2` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t` +) AS `u` CROSS JOIN ( SELECT `o0`.`Nickname`, `o0`.`SquadId` FROM `Officers` AS `o0` -) AS `t0` -WHERE (`t`.`Nickname` = `t0`.`Nickname`) AND (`t`.`SquadId` = `t0`.`SquadId`) -ORDER BY `t`.`Nickname`, `t0`.`Nickname` +) AS `u0` +WHERE (`u`.`Nickname` = `u0`.`Nickname`) AND (`u`.`SquadId` = `u0`.`SquadId`) +ORDER BY `u`.`Nickname`, `u0`.`Nickname` """); } @@ -4764,18 +4916,18 @@ FROM JSON_TABLE('["Ephyra",null]', '$[*]' COLUMNS ( } else { - AssertSql( + AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Cities` AS `c` ON `t`.`AssignedCityName` = `c`.`Name` -WHERE (`t`.`SquadId` < 2) AND (`c`.`Name` IS NULL OR (`c`.`Name` = 'Ephyra')) +) AS `u` +LEFT JOIN `Cities` AS `c` ON `u`.`AssignedCityName` = `c`.`Name` +WHERE (`u`.`SquadId` < 2) AND (`c`.`Name` IS NULL OR (`c`.`Name` = 'Ephyra')) """); } } @@ -4795,17 +4947,17 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -WHERE (`t0`.`Discriminator` = 'Officer') AND (( +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE (`u`.`Discriminator` = 'Officer') AND (( SELECT COUNT(*) FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` FROM `Officers` AS `o0` - ) AS `t1` - WHERE ((`t0`.`Nickname` IS NOT NULL AND (`t0`.`SquadId` IS NOT NULL)) AND ((`t0`.`Nickname` = `t1`.`LeaderNickname`) AND (`t0`.`SquadId` = `t1`.`LeaderSquadId`))) AND (`t1`.`Nickname` = 'Dom')) > 0) + ) AS `u0` + WHERE ((`u`.`Nickname` IS NOT NULL AND (`u`.`SquadId` IS NOT NULL)) AND ((`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`))) AND (`u0`.`Nickname` = 'Dom')) > 0) """); } @@ -4817,7 +4969,6 @@ public override async Task Select_null_conditional_with_inheritance(bool async) """ SELECT CASE WHEN `l`.`CommanderName` IS NOT NULL THEN `l`.`CommanderName` - ELSE NULL END FROM `LocustHordes` AS `l` """); @@ -4831,7 +4982,6 @@ public override async Task Select_null_conditional_with_inheritance_negative(boo """ SELECT CASE WHEN `l`.`CommanderName` IS NOT NULL THEN `l`.`Eradicated` - ELSE NULL END FROM `LocustHordes` AS `l` """); @@ -4843,7 +4993,7 @@ public override async Task Project_collection_navigation_with_inheritance1(bool AssertSql( """ -SELECT `l`.`Id`, `l0`.`Name`, `l1`.`Id`, `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT `l`.`Id`, `l0`.`Name`, `l1`.`Id`, `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM `LocustHordes` AS `l` LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` LEFT JOIN `LocustHordes` AS `l1` ON `l0`.`Name` = `l1`.`CommanderName` @@ -4853,7 +5003,7 @@ LEFT JOIN ( UNION ALL SELECT `l3`.`Name`, `l3`.`LocustHordeId`, `l3`.`ThreatLevel`, `l3`.`ThreatLevelByte`, `l3`.`ThreatLevelNullableByte`, `l3`.`DefeatedByNickname`, `l3`.`DefeatedBySquadId`, `l3`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l3` -) AS `t` ON `l1`.`Id` = `t`.`LocustHordeId` +) AS `u` ON `l1`.`Id` = `u`.`LocustHordeId` ORDER BY `l`.`Id`, `l0`.`Name`, `l1`.`Id` """); } @@ -4864,7 +5014,7 @@ public override async Task Project_collection_navigation_with_inheritance2(bool AssertSql( """ -SELECT `l`.`Id`, `l0`.`Name`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `l`.`Id`, `l0`.`Name`, `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM `LocustHordes` AS `l` LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` LEFT JOIN ( @@ -4873,15 +5023,15 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t` ON (`l0`.`DefeatedByNickname` = `t`.`Nickname`) AND (`l0`.`DefeatedBySquadId` = `t`.`SquadId`) +) AS `u` ON (`l0`.`DefeatedByNickname` = `u`.`Nickname`) AND (`l0`.`DefeatedBySquadId` = `u`.`SquadId`) LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON ((`t`.`Nickname` = `t0`.`LeaderNickname`) OR (`t`.`Nickname` IS NULL AND (`t0`.`LeaderNickname` IS NULL))) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) -ORDER BY `l`.`Id`, `l0`.`Name`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` +) AS `u0` ON ((`u`.`Nickname` = `u0`.`LeaderNickname`) OR (`u`.`Nickname` IS NULL AND (`u0`.`LeaderNickname` IS NULL))) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `l`.`Id`, `l0`.`Name`, `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -4891,7 +5041,7 @@ public override async Task Project_collection_navigation_with_inheritance3(bool AssertSql( """ -SELECT `l`.`Id`, `l0`.`Name`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `l`.`Id`, `l0`.`Name`, `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM `LocustHordes` AS `l` LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` LEFT JOIN ( @@ -4900,15 +5050,15 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t` ON (`l0`.`DefeatedByNickname` = `t`.`Nickname`) AND (`l0`.`DefeatedBySquadId` = `t`.`SquadId`) +) AS `u` ON (`l0`.`DefeatedByNickname` = `u`.`Nickname`) AND (`l0`.`DefeatedBySquadId` = `u`.`SquadId`) LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON ((`t`.`Nickname` = `t0`.`LeaderNickname`) OR (`t`.`Nickname` IS NULL AND (`t0`.`LeaderNickname` IS NULL))) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) -ORDER BY `l`.`Id`, `l0`.`Name`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` +) AS `u0` ON ((`u`.`Nickname` = `u0`.`LeaderNickname`) OR (`u`.`Nickname` IS NULL AND (`u0`.`LeaderNickname` IS NULL))) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `l`.`Id`, `l0`.`Name`, `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -4918,21 +5068,21 @@ public override async Task Include_reference_on_derived_type_using_string(bool a AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`DefeatedByNickname` = `t0`.`Nickname`) AND (`t`.`DefeatedBySquadId` = `t0`.`SquadId`) +) AS `u0` ON (`u`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`u`.`DefeatedBySquadId` = `u0`.`SquadId`) """); } @@ -4942,22 +5092,22 @@ public override async Task Include_reference_on_derived_type_using_string_nested AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`DefeatedByNickname` = `t0`.`Nickname`) AND (`t`.`DefeatedBySquadId` = `t0`.`SquadId`) -LEFT JOIN `Squads` AS `s` ON `t0`.`SquadId` = `s`.`Id` +) AS `u0` ON (`u`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`u`.`DefeatedBySquadId` = `u0`.`SquadId`) +LEFT JOIN `Squads` AS `s` ON `u0`.`SquadId` = `s`.`Id` """); } @@ -4966,34 +5116,34 @@ public override async Task Include_reference_on_derived_type_using_string_nested await base.Include_reference_on_derived_type_using_string_nested2(async); AssertSql( -$""" -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator`, `t1`.`Name`, `t1`.`Location`, `t1`.`Nation` +""" +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `s`.`Nickname`, `s`.`SquadId`, `s`.`AssignedCityName`, `s`.`CityOfBirthName`, `s`.`FullName`, `s`.`HasSoulPatch`, `s`.`LeaderNickname`, `s`.`LeaderSquadId`, `s`.`Rank`, `s`.`Discriminator`, `s`.`Name`, `s`.`Location`, `s`.`Nation` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`DefeatedByNickname` = `t0`.`Nickname`) AND (`t`.`DefeatedBySquadId` = `t0`.`SquadId`) +) AS `u0` ON (`u`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`u`.`DefeatedBySquadId` = `u0`.`SquadId`) LEFT JOIN ( - SELECT `t2`.`Nickname`, `t2`.`SquadId`, `t2`.`AssignedCityName`, `t2`.`CityOfBirthName`, `t2`.`FullName`, `t2`.`HasSoulPatch`, `t2`.`LeaderNickname`, `t2`.`LeaderSquadId`, `t2`.`Rank`, `t2`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation` + SELECT `u1`.`Nickname`, `u1`.`SquadId`, `u1`.`AssignedCityName`, `u1`.`CityOfBirthName`, `u1`.`FullName`, `u1`.`HasSoulPatch`, `u1`.`LeaderNickname`, `u1`.`LeaderSquadId`, `u1`.`Rank`, `u1`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Gear'")} AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Officer'")} AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` - ) AS `t2` - INNER JOIN `Cities` AS `c` ON `t2`.`CityOfBirthName` = `c`.`Name` -) AS `t1` ON ((`t0`.`Nickname` = `t1`.`LeaderNickname`) OR (`t0`.`Nickname` IS NULL AND (`t1`.`LeaderNickname` IS NULL))) AND (`t0`.`SquadId` = `t1`.`LeaderSquadId`) -ORDER BY `t`.`Name`, `t0`.`Nickname`, `t0`.`SquadId`, `t1`.`Nickname`, `t1`.`SquadId` + ) AS `u1` + INNER JOIN `Cities` AS `c` ON `u1`.`CityOfBirthName` = `c`.`Name` +) AS `s` ON ((`u0`.`Nickname` = `s`.`LeaderNickname`) OR (`u0`.`Nickname` IS NULL AND (`s`.`LeaderNickname` IS NULL))) AND (`u0`.`SquadId` = `s`.`LeaderSquadId`) +ORDER BY `u`.`Name`, `u0`.`Nickname`, `u0`.`SquadId`, `s`.`Nickname`, `s`.`SquadId` """); } @@ -5003,21 +5153,21 @@ public override async Task Include_reference_on_derived_type_using_lambda(bool a AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`DefeatedByNickname` = `t0`.`Nickname`) AND (`t`.`DefeatedBySquadId` = `t0`.`SquadId`) +) AS `u0` ON (`u`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`u`.`DefeatedBySquadId` = `u0`.`SquadId`) """); } @@ -5027,21 +5177,21 @@ public override async Task Include_reference_on_derived_type_using_lambda_with_s AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`DefeatedByNickname` = `t0`.`Nickname`) AND (`t`.`DefeatedBySquadId` = `t0`.`SquadId`) +) AS `u0` ON (`u`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`u`.`DefeatedBySquadId` = `u0`.`SquadId`) """); } @@ -5051,21 +5201,21 @@ public override async Task Include_reference_on_derived_type_using_lambda_with_t AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`DefeatedByNickname` = `t0`.`Nickname`) AND (`t`.`DefeatedBySquadId` = `t0`.`SquadId`) +) AS `u0` ON (`u`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`u`.`DefeatedBySquadId` = `u0`.`SquadId`) """); } @@ -5075,22 +5225,22 @@ public override async Task Include_collection_on_derived_type_using_string(bool AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON (`t`.`Nickname` = `t0`.`LeaderNickname`) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` +) AS `u0` ON (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -5100,22 +5250,22 @@ public override async Task Include_collection_on_derived_type_using_lambda(bool AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON (`t`.`Nickname` = `t0`.`LeaderNickname`) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` +) AS `u0` ON (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -5125,22 +5275,22 @@ public override async Task Include_collection_on_derived_type_using_lambda_with_ AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON (`t`.`Nickname` = `t0`.`LeaderNickname`) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` +) AS `u0` ON (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -5150,17 +5300,17 @@ public override async Task Include_base_navigation_on_derived_entity(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`GearNickName`, `t0`.`GearSquadId`, `t0`.`IssueDate`, `t0`.`Note`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) -LEFT JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id` +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `t`.`Id` """); } @@ -5170,7 +5320,7 @@ public override async Task ThenInclude_collection_on_derived_after_base_referenc AssertSql( """ -SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -5178,9 +5328,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -LEFT JOIN `Weapons` AS `w` ON `t0`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId` +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `t`.`Id`, `u`.`Nickname`, `u`.`SquadId` """); } @@ -5190,7 +5340,7 @@ public override async Task ThenInclude_collection_on_derived_after_derived_refer AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM `LocustHordes` AS `l` LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` LEFT JOIN ( @@ -5199,15 +5349,15 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` ON (`l0`.`DefeatedByNickname` = `t`.`Nickname`) AND (`l0`.`DefeatedBySquadId` = `t`.`SquadId`) +) AS `u` ON (`l0`.`DefeatedByNickname` = `u`.`Nickname`) AND (`l0`.`DefeatedBySquadId` = `u`.`SquadId`) LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON ((`t`.`Nickname` = `t0`.`LeaderNickname`) OR (`t`.`Nickname` IS NULL AND (`t0`.`LeaderNickname` IS NULL))) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) -ORDER BY `l`.`Id`, `l0`.`Name`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` +) AS `u0` ON ((`u`.`Nickname` = `u0`.`LeaderNickname`) OR (`u`.`Nickname` IS NULL AND (`u0`.`LeaderNickname` IS NULL))) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `l`.`Id`, `l0`.`Name`, `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -5216,33 +5366,33 @@ public override async Task ThenInclude_collection_on_derived_after_derived_colle await base.ThenInclude_collection_on_derived_after_derived_collection(async); AssertSql( -$""" -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator`, `t1`.`Nickname0`, `t1`.`SquadId0`, `t1`.`AssignedCityName0`, `t1`.`CityOfBirthName0`, `t1`.`FullName0`, `t1`.`HasSoulPatch0`, `t1`.`LeaderNickname0`, `t1`.`LeaderSquadId0`, `t1`.`Rank0`, `t1`.`Discriminator0` +""" +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `s`.`Nickname`, `s`.`SquadId`, `s`.`AssignedCityName`, `s`.`CityOfBirthName`, `s`.`FullName`, `s`.`HasSoulPatch`, `s`.`LeaderNickname`, `s`.`LeaderSquadId`, `s`.`Rank`, `s`.`Discriminator`, `s`.`Nickname0`, `s`.`SquadId0`, `s`.`AssignedCityName0`, `s`.`CityOfBirthName0`, `s`.`FullName0`, `s`.`HasSoulPatch0`, `s`.`LeaderNickname0`, `s`.`LeaderSquadId0`, `s`.`Rank0`, `s`.`Discriminator0` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `t2`.`Nickname` AS `Nickname0`, `t2`.`SquadId` AS `SquadId0`, `t2`.`AssignedCityName` AS `AssignedCityName0`, `t2`.`CityOfBirthName` AS `CityOfBirthName0`, `t2`.`FullName` AS `FullName0`, `t2`.`HasSoulPatch` AS `HasSoulPatch0`, `t2`.`LeaderNickname` AS `LeaderNickname0`, `t2`.`LeaderSquadId` AS `LeaderSquadId0`, `t2`.`Rank` AS `Rank0`, `t2`.`Discriminator` AS `Discriminator0` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u1`.`Nickname` AS `Nickname0`, `u1`.`SquadId` AS `SquadId0`, `u1`.`AssignedCityName` AS `AssignedCityName0`, `u1`.`CityOfBirthName` AS `CityOfBirthName0`, `u1`.`FullName` AS `FullName0`, `u1`.`HasSoulPatch` AS `HasSoulPatch0`, `u1`.`LeaderNickname` AS `LeaderNickname0`, `u1`.`LeaderSquadId` AS `LeaderSquadId0`, `u1`.`Rank` AS `Rank0`, `u1`.`Discriminator` AS `Discriminator0` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Gear'")} AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Officer'")} AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` - ) AS `t0` + ) AS `u0` LEFT JOIN ( - SELECT `g1`.`Nickname`, `g1`.`SquadId`, `g1`.`AssignedCityName`, `g1`.`CityOfBirthName`, `g1`.`FullName`, `g1`.`HasSoulPatch`, `g1`.`LeaderNickname`, `g1`.`LeaderSquadId`, `g1`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Gear'")} AS `Discriminator` + SELECT `g1`.`Nickname`, `g1`.`SquadId`, `g1`.`AssignedCityName`, `g1`.`CityOfBirthName`, `g1`.`FullName`, `g1`.`HasSoulPatch`, `g1`.`LeaderNickname`, `g1`.`LeaderSquadId`, `g1`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g1` UNION ALL - SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`AssignedCityName`, `o1`.`CityOfBirthName`, `o1`.`FullName`, `o1`.`HasSoulPatch`, `o1`.`LeaderNickname`, `o1`.`LeaderSquadId`, `o1`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Officer'")} AS `Discriminator` + SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`AssignedCityName`, `o1`.`CityOfBirthName`, `o1`.`FullName`, `o1`.`HasSoulPatch`, `o1`.`LeaderNickname`, `o1`.`LeaderSquadId`, `o1`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o1` - ) AS `t2` ON (`t0`.`Nickname` = `t2`.`LeaderNickname`) AND (`t0`.`SquadId` = `t2`.`LeaderSquadId`) -) AS `t1` ON (`t`.`Nickname` = `t1`.`LeaderNickname`) AND (`t`.`SquadId` = `t1`.`LeaderSquadId`) -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`Nickname0` + ) AS `u1` ON (`u0`.`Nickname` = `u1`.`LeaderNickname`) AND (`u0`.`SquadId` = `u1`.`LeaderSquadId`) +) AS `s` ON (`u`.`Nickname` = `s`.`LeaderNickname`) AND (`u`.`SquadId` = `s`.`LeaderSquadId`) +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `s`.`Nickname`, `s`.`SquadId`, `s`.`Nickname0` """); } @@ -5251,27 +5401,27 @@ public override async Task ThenInclude_reference_on_derived_after_derived_collec await base.ThenInclude_reference_on_derived_after_derived_collection(async); AssertSql( -$""" -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `t1`.`Name`, `t1`.`LocustHordeId`, `t1`.`ThreatLevel`, `t1`.`ThreatLevelByte`, `t1`.`ThreatLevelNullableByte`, `t1`.`DefeatedByNickname`, `t1`.`DefeatedBySquadId`, `t1`.`HighCommandId`, `t1`.`Discriminator`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator0` +""" +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `s`.`Name`, `s`.`LocustHordeId`, `s`.`ThreatLevel`, `s`.`ThreatLevelByte`, `s`.`ThreatLevelNullableByte`, `s`.`DefeatedByNickname`, `s`.`DefeatedBySquadId`, `s`.`HighCommandId`, `s`.`Discriminator`, `s`.`Nickname`, `s`.`SquadId`, `s`.`AssignedCityName`, `s`.`CityOfBirthName`, `s`.`FullName`, `s`.`HasSoulPatch`, `s`.`LeaderNickname`, `s`.`LeaderSquadId`, `s`.`Rank`, `s`.`Discriminator0` FROM `LocustHordes` AS `l` LEFT JOIN ( - SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` AS `Discriminator0` + SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` AS `Discriminator0` FROM ( - SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL")} AS `DefeatedByNickname`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `DefeatedBySquadId`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `HighCommandId`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'LocustLeader'")} AS `Discriminator` + SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l0` UNION ALL - SELECT `l1`.`Name`, `l1`.`LocustHordeId`, `l1`.`ThreatLevel`, `l1`.`ThreatLevelByte`, `l1`.`ThreatLevelNullableByte`, `l1`.`DefeatedByNickname`, `l1`.`DefeatedBySquadId`, `l1`.`HighCommandId`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'LocustCommander'")} AS `Discriminator` + SELECT `l1`.`Name`, `l1`.`LocustHordeId`, `l1`.`ThreatLevel`, `l1`.`ThreatLevelByte`, `l1`.`ThreatLevelNullableByte`, `l1`.`DefeatedByNickname`, `l1`.`DefeatedBySquadId`, `l1`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l1` - ) AS `t` + ) AS `u` LEFT JOIN ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Gear'")} AS `Discriminator` + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Officer'")} AS `Discriminator` + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` - ) AS `t0` ON (`t`.`DefeatedByNickname` = `t0`.`Nickname`) AND (`t`.`DefeatedBySquadId` = `t0`.`SquadId`) -) AS `t1` ON `l`.`Id` = `t1`.`LocustHordeId` -ORDER BY `l`.`Id`, `t1`.`Name`, `t1`.`Nickname` + ) AS `u0` ON (`u`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`u`.`DefeatedBySquadId` = `u0`.`SquadId`) +) AS `s` ON `l`.`Id` = `s`.`LocustHordeId` +ORDER BY `l`.`Id`, `s`.`Name`, `s`.`Nickname` """); } @@ -5281,7 +5431,7 @@ public override async Task Multiple_derived_included_on_one_method(bool async) AssertSql( """ -SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM `LocustHordes` AS `l` LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` LEFT JOIN ( @@ -5290,15 +5440,15 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` ON (`l0`.`DefeatedByNickname` = `t`.`Nickname`) AND (`l0`.`DefeatedBySquadId` = `t`.`SquadId`) +) AS `u` ON (`l0`.`DefeatedByNickname` = `u`.`Nickname`) AND (`l0`.`DefeatedBySquadId` = `u`.`SquadId`) LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON ((`t`.`Nickname` = `t0`.`LeaderNickname`) OR (`t`.`Nickname` IS NULL AND (`t0`.`LeaderNickname` IS NULL))) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) -ORDER BY `l`.`Id`, `l0`.`Name`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` +) AS `u0` ON ((`u`.`Nickname` = `u0`.`LeaderNickname`) OR (`u`.`Nickname` IS NULL AND (`u0`.`LeaderNickname` IS NULL))) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `l`.`Id`, `l0`.`Name`, `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -5307,28 +5457,28 @@ public override async Task Include_on_derived_multi_level(bool async) await base.Include_on_derived_multi_level(async); AssertSql( -$""" -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `t0`.`Id`, `t0`.`Banner`, `t0`.`Banner5`, `t0`.`InternalNumber`, `t0`.`Name`, `t0`.`SquadId0`, `t0`.`MissionId` +""" +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `s1`.`Nickname`, `s1`.`SquadId`, `s1`.`AssignedCityName`, `s1`.`CityOfBirthName`, `s1`.`FullName`, `s1`.`HasSoulPatch`, `s1`.`LeaderNickname`, `s1`.`LeaderSquadId`, `s1`.`Rank`, `s1`.`Discriminator`, `s1`.`Id`, `s1`.`Banner`, `s1`.`Banner5`, `s1`.`InternalNumber`, `s1`.`Name`, `s1`.`SquadId0`, `s1`.`MissionId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `s0`.`SquadId` AS `SquadId0`, `s0`.`MissionId` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `s0`.`SquadId` AS `SquadId0`, `s0`.`MissionId` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Gear'")} AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Officer'")} AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` - ) AS `t1` - INNER JOIN `Squads` AS `s` ON `t1`.`SquadId` = `s`.`Id` + ) AS `u0` + INNER JOIN `Squads` AS `s` ON `u0`.`SquadId` = `s`.`Id` LEFT JOIN `SquadMissions` AS `s0` ON `s`.`Id` = `s0`.`SquadId` -) AS `t0` ON (`t`.`Nickname` = `t0`.`LeaderNickname`) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`Id`, `t0`.`SquadId0` +) AS `s1` ON (`u`.`Nickname` = `s1`.`LeaderNickname`) AND (`u`.`SquadId` = `s1`.`LeaderSquadId`) +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `s1`.`Nickname`, `s1`.`SquadId`, `s1`.`Id`, `s1`.`SquadId0` """); } @@ -5339,7 +5489,7 @@ public override async Task Projecting_nullable_bool_in_conditional_works(bool as AssertSql( """ SELECT CASE - WHEN `t0`.`Nickname` IS NOT NULL AND (`t0`.`SquadId` IS NOT NULL) THEN `t0`.`HasSoulPatch` + WHEN `u`.`Nickname` IS NOT NULL AND (`u`.`SquadId` IS NOT NULL) THEN `u`.`HasSoulPatch` ELSE FALSE END AS `Prop` FROM `Tags` AS `t` @@ -5349,25 +5499,78 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) """); } - public override async Task Enum_ToString_is_client_eval(bool async) + public override async Task ToString_enum_property_projection(bool async) { - await base.Enum_ToString_is_client_eval(async); + await base.ToString_enum_property_projection(async); AssertSql( """ -SELECT `t`.`Rank` +SELECT CASE `u`.`Rank` + WHEN 0 THEN 'None' + WHEN 1 THEN 'Private' + WHEN 2 THEN 'Corporal' + WHEN 4 THEN 'Sergeant' + WHEN 8 THEN 'Lieutenant' + WHEN 16 THEN 'Captain' + WHEN 32 THEN 'Major' + WHEN 64 THEN 'Colonel' + WHEN 128 THEN 'General' + ELSE CAST(`u`.`Rank` AS char) +END FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`Rank` + SELECT `g`.`Rank` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`Rank` + SELECT `o`.`Rank` FROM `Officers` AS `o` -) AS `t` -ORDER BY `t`.`SquadId`, `t`.`Nickname` +) AS `u` +"""); + } + + public override async Task ToString_nullable_enum_property_projection(bool async) + { + await base.ToString_nullable_enum_property_projection(async); + + AssertSql( +""" +SELECT CASE `w`.`AmmunitionType` + WHEN 1 THEN 'Cartridge' + WHEN 2 THEN 'Shell' + ELSE COALESCE(CAST(`w`.`AmmunitionType` AS char), '') +END +FROM `Weapons` AS `w` +"""); + } + + public override async Task ToString_enum_contains(bool async) + { + await base.ToString_enum_contains(async); + + AssertSql( +""" +SELECT `m`.`CodeName` +FROM `Missions` AS `m` +WHERE CAST(`m`.`Difficulty` AS char) LIKE '%Med%' +"""); + } + + public override async Task ToString_nullable_enum_contains(bool async) + { + await base.ToString_nullable_enum_contains(async); + + AssertSql( +""" +SELECT `w`.`Name` +FROM `Weapons` AS `w` +WHERE CASE `w`.`AmmunitionType` + WHEN 1 THEN 'Cartridge' + WHEN 2 THEN 'Shell' + ELSE COALESCE(CAST(`w`.`AmmunitionType` AS char), '') +END LIKE '%Cart%' """); } @@ -5377,17 +5580,17 @@ public override async Task Correlated_collections_naked_navigation_with_ToList(b AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` -WHERE `t`.`Nickname` <> 'Marcus' -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `u` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +WHERE `u`.`Nickname` <> 'Marcus' +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -5400,16 +5603,16 @@ public override async Task Correlated_collections_naked_navigation_with_ToList_f SELECT ( SELECT COUNT(*) FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName`) + WHERE `u`.`FullName` = `w`.`OwnerFullName`) FROM ( SELECT `g`.`Nickname`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`Nickname` <> 'Marcus' -ORDER BY `t`.`Nickname` +) AS `u` +WHERE `u`.`Nickname` <> 'Marcus' +ORDER BY `u`.`Nickname` """); } @@ -5419,17 +5622,17 @@ public override async Task Correlated_collections_naked_navigation_with_ToArray( AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` -WHERE `t`.`Nickname` <> 'Marcus' -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `u` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +WHERE `u`.`Nickname` <> 'Marcus' +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -5439,21 +5642,21 @@ public override async Task Correlated_collections_basic_projection(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t0`.`AmmunitionType`, `t0`.`IsAutomatic`, `t0`.`Name`, `t0`.`OwnerFullName`, `t0`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` WHERE (`w`.`IsAutomatic` = TRUE) OR ((`w`.`Name` <> 'foo') OR `w`.`Name` IS NULL) -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` -WHERE `t`.`Nickname` <> 'Marcus' -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` +WHERE `u`.`Nickname` <> 'Marcus' +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -5463,21 +5666,21 @@ public override async Task Correlated_collections_basic_projection_explicit_to_l AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t0`.`AmmunitionType`, `t0`.`IsAutomatic`, `t0`.`Name`, `t0`.`OwnerFullName`, `t0`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` WHERE (`w`.`IsAutomatic` = TRUE) OR ((`w`.`Name` <> 'foo') OR `w`.`Name` IS NULL) -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` -WHERE `t`.`Nickname` <> 'Marcus' -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` +WHERE `u`.`Nickname` <> 'Marcus' +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -5487,21 +5690,21 @@ public override async Task Correlated_collections_basic_projection_explicit_to_a AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t0`.`AmmunitionType`, `t0`.`IsAutomatic`, `t0`.`Name`, `t0`.`OwnerFullName`, `t0`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` WHERE (`w`.`IsAutomatic` = TRUE) OR ((`w`.`Name` <> 'foo') OR `w`.`Name` IS NULL) -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` -WHERE `t`.`Nickname` <> 'Marcus' -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` +WHERE `u`.`Nickname` <> 'Marcus' +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -5511,21 +5714,21 @@ public override async Task Correlated_collections_basic_projection_ordered(bool AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t0`.`AmmunitionType`, `t0`.`IsAutomatic`, `t0`.`Name`, `t0`.`OwnerFullName`, `t0`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` WHERE (`w`.`IsAutomatic` = TRUE) OR ((`w`.`Name` <> 'foo') OR `w`.`Name` IS NULL) -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` -WHERE `t`.`Nickname` <> 'Marcus' -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Name` DESC +) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` +WHERE `u`.`Nickname` <> 'Marcus' +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `w0`.`Name` DESC """); } @@ -5535,24 +5738,24 @@ public override async Task Correlated_collections_basic_projection_composite_key AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname`, `t0`.`FullName`, `t0`.`SquadId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u1`.`Nickname`, `u1`.`FullName`, `u1`.`SquadId` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `t1`.`Nickname`, `t1`.`FullName`, `t1`.`SquadId`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId` + SELECT `u0`.`Nickname`, `u0`.`FullName`, `u0`.`SquadId`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` FROM `Officers` AS `o0` - ) AS `t1` - WHERE `t1`.`HasSoulPatch` = FALSE -) AS `t0` ON (`t`.`Nickname` = `t0`.`LeaderNickname`) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) -WHERE `t`.`Nickname` <> 'Foo' -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` + ) AS `u0` + WHERE `u0`.`HasSoulPatch` = FALSE +) AS `u1` ON (`u`.`Nickname` = `u1`.`LeaderNickname`) AND (`u`.`SquadId` = `u1`.`LeaderSquadId`) +WHERE `u`.`Nickname` <> 'Foo' +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u1`.`Nickname` """); } @@ -5562,21 +5765,21 @@ public override async Task Correlated_collections_basic_projecting_single_proper AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`Name`, `t0`.`Id` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w0`.`Name`, `w0`.`Id` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `w`.`Name`, `w`.`Id`, `w`.`OwnerFullName` FROM `Weapons` AS `w` WHERE (`w`.`IsAutomatic` = TRUE) OR ((`w`.`Name` <> 'foo') OR `w`.`Name` IS NULL) -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` -WHERE `t`.`Nickname` <> 'Marcus' -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` +WHERE `u`.`Nickname` <> 'Marcus' +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -5585,22 +5788,22 @@ public override async Task Correlated_collections_basic_projecting_constant(bool await base.Correlated_collections_basic_projecting_constant(async); AssertSql( -$""" -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`c`, `t0`.`Id` +""" +SELECT `u`.`Nickname`, `u`.`SquadId`, `w0`.`c`, `w0`.`Id` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'BFG'")} AS `c`, `w`.`Id`, `w`.`OwnerFullName` + SELECT 'BFG' AS `c`, `w`.`Id`, `w`.`OwnerFullName` FROM `Weapons` AS `w` WHERE (`w`.`IsAutomatic` = TRUE) OR ((`w`.`Name` <> 'foo') OR `w`.`Name` IS NULL) -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` -WHERE `t`.`Nickname` <> 'Marcus' -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` +WHERE `u`.`Nickname` <> 'Marcus' +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -5609,22 +5812,22 @@ public override async Task Correlated_collections_basic_projecting_constant_bool await base.Correlated_collections_basic_projecting_constant_bool(async); AssertSql( -$""" -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`c`, `t0`.`Id` +""" +SELECT `u`.`Nickname`, `u`.`SquadId`, `w0`.`c`, `w0`.`Id` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"TRUE", "signed")} AS `c`, `w`.`Id`, `w`.`OwnerFullName` + SELECT TRUE AS `c`, `w`.`Id`, `w`.`OwnerFullName` FROM `Weapons` AS `w` WHERE (`w`.`IsAutomatic` = TRUE) OR ((`w`.`Name` <> 'foo') OR `w`.`Name` IS NULL) -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` -WHERE `t`.`Nickname` <> 'Marcus' -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` +WHERE `u`.`Nickname` <> 'Marcus' +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -5634,22 +5837,22 @@ public override async Task Correlated_collections_projection_of_collection_thru_ AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `s`.`Id`, `t0`.`SquadId`, `t0`.`MissionId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `s`.`Id`, `s1`.`SquadId`, `s1`.`MissionId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Squads` AS `s` ON `t`.`SquadId` = `s`.`Id` +) AS `u` +INNER JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` LEFT JOIN ( SELECT `s0`.`SquadId`, `s0`.`MissionId` FROM `SquadMissions` AS `s0` WHERE `s0`.`MissionId` <> 17 -) AS `t0` ON `s`.`Id` = `t0`.`SquadId` -WHERE `t`.`Nickname` <> 'Marcus' -ORDER BY `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `s`.`Id`, `t0`.`SquadId` +) AS `s1` ON `s`.`Id` = `s1`.`SquadId` +WHERE `u`.`Nickname` <> 'Marcus' +ORDER BY `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `s`.`Id`, `s1`.`SquadId` """); } @@ -5659,7 +5862,7 @@ public override async Task Correlated_collections_project_anonymous_collection_r AssertSql( """ -SELECT `s`.`Name`, `s`.`Id`, `t`.`FullName`, `t`.`Rank`, `t`.`Nickname`, `t`.`SquadId` +SELECT `s`.`Name`, `s`.`Id`, `u`.`FullName`, `u`.`Rank`, `u`.`Nickname`, `u`.`SquadId` FROM `Squads` AS `s` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`Rank` @@ -5667,9 +5870,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName`, `o`.`Rank` FROM `Officers` AS `o` -) AS `t` ON `s`.`Id` = `t`.`SquadId` +) AS `u` ON `s`.`Id` = `u`.`SquadId` WHERE `s`.`Id` < 20 -ORDER BY `s`.`Id`, `t`.`Nickname` +ORDER BY `s`.`Id`, `u`.`Nickname` """); } @@ -5679,20 +5882,20 @@ public override async Task Correlated_collections_nested(bool async) AssertSql( """ -SELECT `s`.`Id`, `t0`.`SquadId`, `t0`.`MissionId`, `t0`.`Id`, `t0`.`SquadId0`, `t0`.`MissionId0` +SELECT `s`.`Id`, `s3`.`SquadId`, `s3`.`MissionId`, `s3`.`Id`, `s3`.`SquadId0`, `s3`.`MissionId0` FROM `Squads` AS `s` LEFT JOIN ( - SELECT `s0`.`SquadId`, `s0`.`MissionId`, `m`.`Id`, `t`.`SquadId` AS `SquadId0`, `t`.`MissionId` AS `MissionId0` + SELECT `s0`.`SquadId`, `s0`.`MissionId`, `m`.`Id`, `s2`.`SquadId` AS `SquadId0`, `s2`.`MissionId` AS `MissionId0` FROM `SquadMissions` AS `s0` INNER JOIN `Missions` AS `m` ON `s0`.`MissionId` = `m`.`Id` LEFT JOIN ( SELECT `s1`.`SquadId`, `s1`.`MissionId` FROM `SquadMissions` AS `s1` WHERE `s1`.`SquadId` < 7 - ) AS `t` ON `m`.`Id` = `t`.`MissionId` + ) AS `s2` ON `m`.`Id` = `s2`.`MissionId` WHERE `s0`.`MissionId` < 42 -) AS `t0` ON `s`.`Id` = `t0`.`SquadId` -ORDER BY `s`.`Id`, `t0`.`SquadId`, `t0`.`MissionId`, `t0`.`Id`, `t0`.`SquadId0` +) AS `s3` ON `s`.`Id` = `s3`.`SquadId` +ORDER BY `s`.`Id`, `s3`.`SquadId`, `s3`.`MissionId`, `s3`.`Id`, `s3`.`SquadId0` """); } @@ -5702,20 +5905,20 @@ public override async Task Correlated_collections_nested_mixed_streaming_with_bu AssertSql( """ -SELECT `s`.`Id`, `t0`.`SquadId`, `t0`.`MissionId`, `t0`.`Id`, `t0`.`SquadId0`, `t0`.`MissionId0` +SELECT `s`.`Id`, `s3`.`SquadId`, `s3`.`MissionId`, `s3`.`Id`, `s3`.`SquadId0`, `s3`.`MissionId0` FROM `Squads` AS `s` LEFT JOIN ( - SELECT `s0`.`SquadId`, `s0`.`MissionId`, `m`.`Id`, `t`.`SquadId` AS `SquadId0`, `t`.`MissionId` AS `MissionId0` + SELECT `s0`.`SquadId`, `s0`.`MissionId`, `m`.`Id`, `s2`.`SquadId` AS `SquadId0`, `s2`.`MissionId` AS `MissionId0` FROM `SquadMissions` AS `s0` INNER JOIN `Missions` AS `m` ON `s0`.`MissionId` = `m`.`Id` LEFT JOIN ( SELECT `s1`.`SquadId`, `s1`.`MissionId` FROM `SquadMissions` AS `s1` WHERE `s1`.`SquadId` < 2 - ) AS `t` ON `m`.`Id` = `t`.`MissionId` + ) AS `s2` ON `m`.`Id` = `s2`.`MissionId` WHERE `s0`.`MissionId` < 3 -) AS `t0` ON `s`.`Id` = `t0`.`SquadId` -ORDER BY `s`.`Id`, `t0`.`SquadId`, `t0`.`MissionId`, `t0`.`Id`, `t0`.`SquadId0` +) AS `s3` ON `s`.`Id` = `s3`.`SquadId` +ORDER BY `s`.`Id`, `s3`.`SquadId`, `s3`.`MissionId`, `s3`.`Id`, `s3`.`SquadId0` """); } @@ -5725,20 +5928,20 @@ public override async Task Correlated_collections_nested_mixed_streaming_with_bu AssertSql( """ -SELECT `s`.`Id`, `t0`.`SquadId`, `t0`.`MissionId`, `t0`.`Id`, `t0`.`SquadId0`, `t0`.`MissionId0` +SELECT `s`.`Id`, `s3`.`SquadId`, `s3`.`MissionId`, `s3`.`Id`, `s3`.`SquadId0`, `s3`.`MissionId0` FROM `Squads` AS `s` LEFT JOIN ( - SELECT `s0`.`SquadId`, `s0`.`MissionId`, `m`.`Id`, `t`.`SquadId` AS `SquadId0`, `t`.`MissionId` AS `MissionId0` + SELECT `s0`.`SquadId`, `s0`.`MissionId`, `m`.`Id`, `s2`.`SquadId` AS `SquadId0`, `s2`.`MissionId` AS `MissionId0` FROM `SquadMissions` AS `s0` INNER JOIN `Missions` AS `m` ON `s0`.`MissionId` = `m`.`Id` LEFT JOIN ( SELECT `s1`.`SquadId`, `s1`.`MissionId` FROM `SquadMissions` AS `s1` WHERE `s1`.`SquadId` < 7 - ) AS `t` ON `m`.`Id` = `t`.`MissionId` + ) AS `s2` ON `m`.`Id` = `s2`.`MissionId` WHERE `s0`.`MissionId` < 42 -) AS `t0` ON `s`.`Id` = `t0`.`SquadId` -ORDER BY `s`.`Id`, `t0`.`SquadId`, `t0`.`MissionId`, `t0`.`Id`, `t0`.`SquadId0` +) AS `s3` ON `s`.`Id` = `s3`.`SquadId` +ORDER BY `s`.`Id`, `s3`.`SquadId`, `s3`.`MissionId`, `s3`.`Id`, `s3`.`SquadId0` """); } @@ -5748,28 +5951,28 @@ public override async Task Correlated_collections_nested_with_custom_ordering(bo AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t1`.`FullName`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`Id`, `t1`.`AmmunitionType`, `t1`.`IsAutomatic`, `t1`.`Name`, `t1`.`OwnerFullName`, `t1`.`SynergyWithId` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `s`.`FullName`, `s`.`Nickname`, `s`.`SquadId`, `s`.`Id`, `s`.`AmmunitionType`, `s`.`IsAutomatic`, `s`.`Name`, `s`.`OwnerFullName`, `s`.`SynergyWithId` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `t0`.`FullName`, `t0`.`Nickname`, `t0`.`SquadId`, `t2`.`Id`, `t2`.`AmmunitionType`, `t2`.`IsAutomatic`, `t2`.`Name`, `t2`.`OwnerFullName`, `t2`.`SynergyWithId`, `t0`.`Rank`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId` + SELECT `u0`.`FullName`, `u0`.`Nickname`, `u0`.`SquadId`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId`, `u0`.`Rank`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank` FROM `Officers` AS `o0` - ) AS `t0` + ) AS `u0` LEFT JOIN ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` WHERE (`w`.`Name` <> 'Bar') OR `w`.`Name` IS NULL - ) AS `t2` ON `t0`.`FullName` = `t2`.`OwnerFullName` - WHERE `t0`.`FullName` <> 'Foo' -) AS `t1` ON (`t`.`Nickname` = `t1`.`LeaderNickname`) AND (`t`.`SquadId` = `t1`.`LeaderSquadId`) -ORDER BY `t`.`HasSoulPatch` DESC, `t`.`Nickname`, `t`.`SquadId`, `t1`.`Rank`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`IsAutomatic` + ) AS `w0` ON `u0`.`FullName` = `w0`.`OwnerFullName` + WHERE `u0`.`FullName` <> 'Foo' +) AS `s` ON (`u`.`Nickname` = `s`.`LeaderNickname`) AND (`u`.`SquadId` = `s`.`LeaderSquadId`) +ORDER BY `u`.`HasSoulPatch` DESC, `u`.`Nickname`, `u`.`SquadId`, `s`.`Rank`, `s`.`Nickname`, `s`.`SquadId`, `s`.`IsAutomatic` """); } @@ -5779,25 +5982,25 @@ public override async Task Correlated_collections_same_collection_projected_mult AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t0`.`AmmunitionType`, `t0`.`IsAutomatic`, `t0`.`Name`, `t0`.`OwnerFullName`, `t0`.`SynergyWithId`, `t1`.`Id`, `t1`.`AmmunitionType`, `t1`.`IsAutomatic`, `t1`.`Name`, `t1`.`OwnerFullName`, `t1`.`SynergyWithId` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `w1`.`Id`, `w1`.`AmmunitionType`, `w1`.`IsAutomatic`, `w1`.`Name`, `w1`.`OwnerFullName`, `w1`.`SynergyWithId`, `w2`.`Id`, `w2`.`AmmunitionType`, `w2`.`IsAutomatic`, `w2`.`Name`, `w2`.`OwnerFullName`, `w2`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` WHERE `w`.`IsAutomatic` = TRUE -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` +) AS `w1` ON `u`.`FullName` = `w1`.`OwnerFullName` LEFT JOIN ( SELECT `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM `Weapons` AS `w0` WHERE `w0`.`IsAutomatic` = TRUE -) AS `t1` ON `t`.`FullName` = `t1`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id` +) AS `w2` ON `u`.`FullName` = `w2`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `w1`.`Id` """); } @@ -5807,25 +6010,25 @@ public override async Task Correlated_collections_similar_collection_projected_m AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t0`.`AmmunitionType`, `t0`.`IsAutomatic`, `t0`.`Name`, `t0`.`OwnerFullName`, `t0`.`SynergyWithId`, `t1`.`Id`, `t1`.`AmmunitionType`, `t1`.`IsAutomatic`, `t1`.`Name`, `t1`.`OwnerFullName`, `t1`.`SynergyWithId` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `w1`.`Id`, `w1`.`AmmunitionType`, `w1`.`IsAutomatic`, `w1`.`Name`, `w1`.`OwnerFullName`, `w1`.`SynergyWithId`, `w2`.`Id`, `w2`.`AmmunitionType`, `w2`.`IsAutomatic`, `w2`.`Name`, `w2`.`OwnerFullName`, `w2`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName`, `o`.`Rank` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` WHERE `w`.`IsAutomatic` = TRUE -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` +) AS `w1` ON `u`.`FullName` = `w1`.`OwnerFullName` LEFT JOIN ( SELECT `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM `Weapons` AS `w0` WHERE `w0`.`IsAutomatic` = FALSE -) AS `t1` ON `t`.`FullName` = `t1`.`OwnerFullName` -ORDER BY `t`.`Rank`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`OwnerFullName`, `t0`.`Id`, `t1`.`IsAutomatic` +) AS `w2` ON `u`.`FullName` = `w2`.`OwnerFullName` +ORDER BY `u`.`Rank`, `u`.`Nickname`, `u`.`SquadId`, `w1`.`OwnerFullName`, `w1`.`Id`, `w2`.`IsAutomatic` """); } @@ -5835,24 +6038,24 @@ public override async Task Correlated_collections_different_collections_projecte AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`Name`, `t0`.`IsAutomatic`, `t0`.`Id`, `t1`.`Nickname`, `t1`.`Rank`, `t1`.`SquadId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w0`.`Name`, `w0`.`IsAutomatic`, `w0`.`Id`, `u0`.`Nickname`, `u0`.`Rank`, `u0`.`SquadId` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `w`.`Name`, `w`.`IsAutomatic`, `w`.`Id`, `w`.`OwnerFullName` FROM `Weapons` AS `w` WHERE `w`.`IsAutomatic` = TRUE -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` +) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank` FROM `Officers` AS `o0` -) AS `t1` ON (`t`.`Nickname` = `t1`.`LeaderNickname`) AND (`t`.`SquadId` = `t1`.`LeaderSquadId`) -ORDER BY `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t1`.`FullName`, `t1`.`Nickname` +) AS `u0` ON (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `w0`.`Id`, `u0`.`FullName`, `u0`.`Nickname` """); } @@ -5861,24 +6064,24 @@ public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_ await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys(async); AssertSql( -$""" -SELECT `t`.`FullName` +""" +SELECT `u`.`FullName` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) WHERE EXISTS ( SELECT 1 FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`LeaderNickname`, `g`.`LeaderSquadId` FROM `Gears` AS `g` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` FROM `Officers` AS `o0` - ) AS `t1` - WHERE (`t`.`Nickname` = `t1`.`LeaderNickname`) AND (`t`.`SquadId` = `t1`.`LeaderSquadId`)) -ORDER BY `t`.`HasSoulPatch` DESC, `t0`.`Note` + ) AS `u0` + WHERE (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`)) +ORDER BY `u`.`HasSoulPatch` DESC, `t`.`Note` """); } @@ -5888,41 +6091,41 @@ public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_ AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t2`.`Nickname`, `t2`.`SquadId`, `t3`.`Id`, `t3`.`AmmunitionType`, `t3`.`IsAutomatic`, `t3`.`Name`, `t3`.`OwnerFullName`, `t3`.`SynergyWithId`, `t3`.`Nickname`, `t3`.`SquadId` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `t`.`Id`, `u1`.`Nickname`, `u1`.`SquadId`, `s`.`Id`, `s`.`AmmunitionType`, `s`.`IsAutomatic`, `s`.`Name`, `s`.`OwnerFullName`, `s`.`SynergyWithId`, `s`.`Nickname`, `s`.`SquadId` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) LEFT JOIN ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` - FROM `Gears` AS `g` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName` + FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName` - FROM `Officers` AS `o0` -) AS `t2` ON (`t0`.`GearNickName` = `t2`.`Nickname`) AND (`t0`.`GearSquadId` = `t2`.`SquadId`) + SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`FullName` + FROM `Officers` AS `o1` +) AS `u1` ON (`t`.`GearNickName` = `u1`.`Nickname`) AND (`t`.`GearSquadId` = `u1`.`SquadId`) LEFT JOIN ( - SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `t4`.`Nickname`, `t4`.`SquadId` + SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u2`.`Nickname`, `u2`.`SquadId` FROM `Weapons` AS `w` LEFT JOIN ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName` - FROM `Gears` AS `g0` + SELECT `g1`.`Nickname`, `g1`.`SquadId`, `g1`.`FullName` + FROM `Gears` AS `g1` UNION ALL - SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`FullName` - FROM `Officers` AS `o1` - ) AS `t4` ON `w`.`OwnerFullName` = `t4`.`FullName` -) AS `t3` ON `t2`.`FullName` = `t3`.`OwnerFullName` + SELECT `o2`.`Nickname`, `o2`.`SquadId`, `o2`.`FullName` + FROM `Officers` AS `o2` + ) AS `u2` ON `w`.`OwnerFullName` = `u2`.`FullName` +) AS `s` ON `u1`.`FullName` = `s`.`OwnerFullName` WHERE EXISTS ( SELECT 1 FROM ( - SELECT `g1`.`Nickname`, `g1`.`SquadId`, `g1`.`AssignedCityName`, `g1`.`CityOfBirthName`, `g1`.`FullName`, `g1`.`HasSoulPatch`, `g1`.`LeaderNickname`, `g1`.`LeaderSquadId`, `g1`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g1` + SELECT `g`.`LeaderNickname`, `g`.`LeaderSquadId` + FROM `Gears` AS `g` UNION ALL - SELECT `o2`.`Nickname`, `o2`.`SquadId`, `o2`.`AssignedCityName`, `o2`.`CityOfBirthName`, `o2`.`FullName`, `o2`.`HasSoulPatch`, `o2`.`LeaderNickname`, `o2`.`LeaderSquadId`, `o2`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o2` - ) AS `t1` - WHERE (`t`.`Nickname` = `t1`.`LeaderNickname`) AND (`t`.`SquadId` = `t1`.`LeaderSquadId`)) -ORDER BY `t`.`HasSoulPatch` DESC, `t0`.`Note`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t2`.`Nickname`, `t2`.`SquadId`, `t3`.`IsAutomatic`, `t3`.`Nickname` DESC, `t3`.`Id` + SELECT `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` + FROM `Officers` AS `o0` + ) AS `u0` + WHERE (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`)) +ORDER BY `u`.`HasSoulPatch` DESC, `t`.`Note`, `u`.`Nickname`, `u`.`SquadId`, `t`.`Id`, `u1`.`Nickname`, `u1`.`SquadId`, `s`.`IsAutomatic`, `s`.`Nickname` DESC, `s`.`Id` """); } @@ -5933,41 +6136,41 @@ public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_ AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t2`.`Nickname`, `t2`.`SquadId`, `t3`.`Id`, `t3`.`AmmunitionType`, `t3`.`IsAutomatic`, `t3`.`Name`, `t3`.`OwnerFullName`, `t3`.`SynergyWithId`, `t3`.`Nickname`, `t3`.`SquadId` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `t`.`Id`, `u1`.`Nickname`, `u1`.`SquadId`, `s`.`Id`, `s`.`AmmunitionType`, `s`.`IsAutomatic`, `s`.`Name`, `s`.`OwnerFullName`, `s`.`SynergyWithId`, `s`.`Nickname`, `s`.`SquadId` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) LEFT JOIN ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` - FROM `Gears` AS `g` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName` + FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName` - FROM `Officers` AS `o0` -) AS `t2` ON (`t0`.`GearNickName` = `t2`.`Nickname`) AND (`t0`.`GearSquadId` = `t2`.`SquadId`) + SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`FullName` + FROM `Officers` AS `o1` +) AS `u1` ON (`t`.`GearNickName` = `u1`.`Nickname`) AND (`t`.`GearSquadId` = `u1`.`SquadId`) LEFT JOIN ( - SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `t4`.`Nickname`, `t4`.`SquadId` + SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u2`.`Nickname`, `u2`.`SquadId` FROM `Weapons` AS `w` LEFT JOIN ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName` - FROM `Gears` AS `g0` + SELECT `g1`.`Nickname`, `g1`.`SquadId`, `g1`.`FullName` + FROM `Gears` AS `g1` UNION ALL - SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`FullName` - FROM `Officers` AS `o1` - ) AS `t4` ON `w`.`OwnerFullName` = `t4`.`FullName` -) AS `t3` ON `t2`.`FullName` = `t3`.`OwnerFullName` + SELECT `o2`.`Nickname`, `o2`.`SquadId`, `o2`.`FullName` + FROM `Officers` AS `o2` + ) AS `u2` ON `w`.`OwnerFullName` = `u2`.`FullName` +) AS `s` ON `u1`.`FullName` = `s`.`OwnerFullName` WHERE EXISTS ( SELECT 1 FROM ( - SELECT `g1`.`Nickname`, `g1`.`SquadId`, `g1`.`AssignedCityName`, `g1`.`CityOfBirthName`, `g1`.`FullName`, `g1`.`HasSoulPatch`, `g1`.`LeaderNickname`, `g1`.`LeaderSquadId`, `g1`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g1` + SELECT `g`.`LeaderNickname`, `g`.`LeaderSquadId` + FROM `Gears` AS `g` UNION ALL - SELECT `o2`.`Nickname`, `o2`.`SquadId`, `o2`.`AssignedCityName`, `o2`.`CityOfBirthName`, `o2`.`FullName`, `o2`.`HasSoulPatch`, `o2`.`LeaderNickname`, `o2`.`LeaderSquadId`, `o2`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o2` - ) AS `t1` - WHERE (`t`.`Nickname` = `t1`.`LeaderNickname`) AND (`t`.`SquadId` = `t1`.`LeaderSquadId`)) -ORDER BY `t`.`HasSoulPatch` DESC, `t0`.`Note`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t2`.`Nickname`, `t2`.`SquadId`, `t3`.`IsAutomatic`, `t3`.`Nickname` DESC, `t3`.`Id` + SELECT `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` + FROM `Officers` AS `o0` + ) AS `u0` + WHERE (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`)) +ORDER BY `u`.`HasSoulPatch` DESC, `t`.`Note`, `u`.`Nickname`, `u`.`SquadId`, `t`.`Id`, `u1`.`Nickname`, `u1`.`SquadId`, `s`.`IsAutomatic`, `s`.`Nickname` DESC, `s`.`Id` """); } @@ -5979,44 +6182,44 @@ public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_ AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t2`.`Nickname`, `t2`.`SquadId`, `t3`.`Id`, `t3`.`AmmunitionType`, `t3`.`IsAutomatic`, `t3`.`Name`, `t3`.`OwnerFullName`, `t3`.`SynergyWithId`, `t3`.`Nickname`, `t3`.`SquadId` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `t`.`Id`, `u1`.`Nickname`, `u1`.`SquadId`, `s`.`Id`, `s`.`AmmunitionType`, `s`.`IsAutomatic`, `s`.`Name`, `s`.`OwnerFullName`, `s`.`SynergyWithId`, `s`.`Nickname`, `s`.`SquadId` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) LEFT JOIN ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` - FROM `Gears` AS `g` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName` + FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName` - FROM `Officers` AS `o0` -) AS `t2` ON (`t0`.`GearNickName` = `t2`.`Nickname`) AND (`t0`.`GearSquadId` = `t2`.`SquadId`) + SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`FullName` + FROM `Officers` AS `o1` +) AS `u1` ON (`t`.`GearNickName` = `u1`.`Nickname`) AND (`t`.`GearSquadId` = `u1`.`SquadId`) LEFT JOIN ( - SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `t4`.`Nickname`, `t4`.`SquadId`, ( + SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u2`.`Nickname`, `u2`.`SquadId`, ( SELECT COUNT(*) FROM `Weapons` AS `w0` - WHERE `t4`.`FullName` IS NOT NULL AND (`t4`.`FullName` = `w0`.`OwnerFullName`)) AS `c` + WHERE `u2`.`FullName` IS NOT NULL AND (`u2`.`FullName` = `w0`.`OwnerFullName`)) AS `c` FROM `Weapons` AS `w` LEFT JOIN ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName` - FROM `Gears` AS `g0` + SELECT `g1`.`Nickname`, `g1`.`SquadId`, `g1`.`FullName` + FROM `Gears` AS `g1` UNION ALL - SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`FullName` - FROM `Officers` AS `o1` - ) AS `t4` ON `w`.`OwnerFullName` = `t4`.`FullName` -) AS `t3` ON `t2`.`FullName` = `t3`.`OwnerFullName` + SELECT `o2`.`Nickname`, `o2`.`SquadId`, `o2`.`FullName` + FROM `Officers` AS `o2` + ) AS `u2` ON `w`.`OwnerFullName` = `u2`.`FullName` +) AS `s` ON `u1`.`FullName` = `s`.`OwnerFullName` WHERE EXISTS ( SELECT 1 FROM ( - SELECT `g1`.`Nickname`, `g1`.`SquadId`, `g1`.`AssignedCityName`, `g1`.`CityOfBirthName`, `g1`.`FullName`, `g1`.`HasSoulPatch`, `g1`.`LeaderNickname`, `g1`.`LeaderSquadId`, `g1`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g1` + SELECT `g`.`LeaderNickname`, `g`.`LeaderSquadId` + FROM `Gears` AS `g` UNION ALL - SELECT `o2`.`Nickname`, `o2`.`SquadId`, `o2`.`AssignedCityName`, `o2`.`CityOfBirthName`, `o2`.`FullName`, `o2`.`HasSoulPatch`, `o2`.`LeaderNickname`, `o2`.`LeaderSquadId`, `o2`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o2` - ) AS `t1` - WHERE (`t`.`Nickname` = `t1`.`LeaderNickname`) AND (`t`.`SquadId` = `t1`.`LeaderSquadId`)) -ORDER BY `t`.`HasSoulPatch` DESC, `t0`.`Note`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t2`.`Nickname`, `t2`.`SquadId`, `t3`.`Id` DESC, `t3`.`c`, `t3`.`Nickname` + SELECT `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` + FROM `Officers` AS `o0` + ) AS `u0` + WHERE (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`)) +ORDER BY `u`.`HasSoulPatch` DESC, `t`.`Note`, `u`.`Nickname`, `u`.`SquadId`, `t`.`Id`, `u1`.`Nickname`, `u1`.`SquadId`, `s`.`Id` DESC, `s`.`c`, `s`.`Nickname` """); } @@ -6026,73 +6229,73 @@ public override async Task Correlated_collections_multiple_nested_complex_collec AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t2`.`Nickname`, `t2`.`SquadId`, `t3`.`FullName`, `t3`.`Nickname`, `t3`.`SquadId`, `t3`.`Id`, `t3`.`Nickname0`, `t3`.`SquadId0`, `t3`.`Id0`, `t3`.`Name`, `t3`.`IsAutomatic`, `t3`.`Id1`, `t3`.`Nickname00`, `t3`.`HasSoulPatch`, `t3`.`SquadId00`, `t8`.`Id`, `t8`.`AmmunitionType`, `t8`.`IsAutomatic`, `t8`.`Name`, `t8`.`OwnerFullName`, `t8`.`SynergyWithId`, `t8`.`Nickname`, `t8`.`SquadId` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `t`.`Id`, `u1`.`Nickname`, `u1`.`SquadId`, `s1`.`FullName`, `s1`.`Nickname`, `s1`.`SquadId`, `s1`.`Id`, `s1`.`Nickname0`, `s1`.`SquadId0`, `s1`.`Id0`, `s1`.`Name`, `s1`.`IsAutomatic`, `s1`.`Id1`, `s1`.`Nickname00`, `s1`.`HasSoulPatch`, `s1`.`SquadId00`, `s2`.`Id`, `s2`.`AmmunitionType`, `s2`.`IsAutomatic`, `s2`.`Name`, `s2`.`OwnerFullName`, `s2`.`SynergyWithId`, `s2`.`Nickname`, `s2`.`SquadId` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) LEFT JOIN ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` - FROM `Gears` AS `g` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName` + FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName` - FROM `Officers` AS `o0` -) AS `t2` ON (`t0`.`GearNickName` = `t2`.`Nickname`) AND (`t0`.`GearSquadId` = `t2`.`SquadId`) + SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`FullName` + FROM `Officers` AS `o1` +) AS `u1` ON (`t`.`GearNickName` = `u1`.`Nickname`) AND (`t`.`GearSquadId` = `u1`.`SquadId`) LEFT JOIN ( - SELECT `t4`.`FullName`, `t4`.`Nickname`, `t4`.`SquadId`, `t5`.`Id`, `t5`.`Nickname` AS `Nickname0`, `t5`.`SquadId` AS `SquadId0`, `t5`.`Id0`, `t5`.`Name`, `t5`.`IsAutomatic`, `t5`.`Id1`, `t5`.`Nickname0` AS `Nickname00`, `t5`.`HasSoulPatch`, `t5`.`SquadId0` AS `SquadId00`, `t4`.`Rank`, `t5`.`IsAutomatic0`, `t4`.`LeaderNickname`, `t4`.`LeaderSquadId` + SELECT `u2`.`FullName`, `u2`.`Nickname`, `u2`.`SquadId`, `s0`.`Id`, `s0`.`Nickname` AS `Nickname0`, `s0`.`SquadId` AS `SquadId0`, `s0`.`Id0`, `s0`.`Name`, `s0`.`IsAutomatic`, `s0`.`Id1`, `s0`.`Nickname0` AS `Nickname00`, `s0`.`HasSoulPatch`, `s0`.`SquadId0` AS `SquadId00`, `u2`.`Rank`, `s0`.`IsAutomatic0`, `u2`.`LeaderNickname`, `u2`.`LeaderSquadId` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank` - FROM `Gears` AS `g0` + SELECT `g1`.`Nickname`, `g1`.`SquadId`, `g1`.`FullName`, `g1`.`LeaderNickname`, `g1`.`LeaderSquadId`, `g1`.`Rank` + FROM `Gears` AS `g1` UNION ALL - SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`FullName`, `o1`.`LeaderNickname`, `o1`.`LeaderSquadId`, `o1`.`Rank` - FROM `Officers` AS `o1` - ) AS `t4` + SELECT `o2`.`Nickname`, `o2`.`SquadId`, `o2`.`FullName`, `o2`.`LeaderNickname`, `o2`.`LeaderSquadId`, `o2`.`Rank` + FROM `Officers` AS `o2` + ) AS `u2` LEFT JOIN ( - SELECT `w`.`Id`, `t6`.`Nickname`, `t6`.`SquadId`, `s`.`Id` AS `Id0`, `w0`.`Name`, `w0`.`IsAutomatic`, `w0`.`Id` AS `Id1`, `t7`.`Nickname` AS `Nickname0`, `t7`.`HasSoulPatch`, `t7`.`SquadId` AS `SquadId0`, `w`.`IsAutomatic` AS `IsAutomatic0`, `w`.`OwnerFullName` + SELECT `w`.`Id`, `u3`.`Nickname`, `u3`.`SquadId`, `s`.`Id` AS `Id0`, `w0`.`Name`, `w0`.`IsAutomatic`, `w0`.`Id` AS `Id1`, `u4`.`Nickname` AS `Nickname0`, `u4`.`HasSoulPatch`, `u4`.`SquadId` AS `SquadId0`, `w`.`IsAutomatic` AS `IsAutomatic0`, `w`.`OwnerFullName` FROM `Weapons` AS `w` LEFT JOIN ( - SELECT `g1`.`Nickname`, `g1`.`SquadId`, `g1`.`FullName` - FROM `Gears` AS `g1` - UNION ALL - SELECT `o2`.`Nickname`, `o2`.`SquadId`, `o2`.`FullName` - FROM `Officers` AS `o2` - ) AS `t6` ON `w`.`OwnerFullName` = `t6`.`FullName` - LEFT JOIN `Squads` AS `s` ON `t6`.`SquadId` = `s`.`Id` - LEFT JOIN `Weapons` AS `w0` ON `t6`.`FullName` = `w0`.`OwnerFullName` - LEFT JOIN ( - SELECT `g2`.`Nickname`, `g2`.`SquadId`, `g2`.`HasSoulPatch` + SELECT `g2`.`Nickname`, `g2`.`SquadId`, `g2`.`FullName` FROM `Gears` AS `g2` UNION ALL - SELECT `o3`.`Nickname`, `o3`.`SquadId`, `o3`.`HasSoulPatch` + SELECT `o3`.`Nickname`, `o3`.`SquadId`, `o3`.`FullName` FROM `Officers` AS `o3` - ) AS `t7` ON `s`.`Id` = `t7`.`SquadId` + ) AS `u3` ON `w`.`OwnerFullName` = `u3`.`FullName` + LEFT JOIN `Squads` AS `s` ON `u3`.`SquadId` = `s`.`Id` + LEFT JOIN `Weapons` AS `w0` ON `u3`.`FullName` = `w0`.`OwnerFullName` + LEFT JOIN ( + SELECT `g3`.`Nickname`, `g3`.`SquadId`, `g3`.`HasSoulPatch` + FROM `Gears` AS `g3` + UNION ALL + SELECT `o4`.`Nickname`, `o4`.`SquadId`, `o4`.`HasSoulPatch` + FROM `Officers` AS `o4` + ) AS `u4` ON `s`.`Id` = `u4`.`SquadId` WHERE (`w`.`Name` <> 'Bar') OR `w`.`Name` IS NULL - ) AS `t5` ON `t4`.`FullName` = `t5`.`OwnerFullName` - WHERE `t4`.`FullName` <> 'Foo' -) AS `t3` ON (`t`.`Nickname` = `t3`.`LeaderNickname`) AND (`t`.`SquadId` = `t3`.`LeaderSquadId`) + ) AS `s0` ON `u2`.`FullName` = `s0`.`OwnerFullName` + WHERE `u2`.`FullName` <> 'Foo' +) AS `s1` ON (`u`.`Nickname` = `s1`.`LeaderNickname`) AND (`u`.`SquadId` = `s1`.`LeaderSquadId`) LEFT JOIN ( - SELECT `w1`.`Id`, `w1`.`AmmunitionType`, `w1`.`IsAutomatic`, `w1`.`Name`, `w1`.`OwnerFullName`, `w1`.`SynergyWithId`, `t9`.`Nickname`, `t9`.`SquadId` + SELECT `w1`.`Id`, `w1`.`AmmunitionType`, `w1`.`IsAutomatic`, `w1`.`Name`, `w1`.`OwnerFullName`, `w1`.`SynergyWithId`, `u5`.`Nickname`, `u5`.`SquadId` FROM `Weapons` AS `w1` LEFT JOIN ( - SELECT `g3`.`Nickname`, `g3`.`SquadId`, `g3`.`FullName` - FROM `Gears` AS `g3` + SELECT `g4`.`Nickname`, `g4`.`SquadId`, `g4`.`FullName` + FROM `Gears` AS `g4` UNION ALL - SELECT `o4`.`Nickname`, `o4`.`SquadId`, `o4`.`FullName` - FROM `Officers` AS `o4` - ) AS `t9` ON `w1`.`OwnerFullName` = `t9`.`FullName` -) AS `t8` ON `t2`.`FullName` = `t8`.`OwnerFullName` + SELECT `o5`.`Nickname`, `o5`.`SquadId`, `o5`.`FullName` + FROM `Officers` AS `o5` + ) AS `u5` ON `w1`.`OwnerFullName` = `u5`.`FullName` +) AS `s2` ON `u1`.`FullName` = `s2`.`OwnerFullName` WHERE EXISTS ( SELECT 1 FROM ( - SELECT `g4`.`Nickname`, `g4`.`SquadId`, `g4`.`AssignedCityName`, `g4`.`CityOfBirthName`, `g4`.`FullName`, `g4`.`HasSoulPatch`, `g4`.`LeaderNickname`, `g4`.`LeaderSquadId`, `g4`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g4` + SELECT `g`.`LeaderNickname`, `g`.`LeaderSquadId` + FROM `Gears` AS `g` UNION ALL - SELECT `o5`.`Nickname`, `o5`.`SquadId`, `o5`.`AssignedCityName`, `o5`.`CityOfBirthName`, `o5`.`FullName`, `o5`.`HasSoulPatch`, `o5`.`LeaderNickname`, `o5`.`LeaderSquadId`, `o5`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o5` - ) AS `t1` - WHERE (`t`.`Nickname` = `t1`.`LeaderNickname`) AND (`t`.`SquadId` = `t1`.`LeaderSquadId`)) -ORDER BY `t`.`HasSoulPatch` DESC, `t0`.`Note`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t2`.`Nickname`, `t2`.`SquadId`, `t3`.`Rank`, `t3`.`Nickname`, `t3`.`SquadId`, `t3`.`IsAutomatic0`, `t3`.`Id`, `t3`.`Nickname0`, `t3`.`SquadId0`, `t3`.`Id0`, `t3`.`Id1`, `t3`.`Nickname00`, `t3`.`SquadId00`, `t8`.`IsAutomatic`, `t8`.`Nickname` DESC, `t8`.`Id` + SELECT `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` + FROM `Officers` AS `o0` + ) AS `u0` + WHERE (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`)) +ORDER BY `u`.`HasSoulPatch` DESC, `t`.`Note`, `u`.`Nickname`, `u`.`SquadId`, `t`.`Id`, `u1`.`Nickname`, `u1`.`SquadId`, `s1`.`Rank`, `s1`.`Nickname`, `s1`.`SquadId`, `s1`.`IsAutomatic0`, `s1`.`Id`, `s1`.`Nickname0`, `s1`.`SquadId0`, `s1`.`Id0`, `s1`.`Id1`, `s1`.`Nickname00`, `s1`.`SquadId00`, `s2`.`IsAutomatic`, `s2`.`Nickname` DESC, `s2`.`Id` """); } @@ -6102,23 +6305,23 @@ public override async Task Correlated_collections_inner_subquery_selector_refere AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`ReportName`, `t0`.`OfficerName`, `t0`.`Nickname`, `t0`.`SquadId` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `u1`.`ReportName`, `u1`.`OfficerName`, `u1`.`Nickname`, `u1`.`SquadId` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN LATERAL ( - SELECT `t1`.`FullName` AS `ReportName`, `t`.`FullName` AS `OfficerName`, `t1`.`Nickname`, `t1`.`SquadId` + SELECT `u0`.`FullName` AS `ReportName`, `u`.`FullName` AS `OfficerName`, `u0`.`Nickname`, `u0`.`SquadId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`LeaderNickname`, `g`.`LeaderSquadId` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` FROM `Officers` AS `o0` - ) AS `t1` - WHERE (`t`.`Nickname` = `t1`.`LeaderNickname`) AND (`t`.`SquadId` = `t1`.`LeaderSquadId`) -) AS `t0` ON TRUE -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` + ) AS `u0` + WHERE (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +) AS `u1` ON TRUE +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u1`.`Nickname` """); } @@ -6128,23 +6331,23 @@ public override async Task Correlated_collections_inner_subquery_predicate_refer AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`ReportName`, `t0`.`Nickname`, `t0`.`SquadId` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `u1`.`ReportName`, `u1`.`Nickname`, `u1`.`SquadId` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN LATERAL ( - SELECT `t1`.`FullName` AS `ReportName`, `t1`.`Nickname`, `t1`.`SquadId` + SELECT `u0`.`FullName` AS `ReportName`, `u0`.`Nickname`, `u0`.`SquadId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`LeaderNickname`, `g`.`LeaderSquadId` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` FROM `Officers` AS `o0` - ) AS `t1` - WHERE ((`t`.`Nickname` = `t1`.`LeaderNickname`) AND (`t`.`SquadId` = `t1`.`LeaderSquadId`)) AND (`t`.`FullName` <> 'Foo') -) AS `t0` ON TRUE -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` + ) AS `u0` + WHERE ((`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`)) AND (`u`.`FullName` <> 'Foo') +) AS `u1` ON TRUE +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u1`.`Nickname` """); } @@ -6154,28 +6357,28 @@ public override async Task Correlated_collections_nested_inner_subquery_referenc AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t1`.`FullName`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`Name`, `t1`.`Nickname0`, `t1`.`Id` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `s`.`FullName`, `s`.`Nickname`, `s`.`SquadId`, `s`.`Name`, `s`.`Nickname0`, `s`.`Id` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `t0`.`FullName`, `t0`.`Nickname`, `t0`.`SquadId`, `t2`.`Name`, `t2`.`Nickname` AS `Nickname0`, `t2`.`Id`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId` + SELECT `u0`.`FullName`, `u0`.`Nickname`, `u0`.`SquadId`, `w0`.`Name`, `w0`.`Nickname` AS `Nickname0`, `w0`.`Id`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`LeaderNickname`, `g`.`LeaderSquadId` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` FROM `Officers` AS `o0` - ) AS `t0` + ) AS `u0` LEFT JOIN LATERAL ( - SELECT `w`.`Name`, `t0`.`Nickname`, `w`.`Id` + SELECT `w`.`Name`, `u0`.`Nickname`, `w`.`Id` FROM `Weapons` AS `w` - WHERE (`t0`.`FullName` = `w`.`OwnerFullName`) AND ((`w`.`Name` <> 'Bar') OR `w`.`Name` IS NULL) - ) AS `t2` ON TRUE - WHERE `t0`.`FullName` <> 'Foo' -) AS `t1` ON (`t`.`Nickname` = `t1`.`LeaderNickname`) AND (`t`.`SquadId` = `t1`.`LeaderSquadId`) -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t1`.`Nickname`, `t1`.`SquadId` + WHERE (`u0`.`FullName` = `w`.`OwnerFullName`) AND ((`w`.`Name` <> 'Bar') OR `w`.`Name` IS NULL) + ) AS `w0` ON TRUE + WHERE `u0`.`FullName` <> 'Foo' +) AS `s` ON (`u`.`Nickname` = `s`.`LeaderNickname`) AND (`u`.`SquadId` = `s`.`LeaderSquadId`) +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `s`.`Nickname`, `s`.`SquadId` """); } @@ -6185,28 +6388,28 @@ public override async Task Correlated_collections_nested_inner_subquery_referenc AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t1`.`FullName`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`Name`, `t1`.`Nickname0`, `t1`.`Id` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `s`.`FullName`, `s`.`Nickname`, `s`.`SquadId`, `s`.`Name`, `s`.`Nickname0`, `s`.`Id` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN LATERAL ( - SELECT `t0`.`FullName`, `t0`.`Nickname`, `t0`.`SquadId`, `t2`.`Name`, `t2`.`Nickname` AS `Nickname0`, `t2`.`Id` + SELECT `u0`.`FullName`, `u0`.`Nickname`, `u0`.`SquadId`, `w0`.`Name`, `w0`.`Nickname` AS `Nickname0`, `w0`.`Id` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`LeaderNickname`, `g`.`LeaderSquadId` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` FROM `Officers` AS `o0` - ) AS `t0` + ) AS `u0` LEFT JOIN ( - SELECT `w`.`Name`, `t`.`Nickname`, `w`.`Id`, `w`.`OwnerFullName` + SELECT `w`.`Name`, `u`.`Nickname`, `w`.`Id`, `w`.`OwnerFullName` FROM `Weapons` AS `w` WHERE (`w`.`Name` <> 'Bar') OR `w`.`Name` IS NULL - ) AS `t2` ON `t0`.`FullName` = `t2`.`OwnerFullName` - WHERE ((`t`.`Nickname` = `t0`.`LeaderNickname`) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`)) AND (`t0`.`FullName` <> 'Foo') -) AS `t1` ON TRUE -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t1`.`Nickname`, `t1`.`SquadId` + ) AS `w0` ON `u0`.`FullName` = `w0`.`OwnerFullName` + WHERE ((`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`)) AND (`u0`.`FullName` <> 'Foo') +) AS `s` ON TRUE +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `s`.`Nickname`, `s`.`SquadId` """); } @@ -6215,34 +6418,34 @@ public override async Task Correlated_collections_on_select_many(bool async) await base.Correlated_collections_on_select_many(async); AssertSql( -$""" -SELECT `t`.`Nickname`, `s`.`Name`, `t`.`SquadId`, `s`.`Id`, `t0`.`Id`, `t0`.`AmmunitionType`, `t0`.`IsAutomatic`, `t0`.`Name`, `t0`.`OwnerFullName`, `t0`.`SynergyWithId`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` +""" +SELECT `u`.`Nickname`, `s`.`Name`, `u`.`SquadId`, `s`.`Id`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId`, `u1`.`Nickname`, `u1`.`SquadId`, `u1`.`AssignedCityName`, `u1`.`CityOfBirthName`, `u1`.`FullName`, `u1`.`HasSoulPatch`, `u1`.`LeaderNickname`, `u1`.`LeaderSquadId`, `u1`.`Rank`, `u1`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` +) AS `u` CROSS JOIN `Squads` AS `s` LEFT JOIN ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` WHERE (`w`.`IsAutomatic` = TRUE) OR ((`w`.`Name` <> 'foo') OR `w`.`Name` IS NULL) -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` +) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` LEFT JOIN ( - SELECT `t2`.`Nickname`, `t2`.`SquadId`, `t2`.`AssignedCityName`, `t2`.`CityOfBirthName`, `t2`.`FullName`, `t2`.`HasSoulPatch`, `t2`.`LeaderNickname`, `t2`.`LeaderSquadId`, `t2`.`Rank`, `t2`.`Discriminator` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Gear'")} AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Officer'")} AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` - ) AS `t2` - WHERE `t2`.`HasSoulPatch` = FALSE -) AS `t1` ON `s`.`Id` = `t1`.`SquadId` -WHERE `t`.`HasSoulPatch` = TRUE -ORDER BY `t`.`Nickname`, `s`.`Id` DESC, `t`.`SquadId`, `t0`.`Id`, `t1`.`Nickname` + ) AS `u0` + WHERE `u0`.`HasSoulPatch` = FALSE +) AS `u1` ON `s`.`Id` = `u1`.`SquadId` +WHERE `u`.`HasSoulPatch` = TRUE +ORDER BY `u`.`Nickname`, `s`.`Id` DESC, `u`.`SquadId`, `w0`.`Id`, `u1`.`Nickname` """); } @@ -6252,23 +6455,23 @@ public override async Task Correlated_collections_with_Skip(bool async) AssertSql( """ -SELECT `s`.`Id`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` +SELECT `s`.`Id`, `u1`.`Nickname`, `u1`.`SquadId`, `u1`.`AssignedCityName`, `u1`.`CityOfBirthName`, `u1`.`FullName`, `u1`.`HasSoulPatch`, `u1`.`LeaderNickname`, `u1`.`LeaderSquadId`, `u1`.`Rank`, `u1`.`Discriminator` FROM `Squads` AS `s` LEFT JOIN ( - SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( - SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, ROW_NUMBER() OVER(PARTITION BY `t`.`SquadId` ORDER BY `t`.`Nickname`) AS `row` + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, ROW_NUMBER() OVER(PARTITION BY `u`.`SquadId` ORDER BY `u`.`Nickname`) AS `row` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` - ) AS `t` - ) AS `t0` - WHERE 1 < `t0`.`row` -) AS `t1` ON `s`.`Id` = `t1`.`SquadId` -ORDER BY `s`.`Name`, `s`.`Id`, `t1`.`SquadId`, `t1`.`Nickname` + ) AS `u` + ) AS `u0` + WHERE 1 < `u0`.`row` +) AS `u1` ON `s`.`Id` = `u1`.`SquadId` +ORDER BY `s`.`Name`, `s`.`Id`, `u1`.`SquadId`, `u1`.`Nickname` """); } @@ -6278,23 +6481,23 @@ public override async Task Correlated_collections_with_Take(bool async) AssertSql( """ -SELECT `s`.`Id`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` +SELECT `s`.`Id`, `u1`.`Nickname`, `u1`.`SquadId`, `u1`.`AssignedCityName`, `u1`.`CityOfBirthName`, `u1`.`FullName`, `u1`.`HasSoulPatch`, `u1`.`LeaderNickname`, `u1`.`LeaderSquadId`, `u1`.`Rank`, `u1`.`Discriminator` FROM `Squads` AS `s` LEFT JOIN ( - SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( - SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, ROW_NUMBER() OVER(PARTITION BY `t`.`SquadId` ORDER BY `t`.`Nickname`) AS `row` + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, ROW_NUMBER() OVER(PARTITION BY `u`.`SquadId` ORDER BY `u`.`Nickname`) AS `row` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` - ) AS `t` - ) AS `t0` - WHERE `t0`.`row` <= 2 -) AS `t1` ON `s`.`Id` = `t1`.`SquadId` -ORDER BY `s`.`Name`, `s`.`Id`, `t1`.`SquadId`, `t1`.`Nickname` + ) AS `u` + ) AS `u0` + WHERE `u0`.`row` <= 2 +) AS `u1` ON `s`.`Id` = `u1`.`SquadId` +ORDER BY `s`.`Name`, `s`.`Id`, `u1`.`SquadId`, `u1`.`Nickname` """); } @@ -6304,25 +6507,25 @@ public override async Task Correlated_collections_with_Distinct(bool async) AssertSql( """ -SELECT `s`.`Id`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` +SELECT `s`.`Id`, `u1`.`Nickname`, `u1`.`SquadId`, `u1`.`AssignedCityName`, `u1`.`CityOfBirthName`, `u1`.`FullName`, `u1`.`HasSoulPatch`, `u1`.`LeaderNickname`, `u1`.`LeaderSquadId`, `u1`.`Rank`, `u1`.`Discriminator` FROM `Squads` AS `s` LEFT JOIN LATERAL ( - SELECT DISTINCT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` + SELECT DISTINCT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( - SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` - ) AS `t` - WHERE `s`.`Id` = `t`.`SquadId` - ORDER BY `t`.`Nickname` + ) AS `u` + WHERE `s`.`Id` = `u`.`SquadId` + ORDER BY `u`.`Nickname` LIMIT 18446744073709551610 OFFSET 0 - ) AS `t0` -) AS `t1` ON TRUE -ORDER BY `s`.`Name`, `s`.`Id`, `t1`.`Nickname` + ) AS `u0` +) AS `u1` ON TRUE +ORDER BY `s`.`Name`, `s`.`Id`, `u1`.`Nickname` """); } @@ -6334,16 +6537,16 @@ public override async Task Correlated_collections_with_FirstOrDefault(bool async AssertSql( """ SELECT ( - SELECT `t`.`FullName` + SELECT `u`.`FullName` FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` - ) AS `t` - WHERE `s`.`Id` = `t`.`SquadId` - ORDER BY `t`.`Nickname` + ) AS `u` + WHERE `s`.`Id` = `u`.`SquadId` + ORDER BY `u`.`Nickname` LIMIT 1) FROM `Squads` AS `s` ORDER BY `s`.`Name` @@ -6356,7 +6559,7 @@ public override async Task Correlated_collections_on_left_join_with_predicate(bo AssertSql( """ -SELECT `t0`.`Nickname`, `t`.`Id`, `t0`.`SquadId`, `w`.`Name`, `w`.`Id` +SELECT `u`.`Nickname`, `t`.`Id`, `u`.`SquadId`, `w`.`Name`, `w`.`Id` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`HasSoulPatch` @@ -6364,10 +6567,10 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON `t`.`GearNickName` = `t0`.`Nickname` -LEFT JOIN `Weapons` AS `w` ON `t0`.`FullName` = `w`.`OwnerFullName` -WHERE `t0`.`HasSoulPatch` = FALSE -ORDER BY `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId` +) AS `u` ON `t`.`GearNickName` = `u`.`Nickname` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +WHERE `u`.`HasSoulPatch` = FALSE +ORDER BY `t`.`Id`, `u`.`Nickname`, `u`.`SquadId` """); } @@ -6377,7 +6580,7 @@ public override async Task Correlated_collections_on_left_join_with_null_value(b AssertSql( """ -SELECT `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `w`.`Name`, `w`.`Id` +SELECT `t`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `w`.`Name`, `w`.`Id` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` @@ -6385,9 +6588,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t0` ON `t`.`GearNickName` = `t0`.`Nickname` -LEFT JOIN `Weapons` AS `w` ON `t0`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t`.`Note`, `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId` +) AS `u` ON `t`.`GearNickName` = `u`.`Nickname` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `t`.`Note`, `t`.`Id`, `u`.`Nickname`, `u`.`SquadId` """); } @@ -6397,20 +6600,20 @@ public override async Task Correlated_collections_left_join_with_self_reference( AssertSql( """ -SELECT `t`.`Note`, `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `t1`.`FullName`, `t1`.`Nickname`, `t1`.`SquadId` +SELECT `t`.`Note`, `t`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `u0`.`FullName`, `u0`.`Nickname`, `u0`.`SquadId` FROM `Tags` AS `t` LEFT JOIN ( SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON `t`.`GearNickName` = `t0`.`Nickname` +) AS `u` ON `t`.`GearNickName` = `u`.`Nickname` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`LeaderNickname`, `g`.`LeaderSquadId` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` FROM `Officers` AS `o0` -) AS `t1` ON ((`t0`.`Nickname` = `t1`.`LeaderNickname`) OR (`t0`.`Nickname` IS NULL AND (`t1`.`LeaderNickname` IS NULL))) AND (`t0`.`SquadId` = `t1`.`LeaderSquadId`) -ORDER BY `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `t1`.`Nickname` +) AS `u0` ON ((`u`.`Nickname` = `u0`.`LeaderNickname`) OR (`u`.`Nickname` IS NULL AND (`u0`.`LeaderNickname` IS NULL))) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `t`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -6420,7 +6623,7 @@ public override async Task Correlated_collections_deeply_nested_left_join(bool a AssertSql( """ -SELECT `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `s`.`Id`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`Id`, `t1`.`AmmunitionType`, `t1`.`IsAutomatic`, `t1`.`Name`, `t1`.`OwnerFullName`, `t1`.`SynergyWithId` +SELECT `t`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `s`.`Id`, `s0`.`Nickname`, `s0`.`SquadId`, `s0`.`Id`, `s0`.`AmmunitionType`, `s0`.`IsAutomatic`, `s0`.`Name`, `s0`.`OwnerFullName`, `s0`.`SynergyWithId` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId` @@ -6428,25 +6631,25 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON `t`.`GearNickName` = `t0`.`Nickname` -LEFT JOIN `Squads` AS `s` ON `t0`.`SquadId` = `s`.`Id` +) AS `u` ON `t`.`GearNickName` = `u`.`Nickname` +LEFT JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` LEFT JOIN ( - SELECT `t2`.`Nickname`, `t2`.`SquadId`, `t3`.`Id`, `t3`.`AmmunitionType`, `t3`.`IsAutomatic`, `t3`.`Name`, `t3`.`OwnerFullName`, `t3`.`SynergyWithId` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName`, `g0`.`HasSoulPatch` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName`, `o0`.`HasSoulPatch` FROM `Officers` AS `o0` - ) AS `t2` + ) AS `u0` LEFT JOIN ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` WHERE `w`.`IsAutomatic` = TRUE - ) AS `t3` ON `t2`.`FullName` = `t3`.`OwnerFullName` - WHERE `t2`.`HasSoulPatch` = TRUE -) AS `t1` ON `s`.`Id` = `t1`.`SquadId` -ORDER BY `t`.`Note`, `t0`.`Nickname` DESC, `t`.`Id`, `t0`.`SquadId`, `s`.`Id`, `t1`.`Nickname`, `t1`.`SquadId` + ) AS `w0` ON `u0`.`FullName` = `w0`.`OwnerFullName` + WHERE `u0`.`HasSoulPatch` = TRUE +) AS `s0` ON `s`.`Id` = `s0`.`SquadId` +ORDER BY `t`.`Note`, `u`.`Nickname` DESC, `t`.`Id`, `u`.`SquadId`, `s`.`Id`, `s0`.`Nickname`, `s0`.`SquadId` """); } @@ -6456,7 +6659,7 @@ public override async Task Correlated_collections_from_left_join_with_additional AssertSql( """ -SELECT `w`.`Id`, `t`.`Nickname`, `t`.`SquadId`, `s`.`Id`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`Id`, `t1`.`AmmunitionType`, `t1`.`IsAutomatic`, `t1`.`Name`, `t1`.`OwnerFullName`, `t1`.`SynergyWithId`, `t1`.`Rank` +SELECT `w`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `s`.`Id`, `s0`.`Nickname`, `s0`.`SquadId`, `s0`.`Id`, `s0`.`AmmunitionType`, `s0`.`IsAutomatic`, `s0`.`Name`, `s0`.`OwnerFullName`, `s0`.`SynergyWithId`, `s0`.`Rank` FROM `Weapons` AS `w` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` @@ -6464,24 +6667,24 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` ON `w`.`OwnerFullName` = `t`.`FullName` -LEFT JOIN `Squads` AS `s` ON `t`.`SquadId` = `s`.`Id` +) AS `u` ON `w`.`OwnerFullName` = `u`.`FullName` +LEFT JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` LEFT JOIN ( - SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t2`.`Id`, `t2`.`AmmunitionType`, `t2`.`IsAutomatic`, `t2`.`Name`, `t2`.`OwnerFullName`, `t2`.`SynergyWithId`, `t0`.`Rank`, `t0`.`FullName` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `w1`.`Id`, `w1`.`AmmunitionType`, `w1`.`IsAutomatic`, `w1`.`Name`, `w1`.`OwnerFullName`, `w1`.`SynergyWithId`, `u0`.`Rank`, `u0`.`FullName` FROM ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName`, `g0`.`Rank` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName`, `o0`.`Rank` FROM `Officers` AS `o0` - ) AS `t0` + ) AS `u0` LEFT JOIN ( SELECT `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM `Weapons` AS `w0` WHERE `w0`.`IsAutomatic` = FALSE - ) AS `t2` ON `t0`.`FullName` = `t2`.`OwnerFullName` -) AS `t1` ON `s`.`Id` = `t1`.`SquadId` -ORDER BY `w`.`Name`, `w`.`Id`, `t`.`Nickname`, `t`.`SquadId`, `s`.`Id`, `t1`.`FullName` DESC, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`Id` + ) AS `w1` ON `u0`.`FullName` = `w1`.`OwnerFullName` +) AS `s0` ON `s`.`Id` = `s0`.`SquadId` +ORDER BY `w`.`Name`, `w`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `s`.`Id`, `s0`.`FullName` DESC, `s0`.`Nickname`, `s0`.`SquadId`, `s0`.`Id` """); } @@ -6491,16 +6694,16 @@ public override async Task Correlated_collections_complex_scenario1(bool async) AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t1`.`Id`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`Id0`, `t1`.`Nickname0`, `t1`.`HasSoulPatch`, `t1`.`SquadId0` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `s0`.`Id`, `s0`.`Nickname`, `s0`.`SquadId`, `s0`.`Id0`, `s0`.`Nickname0`, `s0`.`HasSoulPatch`, `s0`.`SquadId0` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `w`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `s`.`Id` AS `Id0`, `t2`.`Nickname` AS `Nickname0`, `t2`.`HasSoulPatch`, `t2`.`SquadId` AS `SquadId0`, `w`.`OwnerFullName` + SELECT `w`.`Id`, `u0`.`Nickname`, `u0`.`SquadId`, `s`.`Id` AS `Id0`, `u1`.`Nickname` AS `Nickname0`, `u1`.`HasSoulPatch`, `u1`.`SquadId` AS `SquadId0`, `w`.`OwnerFullName` FROM `Weapons` AS `w` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName` @@ -6508,17 +6711,17 @@ LEFT JOIN ( UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName` FROM `Officers` AS `o0` - ) AS `t0` ON `w`.`OwnerFullName` = `t0`.`FullName` - LEFT JOIN `Squads` AS `s` ON `t0`.`SquadId` = `s`.`Id` + ) AS `u0` ON `w`.`OwnerFullName` = `u0`.`FullName` + LEFT JOIN `Squads` AS `s` ON `u0`.`SquadId` = `s`.`Id` LEFT JOIN ( SELECT `g1`.`Nickname`, `g1`.`SquadId`, `g1`.`HasSoulPatch` FROM `Gears` AS `g1` UNION ALL SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`HasSoulPatch` FROM `Officers` AS `o1` - ) AS `t2` ON `s`.`Id` = `t2`.`SquadId` -) AS `t1` ON `t`.`FullName` = `t1`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t1`.`Id`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`Id0`, `t1`.`Nickname0` + ) AS `u1` ON `s`.`Id` = `u1`.`SquadId` +) AS `s0` ON `u`.`FullName` = `s0`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `s0`.`Id`, `s0`.`Nickname`, `s0`.`SquadId`, `s0`.`Id0`, `s0`.`Nickname0` """); } @@ -6528,22 +6731,22 @@ public override async Task Correlated_collections_complex_scenario2(bool async) AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t3`.`FullName`, `t3`.`Nickname`, `t3`.`SquadId`, `t3`.`Id`, `t3`.`Nickname0`, `t3`.`SquadId0`, `t3`.`Id0`, `t3`.`Nickname00`, `t3`.`HasSoulPatch`, `t3`.`SquadId00` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `s1`.`FullName`, `s1`.`Nickname`, `s1`.`SquadId`, `s1`.`Id`, `s1`.`Nickname0`, `s1`.`SquadId0`, `s1`.`Id0`, `s1`.`Nickname00`, `s1`.`HasSoulPatch`, `s1`.`SquadId00` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `t0`.`FullName`, `t0`.`Nickname`, `t0`.`SquadId`, `t1`.`Id`, `t1`.`Nickname` AS `Nickname0`, `t1`.`SquadId` AS `SquadId0`, `t1`.`Id0`, `t1`.`Nickname0` AS `Nickname00`, `t1`.`HasSoulPatch`, `t1`.`SquadId0` AS `SquadId00`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId` + SELECT `u0`.`FullName`, `u0`.`Nickname`, `u0`.`SquadId`, `s0`.`Id`, `s0`.`Nickname` AS `Nickname0`, `s0`.`SquadId` AS `SquadId0`, `s0`.`Id0`, `s0`.`Nickname0` AS `Nickname00`, `s0`.`HasSoulPatch`, `s0`.`SquadId0` AS `SquadId00`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`LeaderNickname`, `g`.`LeaderSquadId` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` FROM `Officers` AS `o0` - ) AS `t0` + ) AS `u0` LEFT JOIN ( - SELECT `w`.`Id`, `t2`.`Nickname`, `t2`.`SquadId`, `s`.`Id` AS `Id0`, `t4`.`Nickname` AS `Nickname0`, `t4`.`HasSoulPatch`, `t4`.`SquadId` AS `SquadId0`, `w`.`OwnerFullName` + SELECT `w`.`Id`, `u1`.`Nickname`, `u1`.`SquadId`, `s`.`Id` AS `Id0`, `u2`.`Nickname` AS `Nickname0`, `u2`.`HasSoulPatch`, `u2`.`SquadId` AS `SquadId0`, `w`.`OwnerFullName` FROM `Weapons` AS `w` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName` @@ -6551,18 +6754,18 @@ LEFT JOIN ( UNION ALL SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`FullName` FROM `Officers` AS `o1` - ) AS `t2` ON `w`.`OwnerFullName` = `t2`.`FullName` - LEFT JOIN `Squads` AS `s` ON `t2`.`SquadId` = `s`.`Id` + ) AS `u1` ON `w`.`OwnerFullName` = `u1`.`FullName` + LEFT JOIN `Squads` AS `s` ON `u1`.`SquadId` = `s`.`Id` LEFT JOIN ( SELECT `g1`.`Nickname`, `g1`.`SquadId`, `g1`.`HasSoulPatch` FROM `Gears` AS `g1` UNION ALL SELECT `o2`.`Nickname`, `o2`.`SquadId`, `o2`.`HasSoulPatch` FROM `Officers` AS `o2` - ) AS `t4` ON `s`.`Id` = `t4`.`SquadId` - ) AS `t1` ON `t0`.`FullName` = `t1`.`OwnerFullName` -) AS `t3` ON (`t`.`Nickname` = `t3`.`LeaderNickname`) AND (`t`.`SquadId` = `t3`.`LeaderSquadId`) -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t3`.`Nickname`, `t3`.`SquadId`, `t3`.`Id`, `t3`.`Nickname0`, `t3`.`SquadId0`, `t3`.`Id0`, `t3`.`Nickname00` + ) AS `u2` ON `s`.`Id` = `u2`.`SquadId` + ) AS `s0` ON `u0`.`FullName` = `s0`.`OwnerFullName` +) AS `s1` ON (`u`.`Nickname` = `s1`.`LeaderNickname`) AND (`u`.`SquadId` = `s1`.`LeaderSquadId`) +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `s1`.`Nickname`, `s1`.`SquadId`, `s1`.`Id`, `s1`.`Nickname0`, `s1`.`SquadId0`, `s1`.`Id0`, `s1`.`Nickname00` """); } @@ -6572,16 +6775,16 @@ public override async Task Correlated_collections_with_funky_orderby_complex_sce AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t1`.`Id`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`Id0`, `t1`.`Nickname0`, `t1`.`HasSoulPatch`, `t1`.`SquadId0` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `s0`.`Id`, `s0`.`Nickname`, `s0`.`SquadId`, `s0`.`Id0`, `s0`.`Nickname0`, `s0`.`HasSoulPatch`, `s0`.`SquadId0` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `w`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `s`.`Id` AS `Id0`, `t2`.`Nickname` AS `Nickname0`, `t2`.`HasSoulPatch`, `t2`.`SquadId` AS `SquadId0`, `w`.`OwnerFullName` + SELECT `w`.`Id`, `u0`.`Nickname`, `u0`.`SquadId`, `s`.`Id` AS `Id0`, `u1`.`Nickname` AS `Nickname0`, `u1`.`HasSoulPatch`, `u1`.`SquadId` AS `SquadId0`, `w`.`OwnerFullName` FROM `Weapons` AS `w` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName` @@ -6589,17 +6792,17 @@ LEFT JOIN ( UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName` FROM `Officers` AS `o0` - ) AS `t0` ON `w`.`OwnerFullName` = `t0`.`FullName` - LEFT JOIN `Squads` AS `s` ON `t0`.`SquadId` = `s`.`Id` + ) AS `u0` ON `w`.`OwnerFullName` = `u0`.`FullName` + LEFT JOIN `Squads` AS `s` ON `u0`.`SquadId` = `s`.`Id` LEFT JOIN ( SELECT `g1`.`Nickname`, `g1`.`SquadId`, `g1`.`HasSoulPatch` FROM `Gears` AS `g1` UNION ALL SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`HasSoulPatch` FROM `Officers` AS `o1` - ) AS `t2` ON `s`.`Id` = `t2`.`SquadId` -) AS `t1` ON `t`.`FullName` = `t1`.`OwnerFullName` -ORDER BY `t`.`FullName`, `t`.`Nickname` DESC, `t`.`SquadId`, `t1`.`Id`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`Id0`, `t1`.`Nickname0` + ) AS `u1` ON `s`.`Id` = `u1`.`SquadId` +) AS `s0` ON `u`.`FullName` = `s0`.`OwnerFullName` +ORDER BY `u`.`FullName`, `u`.`Nickname` DESC, `u`.`SquadId`, `s0`.`Id`, `s0`.`Nickname`, `s0`.`SquadId`, `s0`.`Id0`, `s0`.`Nickname0` """); } @@ -6609,22 +6812,22 @@ public override async Task Correlated_collections_with_funky_orderby_complex_sce AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t3`.`FullName`, `t3`.`Nickname`, `t3`.`SquadId`, `t3`.`Id`, `t3`.`Nickname0`, `t3`.`SquadId0`, `t3`.`Id0`, `t3`.`Nickname00`, `t3`.`HasSoulPatch`, `t3`.`SquadId00` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `s1`.`FullName`, `s1`.`Nickname`, `s1`.`SquadId`, `s1`.`Id`, `s1`.`Nickname0`, `s1`.`SquadId0`, `s1`.`Id0`, `s1`.`Nickname00`, `s1`.`HasSoulPatch`, `s1`.`SquadId00` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `t0`.`FullName`, `t0`.`Nickname`, `t0`.`SquadId`, `t1`.`Id`, `t1`.`Nickname` AS `Nickname0`, `t1`.`SquadId` AS `SquadId0`, `t1`.`Id0`, `t1`.`Nickname0` AS `Nickname00`, `t1`.`HasSoulPatch`, `t1`.`SquadId0` AS `SquadId00`, `t0`.`HasSoulPatch` AS `HasSoulPatch0`, `t1`.`IsAutomatic`, `t1`.`Name`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId` + SELECT `u0`.`FullName`, `u0`.`Nickname`, `u0`.`SquadId`, `s0`.`Id`, `s0`.`Nickname` AS `Nickname0`, `s0`.`SquadId` AS `SquadId0`, `s0`.`Id0`, `s0`.`Nickname0` AS `Nickname00`, `s0`.`HasSoulPatch`, `s0`.`SquadId0` AS `SquadId00`, `u0`.`HasSoulPatch` AS `HasSoulPatch0`, `s0`.`IsAutomatic`, `s0`.`Name`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` FROM `Officers` AS `o0` - ) AS `t0` + ) AS `u0` LEFT JOIN ( - SELECT `w`.`Id`, `t2`.`Nickname`, `t2`.`SquadId`, `s`.`Id` AS `Id0`, `t4`.`Nickname` AS `Nickname0`, `t4`.`HasSoulPatch`, `t4`.`SquadId` AS `SquadId0`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName` + SELECT `w`.`Id`, `u1`.`Nickname`, `u1`.`SquadId`, `s`.`Id` AS `Id0`, `u2`.`Nickname` AS `Nickname0`, `u2`.`HasSoulPatch`, `u2`.`SquadId` AS `SquadId0`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName` FROM `Weapons` AS `w` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName` @@ -6632,18 +6835,18 @@ LEFT JOIN ( UNION ALL SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`FullName` FROM `Officers` AS `o1` - ) AS `t2` ON `w`.`OwnerFullName` = `t2`.`FullName` - LEFT JOIN `Squads` AS `s` ON `t2`.`SquadId` = `s`.`Id` + ) AS `u1` ON `w`.`OwnerFullName` = `u1`.`FullName` + LEFT JOIN `Squads` AS `s` ON `u1`.`SquadId` = `s`.`Id` LEFT JOIN ( SELECT `g1`.`Nickname`, `g1`.`SquadId`, `g1`.`HasSoulPatch` FROM `Gears` AS `g1` UNION ALL SELECT `o2`.`Nickname`, `o2`.`SquadId`, `o2`.`HasSoulPatch` FROM `Officers` AS `o2` - ) AS `t4` ON `s`.`Id` = `t4`.`SquadId` - ) AS `t1` ON `t0`.`FullName` = `t1`.`OwnerFullName` -) AS `t3` ON (`t`.`Nickname` = `t3`.`LeaderNickname`) AND (`t`.`SquadId` = `t3`.`LeaderSquadId`) -ORDER BY `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t3`.`FullName`, `t3`.`HasSoulPatch0` DESC, `t3`.`Nickname`, `t3`.`SquadId`, `t3`.`IsAutomatic`, `t3`.`Name` DESC, `t3`.`Id`, `t3`.`Nickname0`, `t3`.`SquadId0`, `t3`.`Id0`, `t3`.`Nickname00` + ) AS `u2` ON `s`.`Id` = `u2`.`SquadId` + ) AS `s0` ON `u0`.`FullName` = `s0`.`OwnerFullName` +) AS `s1` ON (`u`.`Nickname` = `s1`.`LeaderNickname`) AND (`u`.`SquadId` = `s1`.`LeaderSquadId`) +ORDER BY `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `s1`.`FullName`, `s1`.`HasSoulPatch0` DESC, `s1`.`Nickname`, `s1`.`SquadId`, `s1`.`IsAutomatic`, `s1`.`Name` DESC, `s1`.`Id`, `s1`.`Nickname0`, `s1`.`SquadId0`, `s1`.`Id0`, `s1`.`Nickname00` """); } @@ -6653,21 +6856,21 @@ public override async Task Correlated_collection_with_top_level_FirstOrDefault(b AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u0`.`Nickname`, `u0`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( - SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`FullName` + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`FullName` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` - ) AS `t` - ORDER BY `t`.`Nickname` + ) AS `u` + ORDER BY `u`.`Nickname` LIMIT 1 -) AS `t0` -LEFT JOIN `Weapons` AS `w` ON `t0`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t0`.`Nickname`, `t0`.`SquadId` +) AS `u0` +LEFT JOIN `Weapons` AS `w` ON `u0`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u0`.`Nickname`, `u0`.`SquadId` """); } @@ -6679,12 +6882,12 @@ public override async Task Correlated_collection_with_top_level_Count(bool async """ SELECT COUNT(*) FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT 1 FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT 1 FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -6694,21 +6897,21 @@ public override async Task Correlated_collection_with_top_level_Last_with_orderb AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u0`.`Nickname`, `u0`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( - SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`FullName` + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`FullName` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` - ) AS `t` - ORDER BY `t`.`FullName` + ) AS `u` + ORDER BY `u`.`FullName` LIMIT 1 -) AS `t0` -LEFT JOIN `Weapons` AS `w` ON `t0`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t0`.`FullName`, `t0`.`Nickname`, `t0`.`SquadId` +) AS `u0` +LEFT JOIN `Weapons` AS `w` ON `u0`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u0`.`FullName`, `u0`.`Nickname`, `u0`.`SquadId` """); } @@ -6718,21 +6921,21 @@ public override async Task Correlated_collection_with_top_level_Last_with_order_ AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u0`.`Nickname`, `u0`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( - SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`FullName` + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`FullName` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` - ) AS `t` - ORDER BY `t`.`FullName` DESC + ) AS `u` + ORDER BY `u`.`FullName` DESC LIMIT 1 -) AS `t0` -LEFT JOIN `Weapons` AS `w` ON `t0`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t0`.`FullName` DESC, `t0`.`Nickname`, `t0`.`SquadId`, `w`.`Name` +) AS `u0` +LEFT JOIN `Weapons` AS `w` ON `u0`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u0`.`FullName` DESC, `u0`.`Nickname`, `u0`.`SquadId`, `w`.`Name` """); } @@ -6742,20 +6945,20 @@ public override async Task Null_semantics_on_nullable_bool_from_inner_join_subqu AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CapitalName`, `t0`.`Name`, `t0`.`ServerAddress`, `t0`.`CommanderName`, `t0`.`Eradicated` +SELECT `l2`.`Id`, `l2`.`CapitalName`, `l2`.`Name`, `l2`.`ServerAddress`, `l2`.`CommanderName`, `l2`.`Eradicated` FROM ( - SELECT `l0`.`Name` - FROM `LocustLeaders` AS `l0` + SELECT `l`.`Name` + FROM `LocustLeaders` AS `l` UNION ALL - SELECT `l1`.`Name` - FROM `LocustCommanders` AS `l1` -) AS `t` + SELECT `l0`.`Name` + FROM `LocustCommanders` AS `l0` +) AS `u` INNER JOIN ( - SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated` - FROM `LocustHordes` AS `l` - WHERE `l`.`Name` = 'Swarm' -) AS `t0` ON `t`.`Name` = `t0`.`CommanderName` -WHERE (`t0`.`Eradicated` <> TRUE) OR (`t0`.`Eradicated` IS NULL) + SELECT `l1`.`Id`, `l1`.`CapitalName`, `l1`.`Name`, `l1`.`ServerAddress`, `l1`.`CommanderName`, `l1`.`Eradicated` + FROM `LocustHordes` AS `l1` + WHERE `l1`.`Name` = 'Swarm' +) AS `l2` ON `u`.`Name` = `l2`.`CommanderName` +WHERE (`l2`.`Eradicated` = FALSE) OR (`l2`.`Eradicated` IS NULL) """); } @@ -6765,20 +6968,20 @@ public override async Task Null_semantics_on_nullable_bool_from_left_join_subque AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CapitalName`, `t0`.`Name`, `t0`.`ServerAddress`, `t0`.`CommanderName`, `t0`.`Eradicated` +SELECT `l2`.`Id`, `l2`.`CapitalName`, `l2`.`Name`, `l2`.`ServerAddress`, `l2`.`CommanderName`, `l2`.`Eradicated` FROM ( - SELECT `l0`.`Name` - FROM `LocustLeaders` AS `l0` + SELECT `l`.`Name` + FROM `LocustLeaders` AS `l` UNION ALL - SELECT `l1`.`Name` - FROM `LocustCommanders` AS `l1` -) AS `t` + SELECT `l0`.`Name` + FROM `LocustCommanders` AS `l0` +) AS `u` LEFT JOIN ( - SELECT `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated` - FROM `LocustHordes` AS `l` - WHERE `l`.`Name` = 'Swarm' -) AS `t0` ON `t`.`Name` = `t0`.`CommanderName` -WHERE (`t0`.`Eradicated` <> TRUE) OR (`t0`.`Eradicated` IS NULL) + SELECT `l1`.`Id`, `l1`.`CapitalName`, `l1`.`Name`, `l1`.`ServerAddress`, `l1`.`CommanderName`, `l1`.`Eradicated` + FROM `LocustHordes` AS `l1` + WHERE `l1`.`Name` = 'Swarm' +) AS `l2` ON `u`.`Name` = `l2`.`CommanderName` +WHERE (`l2`.`Eradicated` = FALSE) OR (`l2`.`Eradicated` IS NULL) """); } @@ -6790,29 +6993,29 @@ public override async Task Include_on_derived_type_with_order_by_and_paging(bool """ @__p_0='10' -SELECT `t2`.`Name`, `t2`.`LocustHordeId`, `t2`.`ThreatLevel`, `t2`.`ThreatLevelByte`, `t2`.`ThreatLevelNullableByte`, `t2`.`DefeatedByNickname`, `t2`.`DefeatedBySquadId`, `t2`.`HighCommandId`, `t2`.`Discriminator`, `t2`.`Nickname`, `t2`.`SquadId`, `t2`.`AssignedCityName`, `t2`.`CityOfBirthName`, `t2`.`FullName`, `t2`.`HasSoulPatch`, `t2`.`LeaderNickname`, `t2`.`LeaderSquadId`, `t2`.`Rank`, `t2`.`Discriminator0` AS `Discriminator`, `t2`.`Id`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `s`.`Name`, `s`.`LocustHordeId`, `s`.`ThreatLevel`, `s`.`ThreatLevelByte`, `s`.`ThreatLevelNullableByte`, `s`.`DefeatedByNickname`, `s`.`DefeatedBySquadId`, `s`.`HighCommandId`, `s`.`Discriminator`, `s`.`Nickname`, `s`.`SquadId`, `s`.`AssignedCityName`, `s`.`CityOfBirthName`, `s`.`FullName`, `s`.`HasSoulPatch`, `s`.`LeaderNickname`, `s`.`LeaderSquadId`, `s`.`Rank`, `s`.`Discriminator0` AS `Discriminator`, `s`.`Id`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( - SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` AS `Discriminator0`, `t1`.`Id`, `t1`.`Note` + SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` AS `Discriminator0`, `t`.`Id`, `t`.`Note` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` - ) AS `t` + ) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` - ) AS `t0` ON (`t`.`DefeatedByNickname` = `t0`.`Nickname`) AND (`t`.`DefeatedBySquadId` = `t0`.`SquadId`) - LEFT JOIN `Tags` AS `t1` ON ((`t0`.`Nickname` = `t1`.`GearNickName`) OR (`t0`.`Nickname` IS NULL AND (`t1`.`GearNickName` IS NULL))) AND ((`t0`.`SquadId` = `t1`.`GearSquadId`) OR (`t0`.`SquadId` IS NULL AND (`t1`.`GearSquadId` IS NULL))) - ORDER BY `t1`.`Note` + ) AS `u0` ON (`u`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`u`.`DefeatedBySquadId` = `u0`.`SquadId`) + LEFT JOIN `Tags` AS `t` ON ((`u0`.`Nickname` = `t`.`GearNickName`) OR (`u0`.`Nickname` IS NULL AND (`t`.`GearNickName` IS NULL))) AND ((`u0`.`SquadId` = `t`.`GearSquadId`) OR (`u0`.`SquadId` IS NULL AND (`t`.`GearSquadId` IS NULL))) + ORDER BY `t`.`Note` LIMIT @__p_0 -) AS `t2` -LEFT JOIN `Weapons` AS `w` ON `t2`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t2`.`Note`, `t2`.`Name`, `t2`.`Nickname`, `t2`.`SquadId`, `t2`.`Id` +) AS `s` +LEFT JOIN `Weapons` AS `w` ON `s`.`FullName` = `w`.`OwnerFullName` +ORDER BY `s`.`Note`, `s`.`Name`, `s`.`Nickname`, `s`.`SquadId`, `s`.`Id` """); } @@ -6822,15 +7025,15 @@ public override async Task Select_required_navigation_on_derived_type(bool async AssertSql( """ -SELECT `l`.`Name` +SELECT `l1`.`Name` FROM ( SELECT NULL AS `HighCommandId` - FROM `LocustLeaders` AS `l0` + FROM `LocustLeaders` AS `l` UNION ALL - SELECT `l1`.`HighCommandId` - FROM `LocustCommanders` AS `l1` -) AS `t` -LEFT JOIN `LocustHighCommands` AS `l` ON `t`.`HighCommandId` = `l`.`Id` + SELECT `l0`.`HighCommandId` + FROM `LocustCommanders` AS `l0` +) AS `u` +LEFT JOIN `LocustHighCommands` AS `l1` ON `u`.`HighCommandId` = `l1`.`Id` """); } @@ -6847,8 +7050,8 @@ public override async Task Select_required_navigation_on_the_same_type_with_cast UNION ALL SELECT `o`.`CityOfBirthName` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Cities` AS `c` ON `t`.`CityOfBirthName` = `c`.`Name` +) AS `u` +INNER JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` """); } @@ -6858,16 +7061,16 @@ public override async Task Where_required_navigation_on_derived_type(bool async) AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM ( - SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` - FROM `LocustLeaders` AS `l0` + SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` + FROM `LocustLeaders` AS `l` UNION ALL - SELECT `l1`.`Name`, `l1`.`LocustHordeId`, `l1`.`ThreatLevel`, `l1`.`ThreatLevelByte`, `l1`.`ThreatLevelNullableByte`, `l1`.`DefeatedByNickname`, `l1`.`DefeatedBySquadId`, `l1`.`HighCommandId`, 'LocustCommander' AS `Discriminator` - FROM `LocustCommanders` AS `l1` -) AS `t` -LEFT JOIN `LocustHighCommands` AS `l` ON `t`.`HighCommandId` = `l`.`Id` -WHERE `l`.`IsOperational` = TRUE + SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` + FROM `LocustCommanders` AS `l0` +) AS `u` +LEFT JOIN `LocustHighCommands` AS `l1` ON `u`.`HighCommandId` = `l1`.`Id` +WHERE `l1`.`IsOperational` = TRUE """); } @@ -6877,23 +7080,23 @@ public override async Task Outer_parameter_in_join_key(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t1`.`Note`, `t1`.`Id`, `t1`.`Nickname`, `t1`.`SquadId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `s`.`Note`, `s`.`Id`, `s`.`Nickname`, `s`.`SquadId` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN LATERAL ( - SELECT `t0`.`Note`, `t0`.`Id`, `t2`.`Nickname`, `t2`.`SquadId` - FROM `Tags` AS `t0` + SELECT `t`.`Note`, `t`.`Id`, `u0`.`Nickname`, `u0`.`SquadId` + FROM `Tags` AS `t` INNER JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName` FROM `Officers` AS `o0` - ) AS `t2` ON `t`.`FullName` = `t2`.`FullName` -) AS `t1` ON TRUE -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t1`.`Id`, `t1`.`Nickname` + ) AS `u0` ON `u`.`FullName` = `u0`.`FullName` +) AS `s` ON TRUE +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `s`.`Id`, `s`.`Nickname` """); } @@ -6903,23 +7106,23 @@ public override async Task Outer_parameter_in_join_key_inner_and_outer(bool asyn AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t1`.`Note`, `t1`.`Id`, `t1`.`Nickname`, `t1`.`SquadId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `s`.`Note`, `s`.`Id`, `s`.`Nickname`, `s`.`SquadId` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN LATERAL ( - SELECT `t0`.`Note`, `t0`.`Id`, `t2`.`Nickname`, `t2`.`SquadId` - FROM `Tags` AS `t0` + SELECT `t`.`Note`, `t`.`Id`, `u0`.`Nickname`, `u0`.`SquadId` + FROM `Tags` AS `t` INNER JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId` FROM `Officers` AS `o0` - ) AS `t2` ON `t`.`FullName` = `t`.`Nickname` -) AS `t1` ON TRUE -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t1`.`Id`, `t1`.`Nickname` + ) AS `u0` ON `u`.`FullName` = `u`.`Nickname` +) AS `s` ON TRUE +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `s`.`Id`, `s`.`Nickname` """); } @@ -6929,23 +7132,23 @@ public override async Task Outer_parameter_in_group_join_with_DefaultIfEmpty(boo AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t1`.`Note`, `t1`.`Id`, `t1`.`Nickname`, `t1`.`SquadId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `s`.`Note`, `s`.`Id`, `s`.`Nickname`, `s`.`SquadId` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN LATERAL ( - SELECT `t0`.`Note`, `t0`.`Id`, `t2`.`Nickname`, `t2`.`SquadId` - FROM `Tags` AS `t0` + SELECT `t`.`Note`, `t`.`Id`, `u0`.`Nickname`, `u0`.`SquadId` + FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName` FROM `Officers` AS `o0` - ) AS `t2` ON `t`.`FullName` = `t2`.`FullName` -) AS `t1` ON TRUE -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t1`.`Id`, `t1`.`Nickname` + ) AS `u0` ON `u`.`FullName` = `u0`.`FullName` +) AS `s` ON TRUE +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `s`.`Id`, `s`.`Nickname` """); } @@ -6956,8 +7159,8 @@ public override async Task Negated_bool_ternary_inside_anonymous_type_in_project AssertSql( """ SELECT NOT (CASE - WHEN `t0`.`HasSoulPatch` = TRUE THEN TRUE - ELSE COALESCE(`t0`.`HasSoulPatch`, TRUE) + WHEN `u`.`HasSoulPatch` = TRUE THEN TRUE + ELSE COALESCE(`u`.`HasSoulPatch`, TRUE) END) AS `c` FROM `Tags` AS `t` LEFT JOIN ( @@ -6966,7 +7169,7 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) """); } @@ -6976,16 +7179,16 @@ public override async Task Order_by_entity_qsre(bool async) AssertSql( """ -SELECT `t`.`FullName` +SELECT `u`.`FullName` FROM ( SELECT `g`.`Nickname`, `g`.`AssignedCityName`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`AssignedCityName`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Cities` AS `c` ON `t`.`AssignedCityName` = `c`.`Name` -ORDER BY `c`.`Name`, `t`.`Nickname` DESC +) AS `u` +LEFT JOIN `Cities` AS `c` ON `u`.`AssignedCityName` = `c`.`Name` +ORDER BY `c`.`Name`, `u`.`Nickname` DESC """); } @@ -6995,13 +7198,13 @@ public override async Task Order_by_entity_qsre_with_inheritance(bool async) AssertSql( """ -SELECT `t`.`Name` +SELECT `u`.`Name` FROM ( - SELECT `l0`.`Name`, `l0`.`HighCommandId` - FROM `LocustCommanders` AS `l0` -) AS `t` -INNER JOIN `LocustHighCommands` AS `l` ON `t`.`HighCommandId` = `l`.`Id` -ORDER BY `l`.`Id`, `t`.`Name` + SELECT `l`.`Name`, `l`.`HighCommandId` + FROM `LocustCommanders` AS `l` +) AS `u` +INNER JOIN `LocustHighCommands` AS `l0` ON `u`.`HighCommandId` = `l0`.`Id` +ORDER BY `l0`.`Id`, `u`.`Name` """); } @@ -7019,8 +7222,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` ON `w`.`OwnerFullName` = `t`.`FullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `w`.`Id` +) AS `u` ON `w`.`OwnerFullName` = `u`.`FullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `w`.`Id` """); } @@ -7038,9 +7241,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` ON `w`.`OwnerFullName` = `t`.`FullName` +) AS `u` ON `w`.`OwnerFullName` = `u`.`FullName` LEFT JOIN `Weapons` AS `w0` ON `w`.`SynergyWithId` = `w0`.`Id` -ORDER BY `w`.`IsAutomatic`, `t`.`Nickname` DESC, `t`.`SquadId` DESC, `w0`.`Id`, `w`.`Name` +ORDER BY `w`.`IsAutomatic`, `u`.`Nickname` DESC, `u`.`SquadId` DESC, `w0`.`Id`, `w`.`Name` """); } @@ -7062,21 +7265,21 @@ public override async Task Join_on_entity_qsre_keys_composite_key(bool async) AssertSql( """ -SELECT `t`.`FullName` AS `GearName1`, `t0`.`FullName` AS `GearName2` +SELECT `u`.`FullName` AS `GearName1`, `u0`.`FullName` AS `GearName2` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` INNER JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName` FROM `Officers` AS `o0` -) AS `t0` ON (`t`.`Nickname` = `t0`.`Nickname`) AND (`t`.`SquadId` = `t0`.`SquadId`) +) AS `u0` ON (`u`.`Nickname` = `u0`.`Nickname`) AND (`u`.`SquadId` = `u0`.`SquadId`) """); } @@ -7086,18 +7289,18 @@ public override async Task Join_on_entity_qsre_keys_inheritance(bool async) AssertSql( """ -SELECT `t`.`FullName` AS `GearName`, `t0`.`FullName` AS `OfficerName` +SELECT `u`.`FullName` AS `GearName`, `u0`.`FullName` AS `OfficerName` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` INNER JOIN ( SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName` FROM `Officers` AS `o0` -) AS `t0` ON (`t`.`Nickname` = `t0`.`Nickname`) AND (`t`.`SquadId` = `t0`.`SquadId`) +) AS `u0` ON (`u`.`Nickname` = `u0`.`Nickname`) AND (`u`.`SquadId` = `u0`.`SquadId`) """); } @@ -7120,19 +7323,19 @@ public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation(bool AssertSql( """ -SELECT `c`.`Name` AS `CityName`, `t0`.`Nickname` AS `GearNickname` +SELECT `c`.`Name` AS `CityName`, `s`.`Nickname` AS `GearNickname` FROM `Cities` AS `c` INNER JOIN ( - SELECT `t`.`Nickname`, `c0`.`Name` + SELECT `u`.`Nickname`, `c0`.`Name` FROM ( SELECT `g`.`Nickname`, `g`.`AssignedCityName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`AssignedCityName` FROM `Officers` AS `o` - ) AS `t` - LEFT JOIN `Cities` AS `c0` ON `t`.`AssignedCityName` = `c0`.`Name` -) AS `t0` ON `c`.`Name` = `t0`.`Name` + ) AS `u` + LEFT JOIN `Cities` AS `c0` ON `u`.`AssignedCityName` = `c0`.`Name` +) AS `s` ON `c`.`Name` = `s`.`Name` """); } @@ -7142,26 +7345,26 @@ public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation_comp AssertSql( """ -SELECT `t`.`Nickname`, `t1`.`Note` +SELECT `u`.`Nickname`, `s`.`Note` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t` +) AS `u` INNER JOIN ( - SELECT `t0`.`Note`, `t2`.`Nickname`, `t2`.`SquadId` - FROM `Tags` AS `t0` + SELECT `t`.`Note`, `u0`.`Nickname`, `u0`.`SquadId` + FROM `Tags` AS `t` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId` FROM `Officers` AS `o0` - ) AS `t2` ON (`t0`.`GearNickName` = `t2`.`Nickname`) AND (`t0`.`GearSquadId` = `t2`.`SquadId`) - WHERE `t0`.`Note` IN ('Cole''s Tag', 'Dom''s Tag') -) AS `t1` ON (`t`.`Nickname` = `t1`.`Nickname`) AND (`t`.`SquadId` = `t1`.`SquadId`) + ) AS `u0` ON (`t`.`GearNickName` = `u0`.`Nickname`) AND (`t`.`GearSquadId` = `u0`.`SquadId`) + WHERE `t`.`Note` IN ('Cole''s Tag', 'Dom''s Tag') +) AS `s` ON (`u`.`Nickname` = `s`.`Nickname`) AND (`u`.`SquadId` = `s`.`SquadId`) """); } @@ -7171,7 +7374,7 @@ public override async Task Join_on_entity_qsre_keys_inner_key_is_nested_navigati AssertSql( """ -SELECT `s`.`Name` AS `SquadName`, `t0`.`Name` AS `WeaponName` +SELECT `s`.`Name` AS `SquadName`, `s1`.`Name` AS `WeaponName` FROM `Squads` AS `s` INNER JOIN ( SELECT `w`.`Name`, `s0`.`Id` AS `Id0` @@ -7182,10 +7385,10 @@ LEFT JOIN ( UNION ALL SELECT `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` - ) AS `t` ON `w`.`OwnerFullName` = `t`.`FullName` - LEFT JOIN `Squads` AS `s0` ON `t`.`SquadId` = `s0`.`Id` + ) AS `u` ON `w`.`OwnerFullName` = `u`.`FullName` + LEFT JOIN `Squads` AS `s0` ON `u`.`SquadId` = `s0`.`Id` WHERE `w`.`IsAutomatic` = TRUE -) AS `t0` ON `s`.`Id` = `t0`.`Id0` +) AS `s1` ON `s`.`Id` = `s1`.`Id0` """); } @@ -7195,7 +7398,7 @@ public override async Task GroupJoin_on_entity_qsre_keys_inner_key_is_nested_nav AssertSql( """ -SELECT `s`.`Name` AS `SquadName`, `t0`.`Name` AS `WeaponName` +SELECT `s`.`Name` AS `SquadName`, `s1`.`Name` AS `WeaponName` FROM `Squads` AS `s` LEFT JOIN ( SELECT `w`.`Name`, `s0`.`Id` AS `Id0` @@ -7206,9 +7409,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` - ) AS `t` ON `w`.`OwnerFullName` = `t`.`FullName` - LEFT JOIN `Squads` AS `s0` ON `t`.`SquadId` = `s0`.`Id` -) AS `t0` ON `s`.`Id` = `t0`.`Id0` + ) AS `u` ON `w`.`OwnerFullName` = `u`.`FullName` + LEFT JOIN `Squads` AS `s0` ON `u`.`SquadId` = `s0`.`Id` +) AS `s1` ON `s`.`Id` = `s1`.`Id0` """); } @@ -7218,25 +7421,25 @@ public override async Task Streaming_correlated_collection_issue_11403(bool asyn AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t1`.`Id`, `t1`.`AmmunitionType`, `t1`.`IsAutomatic`, `t1`.`Name`, `t1`.`OwnerFullName`, `t1`.`SynergyWithId` +SELECT `u0`.`Nickname`, `u0`.`SquadId`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM ( - SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`FullName` + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`FullName` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` - ) AS `t` - ORDER BY `t`.`Nickname` + ) AS `u` + ORDER BY `u`.`Nickname` LIMIT 1 -) AS `t0` +) AS `u0` LEFT JOIN ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` WHERE `w`.`IsAutomatic` = FALSE -) AS `t1` ON `t0`.`FullName` = `t1`.`OwnerFullName` -ORDER BY `t0`.`Nickname`, `t0`.`SquadId`, `t1`.`Id` +) AS `w0` ON `u0`.`FullName` = `w0`.`OwnerFullName` +ORDER BY `u0`.`Nickname`, `u0`.`SquadId`, `w0`.`Id` """); } @@ -7248,15 +7451,15 @@ public override async Task Project_one_value_type_from_empty_collection(bool asy AssertSql( """ SELECT `s`.`Name`, COALESCE(( - SELECT `t`.`SquadId` + SELECT `u`.`SquadId` FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`SquadId`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t` - WHERE (`s`.`Id` = `t`.`SquadId`) AND (`t`.`HasSoulPatch` = TRUE) + ) AS `u` + WHERE (`s`.`Id` = `u`.`SquadId`) AND (`u`.`HasSoulPatch` = TRUE) LIMIT 1), 0) AS `SquadId` FROM `Squads` AS `s` WHERE `s`.`Name` = 'Kilo' @@ -7271,15 +7474,15 @@ public override async Task Project_one_value_type_converted_to_nullable_from_emp AssertSql( """ SELECT `s`.`Name`, ( - SELECT `t`.`SquadId` + SELECT `u`.`SquadId` FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`SquadId`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t` - WHERE (`s`.`Id` = `t`.`SquadId`) AND (`t`.`HasSoulPatch` = TRUE) + ) AS `u` + WHERE (`s`.`Id` = `u`.`SquadId`) AND (`u`.`HasSoulPatch` = TRUE) LIMIT 1) AS `SquadId` FROM `Squads` AS `s` WHERE `s`.`Name` = 'Kilo' @@ -7292,23 +7495,23 @@ public override async Task Project_one_value_type_with_client_projection_from_em AssertSql( """ -SELECT `s`.`Name`, `t1`.`SquadId`, `t1`.`LeaderSquadId`, `t1`.`c` +SELECT `s`.`Name`, `u1`.`SquadId`, `u1`.`LeaderSquadId`, `u1`.`c` FROM `Squads` AS `s` LEFT JOIN ( - SELECT `t0`.`SquadId`, `t0`.`LeaderSquadId`, `t0`.`c` + SELECT `u0`.`SquadId`, `u0`.`LeaderSquadId`, `u0`.`c` FROM ( - SELECT `t`.`SquadId`, `t`.`LeaderSquadId`, 1 AS `c`, ROW_NUMBER() OVER(PARTITION BY `t`.`SquadId` ORDER BY `t`.`Nickname`, `t`.`SquadId`) AS `row` + SELECT `u`.`SquadId`, `u`.`LeaderSquadId`, 1 AS `c`, ROW_NUMBER() OVER(PARTITION BY `u`.`SquadId` ORDER BY `u`.`Nickname`, `u`.`SquadId`) AS `row` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch`, `g`.`LeaderSquadId` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch`, `o`.`LeaderSquadId` FROM `Officers` AS `o` - ) AS `t` - WHERE `t`.`HasSoulPatch` = TRUE - ) AS `t0` - WHERE `t0`.`row` <= 1 -) AS `t1` ON `s`.`Id` = `t1`.`SquadId` + ) AS `u` + WHERE `u`.`HasSoulPatch` = TRUE + ) AS `u0` + WHERE `u0`.`row` <= 1 +) AS `u1` ON `s`.`Id` = `u1`.`SquadId` WHERE `s`.`Name` = 'Kilo' """); } @@ -7323,15 +7526,15 @@ public override async Task Filter_on_subquery_projecting_one_value_type_from_emp SELECT `s`.`Name` FROM `Squads` AS `s` WHERE (`s`.`Name` = 'Kilo') AND (COALESCE(( - SELECT `t`.`SquadId` + SELECT `u`.`SquadId` FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`SquadId`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t` - WHERE (`s`.`Id` = `t`.`SquadId`) AND (`t`.`HasSoulPatch` = TRUE) + ) AS `u` + WHERE (`s`.`Id` = `u`.`SquadId`) AND (`u`.`HasSoulPatch` = TRUE) LIMIT 1), 0) <> 0) """); } @@ -7346,13 +7549,13 @@ public override async Task Select_subquery_projecting_single_constant_int(bool a SELECT `s`.`Name`, COALESCE(( SELECT 42 FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`SquadId`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t` - WHERE (`s`.`Id` = `t`.`SquadId`) AND (`t`.`HasSoulPatch` = TRUE) + ) AS `u` + WHERE (`s`.`Id` = `u`.`SquadId`) AND (`u`.`HasSoulPatch` = TRUE) LIMIT 1), 0) AS `Gear` FROM `Squads` AS `s` """); @@ -7368,13 +7571,13 @@ public override async Task Select_subquery_projecting_single_constant_string(boo SELECT `s`.`Name`, ( SELECT 'Foo' FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`SquadId`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t` - WHERE (`s`.`Id` = `t`.`SquadId`) AND (`t`.`HasSoulPatch` = TRUE) + ) AS `u` + WHERE (`s`.`Id` = `u`.`SquadId`) AND (`u`.`HasSoulPatch` = TRUE) LIMIT 1) AS `Gear` FROM `Squads` AS `s` """); @@ -7390,13 +7593,13 @@ public override async Task Select_subquery_projecting_single_constant_bool(bool SELECT `s`.`Name`, COALESCE(( SELECT TRUE FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`SquadId`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t` - WHERE (`s`.`Id` = `t`.`SquadId`) AND (`t`.`HasSoulPatch` = TRUE) + ) AS `u` + WHERE (`s`.`Id` = `u`.`SquadId`) AND (`u`.`HasSoulPatch` = TRUE) LIMIT 1), FALSE) AS `Gear` FROM `Squads` AS `s` """); @@ -7408,23 +7611,23 @@ public override async Task Select_subquery_projecting_single_constant_inside_ano AssertSql( """ -SELECT `s`.`Name`, `t1`.`One` +SELECT `s`.`Name`, `u1`.`One` FROM `Squads` AS `s` LEFT JOIN ( - SELECT `t0`.`One`, `t0`.`SquadId` + SELECT `u0`.`One`, `u0`.`SquadId` FROM ( - SELECT 1 AS `One`, `t`.`SquadId`, ROW_NUMBER() OVER(PARTITION BY `t`.`SquadId` ORDER BY `t`.`Nickname`, `t`.`SquadId`) AS `row` + SELECT 1 AS `One`, `u`.`SquadId`, ROW_NUMBER() OVER(PARTITION BY `u`.`SquadId` ORDER BY `u`.`Nickname`, `u`.`SquadId`) AS `row` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t` - WHERE `t`.`HasSoulPatch` = TRUE - ) AS `t0` - WHERE `t0`.`row` <= 1 -) AS `t1` ON `s`.`Id` = `t1`.`SquadId` + ) AS `u` + WHERE `u`.`HasSoulPatch` = TRUE + ) AS `u0` + WHERE `u0`.`row` <= 1 +) AS `u1` ON `s`.`Id` = `u1`.`SquadId` """); } @@ -7434,23 +7637,23 @@ public override async Task Select_subquery_projecting_multiple_constants_inside_ AssertSql( """ -SELECT `s`.`Name`, `t1`.`True1`, `t1`.`False1`, `t1`.`c` +SELECT `s`.`Name`, `u1`.`True1`, `u1`.`False1`, `u1`.`c` FROM `Squads` AS `s` LEFT JOIN ( - SELECT `t0`.`True1`, `t0`.`False1`, `t0`.`c`, `t0`.`SquadId` + SELECT `u0`.`True1`, `u0`.`False1`, `u0`.`c`, `u0`.`SquadId` FROM ( - SELECT TRUE AS `True1`, FALSE AS `False1`, 1 AS `c`, `t`.`SquadId`, ROW_NUMBER() OVER(PARTITION BY `t`.`SquadId` ORDER BY `t`.`Nickname`, `t`.`SquadId`) AS `row` + SELECT TRUE AS `True1`, FALSE AS `False1`, 1 AS `c`, `u`.`SquadId`, ROW_NUMBER() OVER(PARTITION BY `u`.`SquadId` ORDER BY `u`.`Nickname`, `u`.`SquadId`) AS `row` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t` - WHERE `t`.`HasSoulPatch` = TRUE - ) AS `t0` - WHERE `t0`.`row` <= 1 -) AS `t1` ON `s`.`Id` = `t1`.`SquadId` + ) AS `u` + WHERE `u`.`HasSoulPatch` = TRUE + ) AS `u0` + WHERE `u0`.`row` <= 1 +) AS `u1` ON `s`.`Id` = `u1`.`SquadId` """); } @@ -7460,7 +7663,7 @@ public override async Task Include_with_order_by_constant(bool async) AssertSql( """ -SELECT `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM `Squads` AS `s` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -7468,8 +7671,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` ON `s`.`Id` = `t`.`SquadId` -ORDER BY `s`.`Id`, `t`.`Nickname` +) AS `u` ON `s`.`Id` = `u`.`SquadId` +ORDER BY `s`.`Id`, `u`.`Nickname` """); } @@ -7479,16 +7682,16 @@ public override async Task Correlated_collection_order_by_constant(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `w`.`Name`, `w`.`Id` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w`.`Name`, `w`.`Id` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `u` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -7498,23 +7701,23 @@ public override async Task Select_subquery_projecting_single_constant_null_of_no AssertSql( """ -SELECT `s`.`Name`, `t1`.`c` +SELECT `s`.`Name`, `u1`.`c` FROM `Squads` AS `s` LEFT JOIN ( - SELECT `t0`.`c`, `t0`.`SquadId` + SELECT `u0`.`c`, `u0`.`SquadId` FROM ( - SELECT 1 AS `c`, `t`.`SquadId`, ROW_NUMBER() OVER(PARTITION BY `t`.`SquadId` ORDER BY `t`.`Nickname`, `t`.`SquadId`) AS `row` + SELECT 1 AS `c`, `u`.`SquadId`, ROW_NUMBER() OVER(PARTITION BY `u`.`SquadId` ORDER BY `u`.`Nickname`, `u`.`SquadId`) AS `row` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t` - WHERE `t`.`HasSoulPatch` = TRUE - ) AS `t0` - WHERE `t0`.`row` <= 1 -) AS `t1` ON `s`.`Id` = `t1`.`SquadId` + ) AS `u` + WHERE `u`.`HasSoulPatch` = TRUE + ) AS `u0` + WHERE `u0`.`row` <= 1 +) AS `u1` ON `s`.`Id` = `u1`.`SquadId` """); } @@ -7524,23 +7727,23 @@ public override async Task Select_subquery_projecting_single_constant_of_non_map AssertSql( """ -SELECT `s`.`Name`, `t1`.`c` +SELECT `s`.`Name`, `u1`.`c` FROM `Squads` AS `s` LEFT JOIN ( - SELECT `t0`.`c`, `t0`.`SquadId` + SELECT `u0`.`c`, `u0`.`SquadId` FROM ( - SELECT 1 AS `c`, `t`.`SquadId`, ROW_NUMBER() OVER(PARTITION BY `t`.`SquadId` ORDER BY `t`.`Nickname`, `t`.`SquadId`) AS `row` + SELECT 1 AS `c`, `u`.`SquadId`, ROW_NUMBER() OVER(PARTITION BY `u`.`SquadId` ORDER BY `u`.`Nickname`, `u`.`SquadId`) AS `row` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t` - WHERE `t`.`HasSoulPatch` = TRUE - ) AS `t0` - WHERE `t0`.`row` <= 1 -) AS `t1` ON `s`.`Id` = `t1`.`SquadId` + ) AS `u` + WHERE `u`.`HasSoulPatch` = TRUE + ) AS `u0` + WHERE `u0`.`row` <= 1 +) AS `u1` ON `s`.`Id` = `u1`.`SquadId` """); } @@ -7551,22 +7754,22 @@ public override async Task Include_collection_OrderBy_aggregate(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON (`t`.`Nickname` = `t0`.`LeaderNickname`) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) +) AS `u0` ON (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) ORDER BY ( SELECT COUNT(*) FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName`), `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` + WHERE `u`.`FullName` = `w`.`OwnerFullName`), `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -7577,24 +7780,24 @@ public override async Task Include_collection_with_complex_OrderBy2(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON (`t`.`Nickname` = `t0`.`LeaderNickname`) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) +) AS `u0` ON (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) ORDER BY ( SELECT `w`.`IsAutomatic` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` ORDER BY `w`.`Id` - LIMIT 1), `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` + LIMIT 1), `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -7605,24 +7808,24 @@ public override async Task Include_collection_with_complex_OrderBy3(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON (`t`.`Nickname` = `t0`.`LeaderNickname`) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) +) AS `u0` ON (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) ORDER BY COALESCE(( SELECT `w`.`IsAutomatic` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` ORDER BY `w`.`Id` - LIMIT 1), FALSE), `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` + LIMIT 1), FALSE), `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -7632,27 +7835,27 @@ public override async Task Correlated_collection_with_complex_OrderBy(bool async await base.Correlated_collection_with_complex_OrderBy(async); AssertSql( -$""" -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +""" +SELECT `u`.`Nickname`, `u`.`SquadId`, `u1`.`Nickname`, `u1`.`SquadId`, `u1`.`AssignedCityName`, `u1`.`CityOfBirthName`, `u1`.`FullName`, `u1`.`HasSoulPatch`, `u1`.`LeaderNickname`, `u1`.`LeaderSquadId`, `u1`.`Rank`, `u1`.`Discriminator` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Gear'")} AS `Discriminator` + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Officer'")} AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` - ) AS `t1` - WHERE `t1`.`HasSoulPatch` = FALSE -) AS `t0` ON (`t`.`Nickname` = `t0`.`LeaderNickname`) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) + ) AS `u0` + WHERE `u0`.`HasSoulPatch` = FALSE +) AS `u1` ON (`u`.`Nickname` = `u1`.`LeaderNickname`) AND (`u`.`SquadId` = `u1`.`LeaderSquadId`) ORDER BY ( SELECT COUNT(*) FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName`), `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` + WHERE `u`.`FullName` = `w`.`OwnerFullName`), `u`.`Nickname`, `u`.`SquadId`, `u1`.`Nickname` """); } @@ -7662,37 +7865,37 @@ public override async Task Correlated_collection_with_very_complex_order_by(bool await base.Correlated_collection_with_very_complex_order_by(async); AssertSql( -$""" -SELECT `t`.`Nickname`, `t`.`SquadId`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` +""" +SELECT `u`.`Nickname`, `u`.`SquadId`, `u2`.`Nickname`, `u2`.`SquadId`, `u2`.`AssignedCityName`, `u2`.`CityOfBirthName`, `u2`.`FullName`, `u2`.`HasSoulPatch`, `u2`.`LeaderNickname`, `u2`.`LeaderSquadId`, `u2`.`Rank`, `u2`.`Discriminator` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `t2`.`Nickname`, `t2`.`SquadId`, `t2`.`AssignedCityName`, `t2`.`CityOfBirthName`, `t2`.`FullName`, `t2`.`HasSoulPatch`, `t2`.`LeaderNickname`, `t2`.`LeaderSquadId`, `t2`.`Rank`, `t2`.`Discriminator` + SELECT `u1`.`Nickname`, `u1`.`SquadId`, `u1`.`AssignedCityName`, `u1`.`CityOfBirthName`, `u1`.`FullName`, `u1`.`HasSoulPatch`, `u1`.`LeaderNickname`, `u1`.`LeaderSquadId`, `u1`.`Rank`, `u1`.`Discriminator` FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Gear'")} AS `Discriminator` - FROM `Gears` AS `g` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Officer'")} AS `Discriminator` - FROM `Officers` AS `o0` - ) AS `t2` - WHERE `t2`.`HasSoulPatch` = FALSE -) AS `t1` ON (`t`.`Nickname` = `t1`.`LeaderNickname`) AND (`t`.`SquadId` = `t1`.`LeaderSquadId`) + SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`AssignedCityName`, `o1`.`CityOfBirthName`, `o1`.`FullName`, `o1`.`HasSoulPatch`, `o1`.`LeaderNickname`, `o1`.`LeaderSquadId`, `o1`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o1` + ) AS `u1` + WHERE `u1`.`HasSoulPatch` = FALSE +) AS `u2` ON (`u`.`Nickname` = `u2`.`LeaderNickname`) AND (`u`.`SquadId` = `u2`.`LeaderSquadId`) ORDER BY ( SELECT COUNT(*) FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`IsAutomatic` = COALESCE(( - SELECT `t0`.`HasSoulPatch` + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`IsAutomatic` = COALESCE(( + SELECT `u0`.`HasSoulPatch` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g0` + SELECT `g`.`Nickname`, `g`.`HasSoulPatch` + FROM `Gears` AS `g` UNION ALL - SELECT `o1`.`Nickname`, `o1`.`SquadId`, `o1`.`AssignedCityName`, `o1`.`CityOfBirthName`, `o1`.`FullName`, `o1`.`HasSoulPatch`, `o1`.`LeaderNickname`, `o1`.`LeaderSquadId`, `o1`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o1` - ) AS `t0` - WHERE `t0`.`Nickname` = 'Marcus' - LIMIT 1), FALSE))), `t`.`Nickname`, `t`.`SquadId`, `t1`.`Nickname` + SELECT `o0`.`Nickname`, `o0`.`HasSoulPatch` + FROM `Officers` AS `o0` + ) AS `u0` + WHERE `u0`.`Nickname` = 'Marcus' + LIMIT 1), FALSE))), `u`.`Nickname`, `u`.`SquadId`, `u2`.`Nickname` """); } @@ -7717,7 +7920,7 @@ public override async Task Select_subquery_boolean(bool async) SELECT COALESCE(( SELECT `w`.`IsAutomatic` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` ORDER BY `w`.`Id` LIMIT 1), FALSE) FROM ( @@ -7726,7 +7929,7 @@ ORDER BY `w`.`Id` UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -7740,7 +7943,7 @@ public override async Task Select_subquery_boolean_with_pushdown(bool async) SELECT ( SELECT `w`.`IsAutomatic` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` ORDER BY `w`.`Id` LIMIT 1) FROM ( @@ -7749,7 +7952,7 @@ ORDER BY `w`.`Id` UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -7763,7 +7966,7 @@ public override async Task Select_subquery_int_with_inside_cast_and_coalesce(boo SELECT COALESCE(( SELECT `w`.`Id` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` ORDER BY `w`.`Id` LIMIT 1), 42) FROM ( @@ -7772,7 +7975,7 @@ ORDER BY `w`.`Id` UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -7786,16 +7989,16 @@ public override async Task Select_subquery_int_with_outside_cast_and_coalesce(bo SELECT COALESCE(( SELECT `w`.`Id` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` ORDER BY `w`.`Id` - LIMIT 1), 0, 42) + LIMIT 1), 0) FROM ( SELECT `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -7809,7 +8012,7 @@ public override async Task Select_subquery_int_with_pushdown_and_coalesce(bool a SELECT COALESCE(( SELECT `w`.`Id` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` ORDER BY `w`.`Id` LIMIT 1), 42) FROM ( @@ -7818,7 +8021,7 @@ ORDER BY `w`.`Id` UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -7832,12 +8035,12 @@ public override async Task Select_subquery_int_with_pushdown_and_coalesce2(bool SELECT COALESCE(( SELECT `w`.`Id` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` ORDER BY `w`.`Id` LIMIT 1), ( SELECT `w0`.`Id` FROM `Weapons` AS `w0` - WHERE `t`.`FullName` = `w0`.`OwnerFullName` + WHERE `u`.`FullName` = `w0`.`OwnerFullName` ORDER BY `w0`.`Id` LIMIT 1)) FROM ( @@ -7846,7 +8049,7 @@ ORDER BY `w0`.`Id` UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -7860,7 +8063,7 @@ public override async Task Select_subquery_boolean_empty(bool async) SELECT COALESCE(( SELECT `w`.`IsAutomatic` FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` = 'BFG') + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` = 'BFG') ORDER BY `w`.`Id` LIMIT 1), FALSE) FROM ( @@ -7869,7 +8072,7 @@ ORDER BY `w`.`Id` UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -7883,7 +8086,7 @@ public override async Task Select_subquery_boolean_empty_with_pushdown(bool asyn SELECT ( SELECT `w`.`IsAutomatic` FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` = 'BFG') + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` = 'BFG') ORDER BY `w`.`Id` LIMIT 1) FROM ( @@ -7892,7 +8095,7 @@ ORDER BY `w`.`Id` UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -7904,12 +8107,12 @@ public override async Task Select_subquery_distinct_singleordefault_boolean1(boo AssertSql( """ SELECT COALESCE(( - SELECT `t0`.`IsAutomatic` + SELECT `w0`.`IsAutomatic` FROM ( SELECT DISTINCT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Lancer%') - ) AS `t0` + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Lancer%') + ) AS `w0` LIMIT 1), FALSE) FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch` @@ -7917,8 +8120,8 @@ SELECT COALESCE(( UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`HasSoulPatch` = TRUE +) AS `u` +WHERE `u`.`HasSoulPatch` = TRUE """); } @@ -7932,7 +8135,7 @@ public override async Task Select_subquery_distinct_singleordefault_boolean2(boo SELECT COALESCE(( SELECT DISTINCT `w`.`IsAutomatic` FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Lancer%') + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Lancer%') LIMIT 1), FALSE) FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch` @@ -7940,8 +8143,8 @@ SELECT DISTINCT `w`.`IsAutomatic` UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`HasSoulPatch` = TRUE +) AS `u` +WHERE `u`.`HasSoulPatch` = TRUE """); } @@ -7953,12 +8156,12 @@ public override async Task Select_subquery_distinct_singleordefault_boolean_with AssertSql( """ SELECT ( - SELECT `t0`.`IsAutomatic` + SELECT `w0`.`IsAutomatic` FROM ( SELECT DISTINCT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Lancer%') - ) AS `t0` + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Lancer%') + ) AS `w0` LIMIT 1) FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch` @@ -7966,8 +8169,8 @@ public override async Task Select_subquery_distinct_singleordefault_boolean_with UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`HasSoulPatch` = TRUE +) AS `u` +WHERE `u`.`HasSoulPatch` = TRUE """); } @@ -7979,12 +8182,12 @@ public override async Task Select_subquery_distinct_singleordefault_boolean_empt AssertSql( """ SELECT COALESCE(( - SELECT `t0`.`IsAutomatic` + SELECT `w0`.`IsAutomatic` FROM ( SELECT DISTINCT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` = 'BFG') - ) AS `t0` + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` = 'BFG') + ) AS `w0` LIMIT 1), FALSE) FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch` @@ -7992,8 +8195,8 @@ SELECT COALESCE(( UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`HasSoulPatch` = TRUE +) AS `u` +WHERE `u`.`HasSoulPatch` = TRUE """); } @@ -8007,7 +8210,7 @@ public override async Task Select_subquery_distinct_singleordefault_boolean_empt SELECT COALESCE(( SELECT DISTINCT `w`.`IsAutomatic` FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` = 'BFG') + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` = 'BFG') LIMIT 1), FALSE) FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch` @@ -8015,8 +8218,8 @@ SELECT DISTINCT `w`.`IsAutomatic` UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`HasSoulPatch` = TRUE +) AS `u` +WHERE `u`.`HasSoulPatch` = TRUE """); } @@ -8028,12 +8231,12 @@ public override async Task Select_subquery_distinct_singleordefault_boolean_empt AssertSql( """ SELECT ( - SELECT `t0`.`IsAutomatic` + SELECT `w0`.`IsAutomatic` FROM ( SELECT DISTINCT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` = 'BFG') - ) AS `t0` + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` = 'BFG') + ) AS `w0` LIMIT 1) FROM ( SELECT `g`.`FullName`, `g`.`HasSoulPatch` @@ -8041,8 +8244,8 @@ public override async Task Select_subquery_distinct_singleordefault_boolean_empt UNION ALL SELECT `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`HasSoulPatch` = TRUE +) AS `u` +WHERE `u`.`HasSoulPatch` = TRUE """); } @@ -8052,7 +8255,7 @@ public override async Task Cast_subquery_to_base_type_using_typed_ToList(bool as AssertSql( """ -SELECT `c`.`Name`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Nickname`, `t`.`Rank`, `t`.`SquadId` +SELECT `c`.`Name`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Nickname`, `u`.`Rank`, `u`.`SquadId` FROM `Cities` AS `c` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank` @@ -8060,9 +8263,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank` FROM `Officers` AS `o` -) AS `t` ON `c`.`Name` = `t`.`AssignedCityName` +) AS `u` ON `c`.`Name` = `u`.`AssignedCityName` WHERE `c`.`Name` = 'Ephyra' -ORDER BY `c`.`Name`, `t`.`Nickname` +ORDER BY `c`.`Name`, `u`.`Nickname` """); } @@ -8072,7 +8275,7 @@ public override async Task Cast_ordered_subquery_to_base_type_using_typed_ToArra AssertSql( """ -SELECT `c`.`Name`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Nickname`, `t`.`Rank`, `t`.`SquadId` +SELECT `c`.`Name`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Nickname`, `u`.`Rank`, `u`.`SquadId` FROM `Cities` AS `c` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank` @@ -8080,9 +8283,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank` FROM `Officers` AS `o` -) AS `t` ON `c`.`Name` = `t`.`AssignedCityName` +) AS `u` ON `c`.`Name` = `u`.`AssignedCityName` WHERE `c`.`Name` = 'Ephyra' -ORDER BY `c`.`Name`, `t`.`Nickname` DESC +ORDER BY `c`.`Name`, `u`.`Nickname` DESC """); } @@ -8114,18 +8317,18 @@ FROM JSON_TABLE('[]', '$[*]' COLUMNS ( } else { - AssertSql( + AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `w`.`Name`, `w`.`Id` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w`.`Name`, `w`.`Id` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `u` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } } @@ -8251,16 +8454,16 @@ public override async Task String_concat_on_various_types(bool async) AssertSql( """ -SELECT CONCAT(CONCAT('HasSoulPatch ', CAST(`t`.`HasSoulPatch` AS char)), ' HasSoulPatch') AS `HasSoulPatch`, CONCAT(CONCAT('Rank ', CAST(`t`.`Rank` AS char)), ' Rank') AS `Rank`, CONCAT(CONCAT('SquadId ', CAST(`t`.`SquadId` AS char)), ' SquadId') AS `SquadId`, CONCAT(CONCAT('Rating ', COALESCE(CAST(`m`.`Rating` AS char), '')), ' Rating') AS `Rating`, CONCAT(CONCAT('Timeline ', CAST(`m`.`Timeline` AS char)), ' Timeline') AS `Timeline` +SELECT CONCAT(CONCAT('HasSoulPatch ', CAST(`u`.`HasSoulPatch` AS char)), ' HasSoulPatch') AS `HasSoulPatch`, CONCAT(CONCAT('Rank ', CAST(`u`.`Rank` AS char)), ' Rank') AS `Rank`, CONCAT(CONCAT('SquadId ', CAST(`u`.`SquadId` AS char)), ' SquadId') AS `SquadId`, CONCAT(CONCAT('Rating ', COALESCE(CAST(`m`.`Rating` AS char), '')), ' Rating') AS `Rating`, CONCAT(CONCAT('Timeline ', CAST(`m`.`Timeline` AS char)), ' Timeline') AS `Timeline` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch`, `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch`, `o`.`Rank` FROM `Officers` AS `o` -) AS `t` +) AS `u` CROSS JOIN `Missions` AS `m` -ORDER BY `t`.`Nickname`, `m`.`Id` +ORDER BY `u`.`Nickname`, `m`.`Id` """); } @@ -8280,16 +8483,16 @@ public override async Task GroupBy_Property_Include_Select_Average(bool async) await base.GroupBy_Property_Include_Select_Average(async); AssertSql( -$""" -SELECT AVG({SingleStoreTestHelpers.CastAsDouble(@"`t`.`SquadId`")}) +""" +SELECT AVG((`u`.`SquadId` :> double)) FROM ( SELECT `g`.`SquadId`, `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`SquadId`, `o`.`Rank` FROM `Officers` AS `o` -) AS `t` -GROUP BY `t`.`Rank` +) AS `u` +GROUP BY `u`.`Rank` """); } @@ -8299,15 +8502,15 @@ public override async Task GroupBy_Property_Include_Select_Sum(bool async) AssertSql( """ -SELECT COALESCE(SUM(`t`.`SquadId`), 0) +SELECT COALESCE(SUM(`u`.`SquadId`), 0) FROM ( SELECT `g`.`SquadId`, `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`SquadId`, `o`.`Rank` FROM `Officers` AS `o` -) AS `t` -GROUP BY `t`.`Rank` +) AS `u` +GROUP BY `u`.`Rank` """); } @@ -8324,8 +8527,8 @@ SELECT COUNT(*) UNION ALL SELECT `o`.`Rank` FROM `Officers` AS `o` -) AS `t` -GROUP BY `t`.`Rank` +) AS `u` +GROUP BY `u`.`Rank` """); } @@ -8342,8 +8545,8 @@ SELECT COUNT(*) UNION ALL SELECT `o`.`Rank` FROM `Officers` AS `o` -) AS `t` -GROUP BY `t`.`Rank` +) AS `u` +GROUP BY `u`.`Rank` """); } @@ -8353,15 +8556,15 @@ public override async Task GroupBy_Property_Include_Select_Min(bool async) AssertSql( """ -SELECT MIN(`t`.`SquadId`) +SELECT MIN(`u`.`SquadId`) FROM ( SELECT `g`.`SquadId`, `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`SquadId`, `o`.`Rank` FROM `Officers` AS `o` -) AS `t` -GROUP BY `t`.`Rank` +) AS `u` +GROUP BY `u`.`Rank` """); } @@ -8371,16 +8574,16 @@ public override async Task GroupBy_Property_Include_Aggregate_with_anonymous_sel AssertSql( """ -SELECT `t`.`Nickname` AS `Key`, COUNT(*) AS `c` +SELECT `u`.`Nickname` AS `Key`, COUNT(*) AS `c` FROM ( SELECT `g`.`Nickname` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname` FROM `Officers` AS `o` -) AS `t` -GROUP BY `t`.`Nickname` -ORDER BY `t`.`Nickname` +) AS `u` +GROUP BY `u`.`Nickname` +ORDER BY `u`.`Nickname` """); } @@ -8390,34 +8593,34 @@ public override async Task Group_by_with_include_with_entity_in_result_selector( AssertSql( """ -SELECT `t0`.`Rank`, `t0`.`c`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator`, `t1`.`Name`, `t1`.`Location`, `t1`.`Nation` +SELECT `u1`.`Rank`, `u1`.`c`, `s0`.`Nickname`, `s0`.`SquadId`, `s0`.`AssignedCityName`, `s0`.`CityOfBirthName`, `s0`.`FullName`, `s0`.`HasSoulPatch`, `s0`.`LeaderNickname`, `s0`.`LeaderSquadId`, `s0`.`Rank`, `s0`.`Discriminator`, `s0`.`Name`, `s0`.`Location`, `s0`.`Nation` FROM ( - SELECT `t`.`Rank`, COUNT(*) AS `c` + SELECT `u`.`Rank`, COUNT(*) AS `c` FROM ( SELECT `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Rank` FROM `Officers` AS `o` - ) AS `t` - GROUP BY `t`.`Rank` -) AS `t0` + ) AS `u` + GROUP BY `u`.`Rank` +) AS `u1` LEFT JOIN ( - SELECT `t2`.`Nickname`, `t2`.`SquadId`, `t2`.`AssignedCityName`, `t2`.`CityOfBirthName`, `t2`.`FullName`, `t2`.`HasSoulPatch`, `t2`.`LeaderNickname`, `t2`.`LeaderSquadId`, `t2`.`Rank`, `t2`.`Discriminator`, `t2`.`Name`, `t2`.`Location`, `t2`.`Nation` + SELECT `s`.`Nickname`, `s`.`SquadId`, `s`.`AssignedCityName`, `s`.`CityOfBirthName`, `s`.`FullName`, `s`.`HasSoulPatch`, `s`.`LeaderNickname`, `s`.`LeaderSquadId`, `s`.`Rank`, `s`.`Discriminator`, `s`.`Name`, `s`.`Location`, `s`.`Nation` FROM ( - SELECT `t3`.`Nickname`, `t3`.`SquadId`, `t3`.`AssignedCityName`, `t3`.`CityOfBirthName`, `t3`.`FullName`, `t3`.`HasSoulPatch`, `t3`.`LeaderNickname`, `t3`.`LeaderSquadId`, `t3`.`Rank`, `t3`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation`, ROW_NUMBER() OVER(PARTITION BY `t3`.`Rank` ORDER BY `t3`.`Nickname`) AS `row` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation`, ROW_NUMBER() OVER(PARTITION BY `u0`.`Rank` ORDER BY `u0`.`Nickname`) AS `row` FROM ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` - ) AS `t3` - INNER JOIN `Cities` AS `c` ON `t3`.`CityOfBirthName` = `c`.`Name` - ) AS `t2` - WHERE `t2`.`row` <= 1 -) AS `t1` ON `t0`.`Rank` = `t1`.`Rank` -ORDER BY `t0`.`Rank` + ) AS `u0` + INNER JOIN `Cities` AS `c` ON `u0`.`CityOfBirthName` = `c`.`Name` + ) AS `s` + WHERE `s`.`row` <= 1 +) AS `s0` ON `u1`.`Rank` = `s0`.`Rank` +ORDER BY `u1`.`Rank` """); } @@ -8427,15 +8630,15 @@ public override async Task GroupBy_Property_Include_Select_Max(bool async) AssertSql( """ -SELECT MAX(`t`.`SquadId`) +SELECT MAX(`u`.`SquadId`) FROM ( SELECT `g`.`SquadId`, `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`SquadId`, `o`.`Rank` FROM `Officers` AS `o` -) AS `t` -GROUP BY `t`.`Rank` +) AS `u` +GROUP BY `u`.`Rank` """); } @@ -8445,34 +8648,34 @@ public override async Task Include_with_group_by_and_FirstOrDefault_gets_properl AssertSql( """ -SELECT `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator`, `t1`.`Name`, `t1`.`Location`, `t1`.`Nation` +SELECT `s0`.`Nickname`, `s0`.`SquadId`, `s0`.`AssignedCityName`, `s0`.`CityOfBirthName`, `s0`.`FullName`, `s0`.`HasSoulPatch`, `s0`.`LeaderNickname`, `s0`.`LeaderSquadId`, `s0`.`Rank`, `s0`.`Discriminator`, `s0`.`Name`, `s0`.`Location`, `s0`.`Nation` FROM ( - SELECT `t`.`Rank` + SELECT `u`.`Rank` FROM ( SELECT `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Rank` FROM `Officers` AS `o` - ) AS `t` - GROUP BY `t`.`Rank` -) AS `t0` + ) AS `u` + GROUP BY `u`.`Rank` +) AS `u1` LEFT JOIN ( - SELECT `t2`.`Nickname`, `t2`.`SquadId`, `t2`.`AssignedCityName`, `t2`.`CityOfBirthName`, `t2`.`FullName`, `t2`.`HasSoulPatch`, `t2`.`LeaderNickname`, `t2`.`LeaderSquadId`, `t2`.`Rank`, `t2`.`Discriminator`, `t2`.`Name`, `t2`.`Location`, `t2`.`Nation` + SELECT `s`.`Nickname`, `s`.`SquadId`, `s`.`AssignedCityName`, `s`.`CityOfBirthName`, `s`.`FullName`, `s`.`HasSoulPatch`, `s`.`LeaderNickname`, `s`.`LeaderSquadId`, `s`.`Rank`, `s`.`Discriminator`, `s`.`Name`, `s`.`Location`, `s`.`Nation` FROM ( - SELECT `t3`.`Nickname`, `t3`.`SquadId`, `t3`.`AssignedCityName`, `t3`.`CityOfBirthName`, `t3`.`FullName`, `t3`.`HasSoulPatch`, `t3`.`LeaderNickname`, `t3`.`LeaderSquadId`, `t3`.`Rank`, `t3`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation`, ROW_NUMBER() OVER(PARTITION BY `t3`.`Rank` ORDER BY `t3`.`Nickname`, `t3`.`SquadId`, `c`.`Name`) AS `row` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `c`.`Name`, `c`.`Location`, `c`.`Nation`, ROW_NUMBER() OVER(PARTITION BY `u0`.`Rank` ORDER BY `u0`.`Nickname`, `u0`.`SquadId`, `c`.`Name`) AS `row` FROM ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` - ) AS `t3` - INNER JOIN `Cities` AS `c` ON `t3`.`CityOfBirthName` = `c`.`Name` - WHERE `t3`.`HasSoulPatch` = TRUE - ) AS `t2` - WHERE `t2`.`row` <= 1 -) AS `t1` ON `t0`.`Rank` = `t1`.`Rank` + ) AS `u0` + INNER JOIN `Cities` AS `c` ON `u0`.`CityOfBirthName` = `c`.`Name` + WHERE `u0`.`HasSoulPatch` = TRUE + ) AS `s` + WHERE `s`.`row` <= 1 +) AS `s0` ON `u1`.`Rank` = `s0`.`Rank` """); } @@ -8482,13 +8685,13 @@ public override async Task Include_collection_with_Cast_to_base(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `u` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -8498,15 +8701,15 @@ public override async Task Include_with_client_method_and_member_access_still_ap AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`GearNickName`, `t0`.`GearSquadId`, `t0`.`IssueDate`, `t0`.`Note` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) """); } @@ -8516,16 +8719,16 @@ public override async Task Include_with_projection_of_unmapped_property_still_ge AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `u` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -8534,22 +8737,22 @@ public override async Task Multiple_includes_with_client_method_around_entity_an await base.Multiple_includes_with_client_method_around_entity_and_also_projecting_included_collection(); AssertSql( -$""" -SELECT `s`.`Name`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `t0`.`Id`, `t0`.`AmmunitionType`, `t0`.`IsAutomatic`, `t0`.`Name`, `t0`.`OwnerFullName`, `t0`.`SynergyWithId` +""" +SELECT `s`.`Name`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s0`.`Nickname`, `s0`.`SquadId`, `s0`.`AssignedCityName`, `s0`.`CityOfBirthName`, `s0`.`FullName`, `s0`.`HasSoulPatch`, `s0`.`LeaderNickname`, `s0`.`LeaderSquadId`, `s0`.`Rank`, `s0`.`Discriminator`, `s0`.`Id`, `s0`.`AmmunitionType`, `s0`.`IsAutomatic`, `s0`.`Name`, `s0`.`OwnerFullName`, `s0`.`SynergyWithId` FROM `Squads` AS `s` LEFT JOIN ( - SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Gear'")} AS `Discriminator` + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'Officer'")} AS `Discriminator` + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` - ) AS `t` - LEFT JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` -) AS `t0` ON `s`.`Id` = `t0`.`SquadId` + ) AS `u` + LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +) AS `s0` ON `s`.`Id` = `s0`.`SquadId` WHERE `s`.`Name` = 'Delta' -ORDER BY `s`.`Id`, `t0`.`Nickname`, `t0`.`SquadId` +ORDER BY `s`.`Id`, `s0`.`Nickname`, `s0`.`SquadId` """); } @@ -8560,8 +8763,7 @@ public override async Task OrderBy_same_expression_containing_IsNull_correctly_d AssertSql( """ SELECT CASE - WHEN `t`.`LeaderNickname` IS NOT NULL THEN CHAR_LENGTH(`t`.`Nickname`) = 5 - ELSE NULL + WHEN `u`.`LeaderNickname` IS NOT NULL THEN CHAR_LENGTH(`u`.`Nickname`) = 5 END FROM ( SELECT `g`.`Nickname`, `g`.`LeaderNickname` @@ -8569,10 +8771,9 @@ ELSE NULL UNION ALL SELECT `o`.`Nickname`, `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` +) AS `u` ORDER BY CASE - WHEN `t`.`LeaderNickname` IS NOT NULL THEN CHAR_LENGTH(`t`.`Nickname`) = 5 - ELSE NULL + WHEN `u`.`LeaderNickname` IS NOT NULL THEN CHAR_LENGTH(`u`.`Nickname`) = 5 END IS NOT NULL """); } @@ -8608,7 +8809,7 @@ public override async Task GetValueOrDefault_in_filter_non_nullable_column(bool """ SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` -WHERE COALESCE(`w`.`Id`, 0) = 0 +WHERE `w`.`Id` = 0 """); } @@ -8654,18 +8855,18 @@ public override async Task Filter_with_complex_predicate_containing_subquery(boo AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`FullName` <> 'Dom') AND EXISTS ( +) AS `u` +WHERE (`u`.`FullName` <> 'Dom') AND EXISTS ( SELECT 1 FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`IsAutomatic` = TRUE)) + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`IsAutomatic` = TRUE)) """); } @@ -8677,10 +8878,10 @@ public override async Task Query_with_complex_let_containing_ordering_and_filter AssertSql( """ -SELECT `t`.`Nickname`, ( +SELECT `u`.`Nickname`, ( SELECT `w`.`Name` FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`IsAutomatic` = TRUE) + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`IsAutomatic` = TRUE) ORDER BY `w`.`AmmunitionType` DESC LIMIT 1) AS `WeaponName` FROM ( @@ -8689,8 +8890,8 @@ ORDER BY `w`.`AmmunitionType` DESC UNION ALL SELECT `o`.`Nickname`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`Nickname` <> 'Dom' +) AS `u` +WHERE `u`.`Nickname` <> 'Dom' """); } @@ -8709,8 +8910,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -WHERE (SUBSTRING(`t`.`Note`, 0 + 1, `t0`.`SquadId`) = `t`.`GearNickName`) OR ((`t`.`Note` IS NULL OR (`t0`.`SquadId` IS NULL)) AND `t`.`GearNickName` IS NULL) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE (SUBSTRING(`t`.`Note`, 0 + 1, `u`.`SquadId`) = `t`.`GearNickName`) OR ((`t`.`Note` IS NULL OR (`u`.`SquadId` IS NULL)) AND `t`.`GearNickName` IS NULL) """); } @@ -8730,8 +8931,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -LEFT JOIN `Squads` AS `s` ON `t0`.`SquadId` = `s`.`Id` +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +LEFT JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` WHERE (SUBSTRING(`t`.`Note`, 0 + 1, CHAR_LENGTH(`s`.`Name`)) = `t`.`GearNickName`) OR ((`t`.`Note` IS NULL OR (`s`.`Name` IS NULL)) AND `t`.`GearNickName` IS NULL) """); } @@ -8761,14 +8962,14 @@ public override async Task OfTypeNav1(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) -LEFT JOIN `Tags` AS `t1` ON (`t`.`Nickname` = `t1`.`GearNickName`) AND (`t`.`SquadId` = `t1`.`GearSquadId`) -WHERE ((`t0`.`Note` <> 'Foo') OR `t0`.`Note` IS NULL) AND ((`t1`.`Note` <> 'Bar') OR `t1`.`Note` IS NULL) +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) +LEFT JOIN `Tags` AS `t0` ON (`u`.`Nickname` = `t0`.`GearNickName`) AND (`u`.`SquadId` = `t0`.`GearSquadId`) +WHERE ((`t`.`Note` <> 'Foo') OR `t`.`Note` IS NULL) AND ((`t0`.`Note` <> 'Bar') OR `t0`.`Note` IS NULL) """); } @@ -8778,14 +8979,14 @@ public override async Task OfTypeNav2(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) -LEFT JOIN `Cities` AS `c` ON `t`.`AssignedCityName` = `c`.`Name` -WHERE ((`t0`.`Note` <> 'Foo') OR `t0`.`Note` IS NULL) AND ((`c`.`Location` <> 'Bar') OR `c`.`Location` IS NULL) +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) +LEFT JOIN `Cities` AS `c` ON `u`.`AssignedCityName` = `c`.`Name` +WHERE ((`t`.`Note` <> 'Foo') OR `t`.`Note` IS NULL) AND ((`c`.`Location` <> 'Bar') OR `c`.`Location` IS NULL) """); } @@ -8795,15 +8996,15 @@ public override async Task OfTypeNav3(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) -INNER JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` -LEFT JOIN `Tags` AS `t1` ON (`t`.`Nickname` = `t1`.`GearNickName`) AND (`t`.`SquadId` = `t1`.`GearSquadId`) -WHERE ((`t0`.`Note` <> 'Foo') OR `t0`.`Note` IS NULL) AND ((`t1`.`Note` <> 'Bar') OR `t1`.`Note` IS NULL) +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) +INNER JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +LEFT JOIN `Tags` AS `t0` ON (`u`.`Nickname` = `t0`.`GearNickName`) AND (`u`.`SquadId` = `t0`.`GearSquadId`) +WHERE ((`t`.`Note` <> 'Foo') OR `t`.`Note` IS NULL) AND ((`t0`.`Note` <> 'Bar') OR `t0`.`Note` IS NULL) """); } @@ -8870,27 +9071,27 @@ public override async Task Where_contains_on_navigation_with_composite_keys(bool AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE EXISTS ( SELECT 1 FROM `Cities` AS `c` WHERE EXISTS ( SELECT 1 FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`CityOfBirthName` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`CityOfBirthName` FROM `Officers` AS `o0` - ) AS `t0` - WHERE (`c`.`Name` = `t0`.`CityOfBirthName`) AND ((`t0`.`Nickname` = `t`.`Nickname`) AND (`t0`.`SquadId` = `t`.`SquadId`)))) + ) AS `u0` + WHERE (`c`.`Name` = `u0`.`CityOfBirthName`) AND ((`u0`.`Nickname` = `u`.`Nickname`) AND (`u0`.`SquadId` = `u`.`SquadId`)))) """); } @@ -8901,20 +9102,20 @@ public override async Task Include_with_complex_order_by(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Weapons` AS `w0` ON `t`.`FullName` = `w0`.`OwnerFullName` +) AS `u` +LEFT JOIN `Weapons` AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` ORDER BY ( SELECT `w`.`Name` FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Gnasher%') - LIMIT 1), `t`.`Nickname`, `t`.`SquadId` + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` LIKE '%Gnasher%') + LIMIT 1), `u`.`Nickname`, `u`.`SquadId` """); } @@ -8926,26 +9127,26 @@ public override async Task Anonymous_projection_take_followed_by_projecting_sing """ @__p_0='25' -SELECT `t1`.`Id`, `t1`.`AmmunitionType`, `t1`.`IsAutomatic`, `t1`.`Name`, `t1`.`OwnerFullName`, `t1`.`SynergyWithId` +SELECT `w1`.`Id`, `w1`.`AmmunitionType`, `w1`.`IsAutomatic`, `w1`.`Name`, `w1`.`OwnerFullName`, `w1`.`SynergyWithId` FROM ( - SELECT `t`.`FullName` + SELECT `u`.`FullName` FROM ( SELECT `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` - ) AS `t` + ) AS `u` LIMIT @__p_0 -) AS `t0` +) AS `u0` LEFT JOIN ( - SELECT `t2`.`Id`, `t2`.`AmmunitionType`, `t2`.`IsAutomatic`, `t2`.`Name`, `t2`.`OwnerFullName`, `t2`.`SynergyWithId` + SELECT `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, ROW_NUMBER() OVER(PARTITION BY `w`.`OwnerFullName` ORDER BY `w`.`Id`) AS `row` FROM `Weapons` AS `w` - ) AS `t2` - WHERE `t2`.`row` <= 1 -) AS `t1` ON `t0`.`FullName` = `t1`.`OwnerFullName` + ) AS `w0` + WHERE `w0`.`row` <= 1 +) AS `w1` ON `u0`.`FullName` = `w1`.`OwnerFullName` """); } @@ -8958,15 +9159,15 @@ public override async Task Bool_projection_from_subquery_treated_appropriately_i SELECT `c`.`Name`, `c`.`Location`, `c`.`Nation` FROM `Cities` AS `c` WHERE ( - SELECT `t`.`HasSoulPatch` + SELECT `u`.`HasSoulPatch` FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t` - ORDER BY `t`.`Nickname`, `t`.`SquadId` + ) AS `u` + ORDER BY `u`.`Nickname`, `u`.`SquadId` LIMIT 1) """); } @@ -9010,7 +9211,7 @@ FROM JSON_TABLE('["1902-01-02T10:00:00.1234567+01:30"]', '$[*]' COLUMNS ( SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` -WHERE ((@__start_0 <= CONVERT(`m`.`Timeline`, date)) AND (`m`.`Timeline` < @__end_1)) AND (`m`.`Timeline` = '1902-01-02 08:30:00.123456') +WHERE ((@__start_0 <= CONVERT(`m`.`Timeline`, date)) AND (`m`.`Timeline` < @__end_1)) AND (`m`.`Timeline` = TIMESTAMP '1902-01-02 08:30:00.123456') """); } } @@ -9052,21 +9253,21 @@ public override async Task Left_join_projection_using_coalesce_tracking(bool asy AssertSql( """ -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON `t`.`LeaderNickname` = `t0`.`Nickname` +) AS `u0` ON `u`.`LeaderNickname` = `u0`.`Nickname` """); } @@ -9076,21 +9277,21 @@ public override async Task Left_join_projection_using_conditional_tracking(bool AssertSql( """ -SELECT `t0`.`Nickname` IS NULL OR (`t0`.`SquadId` IS NULL), `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u0`.`Nickname` IS NULL OR (`u0`.`SquadId` IS NULL), `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON `t`.`LeaderNickname` = `t0`.`Nickname` +) AS `u0` ON `u`.`LeaderNickname` = `u0`.`Nickname` """); } @@ -9100,7 +9301,7 @@ public override async Task Project_collection_navigation_nested_with_take_compos AssertSql( """ -SELECT `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` +SELECT `t`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `u2`.`Nickname`, `u2`.`SquadId`, `u2`.`AssignedCityName`, `u2`.`CityOfBirthName`, `u2`.`FullName`, `u2`.`HasSoulPatch`, `u2`.`LeaderNickname`, `u2`.`LeaderSquadId`, `u2`.`Rank`, `u2`.`Discriminator` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, 'Gear' AS `Discriminator` @@ -9108,23 +9309,23 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) LEFT JOIN ( - SELECT `t2`.`Nickname`, `t2`.`SquadId`, `t2`.`AssignedCityName`, `t2`.`CityOfBirthName`, `t2`.`FullName`, `t2`.`HasSoulPatch`, `t2`.`LeaderNickname`, `t2`.`LeaderSquadId`, `t2`.`Rank`, `t2`.`Discriminator` + SELECT `u1`.`Nickname`, `u1`.`SquadId`, `u1`.`AssignedCityName`, `u1`.`CityOfBirthName`, `u1`.`FullName`, `u1`.`HasSoulPatch`, `u1`.`LeaderNickname`, `u1`.`LeaderSquadId`, `u1`.`Rank`, `u1`.`Discriminator` FROM ( - SELECT `t3`.`Nickname`, `t3`.`SquadId`, `t3`.`AssignedCityName`, `t3`.`CityOfBirthName`, `t3`.`FullName`, `t3`.`HasSoulPatch`, `t3`.`LeaderNickname`, `t3`.`LeaderSquadId`, `t3`.`Rank`, `t3`.`Discriminator`, ROW_NUMBER() OVER(PARTITION BY `t3`.`LeaderNickname`, `t3`.`LeaderSquadId` ORDER BY `t3`.`Nickname`, `t3`.`SquadId`) AS `row` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, ROW_NUMBER() OVER(PARTITION BY `u0`.`LeaderNickname`, `u0`.`LeaderSquadId` ORDER BY `u0`.`Nickname`, `u0`.`SquadId`) AS `row` FROM ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` - ) AS `t3` - ) AS `t2` - WHERE `t2`.`row` <= 50 -) AS `t1` ON ((`t0`.`Nickname` = `t1`.`LeaderNickname`) OR (`t0`.`Nickname` IS NULL AND (`t1`.`LeaderNickname` IS NULL))) AND (`t0`.`SquadId` = `t1`.`LeaderSquadId`) -WHERE `t0`.`Discriminator` = 'Officer' -ORDER BY `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `t1`.`Nickname` + ) AS `u0` + ) AS `u1` + WHERE `u1`.`row` <= 50 +) AS `u2` ON ((`u`.`Nickname` = `u2`.`LeaderNickname`) OR (`u`.`Nickname` IS NULL AND (`u2`.`LeaderNickname` IS NULL))) AND (`u`.`SquadId` = `u2`.`LeaderSquadId`) +WHERE `u`.`Discriminator` = 'Officer' +ORDER BY `t`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `u2`.`Nickname` """); } @@ -9134,7 +9335,7 @@ public override async Task Project_collection_navigation_nested_composite_key(bo AssertSql( """ -SELECT `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` +SELECT `t`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, 'Gear' AS `Discriminator` @@ -9142,16 +9343,16 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t1` ON ((`t0`.`Nickname` = `t1`.`LeaderNickname`) OR (`t0`.`Nickname` IS NULL AND (`t1`.`LeaderNickname` IS NULL))) AND (`t0`.`SquadId` = `t1`.`LeaderSquadId`) -WHERE `t0`.`Discriminator` = 'Officer' -ORDER BY `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `t1`.`Nickname` +) AS `u0` ON ((`u`.`Nickname` = `u0`.`LeaderNickname`) OR (`u`.`Nickname` IS NULL AND (`u0`.`LeaderNickname` IS NULL))) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +WHERE `u`.`Discriminator` = 'Officer' +ORDER BY `t`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -9161,7 +9362,7 @@ public override async Task Null_checks_in_correlated_predicate_are_correctly_tra AssertSql( """ -SELECT `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `t`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -9169,8 +9370,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON ((`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`)) AND `t`.`Note` IS NOT NULL -ORDER BY `t`.`Id`, `t0`.`Nickname` +) AS `u` ON ((`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`)) AND `t`.`Note` IS NOT NULL +ORDER BY `t`.`Id`, `u`.`Nickname` """); } @@ -9182,19 +9383,19 @@ public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_th """ @__isAutomatic_0='True' -SELECT `t`.`Nickname`, `t`.`FullName`, `t0`.`Id` IS NOT NULL AS `Collection` +SELECT `u`.`Nickname`, `u`.`FullName`, `w0`.`Id` IS NOT NULL AS `Collection` FROM ( SELECT `g`.`Nickname`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `w`.`Id`, `w`.`OwnerFullName` FROM `Weapons` AS `w` WHERE `w`.`IsAutomatic` = @__isAutomatic_0 -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` +) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` """); } @@ -9204,21 +9405,21 @@ public override async Task Join_with_inner_being_a_subquery_projecting_single_pr AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` INNER JOIN ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname` FROM `Officers` AS `o0` -) AS `t0` ON `t`.`Nickname` = `t0`.`Nickname` +) AS `u0` ON `u`.`Nickname` = `u0`.`Nickname` """); } @@ -9228,21 +9429,21 @@ public override async Task Join_with_inner_being_a_subquery_projecting_anonymous AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` INNER JOIN ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname` FROM `Officers` AS `o0` -) AS `t0` ON `t`.`Nickname` = `t0`.`Nickname` +) AS `u0` ON `u`.`Nickname` = `u0`.`Nickname` """); } @@ -9290,13 +9491,13 @@ public override async Task Navigation_based_on_complex_expression4(bool async) AssertSql( """ -SELECT TRUE, `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT TRUE, `l1`.`Name`, `l1`.`LocustHordeId`, `l1`.`ThreatLevel`, `l1`.`ThreatLevelByte`, `l1`.`ThreatLevelNullableByte`, `l1`.`DefeatedByNickname`, `l1`.`DefeatedBySquadId`, `l1`.`HighCommandId`, `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM `LocustHordes` AS `l` CROSS JOIN ( - SELECT `l1`.`Name`, `l1`.`LocustHordeId`, `l1`.`ThreatLevel`, `l1`.`ThreatLevelByte`, `l1`.`ThreatLevelNullableByte`, `l1`.`DefeatedByNickname`, `l1`.`DefeatedBySquadId`, `l1`.`HighCommandId`, 'LocustCommander' AS `Discriminator` - FROM `LocustCommanders` AS `l1` -) AS `t` -LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` + SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` + FROM `LocustCommanders` AS `l0` +) AS `u` +LEFT JOIN `LocustCommanders` AS `l1` ON `l`.`CommanderName` = `l1`.`Name` """); } @@ -9306,13 +9507,13 @@ public override async Task Navigation_based_on_complex_expression5(bool async) AssertSql( """ -SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT `l1`.`Name`, `l1`.`LocustHordeId`, `l1`.`ThreatLevel`, `l1`.`ThreatLevelByte`, `l1`.`ThreatLevelNullableByte`, `l1`.`DefeatedByNickname`, `l1`.`DefeatedBySquadId`, `l1`.`HighCommandId`, `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM `LocustHordes` AS `l` CROSS JOIN ( - SELECT `l1`.`Name`, `l1`.`LocustHordeId`, `l1`.`ThreatLevel`, `l1`.`ThreatLevelByte`, `l1`.`ThreatLevelNullableByte`, `l1`.`DefeatedByNickname`, `l1`.`DefeatedBySquadId`, `l1`.`HighCommandId`, 'LocustCommander' AS `Discriminator` - FROM `LocustCommanders` AS `l1` -) AS `t` -LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` + SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` + FROM `LocustCommanders` AS `l0` +) AS `u` +LEFT JOIN `LocustCommanders` AS `l1` ON `l`.`CommanderName` = `l1`.`Name` """); } @@ -9322,13 +9523,13 @@ public override async Task Navigation_based_on_complex_expression6(bool async) AssertSql( """ -SELECT (`l0`.`Name` = 'Queen Myrrah') AND `l0`.`Name` IS NOT NULL, `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT (`l1`.`Name` = 'Queen Myrrah') AND `l1`.`Name` IS NOT NULL, `l1`.`Name`, `l1`.`LocustHordeId`, `l1`.`ThreatLevel`, `l1`.`ThreatLevelByte`, `l1`.`ThreatLevelNullableByte`, `l1`.`DefeatedByNickname`, `l1`.`DefeatedBySquadId`, `l1`.`HighCommandId`, `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM `LocustHordes` AS `l` CROSS JOIN ( - SELECT `l1`.`Name`, `l1`.`LocustHordeId`, `l1`.`ThreatLevel`, `l1`.`ThreatLevelByte`, `l1`.`ThreatLevelNullableByte`, `l1`.`DefeatedByNickname`, `l1`.`DefeatedBySquadId`, `l1`.`HighCommandId`, 'LocustCommander' AS `Discriminator` - FROM `LocustCommanders` AS `l1` -) AS `t` -LEFT JOIN `LocustCommanders` AS `l0` ON `l`.`CommanderName` = `l0`.`Name` + SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` + FROM `LocustCommanders` AS `l0` +) AS `u` +LEFT JOIN `LocustCommanders` AS `l1` ON `l`.`CommanderName` = `l1`.`Name` """); } @@ -9352,7 +9553,7 @@ public override async Task Select_datetimeoffset_comparison_in_projection(bool a AssertSql( """ -SELECT `m`.`Timeline` > UTC_TIMESTAMP() +SELECT `m`.`Timeline` > UTC_TIMESTAMP(6) FROM `Missions` AS `m` """); } @@ -9363,16 +9564,16 @@ public override async Task OfType_in_subquery_works(bool async) AssertSql( """ -SELECT `t0`.`Name`, `t0`.`Location`, `t0`.`Nation` +SELECT `s`.`Name`, `s`.`Location`, `s`.`Nation` FROM `Officers` AS `o` INNER JOIN ( - SELECT `c`.`Name`, `c`.`Location`, `c`.`Nation`, `t`.`LeaderNickname`, `t`.`LeaderSquadId` + SELECT `c`.`Name`, `c`.`Location`, `c`.`Nation`, `u`.`LeaderNickname`, `u`.`LeaderSquadId` FROM ( SELECT `o0`.`AssignedCityName`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` FROM `Officers` AS `o0` - ) AS `t` - LEFT JOIN `Cities` AS `c` ON `t`.`AssignedCityName` = `c`.`Name` -) AS `t0` ON (`o`.`Nickname` = `t0`.`LeaderNickname`) AND (`o`.`SquadId` = `t0`.`LeaderSquadId`) + ) AS `u` + LEFT JOIN `Cities` AS `c` ON `u`.`AssignedCityName` = `c`.`Name` +) AS `s` ON (`o`.`Nickname` = `s`.`LeaderNickname`) AND (`o`.`SquadId` = `s`.`LeaderSquadId`) """); } @@ -9393,20 +9594,20 @@ public override async Task Accessing_reference_navigation_collection_composition AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t0`.`IsAutomatic`, `t0`.`Name`, `t0`.`Id0` +SELECT `u`.`Nickname`, `u`.`SquadId`, `s`.`Id`, `s`.`IsAutomatic`, `s`.`Name`, `s`.`Id0` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `w`.`Id`, `w`.`IsAutomatic`, `w0`.`Name`, `w0`.`Id` AS `Id0`, `w`.`OwnerFullName` FROM `Weapons` AS `w` LEFT JOIN `Weapons` AS `w0` ON `w`.`SynergyWithId` = `w0`.`Id` -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id` +) AS `s` ON `u`.`FullName` = `s`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `s`.`Id` """); } @@ -9416,7 +9617,7 @@ public override async Task Reference_include_chain_loads_correctly_when_middle_i AssertSql( """ -SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` +SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` @@ -9424,8 +9625,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -LEFT JOIN `Squads` AS `s` ON `t0`.`SquadId` = `s`.`Id` +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +LEFT JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` ORDER BY `t`.`Note` """); } @@ -9436,7 +9637,7 @@ public override async Task Accessing_property_of_optional_navigation_in_child_pr AssertSql( """ -SELECT `t0`.`Nickname` IS NOT NULL AND (`t0`.`SquadId` IS NOT NULL), `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `t1`.`Nickname`, `t1`.`Id`, `t1`.`SquadId` +SELECT `u`.`Nickname` IS NOT NULL AND (`u`.`SquadId` IS NOT NULL), `t`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `s`.`Nickname`, `s`.`Id`, `s`.`SquadId` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` @@ -9444,9 +9645,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) LEFT JOIN ( - SELECT `t2`.`Nickname`, `w`.`Id`, `t2`.`SquadId`, `w`.`OwnerFullName` + SELECT `u0`.`Nickname`, `w`.`Id`, `u0`.`SquadId`, `w`.`OwnerFullName` FROM `Weapons` AS `w` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`FullName` @@ -9454,9 +9655,9 @@ LEFT JOIN ( UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName` FROM `Officers` AS `o0` - ) AS `t2` ON `w`.`OwnerFullName` = `t2`.`FullName` -) AS `t1` ON `t0`.`FullName` = `t1`.`OwnerFullName` -ORDER BY `t`.`Note`, `t`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `t1`.`Id`, `t1`.`Nickname` + ) AS `u0` ON `w`.`OwnerFullName` = `u0`.`FullName` +) AS `s` ON `u`.`FullName` = `s`.`OwnerFullName` +ORDER BY `t`.`Note`, `t`.`Id`, `u`.`Nickname`, `u`.`SquadId`, `s`.`Id`, `s`.`Nickname` """); } @@ -9471,10 +9672,10 @@ public override async Task Collection_navigation_ofType_filter_works(bool async) WHERE EXISTS ( SELECT 1 FROM ( - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`Nickname`, `o`.`CityOfBirthName` FROM `Officers` AS `o` - ) AS `t` - WHERE (`c`.`Name` = `t`.`CityOfBirthName`) AND (`t`.`Nickname` = 'Marcus')) + ) AS `u` + WHERE (`c`.`Name` = `u`.`CityOfBirthName`) AND (`u`.`Nickname` = 'Marcus')) """); } @@ -9486,19 +9687,19 @@ public override async Task Query_reusing_parameter_doesnt_declare_duplicate_para """ @__prm_Inner_Nickname_0='Marcus' (Size = 255) -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( - SELECT DISTINCT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` + SELECT DISTINCT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` - ) AS `t` - WHERE (`t`.`Nickname` <> @__prm_Inner_Nickname_0) AND (`t`.`Nickname` <> @__prm_Inner_Nickname_0) -) AS `t0` -ORDER BY `t0`.`FullName` + ) AS `u` + WHERE `u`.`Nickname` <> @__prm_Inner_Nickname_0 +) AS `u0` +ORDER BY `u0`.`FullName` """); } @@ -9510,39 +9711,39 @@ public override async Task Query_reusing_parameter_with_inner_query_doesnt_decla """ @__squadId_0='1' -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u1`.`Nickname`, `u1`.`SquadId`, `u1`.`AssignedCityName`, `u1`.`CityOfBirthName`, `u1`.`FullName`, `u1`.`HasSoulPatch`, `u1`.`LeaderNickname`, `u1`.`LeaderSquadId`, `u1`.`Rank`, `u1`.`Discriminator` FROM ( - SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` - ) AS `t` - INNER JOIN `Squads` AS `s` ON `t`.`SquadId` = `s`.`Id` + ) AS `u` + INNER JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` WHERE `s`.`Id` IN ( SELECT `s0`.`Id` FROM `Squads` AS `s0` WHERE `s0`.`Id` = @__squadId_0 ) UNION ALL - SELECT `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` - ) AS `t1` - INNER JOIN `Squads` AS `s1` ON `t1`.`SquadId` = `s1`.`Id` + ) AS `u0` + INNER JOIN `Squads` AS `s1` ON `u0`.`SquadId` = `s1`.`Id` WHERE `s1`.`Id` IN ( SELECT `s2`.`Id` FROM `Squads` AS `s2` WHERE `s2`.`Id` = @__squadId_0 ) -) AS `t0` -ORDER BY `t0`.`FullName` +) AS `u1` +ORDER BY `u1`.`FullName` """); } @@ -9559,13 +9760,13 @@ public override async Task Query_reusing_parameter_with_inner_query_expression_d WHERE EXISTS ( SELECT 1 FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`SquadId` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`SquadId` FROM `Officers` AS `o` - ) AS `t` - WHERE ((`s`.`Id` = `t`.`SquadId`) AND (`t`.`SquadId` = @__gearId_0)) AND (`t`.`SquadId` = @__gearId_0)) + ) AS `u` + WHERE ((`s`.`Id` = `u`.`SquadId`) AND (`u`.`SquadId` = @__gearId_0)) AND (`u`.`SquadId` = @__gearId_0)) """); } @@ -9577,22 +9778,22 @@ public override async Task Query_reusing_parameter_doesnt_declare_duplicate_para """ @__entity_equality_prm_Inner_Squad_0_Id='1' (Nullable = true) -SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `s1`.`Nickname`, `s1`.`SquadId`, `s1`.`AssignedCityName`, `s1`.`CityOfBirthName`, `s1`.`FullName`, `s1`.`HasSoulPatch`, `s1`.`LeaderNickname`, `s1`.`LeaderSquadId`, `s1`.`Rank`, `s1`.`Discriminator` FROM ( - SELECT DISTINCT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` + SELECT DISTINCT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` - ) AS `t` - INNER JOIN `Squads` AS `s` ON `t`.`SquadId` = `s`.`Id` + ) AS `u` + INNER JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` WHERE `s`.`Id` = @__entity_equality_prm_Inner_Squad_0_Id -) AS `t0` -INNER JOIN `Squads` AS `s0` ON `t0`.`SquadId` = `s0`.`Id` +) AS `s1` +INNER JOIN `Squads` AS `s0` ON `s1`.`SquadId` = `s0`.`Id` WHERE `s0`.`Id` = @__entity_equality_prm_Inner_Squad_0_Id -ORDER BY `t0`.`FullName` +ORDER BY `s1`.`FullName` """); } @@ -9602,35 +9803,35 @@ public override async Task Complex_GroupBy_after_set_operator(bool async) AssertSql( """ -SELECT `t0`.`Name`, `t0`.`Count`, COALESCE(SUM(`t0`.`Count`), 0) AS `Sum` +SELECT `u1`.`Name`, `u1`.`Count`, COALESCE(SUM(`u1`.`Count`), 0) AS `Sum` FROM ( SELECT `c`.`Name`, ( SELECT COUNT(*) FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName`) AS `Count` + WHERE `u`.`FullName` = `w`.`OwnerFullName`) AS `Count` FROM ( SELECT `g`.`AssignedCityName`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`AssignedCityName`, `o`.`FullName` FROM `Officers` AS `o` - ) AS `t` - LEFT JOIN `Cities` AS `c` ON `t`.`AssignedCityName` = `c`.`Name` + ) AS `u` + LEFT JOIN `Cities` AS `c` ON `u`.`AssignedCityName` = `c`.`Name` UNION ALL SELECT `c0`.`Name`, ( SELECT COUNT(*) FROM `Weapons` AS `w0` - WHERE `t1`.`FullName` = `w0`.`OwnerFullName`) AS `Count` + WHERE `u0`.`FullName` = `w0`.`OwnerFullName`) AS `Count` FROM ( SELECT `g0`.`CityOfBirthName`, `g0`.`FullName` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`CityOfBirthName`, `o0`.`FullName` FROM `Officers` AS `o0` - ) AS `t1` - INNER JOIN `Cities` AS `c0` ON `t1`.`CityOfBirthName` = `c0`.`Name` -) AS `t0` -GROUP BY `t0`.`Name`, `t0`.`Count` + ) AS `u0` + INNER JOIN `Cities` AS `c0` ON `u0`.`CityOfBirthName` = `c0`.`Name` +) AS `u1` +GROUP BY `u1`.`Name`, `u1`.`Count` """); } @@ -9640,35 +9841,35 @@ public override async Task Complex_GroupBy_after_set_operator_using_result_selec AssertSql( """ -SELECT `t0`.`Name`, `t0`.`Count`, COALESCE(SUM(`t0`.`Count`), 0) AS `Sum` +SELECT `u1`.`Name`, `u1`.`Count`, COALESCE(SUM(`u1`.`Count`), 0) AS `Sum` FROM ( SELECT `c`.`Name`, ( SELECT COUNT(*) FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName`) AS `Count` + WHERE `u`.`FullName` = `w`.`OwnerFullName`) AS `Count` FROM ( SELECT `g`.`AssignedCityName`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`AssignedCityName`, `o`.`FullName` FROM `Officers` AS `o` - ) AS `t` - LEFT JOIN `Cities` AS `c` ON `t`.`AssignedCityName` = `c`.`Name` + ) AS `u` + LEFT JOIN `Cities` AS `c` ON `u`.`AssignedCityName` = `c`.`Name` UNION ALL SELECT `c0`.`Name`, ( SELECT COUNT(*) FROM `Weapons` AS `w0` - WHERE `t1`.`FullName` = `w0`.`OwnerFullName`) AS `Count` + WHERE `u0`.`FullName` = `w0`.`OwnerFullName`) AS `Count` FROM ( SELECT `g0`.`CityOfBirthName`, `g0`.`FullName` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`CityOfBirthName`, `o0`.`FullName` FROM `Officers` AS `o0` - ) AS `t1` - INNER JOIN `Cities` AS `c0` ON `t1`.`CityOfBirthName` = `c0`.`Name` -) AS `t0` -GROUP BY `t0`.`Name`, `t0`.`Count` + ) AS `u0` + INNER JOIN `Cities` AS `c0` ON `u0`.`CityOfBirthName` = `c0`.`Name` +) AS `u1` +GROUP BY `u1`.`Name`, `u1`.`Count` """); } @@ -9678,17 +9879,17 @@ public override async Task Left_join_with_GroupBy_with_composite_group_key(bool AssertSql( """ -SELECT `t`.`CityOfBirthName`, `t`.`HasSoulPatch` +SELECT `u`.`CityOfBirthName`, `u`.`HasSoulPatch` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`CityOfBirthName`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`CityOfBirthName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Squads` AS `s` ON `t`.`SquadId` = `s`.`Id` -LEFT JOIN `Tags` AS `t0` ON `t`.`Nickname` = `t0`.`GearNickName` -GROUP BY `t`.`CityOfBirthName`, `t`.`HasSoulPatch` +) AS `u` +INNER JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` +LEFT JOIN `Tags` AS `t` ON `u`.`Nickname` = `t`.`GearNickName` +GROUP BY `u`.`CityOfBirthName`, `u`.`HasSoulPatch` """); } @@ -9698,18 +9899,18 @@ public override async Task GroupBy_with_boolean_grouping_key(bool async) AssertSql( """ -SELECT `t0`.`CityOfBirthName`, `t0`.`HasSoulPatch`, `t0`.`IsMarcus`, COUNT(*) AS `Count` +SELECT `u0`.`CityOfBirthName`, `u0`.`HasSoulPatch`, `u0`.`IsMarcus`, COUNT(*) AS `Count` FROM ( - SELECT `t`.`CityOfBirthName`, `t`.`HasSoulPatch`, `t`.`Nickname` = 'Marcus' AS `IsMarcus` + SELECT `u`.`CityOfBirthName`, `u`.`HasSoulPatch`, `u`.`Nickname` = 'Marcus' AS `IsMarcus` FROM ( SELECT `g`.`Nickname`, `g`.`CityOfBirthName`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`CityOfBirthName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t` -) AS `t0` -GROUP BY `t0`.`CityOfBirthName`, `t0`.`HasSoulPatch`, `t0`.`IsMarcus` + ) AS `u` +) AS `u0` +GROUP BY `u0`.`CityOfBirthName`, `u0`.`HasSoulPatch`, `u0`.`IsMarcus` """); } @@ -9719,7 +9920,7 @@ public override async Task GroupBy_with_boolean_groupin_key_thru_navigation_acce AssertSql( """ -SELECT `t0`.`HasSoulPatch`, LOWER(`s`.`Name`) AS `Name` +SELECT `u`.`HasSoulPatch`, LOWER(`s`.`Name`) AS `Name` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` @@ -9727,9 +9928,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) -LEFT JOIN `Squads` AS `s` ON `t0`.`SquadId` = `s`.`Id` -GROUP BY `t0`.`HasSoulPatch`, `s`.`Name` +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +LEFT JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` +GROUP BY `u`.`HasSoulPatch`, `s`.`Name` """); } @@ -9746,8 +9947,8 @@ public override async Task Group_by_over_projection_with_multiple_properties_acc UNION ALL SELECT `o`.`CityOfBirthName` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Cities` AS `c` ON `t`.`CityOfBirthName` = `c`.`Name` +) AS `u` +INNER JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` GROUP BY `c`.`Name` """); } @@ -9758,7 +9959,7 @@ public override async Task Group_by_on_StartsWith_with_null_parameter_as_argumen AssertSql( """ -SELECT `t0`.`Key` +SELECT `u0`.`Key` FROM ( SELECT FALSE AS `Key` FROM ( @@ -9767,9 +9968,9 @@ SELECT FALSE AS `Key` UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` - ) AS `t` -) AS `t0` -GROUP BY `t0`.`Key` + ) AS `u` +) AS `u0` +GROUP BY `u0`.`Key` """); } @@ -9779,16 +9980,19 @@ public override async Task Group_by_with_having_StartsWith_with_null_parameter_a AssertSql( """ -SELECT `t`.`FullName` +SELECT `u0`.`FullName` FROM ( - SELECT `g`.`FullName` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`FullName` - FROM `Officers` AS `o` -) AS `t` -GROUP BY `t`.`FullName` -HAVING FALSE + SELECT `u`.`FullName`, FALSE AS `c` + FROM ( + SELECT `g`.`FullName` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`FullName` + FROM `Officers` AS `o` + ) AS `u` + GROUP BY `u`.`FullName`, `c` + HAVING `c` +) AS `u0` """); } @@ -9805,7 +10009,7 @@ SELECT FALSE UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -9819,12 +10023,12 @@ public override async Task Select_null_parameter_is_not_null(bool async) SELECT @__p_0 FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT 1 FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT 1 FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -9836,14 +10040,14 @@ public override async Task Where_null_parameter_is_not_null(bool async) """ @__p_0='False' -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE @__p_0 """); } @@ -9854,15 +10058,15 @@ public override async Task OrderBy_StartsWith_with_null_parameter_as_argument(bo AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -ORDER BY `t`.`Nickname` +) AS `u` +ORDER BY `u`.`Nickname` """); } @@ -9872,38 +10076,38 @@ public override async Task OrderBy_Contains_empty_list(bool async) if (SingleStoreTestHelpers.HasPrimitiveCollectionsSupport(Fixture)) { -AssertSql( - """ - SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` - FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` - ) AS `t` - ORDER BY `t`.`SquadId` IN ( - SELECT `i`.`value` - FROM JSON_TABLE('[]', '$[*]' COLUMNS ( - `key` FOR ORDINALITY, - `value` int PATH '$[0]' - )) AS `i` - ) - """); + AssertSql( +""" +SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `t` +ORDER BY `t`.`SquadId` IN ( + SELECT `i`.`value` + FROM JSON_TABLE('[]', '$[*]' COLUMNS ( + `key` FOR ORDINALITY, + `value` int PATH '$[0]' + )) AS `i` +) +"""); } else { -AssertSql( - """ - SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` - FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` - FROM `Gears` AS `g` - UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` - FROM `Officers` AS `o` - ) AS `t` - """); + AssertSql( +""" +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +"""); } } @@ -9915,51 +10119,51 @@ public override async Task Where_with_enum_flags_parameter(bool async) """ @__rank_0='1' (Nullable = true) -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` & @__rank_0) = @__rank_0 +) AS `u` +WHERE CAST(`u`.`Rank` & @__rank_0 AS signed) = @__rank_0 """, // """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` """, // """ @__rank_0='2' (Nullable = true) -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` | @__rank_0) <> @__rank_0 +) AS `u` +WHERE CAST(`u`.`Rank` | @__rank_0 AS signed) <> @__rank_0 """, // """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE FALSE """); } @@ -9970,37 +10174,37 @@ public override async Task FirstOrDefault_navigation_access_entity_equality_in_w AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Cities` AS `c` ON `t`.`AssignedCityName` = `c`.`Name` +) AS `u` +LEFT JOIN `Cities` AS `c` ON `u`.`AssignedCityName` = `c`.`Name` WHERE (`c`.`Name` = ( SELECT `c0`.`Name` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`CityOfBirthName` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`CityOfBirthName` FROM `Officers` AS `o0` - ) AS `t0` - INNER JOIN `Cities` AS `c0` ON `t0`.`CityOfBirthName` = `c0`.`Name` - ORDER BY `t0`.`Nickname` + ) AS `u0` + INNER JOIN `Cities` AS `c0` ON `u0`.`CityOfBirthName` = `c0`.`Name` + ORDER BY `u0`.`Nickname` LIMIT 1)) OR (`c`.`Name` IS NULL AND (( SELECT `c0`.`Name` FROM ( - SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g0`.`Nickname`, `g0`.`CityOfBirthName` FROM `Gears` AS `g0` UNION ALL - SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o0`.`Nickname`, `o0`.`CityOfBirthName` FROM `Officers` AS `o0` - ) AS `t0` - INNER JOIN `Cities` AS `c0` ON `t0`.`CityOfBirthName` = `c0`.`Name` - ORDER BY `t0`.`Nickname` + ) AS `u0` + INNER JOIN `Cities` AS `c0` ON `u0`.`CityOfBirthName` = `c0`.`Name` + ORDER BY `u0`.`Nickname` LIMIT 1) IS NULL)) """); } @@ -10013,41 +10217,41 @@ public override async Task Bitwise_operation_with_non_null_parameter_optimizes_n """ @__ranks_0='134' -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`Rank` & @__ranks_0) <> 0 +) AS `u` +WHERE CAST(`u`.`Rank` & @__ranks_0 AS signed) <> 0 """, // """ @__ranks_0='134' -SELECT (`t`.`Rank` | @__ranks_0) = @__ranks_0 +SELECT CAST(`u`.`Rank` | @__ranks_0 AS signed) = @__ranks_0 FROM ( SELECT `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Rank` FROM `Officers` AS `o` -) AS `t` +) AS `u` """, // """ @__ranks_0='134' -SELECT (`t`.`Rank` | (`t`.`Rank` | (@__ranks_0 | (`t`.`Rank` | @__ranks_0)))) = @__ranks_0 +SELECT CAST(`u`.`Rank` | CAST(`u`.`Rank` | CAST(@__ranks_0 | CAST(`u`.`Rank` | @__ranks_0 AS signed) AS signed) AS signed) AS signed) = @__ranks_0 FROM ( SELECT `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Rank` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -10084,7 +10288,7 @@ public override async Task Bitwise_operation_with_null_arguments(bool async) SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` -WHERE ((`w`.`AmmunitionType` & @__prm_0) <> 0) OR `w`.`AmmunitionType` IS NULL +WHERE (CAST(`w`.`AmmunitionType` & @__prm_0 AS signed) <> 0) OR `w`.`AmmunitionType` IS NULL """, // """ @@ -10092,7 +10296,7 @@ public override async Task Bitwise_operation_with_null_arguments(bool async) SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` -WHERE (`w`.`AmmunitionType` & @__prm_0) = @__prm_0 +WHERE CAST(`w`.`AmmunitionType` & @__prm_0 AS signed) = @__prm_0 """); } @@ -10104,29 +10308,29 @@ public override async Task Logical_operation_with_non_null_parameter_optimizes_n """ @__prm_0='True' -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`HasSoulPatch` <> @__prm_0 +) AS `u` +WHERE `u`.`HasSoulPatch` <> @__prm_0 """, // """ @__prm_0='False' -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE `t`.`HasSoulPatch` <> @__prm_0 +) AS `u` +WHERE `u`.`HasSoulPatch` <> @__prm_0 """); } @@ -10148,23 +10352,20 @@ public override async Task Join_inner_source_custom_projection_followed_by_filte AssertSql( """ SELECT CASE - WHEN `l`.`Name` = 'Locust' THEN TRUE - ELSE NULL -END AS `IsEradicated`, `l`.`CommanderName`, `l`.`Name` + WHEN `l1`.`Name` = 'Locust' THEN TRUE +END AS `IsEradicated`, `l1`.`CommanderName`, `l1`.`Name` FROM ( - SELECT `l0`.`Name` - FROM `LocustLeaders` AS `l0` + SELECT `l`.`Name` + FROM `LocustLeaders` AS `l` UNION ALL - SELECT `l1`.`Name` - FROM `LocustCommanders` AS `l1` -) AS `t` -INNER JOIN `LocustHordes` AS `l` ON `t`.`Name` = `l`.`CommanderName` + SELECT `l0`.`Name` + FROM `LocustCommanders` AS `l0` +) AS `u` +INNER JOIN `LocustHordes` AS `l1` ON `u`.`Name` = `l1`.`CommanderName` WHERE (CASE - WHEN `l`.`Name` = 'Locust' THEN TRUE - ELSE NULL -END <> TRUE) OR (CASE - WHEN `l`.`Name` = 'Locust' THEN TRUE - ELSE NULL + WHEN `l1`.`Name` = 'Locust' THEN TRUE +END = FALSE) OR (CASE + WHEN `l1`.`Name` = 'Locust' THEN TRUE END IS NULL) """); } @@ -10255,16 +10456,16 @@ public override async Task Conditional_expression_with_test_being_simplified_to_ """ @__prm_0='True' -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE CASE - WHEN `t`.`HasSoulPatch` = @__prm_0 THEN TRUE + WHEN `u`.`HasSoulPatch` = @__prm_0 THEN TRUE ELSE FALSE END """); @@ -10280,24 +10481,20 @@ public override async Task Conditional_expression_with_test_being_simplified_to_ @__prm_0='True' @__prm2_1='Marcus' Lancer' (Size = 4000) -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE CASE - WHEN `t`.`HasSoulPatch` = @__prm_0 THEN (( - SELECT `w`.`Name` - FROM `Weapons` AS `w` - WHERE `w`.`Id` = `t`.`SquadId` - LIMIT 1) = @__prm2_1) AND ( + WHEN `u`.`HasSoulPatch` = @__prm_0 THEN ( SELECT `w`.`Name` FROM `Weapons` AS `w` - WHERE `w`.`Id` = `t`.`SquadId` - LIMIT 1) IS NOT NULL + WHERE `w`.`Id` = `u`.`SquadId` + LIMIT 1) = @__prm2_1 ELSE FALSE END """); @@ -10324,7 +10521,7 @@ public override async Task DateTimeOffset_Date_returns_datetime(bool async) """ @__dateTimeOffset_Date_0='0002-03-01T00:00:00.0000000' (DbType = DateTime) -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE CONVERT(`m`.`Timeline`, date) >= @__dateTimeOffset_Date_0 """); @@ -10336,14 +10533,14 @@ public override async Task Conditional_with_conditions_evaluating_to_false_gets_ AssertSql( """ -SELECT `t`.`FullName` +SELECT `u`.`FullName` FROM ( SELECT `g`.`Nickname`, `g`.`CityOfBirthName`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`CityOfBirthName`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -10353,14 +10550,14 @@ public override async Task Conditional_with_conditions_evaluating_to_true_gets_o AssertSql( """ -SELECT `t`.`CityOfBirthName` +SELECT `u`.`CityOfBirthName` FROM ( SELECT `g`.`Nickname`, `g`.`CityOfBirthName`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`CityOfBirthName`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -10377,7 +10574,7 @@ SELECT FALSE UNION ALL SELECT `o`.`Nickname` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -10401,12 +10598,12 @@ public override async Task Group_by_nullable_property_HasValue_and_project_the_g AssertSql( """ -SELECT `t`.`Key` +SELECT `w0`.`Key` FROM ( SELECT `w`.`SynergyWithId` IS NOT NULL AS `Key` FROM `Weapons` AS `w` -) AS `t` -GROUP BY `t`.`Key` +) AS `w0` +GROUP BY `w0`.`Key` """); } @@ -10428,15 +10625,15 @@ public override async Task Checked_context_with_cast_does_not_fail(bool isAsync) AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` -WHERE CAST(`t`.`ThreatLevel` AS unsigned) >= 5 +) AS `u` +WHERE CAST(`u`.`ThreatLevel` AS unsigned) >= 5 """); } @@ -10446,15 +10643,15 @@ public override async Task Checked_context_with_addition_does_not_fail(bool isAs AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` -WHERE CAST(`t`.`ThreatLevel` AS signed) <= (5 + CAST(`t`.`ThreatLevel` AS signed)) +) AS `u` +WHERE CAST(`u`.`ThreatLevel` AS signed) <= (5 + CAST(`u`.`ThreatLevel` AS signed)) """); } @@ -10508,7 +10705,7 @@ public override async Task Where_TimeSpan_Hours(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(hour FROM `m`.`Duration`) = 1 """); @@ -10520,7 +10717,7 @@ public override async Task Where_TimeSpan_Minutes(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(minute FROM `m`.`Duration`) = 2 """); @@ -10532,7 +10729,7 @@ public override async Task Where_TimeSpan_Seconds(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(second FROM `m`.`Duration`) = 3 """); @@ -10544,7 +10741,7 @@ public override async Task Where_TimeSpan_Milliseconds(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE (EXTRACT(microsecond FROM `m`.`Duration`)) DIV (1000) = 456 """); @@ -10556,15 +10753,15 @@ public override async Task Contains_on_collection_of_byte_subquery(bool async) AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` -WHERE `t`.`ThreatLevelByte` IN ( +) AS `u` +WHERE `u`.`ThreatLevelByte` IN ( SELECT `l1`.`ThreatLevelByte` FROM `LocustLeaders` AS `l1` UNION ALL @@ -10580,14 +10777,14 @@ public override async Task Contains_on_collection_of_nullable_byte_subquery(bool AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` WHERE EXISTS ( SELECT 1 FROM ( @@ -10596,8 +10793,8 @@ SELECT 1 UNION ALL SELECT `l2`.`ThreatLevelNullableByte` FROM `LocustCommanders` AS `l2` - ) AS `t0` - WHERE (`t0`.`ThreatLevelNullableByte` = `t`.`ThreatLevelNullableByte`) OR (`t0`.`ThreatLevelNullableByte` IS NULL AND (`t`.`ThreatLevelNullableByte` IS NULL))) + ) AS `u0` + WHERE (`u0`.`ThreatLevelNullableByte` = `u`.`ThreatLevelNullableByte`) OR (`u0`.`ThreatLevelNullableByte` IS NULL AND (`u`.`ThreatLevelNullableByte` IS NULL))) """); } @@ -10607,14 +10804,14 @@ public override async Task Contains_on_collection_of_nullable_byte_subquery_null AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` WHERE EXISTS ( SELECT 1 FROM ( @@ -10623,8 +10820,8 @@ SELECT 1 UNION ALL SELECT `l2`.`ThreatLevelNullableByte` FROM `LocustCommanders` AS `l2` - ) AS `t0` - WHERE `t0`.`ThreatLevelNullableByte` IS NULL) + ) AS `u0` + WHERE `u0`.`ThreatLevelNullableByte` IS NULL) """); } @@ -10634,14 +10831,14 @@ public override async Task Contains_on_collection_of_nullable_byte_subquery_null AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` WHERE EXISTS ( SELECT 1 FROM ( @@ -10650,8 +10847,8 @@ SELECT 1 UNION ALL SELECT `l2`.`ThreatLevelNullableByte` FROM `LocustCommanders` AS `l2` - ) AS `t0` - WHERE `t0`.`ThreatLevelNullableByte` IS NULL) + ) AS `u0` + WHERE `u0`.`ThreatLevelNullableByte` IS NULL) """); } @@ -10661,7 +10858,7 @@ public override async Task Contains_on_byte_array_property_using_byte_column(boo AssertSql( """ -SELECT `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM `Squads` AS `s` CROSS JOIN ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` @@ -10669,8 +10866,8 @@ CROSS JOIN ( UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` -WHERE LOCATE(UNHEX(HEX(`t`.`ThreatLevelByte`)), `s`.`Banner`) > 0 +) AS `u` +WHERE LOCATE(UNHEX(HEX(`u`.`ThreatLevelByte`)), `s`.`Banner`) > 0 """); } @@ -10681,31 +10878,31 @@ public override async Task Subquery_projecting_non_nullable_scalar_contains_non_ AssertSql( """ -SELECT `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` +SELECT `u2`.`Nickname`, `u2`.`SquadId`, `u2`.`AssignedCityName`, `u2`.`CityOfBirthName`, `u2`.`FullName`, `u2`.`HasSoulPatch`, `u2`.`LeaderNickname`, `u2`.`LeaderSquadId`, `u2`.`Rank`, `u2`.`Discriminator` FROM ( SELECT `l`.`ThreatLevelByte` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`ThreatLevelByte` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` JOIN LATERAL ( - SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` - ) AS `t0` - WHERE `t`.`ThreatLevelByte` IN ( + ) AS `u0` + WHERE `u`.`ThreatLevelByte` IN ( SELECT `l1`.`ThreatLevelByte` FROM `LocustLeaders` AS `l1` UNION ALL SELECT `l2`.`ThreatLevelByte` FROM `LocustCommanders` AS `l2` ) -) AS `t1` ON TRUE +) AS `u2` ON TRUE """); } @@ -10716,31 +10913,31 @@ public override async Task Subquery_projecting_non_nullable_scalar_contains_non_ AssertSql( """ -SELECT `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` +SELECT `u2`.`Nickname`, `u2`.`SquadId`, `u2`.`AssignedCityName`, `u2`.`CityOfBirthName`, `u2`.`FullName`, `u2`.`HasSoulPatch`, `u2`.`LeaderNickname`, `u2`.`LeaderSquadId`, `u2`.`Rank`, `u2`.`Discriminator` FROM ( SELECT `l`.`ThreatLevelByte` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`ThreatLevelByte` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` JOIN LATERAL ( - SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` - ) AS `t0` - WHERE `t`.`ThreatLevelByte` NOT IN ( + ) AS `u0` + WHERE `u`.`ThreatLevelByte` NOT IN ( SELECT `l1`.`ThreatLevelByte` FROM `LocustLeaders` AS `l1` UNION ALL SELECT `l2`.`ThreatLevelByte` FROM `LocustCommanders` AS `l2` ) -) AS `t1` ON TRUE +) AS `u2` ON TRUE """); } @@ -10750,23 +10947,23 @@ public override async Task Subquery_projecting_nullable_scalar_contains_nullable AssertSql( """ -SELECT `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` +SELECT `u2`.`Nickname`, `u2`.`SquadId`, `u2`.`AssignedCityName`, `u2`.`CityOfBirthName`, `u2`.`FullName`, `u2`.`HasSoulPatch`, `u2`.`LeaderNickname`, `u2`.`LeaderSquadId`, `u2`.`Rank`, `u2`.`Discriminator` FROM ( SELECT `l`.`ThreatLevelNullableByte` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`ThreatLevelNullableByte` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` JOIN LATERAL ( - SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` - ) AS `t0` + ) AS `u0` WHERE EXISTS ( SELECT 1 FROM ( @@ -10775,9 +10972,9 @@ SELECT 1 UNION ALL SELECT `l2`.`ThreatLevelNullableByte` FROM `LocustCommanders` AS `l2` - ) AS `t2` - WHERE (`t2`.`ThreatLevelNullableByte` = `t`.`ThreatLevelNullableByte`) OR (`t2`.`ThreatLevelNullableByte` IS NULL AND (`t`.`ThreatLevelNullableByte` IS NULL))) -) AS `t1` ON TRUE + ) AS `u1` + WHERE (`u1`.`ThreatLevelNullableByte` = `u`.`ThreatLevelNullableByte`) OR (`u1`.`ThreatLevelNullableByte` IS NULL AND (`u`.`ThreatLevelNullableByte` IS NULL))) +) AS `u2` ON TRUE """); } @@ -10787,23 +10984,23 @@ public override async Task Subquery_projecting_nullable_scalar_contains_nullable AssertSql( """ -SELECT `t1`.`Nickname`, `t1`.`SquadId`, `t1`.`AssignedCityName`, `t1`.`CityOfBirthName`, `t1`.`FullName`, `t1`.`HasSoulPatch`, `t1`.`LeaderNickname`, `t1`.`LeaderSquadId`, `t1`.`Rank`, `t1`.`Discriminator` +SELECT `u2`.`Nickname`, `u2`.`SquadId`, `u2`.`AssignedCityName`, `u2`.`CityOfBirthName`, `u2`.`FullName`, `u2`.`HasSoulPatch`, `u2`.`LeaderNickname`, `u2`.`LeaderSquadId`, `u2`.`Rank`, `u2`.`Discriminator` FROM ( SELECT `l`.`ThreatLevelNullableByte` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`ThreatLevelNullableByte` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` JOIN LATERAL ( - SELECT `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` + SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` - ) AS `t0` + ) AS `u0` WHERE NOT EXISTS ( SELECT 1 FROM ( @@ -10812,9 +11009,9 @@ SELECT 1 UNION ALL SELECT `l2`.`ThreatLevelNullableByte` FROM `LocustCommanders` AS `l2` - ) AS `t2` - WHERE (`t2`.`ThreatLevelNullableByte` = `t`.`ThreatLevelNullableByte`) OR (`t2`.`ThreatLevelNullableByte` IS NULL AND (`t`.`ThreatLevelNullableByte` IS NULL))) -) AS `t1` ON TRUE + ) AS `u1` + WHERE (`u1`.`ThreatLevelNullableByte` = `u`.`ThreatLevelNullableByte`) OR (`u1`.`ThreatLevelNullableByte` IS NULL AND (`u`.`ThreatLevelNullableByte` IS NULL))) +) AS `u2` ON TRUE """); } @@ -10840,15 +11037,15 @@ public override async Task Enum_flags_closure_typed_as_underlying_type_generates """ @__prm_0='133' -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (@__prm_0 & `t`.`Rank`) = `t`.`Rank` +) AS `u` +WHERE CAST(@__prm_0 & `u`.`Rank` AS signed) = `u`.`Rank` """); } @@ -10860,15 +11057,15 @@ public override async Task Enum_flags_closure_typed_as_different_type_generates_ """ @__prm_0='5' -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (@__prm_0 & CAST(`t`.`Rank` AS signed)) = CAST(`t`.`Rank` AS signed) +) AS `u` +WHERE CAST(@__prm_0 & CAST(`u`.`Rank` AS signed) AS signed) = CAST(`u`.`Rank` AS signed) """); } @@ -10880,15 +11077,15 @@ public override async Task Constant_enum_with_same_underlying_value_as_previousl """ @__p_0='1' -SELECT `t`.`Rank` & 1 +SELECT CAST(`u`.`Rank` & 1 AS signed) FROM ( SELECT `g`.`Nickname`, `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`Rank` FROM `Officers` AS `o` -) AS `t` -ORDER BY `t`.`Nickname` +) AS `u` +ORDER BY `u`.`Nickname` LIMIT @__p_0 """); } @@ -10962,8 +11159,8 @@ LEFT JOIN ( UNION ALL SELECT `o`.`CityOfBirthName`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` ON `w`.`OwnerFullName` = `t`.`FullName` -LEFT JOIN `Cities` AS `c` ON `t`.`CityOfBirthName` = `c`.`Name` +) AS `u` ON `w`.`OwnerFullName` = `u`.`FullName` +LEFT JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` GROUP BY `c`.`Name`, `c`.`Location` ORDER BY `c`.`Location` """); @@ -10975,16 +11172,16 @@ public override async Task SelectMany_predicate_with_non_equality_comparison_con AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Weapons` AS `w` ON (`t`.`FullName` <> `w`.`OwnerFullName`) OR `w`.`OwnerFullName` IS NULL -ORDER BY `t`.`Nickname`, `w`.`Id` +) AS `u` +INNER JOIN `Weapons` AS `w` ON (`u`.`FullName` <> `w`.`OwnerFullName`) OR `w`.`OwnerFullName` IS NULL +ORDER BY `u`.`Nickname`, `w`.`Id` """); } @@ -10994,16 +11191,16 @@ public override async Task SelectMany_predicate_with_non_equality_comparison_Def AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Weapons` AS `w` ON (`t`.`FullName` <> `w`.`OwnerFullName`) OR `w`.`OwnerFullName` IS NULL -ORDER BY `t`.`Nickname`, `w`.`Id` +) AS `u` +LEFT JOIN `Weapons` AS `w` ON (`u`.`FullName` <> `w`.`OwnerFullName`) OR `w`.`OwnerFullName` IS NULL +ORDER BY `u`.`Nickname`, `w`.`Id` """); } @@ -11014,20 +11211,20 @@ public override async Task SelectMany_predicate_after_navigation_with_non_equali AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`AmmunitionType`, `t0`.`IsAutomatic`, `t0`.`Name`, `t0`.`OwnerFullName`, `t0`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `s`.`Id`, `s`.`AmmunitionType`, `s`.`IsAutomatic`, `s`.`Name`, `s`.`OwnerFullName`, `s`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM `Weapons` AS `w` LEFT JOIN `Weapons` AS `w0` ON `w`.`SynergyWithId` = `w0`.`Id` -) AS `t0` ON (`t`.`FullName` <> `t0`.`OwnerFullName`) OR `t0`.`OwnerFullName` IS NULL -ORDER BY `t`.`Nickname`, `t0`.`Id` +) AS `s` ON (`u`.`FullName` <> `s`.`OwnerFullName`) OR `s`.`OwnerFullName` IS NULL +ORDER BY `u`.`Nickname`, `s`.`Id` """); } @@ -11044,8 +11241,8 @@ public override async Task SelectMany_without_result_selector_and_non_equality_c UNION ALL SELECT `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Weapons` AS `w` ON (`t`.`FullName` <> `w`.`OwnerFullName`) OR `w`.`OwnerFullName` IS NULL +) AS `u` +LEFT JOIN `Weapons` AS `w` ON (`u`.`FullName` <> `w`.`OwnerFullName`) OR `w`.`OwnerFullName` IS NULL """); } @@ -11055,16 +11252,16 @@ public override async Task Filtered_collection_projection_with_order_comparison_ AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Weapons` AS `w` ON (`t`.`FullName` = `w`.`OwnerFullName`) AND (`t`.`SquadId` < `w`.`Id`) -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `u` +LEFT JOIN `Weapons` AS `w` ON (`u`.`FullName` = `w`.`OwnerFullName`) AND (`u`.`SquadId` < `w`.`Id`) +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -11074,16 +11271,16 @@ public override async Task Filtered_collection_projection_with_order_comparison_ AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Weapons` AS `w` ON (`t`.`FullName` = `w`.`OwnerFullName`) AND (`t`.`SquadId` <= `w`.`Id`) -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `u` +LEFT JOIN `Weapons` AS `w` ON (`u`.`FullName` = `w`.`OwnerFullName`) AND (`u`.`SquadId` <= `w`.`Id`) +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -11093,16 +11290,16 @@ public override async Task Filtered_collection_projection_with_order_comparison_ AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Weapons` AS `w` ON (`t`.`FullName` = `w`.`OwnerFullName`) AND (`t`.`SquadId` >= `w`.`Id`) -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `u` +LEFT JOIN `Weapons` AS `w` ON (`u`.`FullName` = `w`.`OwnerFullName`) AND (`u`.`SquadId` >= `w`.`Id`) +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -11112,22 +11309,22 @@ public override async Task SelectMany_predicate_with_non_equality_comparison_wit AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`AmmunitionType`, `t0`.`IsAutomatic`, `t0`.`Name`, `t0`.`OwnerFullName`, `t0`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` JOIN LATERAL ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM `Weapons` AS `w` - WHERE (`w`.`OwnerFullName` <> `t`.`FullName`) OR `w`.`OwnerFullName` IS NULL + WHERE (`w`.`OwnerFullName` <> `u`.`FullName`) OR `w`.`OwnerFullName` IS NULL ORDER BY `w`.`Id` LIMIT 3 -) AS `t0` ON TRUE -ORDER BY `t`.`Nickname`, `t0`.`Id` +) AS `w0` ON TRUE +ORDER BY `u`.`Nickname`, `w0`.`Id` """); } @@ -11141,16 +11338,16 @@ public override async Task FirstOrDefault_over_int_compared_to_zero(bool async) SELECT `s`.`Name` FROM `Squads` AS `s` WHERE (`s`.`Name` = 'Delta') AND (COALESCE(( - SELECT `t`.`SquadId` + SELECT `u`.`SquadId` FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`SquadId`, `g`.`FullName`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`SquadId`, `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t` - WHERE (`s`.`Id` = `t`.`SquadId`) AND (`t`.`HasSoulPatch` = TRUE) - ORDER BY `t`.`FullName` + ) AS `u` + WHERE (`s`.`Id` = `u`.`SquadId`) AND (`u`.`HasSoulPatch` = TRUE) + ORDER BY `u`.`FullName` LIMIT 1), 0) <> 0) """); } @@ -11161,23 +11358,23 @@ public override async Task Correlated_collection_with_inner_collection_reference AssertSql( """ -SELECT `t`.`FullName`, `t`.`Nickname`, `t`.`SquadId`, `t0`.`ReportName`, `t0`.`OfficerName`, `t0`.`Nickname`, `t0`.`SquadId` +SELECT `u`.`FullName`, `u`.`Nickname`, `u`.`SquadId`, `u1`.`ReportName`, `u1`.`OfficerName`, `u1`.`Nickname`, `u1`.`SquadId` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN LATERAL ( - SELECT `t1`.`FullName` AS `ReportName`, `t`.`FullName` AS `OfficerName`, `t1`.`Nickname`, `t1`.`SquadId` + SELECT `u0`.`FullName` AS `ReportName`, `u`.`FullName` AS `OfficerName`, `u0`.`Nickname`, `u0`.`SquadId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`LeaderNickname`, `g`.`LeaderSquadId` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`FullName`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId` FROM `Officers` AS `o0` - ) AS `t1` - WHERE (`t`.`Nickname` = `t1`.`LeaderNickname`) AND (`t`.`SquadId` = `t1`.`LeaderSquadId`) -) AS `t0` ON TRUE -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` + ) AS `u0` + WHERE (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +) AS `u1` ON TRUE +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u1`.`Nickname` """); } @@ -11187,27 +11384,27 @@ public override async Task Accessing_derived_property_using_hard_and_soft_cast(b AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` -WHERE (`t`.`Discriminator` = 'LocustCommander') AND ((`t`.`HighCommandId` <> 0) OR `t`.`HighCommandId` IS NULL) +) AS `u` +WHERE (`u`.`Discriminator` = 'LocustCommander') AND ((`u`.`HighCommandId` <> 0) OR `u`.`HighCommandId` IS NULL) """, // """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` -WHERE (`t`.`Discriminator` = 'LocustCommander') AND ((`t`.`HighCommandId` <> 0) OR `t`.`HighCommandId` IS NULL) +) AS `u` +WHERE (`u`.`Discriminator` = 'LocustCommander') AND ((`u`.`HighCommandId` <> 0) OR `u`.`HighCommandId` IS NULL) """); } @@ -11217,22 +11414,22 @@ public override async Task Cast_to_derived_followed_by_include_and_FirstOrDefaul AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`DefeatedByNickname` = `t0`.`Nickname`) AND (`t`.`DefeatedBySquadId` = `t0`.`SquadId`) -WHERE `t`.`Name` LIKE '%Queen%' +) AS `u0` ON (`u`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`u`.`DefeatedBySquadId` = `u0`.`SquadId`) +WHERE `u`.`Name` LIKE '%Queen%' LIMIT 1 """); } @@ -11243,24 +11440,24 @@ public override async Task Correlated_collection_take(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `c`.`Name`, `t0`.`Id`, `t0`.`AmmunitionType`, `t0`.`IsAutomatic`, `t0`.`Name`, `t0`.`OwnerFullName`, `t0`.`SynergyWithId`, `c`.`Location`, `c`.`Nation` +SELECT `u`.`Nickname`, `u`.`SquadId`, `c`.`Name`, `w1`.`Id`, `w1`.`AmmunitionType`, `w1`.`IsAutomatic`, `w1`.`Name`, `w1`.`OwnerFullName`, `w1`.`SynergyWithId`, `c`.`Location`, `c`.`Nation` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`CityOfBirthName`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`CityOfBirthName`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Cities` AS `c` ON `t`.`CityOfBirthName` = `c`.`Name` +) AS `u` +INNER JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`AmmunitionType`, `t1`.`IsAutomatic`, `t1`.`Name`, `t1`.`OwnerFullName`, `t1`.`SynergyWithId` + SELECT `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` FROM ( SELECT `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, ROW_NUMBER() OVER(PARTITION BY `w`.`OwnerFullName` ORDER BY `w`.`Id`) AS `row` FROM `Weapons` AS `w` - ) AS `t1` - WHERE `t1`.`row` <= 10 -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `c`.`Name` + ) AS `w0` + WHERE `w0`.`row` <= 10 +) AS `w1` ON `u`.`FullName` = `w1`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `c`.`Name` """); } @@ -11308,22 +11505,22 @@ public override async Task Composite_key_entity_equal(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` CROSS JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` -WHERE (`t`.`Nickname` = `t0`.`Nickname`) AND (`t`.`SquadId` = `t0`.`SquadId`) +) AS `u0` +WHERE (`u`.`Nickname` = `u0`.`Nickname`) AND (`u`.`SquadId` = `u0`.`SquadId`) """); } @@ -11333,22 +11530,22 @@ public override async Task Composite_key_entity_not_equal(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` CROSS JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` -WHERE (`t`.`Nickname` <> `t0`.`Nickname`) OR (`t`.`SquadId` <> `t0`.`SquadId`) +) AS `u0` +WHERE (`u`.`Nickname` <> `u0`.`Nickname`) OR (`u`.`SquadId` <> `u0`.`SquadId`) """); } @@ -11358,19 +11555,19 @@ public override async Task Composite_key_entity_equal_null(bool async) AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, `l`.`DefeatedByNickname`, `l`.`DefeatedBySquadId`, `l`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`DefeatedByNickname` = `t0`.`Nickname`) AND (`t`.`DefeatedBySquadId` = `t0`.`SquadId`) -WHERE `t0`.`Nickname` IS NULL OR (`t0`.`SquadId` IS NULL) +) AS `u0` ON (`u`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`u`.`DefeatedBySquadId` = `u0`.`SquadId`) +WHERE `u0`.`Nickname` IS NULL OR (`u0`.`SquadId` IS NULL) """); } @@ -11380,19 +11577,19 @@ public override async Task Composite_key_entity_not_equal_null(bool async) AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, `l`.`DefeatedByNickname`, `l`.`DefeatedBySquadId`, `l`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`DefeatedByNickname` = `t0`.`Nickname`) AND (`t`.`DefeatedBySquadId` = `t0`.`SquadId`) -WHERE `t0`.`Nickname` IS NOT NULL AND (`t0`.`SquadId` IS NOT NULL) +) AS `u0` ON (`u`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`u`.`DefeatedBySquadId` = `u0`.`SquadId`) +WHERE `u0`.`Nickname` IS NOT NULL AND (`u0`.`SquadId` IS NOT NULL) """); } @@ -11402,7 +11599,7 @@ public override async Task Projecting_property_converted_to_nullable_with_compar AssertSql( """ -SELECT `t`.`Note`, `t`.`GearNickName` IS NOT NULL, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`HasSoulPatch` +SELECT `t`.`Note`, `t`.`GearNickName` IS NOT NULL, `u`.`Nickname`, `u`.`SquadId`, `u`.`HasSoulPatch` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` @@ -11410,10 +11607,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`SquadId` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`SquadId` END = 1 """); } @@ -11424,7 +11620,7 @@ public override async Task Projecting_property_converted_to_nullable_with_additi AssertSql( """ -SELECT `t`.`Note`, `t`.`GearNickName` IS NOT NULL, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`HasSoulPatch` +SELECT `t`.`Note`, `t`.`GearNickName` IS NOT NULL, `u`.`Nickname`, `u`.`SquadId`, `u`.`HasSoulPatch` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` @@ -11432,10 +11628,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE (CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`SquadId` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`SquadId` END + 1) = 2 """); } @@ -11447,8 +11642,7 @@ public override async Task Projecting_property_converted_to_nullable_with_additi AssertSql( """ SELECT `t`.`Note`, CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`SquadId` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`SquadId` END + 1 AS `Value` FROM `Tags` AS `t` LEFT JOIN ( @@ -11457,10 +11651,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`Nickname` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`Nickname` END IS NOT NULL """); } @@ -11473,8 +11666,7 @@ public override async Task Projecting_property_converted_to_nullable_with_condit """ SELECT CASE WHEN (`t`.`Note` <> 'K.I.A.') OR `t`.`Note` IS NULL THEN CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`SquadId` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`SquadId` END ELSE -1 END @@ -11485,7 +11677,7 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) """); } @@ -11496,8 +11688,7 @@ public override async Task Projecting_property_converted_to_nullable_with_functi AssertSql( """ SELECT SUBSTRING(CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`Nickname` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`Nickname` END, 0 + 1, 3) FROM `Tags` AS `t` LEFT JOIN ( @@ -11506,7 +11697,7 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) """); } @@ -11517,8 +11708,7 @@ public override async Task Projecting_property_converted_to_nullable_with_functi AssertSql( """ SELECT `t`.`Note`, SUBSTRING(`t`.`Note`, 0 + 1, CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`SquadId` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`SquadId` END) AS `Function` FROM `Tags` AS `t` LEFT JOIN ( @@ -11527,10 +11717,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`Nickname` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`Nickname` END IS NOT NULL """); } @@ -11542,14 +11731,11 @@ public override async Task Projecting_property_converted_to_nullable_into_elemen AssertSql( """ SELECT CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN CHAR_LENGTH(`t0`.`Nickname`) - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN CHAR_LENGTH(`u`.`Nickname`) END, CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`SquadId` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`SquadId` END, CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`SquadId` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`SquadId` END + 1 FROM `Tags` AS `t` LEFT JOIN ( @@ -11558,10 +11744,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`Nickname` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`Nickname` END IS NOT NULL ORDER BY `t`.`Note` """); @@ -11574,8 +11759,7 @@ public override async Task Projecting_property_converted_to_nullable_into_member AssertSql( """ SELECT CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`SquadId` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`SquadId` END AS `Id` FROM `Tags` AS `t` LEFT JOIN ( @@ -11584,10 +11768,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`Nickname` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`Nickname` END IS NOT NULL ORDER BY `t`.`Note` """); @@ -11600,14 +11783,11 @@ public override async Task Projecting_property_converted_to_nullable_into_new_ar AssertSql( """ SELECT CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN CHAR_LENGTH(`t0`.`Nickname`) - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN CHAR_LENGTH(`u`.`Nickname`) END, CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`SquadId` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`SquadId` END, CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`SquadId` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`SquadId` END + 1 FROM `Tags` AS `t` LEFT JOIN ( @@ -11616,10 +11796,9 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`Nickname` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`Nickname` END IS NOT NULL ORDER BY `t`.`Note` """); @@ -11639,13 +11818,11 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`Nickname` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`Nickname` END IS NOT NULL AND NOT (CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`HasSoulPatch` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`HasSoulPatch` END) ORDER BY `t`.`Note` """); @@ -11657,17 +11834,17 @@ public override async Task Projecting_property_converted_to_nullable_into_member AssertSql( """ -SELECT `t`.`Nickname` +SELECT `u`.`Nickname` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`CityOfBirthName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`CityOfBirthName` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) -WHERE (EXTRACT(month FROM `t0`.`IssueDate`) <> 5) OR EXTRACT(month FROM `t0`.`IssueDate`) IS NULL -ORDER BY `t`.`Nickname` +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) +WHERE (EXTRACT(month FROM `t`.`IssueDate`) <> 5) OR EXTRACT(month FROM `t`.`IssueDate`) IS NULL +ORDER BY `u`.`Nickname` """); } @@ -11677,7 +11854,7 @@ public override async Task Projecting_property_converted_to_nullable_and_use_it_ AssertSql( """ -SELECT `t`.`Note`, `t`.`GearNickName` IS NOT NULL, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`HasSoulPatch` +SELECT `t`.`Note`, `t`.`GearNickName` IS NOT NULL, `u`.`Nickname`, `u`.`SquadId`, `u`.`HasSoulPatch` FROM `Tags` AS `t` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` @@ -11685,14 +11862,12 @@ LEFT JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`GearNickName` = `t0`.`Nickname`) AND (`t`.`GearSquadId` = `t0`.`SquadId`) +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) WHERE CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`Nickname` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`Nickname` END IS NOT NULL ORDER BY CASE - WHEN `t`.`GearNickName` IS NOT NULL THEN `t0`.`SquadId` - ELSE NULL + WHEN `t`.`GearNickName` IS NOT NULL THEN `u`.`SquadId` END, `t`.`Note` """); } @@ -11703,7 +11878,7 @@ public override async Task Where_DateOnly_Year(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(year FROM `m`.`Date`) = 1990 """); @@ -11715,7 +11890,7 @@ public override async Task Where_DateOnly_Month(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(month FROM `m`.`Date`) = 11 """); @@ -11727,7 +11902,7 @@ public override async Task Where_DateOnly_Day(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(day FROM `m`.`Date`) = 10 """); @@ -11739,7 +11914,7 @@ public override async Task Where_DateOnly_DayOfYear(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE DAYOFYEAR(`m`.`Date`) = 314 """); @@ -11751,7 +11926,7 @@ public override async Task Where_DateOnly_DayOfWeek(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE (DAYOFWEEK(`m`.`Date`) - 1) = 6 """); @@ -11763,7 +11938,7 @@ public override async Task Where_DateOnly_AddYears(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE DATE_ADD(`m`.`Date`, INTERVAL CAST(3 AS signed) year) = '1993-11-10' """); @@ -11775,7 +11950,7 @@ public override async Task Where_DateOnly_AddMonths(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE DATE_ADD(`m`.`Date`, INTERVAL CAST(3 AS signed) month) = '1991-02-10' """); @@ -11787,7 +11962,7 @@ public override async Task Where_DateOnly_AddDays(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE DATE_ADD(`m`.`Date`, INTERVAL CAST(3 AS signed) day) = '1990-11-13' """); @@ -11799,7 +11974,7 @@ public override async Task Where_TimeOnly_Hour(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(hour FROM `m`.`Time`) = 10 """); @@ -11811,7 +11986,7 @@ public override async Task Where_TimeOnly_Minute(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(minute FROM `m`.`Time`) = 15 """); @@ -11823,7 +11998,7 @@ public override async Task Where_TimeOnly_Second(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(second FROM `m`.`Time`) = 50 """); @@ -11835,7 +12010,7 @@ public override async Task Where_TimeOnly_Millisecond(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE (EXTRACT(microsecond FROM `m`.`Time`)) DIV (1000) = 500 """); @@ -11847,7 +12022,7 @@ public override async Task Where_TimeOnly_AddHours(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE (ADDTIME(`m`.`Time`, "03:00:00")) = '13:15:50.5':>time(6) """); @@ -11859,7 +12034,7 @@ public override async Task Where_TimeOnly_AddMinutes(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE (ADDTIME(`m`.`Time`, "00:03:00")) = '10:18:50.5':>time(6) """); @@ -11871,7 +12046,7 @@ public override async Task Where_TimeOnly_Add_TimeSpan(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE (ADDTIME(`m`.`Time`, '03:00:00')) = '13:15:50.5':>time(6) """); @@ -11883,7 +12058,7 @@ public override async Task Where_TimeOnly_IsBetween(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE (`m`.`Time` >= '10:00:00') & (`m`.`Time` < '11:00:00') """); @@ -11895,7 +12070,7 @@ public override async Task Where_TimeOnly_subtract_TimeOnly(bool async) AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE (ADDTIME(`m`.`Time`, "-10:00:00")) = '00:15:50.5':>time(6) """); @@ -11907,17 +12082,17 @@ public override async Task Project_navigation_defined_on_base_from_entity_with_i AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`GearNickName`, `t0`.`GearSquadId`, `t0`.`IssueDate`, `t0`.`Note`, `t0`.`Id` IS NULL AS `IsNull`, `c`.`Name`, `c`.`Location`, `c`.`Nation`, `c`.`Name` IS NULL AS `IsNull`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `s`.`Id` IS NULL AS `IsNull` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note`, `t`.`Id` IS NULL AS `IsNull`, `c`.`Name`, `c`.`Location`, `c`.`Nation`, `c`.`Name` IS NULL AS `IsNull`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `s`.`Id` IS NULL AS `IsNull` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) -LEFT JOIN `Cities` AS `c` ON `t`.`CityOfBirthName` = `c`.`Name` -LEFT JOIN `Squads` AS `s` ON `t`.`SquadId` = `s`.`Id` +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) +LEFT JOIN `Cities` AS `c` ON `u`.`CityOfBirthName` = `c`.`Name` +LEFT JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` """); } @@ -11927,23 +12102,23 @@ public override async Task Project_navigation_defined_on_derived_from_entity_wit AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `t0`.`Nickname` IS NULL OR (`t0`.`SquadId` IS NULL) AS `IsNull`, `l`.`Id`, `l`.`CapitalName`, `l`.`Name`, `l`.`ServerAddress`, `l`.`CommanderName`, `l`.`Eradicated`, `l`.`Id` IS NULL AS `IsNull`, `l0`.`Id`, `l0`.`IsOperational`, `l0`.`Name`, `l0`.`Id` IS NULL AS `IsNull` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u0`.`Nickname` IS NULL OR (`u0`.`SquadId` IS NULL) AS `IsNull`, `l1`.`Id`, `l1`.`CapitalName`, `l1`.`Name`, `l1`.`ServerAddress`, `l1`.`CommanderName`, `l1`.`Eradicated`, `l1`.`Id` IS NULL AS `IsNull`, `l2`.`Id`, `l2`.`IsOperational`, `l2`.`Name`, `l2`.`Id` IS NULL AS `IsNull` FROM ( - SELECT `l1`.`Name`, `l1`.`LocustHordeId`, `l1`.`ThreatLevel`, `l1`.`ThreatLevelByte`, `l1`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` - FROM `LocustLeaders` AS `l1` + SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` + FROM `LocustLeaders` AS `l` UNION ALL - SELECT `l2`.`Name`, `l2`.`LocustHordeId`, `l2`.`ThreatLevel`, `l2`.`ThreatLevelByte`, `l2`.`ThreatLevelNullableByte`, `l2`.`DefeatedByNickname`, `l2`.`DefeatedBySquadId`, `l2`.`HighCommandId`, 'LocustCommander' AS `Discriminator` - FROM `LocustCommanders` AS `l2` -) AS `t` + SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` + FROM `LocustCommanders` AS `l0` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`DefeatedByNickname` = `t0`.`Nickname`) AND (`t`.`DefeatedBySquadId` = `t0`.`SquadId`) -LEFT JOIN `LocustHordes` AS `l` ON `t`.`Name` = `l`.`CommanderName` -LEFT JOIN `LocustHighCommands` AS `l0` ON `t`.`HighCommandId` = `l0`.`Id` +) AS `u0` ON (`u`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`u`.`DefeatedBySquadId` = `u0`.`SquadId`) +LEFT JOIN `LocustHordes` AS `l1` ON `u`.`Name` = `l1`.`CommanderName` +LEFT JOIN `LocustHighCommands` AS `l2` ON `u`.`HighCommandId` = `l2`.`Id` """); } @@ -11956,33 +12131,33 @@ public override async Task Join_entity_with_itself_grouped_by_key_followed_by_in @__p_1='10' @__p_0='0' -SELECT `t2`.`Nickname`, `t2`.`SquadId`, `t2`.`AssignedCityName`, `t2`.`CityOfBirthName`, `t2`.`FullName`, `t2`.`HasSoulPatch`, `t2`.`LeaderNickname`, `t2`.`LeaderSquadId`, `t2`.`Rank`, `t2`.`Discriminator`, `t2`.`HasSoulPatch0`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `s`.`Nickname`, `s`.`SquadId`, `s`.`AssignedCityName`, `s`.`CityOfBirthName`, `s`.`FullName`, `s`.`HasSoulPatch`, `s`.`LeaderNickname`, `s`.`LeaderSquadId`, `s`.`Rank`, `s`.`Discriminator`, `s`.`HasSoulPatch0`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( - SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`HasSoulPatch` AS `HasSoulPatch0` + SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u1`.`HasSoulPatch` AS `HasSoulPatch0` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` - ) AS `t` + ) AS `u` INNER JOIN ( - SELECT MIN(CHAR_LENGTH(`t1`.`Nickname`)) AS `c`, `t1`.`HasSoulPatch` + SELECT MIN(CHAR_LENGTH(`u0`.`Nickname`)) AS `c`, `u0`.`HasSoulPatch` FROM ( SELECT `g0`.`Nickname`, `g0`.`HasSoulPatch` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`HasSoulPatch` FROM `Officers` AS `o0` - ) AS `t1` - WHERE `t1`.`Nickname` <> 'Dom' - GROUP BY `t1`.`HasSoulPatch` - ) AS `t0` ON CHAR_LENGTH(`t`.`Nickname`) = `t0`.`c` - ORDER BY `t`.`Nickname` + ) AS `u0` + WHERE `u0`.`Nickname` <> 'Dom' + GROUP BY `u0`.`HasSoulPatch` + ) AS `u1` ON CHAR_LENGTH(`u`.`Nickname`) = `u1`.`c` + ORDER BY `u`.`Nickname` LIMIT @__p_1 OFFSET @__p_0 -) AS `t2` -LEFT JOIN `Weapons` AS `w` ON `t2`.`FullName` = `w`.`OwnerFullName` -ORDER BY `t2`.`Nickname`, `t2`.`SquadId`, `t2`.`HasSoulPatch0` +) AS `s` +LEFT JOIN `Weapons` AS `w` ON `s`.`FullName` = `w`.`OwnerFullName` +ORDER BY `s`.`Nickname`, `s`.`SquadId`, `s`.`HasSoulPatch0` """); } @@ -12013,17 +12188,17 @@ FROM JSON_TABLE('[false,true]', '$[*]' COLUMNS ( } else { - AssertSql( + AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`HasSoulPatch` = TRUE) AND `t`.`HasSoulPatch` IN (FALSE, TRUE) +) AS `u` +WHERE (`u`.`HasSoulPatch` = TRUE) AND `u`.`HasSoulPatch` IN (FALSE, TRUE) """); } } @@ -12055,21 +12230,35 @@ FROM JSON_TABLE('[false,true]', '$[*]' COLUMNS ( } else { - AssertSql( + AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -WHERE (`t`.`HasSoulPatch` = TRUE) AND `t`.`HasSoulPatch` IN (FALSE, TRUE) +) AS `u` +WHERE (`u`.`HasSoulPatch` = TRUE) AND `u`.`HasSoulPatch` IN (FALSE, TRUE) """); } } + public override async Task Parameter_used_multiple_times_take_appropriate_inferred_type_mapping(bool async) + { + await base.Parameter_used_multiple_times_take_appropriate_inferred_type_mapping(async); + + AssertSql( +""" +@__place_0='Ephyra's location' (Size = 4000) + +SELECT `c`.`Name`, `c`.`Location`, `c`.`Nation` +FROM `Cities` AS `c` +WHERE ((`c`.`Nation` = @__place_0) OR (`c`.`Location` = @__place_0)) OR (`c`.`Location` = @__place_0) +"""); + } + public override async Task Enum_matching_take_value_gets_different_type_mapping(bool async) { await base.Enum_matching_take_value_gets_different_type_mapping(async); @@ -12079,15 +12268,15 @@ public override async Task Enum_matching_take_value_gets_different_type_mapping( @__value_1='1' @__p_0='1' -SELECT `t`.`Rank` & @__value_1 +SELECT CAST(`u`.`Rank` & @__value_1 AS signed) FROM ( SELECT `g`.`Nickname`, `g`.`Rank` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`Rank` FROM `Officers` AS `o` -) AS `t` -ORDER BY `t`.`Nickname` +) AS `u` +ORDER BY `u`.`Nickname` LIMIT @__p_0 """); } @@ -12100,19 +12289,19 @@ public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_th """ @__prm_0='1' -SELECT `t`.`Nickname`, `t`.`FullName`, `t0`.`Id` IS NOT NULL AS `Collection` +SELECT `u`.`Nickname`, `u`.`FullName`, `w0`.`Id` IS NOT NULL AS `Collection` FROM ( SELECT `g`.`Nickname`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `w`.`Id`, `w`.`OwnerFullName` FROM `Weapons` AS `w` WHERE `w`.`Id` > @__prm_0 -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` +) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` """); } @@ -12122,25 +12311,25 @@ public override async Task Project_entity_and_collection_element(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `t0`.`Id`, `t0`.`AmmunitionType`, `t0`.`IsAutomatic`, `t0`.`Name`, `t0`.`OwnerFullName`, `t0`.`SynergyWithId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `w2`.`Id`, `w2`.`AmmunitionType`, `w2`.`IsAutomatic`, `w2`.`Name`, `w2`.`OwnerFullName`, `w2`.`SynergyWithId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Squads` AS `s` ON `t`.`SquadId` = `s`.`Id` -LEFT JOIN `Weapons` AS `w` ON `t`.`FullName` = `w`.`OwnerFullName` +) AS `u` +INNER JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`AmmunitionType`, `t1`.`IsAutomatic`, `t1`.`Name`, `t1`.`OwnerFullName`, `t1`.`SynergyWithId` + SELECT `w1`.`Id`, `w1`.`AmmunitionType`, `w1`.`IsAutomatic`, `w1`.`Name`, `w1`.`OwnerFullName`, `w1`.`SynergyWithId` FROM ( SELECT `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId`, ROW_NUMBER() OVER(PARTITION BY `w0`.`OwnerFullName` ORDER BY `w0`.`Id`) AS `row` FROM `Weapons` AS `w0` - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `s`.`Id` + ) AS `w1` + WHERE `w1`.`row` <= 1 +) AS `w2` ON `u`.`FullName` = `w2`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `s`.`Id` """); } @@ -12161,16 +12350,16 @@ public override async Task Correlated_collection_via_SelectMany_with_Distinct_mi AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t1`.`HasSoulPatch` +SELECT `u`.`Nickname`, `u`.`SquadId`, `s`.`HasSoulPatch` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN LATERAL ( - SELECT DISTINCT `t2`.`HasSoulPatch` + SELECT DISTINCT `u1`.`HasSoulPatch` FROM `Weapons` AS `w` LEFT JOIN ( SELECT `g0`.`AssignedCityName`, `g0`.`FullName` @@ -12178,18 +12367,18 @@ LEFT JOIN ( UNION ALL SELECT `o0`.`AssignedCityName`, `o0`.`FullName` FROM `Officers` AS `o0` - ) AS `t0` ON `w`.`OwnerFullName` = `t0`.`FullName` - LEFT JOIN `Cities` AS `c` ON `t0`.`AssignedCityName` = `c`.`Name` + ) AS `u0` ON `w`.`OwnerFullName` = `u0`.`FullName` + LEFT JOIN `Cities` AS `c` ON `u0`.`AssignedCityName` = `c`.`Name` INNER JOIN ( SELECT `g1`.`CityOfBirthName`, `g1`.`HasSoulPatch` FROM `Gears` AS `g1` UNION ALL SELECT `o1`.`CityOfBirthName`, `o1`.`HasSoulPatch` FROM `Officers` AS `o1` - ) AS `t2` ON `c`.`Name` = `t2`.`CityOfBirthName` - WHERE `t`.`FullName` = `w`.`OwnerFullName` -) AS `t1` ON TRUE -ORDER BY `t`.`Nickname`, `t`.`SquadId` + ) AS `u1` ON `c`.`Name` = `u1`.`CityOfBirthName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` +) AS `s` ON TRUE +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -12227,19 +12416,19 @@ public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_th """ @__isAutomatic_0='True' -SELECT `t`.`Nickname`, `t`.`FullName`, `t0`.`Id` IS NOT NULL AS `Collection` +SELECT `u`.`Nickname`, `u`.`FullName`, `w0`.`Id` IS NOT NULL AS `Collection` FROM ( SELECT `g`.`Nickname`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `w`.`Id`, `w`.`OwnerFullName` FROM `Weapons` AS `w` WHERE `w`.`IsAutomatic` <> @__isAutomatic_0 -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` +) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` """); } @@ -12290,11 +12479,11 @@ public override async Task FirstOrDefault_on_empty_collection_of_DateTime_in_sub AssertSql( """ -SELECT `t`.`Nickname`, COALESCE(( - SELECT `t2`.`IssueDate` - FROM `Tags` AS `t2` - WHERE `t2`.`GearNickName` = `t`.`FullName` - ORDER BY `t2`.`Id` +SELECT `u`.`Nickname`, COALESCE(( + SELECT `t1`.`IssueDate` + FROM `Tags` AS `t1` + WHERE `t1`.`GearNickName` = `u`.`FullName` + ORDER BY `t1`.`Id` LIMIT 1), TIMESTAMP '0001-01-01 00:00:00') AS `invalidTagIssueDate` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` @@ -12302,13 +12491,13 @@ ORDER BY `t2`.`Id` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` -LEFT JOIN `Tags` AS `t0` ON (`t`.`Nickname` = `t0`.`GearNickName`) AND (`t`.`SquadId` = `t0`.`GearSquadId`) -WHERE `t0`.`IssueDate` > COALESCE(( - SELECT `t1`.`IssueDate` - FROM `Tags` AS `t1` - WHERE `t1`.`GearNickName` = `t`.`FullName` - ORDER BY `t1`.`Id` +) AS `u` +LEFT JOIN `Tags` AS `t` ON (`u`.`Nickname` = `t`.`GearNickName`) AND (`u`.`SquadId` = `t`.`GearSquadId`) +WHERE `t`.`IssueDate` > COALESCE(( + SELECT `t0`.`IssueDate` + FROM `Tags` AS `t0` + WHERE `t0`.`GearNickName` = `u`.`FullName` + ORDER BY `t0`.`Id` LIMIT 1), TIMESTAMP '0001-01-01 00:00:00') """); } @@ -12323,21 +12512,21 @@ await base AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`IsAutomatic`, `t0`.`Name`, `t0`.`Count` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`Count` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN LATERAL ( SELECT `w`.`IsAutomatic`, `w`.`Name`, COUNT(*) AS `Count` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` GROUP BY `w`.`IsAutomatic`, `w`.`Name` -) AS `t0` ON TRUE -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`IsAutomatic` +) AS `w0` ON TRUE +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `w0`.`IsAutomatic` """); } @@ -12370,20 +12559,20 @@ public override async Task Correlated_collection_with_distinct_not_projecting_id AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`Name`, `t0`.`IsAutomatic` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w0`.`Name`, `w0`.`IsAutomatic` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN LATERAL ( SELECT DISTINCT `w`.`Name`, `w`.`IsAutomatic` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` -) AS `t0` ON TRUE -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Name` + WHERE `u`.`FullName` = `w`.`OwnerFullName` +) AS `w0` ON TRUE +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `w0`.`Name` """); } @@ -12405,24 +12594,24 @@ public override async Task Cast_to_derived_followed_by_multiple_includes(bool as AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`DefeatedByNickname` = `t0`.`Nickname`) AND (`t`.`DefeatedBySquadId` = `t0`.`SquadId`) -LEFT JOIN `Weapons` AS `w` ON `t0`.`FullName` = `w`.`OwnerFullName` -WHERE `t`.`Name` LIKE '%Queen%' -ORDER BY `t`.`Name`, `t0`.`Nickname`, `t0`.`SquadId` +) AS `u0` ON (`u`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`u`.`DefeatedBySquadId` = `u0`.`SquadId`) +LEFT JOIN `Weapons` AS `w` ON `u0`.`FullName` = `w`.`OwnerFullName` +WHERE `u`.`Name` LIKE '%Queen%' +ORDER BY `u`.`Name`, `u0`.`Nickname`, `u0`.`SquadId` """); } @@ -12432,20 +12621,20 @@ public override async Task Correlated_collection_with_distinct_projecting_identi AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t0`.`Name` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w0`.`Id`, `w0`.`Name` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN LATERAL ( SELECT DISTINCT `w`.`Id`, `w`.`Name` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` -) AS `t0` ON TRUE -ORDER BY `t`.`Nickname`, `t`.`SquadId` + WHERE `u`.`FullName` = `w`.`OwnerFullName` +) AS `w0` ON TRUE +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -12455,7 +12644,7 @@ public override async Task Where_equals_method_on_nullable_with_object_overload( AssertSql( """ -SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE `m`.`Rating` IS NULL """); @@ -12468,21 +12657,21 @@ public override async Task AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`Key` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w0`.`Key` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN LATERAL ( SELECT `w`.`IsAutomatic` AS `Key` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` GROUP BY `w`.`IsAutomatic` -) AS `t0` ON TRUE -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `w0` ON TRUE +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -12503,7 +12692,7 @@ public override async Task Include_after_SelectMany_throws(bool async) AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name` FROM `LocustHordes` AS `l` LEFT JOIN `Cities` AS `c` ON `l`.`CapitalName` = `c`.`Name` INNER JOIN ( @@ -12512,8 +12701,8 @@ INNER JOIN ( UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` ON `c`.`Name` = `t`.`CityOfBirthName` -INNER JOIN `Squads` AS `s` ON `t`.`SquadId` = `s`.`Id` +) AS `u` ON `c`.`Name` = `u`.`CityOfBirthName` +INNER JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` """); } @@ -12523,19 +12712,19 @@ public override async Task Correlated_collection_with_distinct_projecting_identi AssertSql( """ -SELECT `s`.`Id`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`HasSoulPatch` +SELECT `s`.`Id`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`HasSoulPatch` FROM `Squads` AS `s` LEFT JOIN ( - SELECT DISTINCT `t`.`Nickname`, `t`.`SquadId`, `t`.`HasSoulPatch` + SELECT DISTINCT `u`.`Nickname`, `u`.`SquadId`, `u`.`HasSoulPatch` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t` -) AS `t0` ON `s`.`Id` = `t0`.`SquadId` -ORDER BY `s`.`Id`, `t0`.`Nickname` + ) AS `u` +) AS `u0` ON `s`.`Id` = `u0`.`SquadId` +ORDER BY `s`.`Id`, `u0`.`Nickname` """); } @@ -12545,14 +12734,14 @@ public override async Task Include_on_entity_that_is_not_present_in_final_projec AssertSql( """ -SELECT `t`.`Nickname`, `t`.`Discriminator` = 'Officer' AS `IsOfficer` +SELECT `u`.`Nickname`, `u`.`Discriminator` = 'Officer' AS `IsOfficer` FROM ( SELECT `g`.`Nickname`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -12574,10 +12763,10 @@ public override async Task ToString_boolean_property_nullable(bool async) AssertSql( """ -SELECT CASE - WHEN `l`.`Eradicated` = FALSE THEN 'False' - WHEN `l`.`Eradicated` = TRUE THEN 'True' - ELSE NULL +SELECT CASE `l`.`Eradicated` + WHEN FALSE THEN 'False' + WHEN TRUE THEN 'True' + ELSE '' END FROM `LocustHordes` AS `l` """); @@ -12589,31 +12778,31 @@ public override async Task Correlated_collection_after_distinct_3_levels(bool as AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t2`.`Nickname`, `t2`.`FullName`, `t2`.`HasSoulPatch`, `t2`.`Id`, `t2`.`Name`, `t2`.`Nickname0`, `t2`.`FullName0`, `t2`.`HasSoulPatch0`, `t2`.`Id0` +SELECT `s0`.`Id`, `s0`.`Name`, `s1`.`Nickname`, `s1`.`FullName`, `s1`.`HasSoulPatch`, `s1`.`Id`, `s1`.`Name`, `s1`.`Nickname0`, `s1`.`FullName0`, `s1`.`HasSoulPatch0`, `s1`.`Id0` FROM ( SELECT DISTINCT `s`.`Id`, `s`.`Name` FROM `Squads` AS `s` -) AS `t` +) AS `s0` LEFT JOIN LATERAL ( - SELECT `t0`.`Nickname`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t1`.`Id`, `t1`.`Name`, `t1`.`Nickname` AS `Nickname0`, `t1`.`FullName` AS `FullName0`, `t1`.`HasSoulPatch` AS `HasSoulPatch0`, `t1`.`Id0` + SELECT `u0`.`Nickname`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `w0`.`Id`, `w0`.`Name`, `w0`.`Nickname` AS `Nickname0`, `w0`.`FullName` AS `FullName0`, `w0`.`HasSoulPatch` AS `HasSoulPatch0`, `w0`.`Id0` FROM ( - SELECT DISTINCT `t3`.`Nickname`, `t3`.`FullName`, `t3`.`HasSoulPatch` + SELECT DISTINCT `u`.`Nickname`, `u`.`FullName`, `u`.`HasSoulPatch` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName`, `g`.`HasSoulPatch` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName`, `o`.`HasSoulPatch` FROM `Officers` AS `o` - ) AS `t3` - WHERE `t3`.`SquadId` = `t`.`Id` - ) AS `t0` + ) AS `u` + WHERE `u`.`SquadId` = `s0`.`Id` + ) AS `u0` LEFT JOIN LATERAL ( - SELECT `t`.`Id`, `t`.`Name`, `t0`.`Nickname`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `w`.`Id` AS `Id0` + SELECT `s0`.`Id`, `s0`.`Name`, `u0`.`Nickname`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `w`.`Id` AS `Id0` FROM `Weapons` AS `w` - WHERE `w`.`OwnerFullName` = `t0`.`FullName` - ) AS `t1` ON TRUE -) AS `t2` ON TRUE -ORDER BY `t`.`Id`, `t2`.`Nickname`, `t2`.`FullName`, `t2`.`HasSoulPatch` + WHERE `w`.`OwnerFullName` = `u0`.`FullName` + ) AS `w0` ON TRUE +) AS `s1` ON TRUE +ORDER BY `s0`.`Id`, `s1`.`Nickname`, `s1`.`FullName`, `s1`.`HasSoulPatch` """); } @@ -12624,8 +12813,8 @@ public override async Task ToString_boolean_property_non_nullable(bool async) AssertSql( """ SELECT CASE - WHEN `w`.`IsAutomatic` = FALSE THEN 'False' - ELSE 'True' + WHEN `w`.`IsAutomatic` = TRUE THEN 'True' + ELSE 'False' END FROM `Weapons` AS `w` """); @@ -12650,14 +12839,14 @@ public override async Task String_concat_nullable_expressions_are_coalesced(bool AssertSql( """ -SELECT CONCAT(CONCAT(CONCAT(`t`.`FullName`, ''), COALESCE(`t`.`LeaderNickname`, '')), '') +SELECT CONCAT(CONCAT(CONCAT(`u`.`FullName`, ''), COALESCE(`u`.`LeaderNickname`, '')), '') FROM ( SELECT `g`.`FullName`, `g`.`LeaderNickname` FROM `Gears` AS `g` UNION ALL SELECT `o`.`FullName`, `o`.`LeaderNickname` FROM `Officers` AS `o` -) AS `t` +) AS `u` """); } @@ -12667,19 +12856,19 @@ public override async Task Correlated_collection_with_distinct_projecting_identi AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`Id`, `t0`.`Name`, `t0`.`OwnerFullName` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w0`.`Id`, `w0`.`Name`, `w0`.`OwnerFullName` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT DISTINCT `w`.`Id`, `w`.`Name`, `w`.`OwnerFullName` FROM `Weapons` AS `w` -) AS `t0` ON `t`.`FullName` = `t0`.`OwnerFullName` -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -12690,21 +12879,21 @@ public override async Task Correlated_collection_with_groupby_not_projecting_ide AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t0`.`Key`, `t0`.`Count` +SELECT `u`.`Nickname`, `u`.`SquadId`, `w0`.`Key`, `w0`.`Count` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN LATERAL ( SELECT `w`.`IsAutomatic` AS `Key`, COUNT(*) AS `Count` FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName` + WHERE `u`.`FullName` = `w`.`OwnerFullName` GROUP BY `w`.`IsAutomatic` -) AS `t0` ON TRUE -ORDER BY `t`.`Nickname`, `t`.`SquadId` +) AS `w0` ON TRUE +ORDER BY `u`.`Nickname`, `u`.`SquadId` """); } @@ -12715,7 +12904,7 @@ public override async Task Project_discriminator_columns(bool async) AssertSql(); } - [ConditionalTheory(Skip = "Another LATERAL JOIN bug in MySQL. Grouping leads to unexpected result set.")] + [ConditionalTheory(Skip = "Another LATERAL JOIN bug in SingleStore. Grouping leads to unexpected result set.")] public override async Task Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection( bool async) @@ -13009,13 +13198,13 @@ public override async Task Where_subquery_equality_to_null_with_composite_key(bo WHERE NOT EXISTS ( SELECT 1 FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`SquadId` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`SquadId` FROM `Officers` AS `o` - ) AS `t` - WHERE `s`.`Id` = `t`.`SquadId`) + ) AS `u` + WHERE `s`.`Id` = `u`.`SquadId`) """); } @@ -13025,18 +13214,18 @@ public override async Task Where_subquery_equality_to_null_without_composite_key AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE NOT EXISTS ( SELECT 1 FROM `Weapons` AS `w` - WHERE `t`.`FullName` = `w`.`OwnerFullName`) + WHERE `u`.`FullName` = `w`.`OwnerFullName`) """); } @@ -13046,21 +13235,21 @@ public override async Task Include_reference_on_derived_type_using_EF_Property(b AssertSql( """ -SELECT `t`.`Name`, `t`.`LocustHordeId`, `t`.`ThreatLevel`, `t`.`ThreatLevelByte`, `t`.`ThreatLevelNullableByte`, `t`.`DefeatedByNickname`, `t`.`DefeatedBySquadId`, `t`.`HighCommandId`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` FROM `LocustLeaders` AS `l` UNION ALL SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` FROM `LocustCommanders` AS `l0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t0` ON (`t`.`DefeatedByNickname` = `t0`.`Nickname`) AND (`t`.`DefeatedBySquadId` = `t0`.`SquadId`) +) AS `u0` ON (`u`.`DefeatedByNickname` = `u0`.`Nickname`) AND (`u`.`DefeatedBySquadId` = `u0`.`SquadId`) """); } @@ -13070,22 +13259,22 @@ public override async Task Include_collection_on_derived_type_using_EF_Property( AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g0` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON (`t`.`Nickname` = `t0`.`LeaderNickname`) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` +) AS `u0` ON (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } @@ -13095,28 +13284,22 @@ public override async Task EF_Property_based_Include_navigation_on_derived_type( AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `t0`.`Nickname`, `t0`.`SquadId`, `t0`.`AssignedCityName`, `t0`.`CityOfBirthName`, `t0`.`FullName`, `t0`.`HasSoulPatch`, `t0`.`LeaderNickname`, `t0`.`LeaderSquadId`, `t0`.`Rank`, `t0`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator` FROM ( SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o0` -) AS `t0` ON (`t`.`Nickname` = `t0`.`LeaderNickname`) AND (`t`.`SquadId` = `t0`.`LeaderSquadId`) -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `t0`.`Nickname` +) AS `u0` ON (`u`.`Nickname` = `u0`.`LeaderNickname`) AND (`u`.`SquadId` = `u0`.`LeaderSquadId`) +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname` """); } - [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed")] - public override Task Set_operator_with_navigation_in_projection_groupby_aggregate(bool async) - { - return base.Set_operator_with_navigation_in_projection_groupby_aggregate(async); - } - public override async Task ToString_string_property_projection(bool async) { await base.ToString_string_property_projection(async); @@ -13136,15 +13319,15 @@ public override async Task ElementAt_basic_with_OrderBy(bool async) """ @__p_0='0' -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -ORDER BY `t`.`FullName` +) AS `u` +ORDER BY `u`.`FullName` LIMIT 1 OFFSET @__p_0 """); } @@ -13157,15 +13340,15 @@ public override async Task ElementAtOrDefault_basic_with_OrderBy(bool async) """ @__p_0='1' -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -ORDER BY `t`.`FullName` +) AS `u` +ORDER BY `u`.`FullName` LIMIT 1 OFFSET @__p_0 """); } @@ -13178,20 +13361,20 @@ public override async Task ElementAtOrDefault_basic_with_OrderBy_parameter(bool """ @__p_0='2' -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -ORDER BY `t`.`FullName` +) AS `u` +ORDER BY `u`.`FullName` LIMIT 1 OFFSET @__p_0 """); } - [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed.")] + [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed")] public override async Task Where_subquery_with_ElementAtOrDefault_equality_to_null_with_composite_key(bool async) { await base.Where_subquery_with_ElementAtOrDefault_equality_to_null_with_composite_key(async); @@ -13203,14 +13386,14 @@ public override async Task Where_subquery_with_ElementAtOrDefault_equality_to_nu WHERE NOT EXISTS ( SELECT 1 FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`Nickname`, `g`.`SquadId` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`Nickname`, `o`.`SquadId` FROM `Officers` AS `o` - ) AS `t` - WHERE `s`.`Id` = `t`.`SquadId` - ORDER BY `t`.`Nickname` + ) AS `u` + WHERE `s`.`Id` = `u`.`SquadId` + ORDER BY `u`.`Nickname` LIMIT 18446744073709551610 OFFSET 2) """); } @@ -13242,22 +13425,22 @@ public override async Task DateTimeOffset_to_unix_time_milliseconds(bool async) """ @__unixEpochMilliseconds_0='0' -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `s1`.`SquadId`, `s1`.`MissionId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `s1`.`SquadId`, `s1`.`MissionId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Squads` AS `s` ON `t`.`SquadId` = `s`.`Id` +) AS `u` +INNER JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` LEFT JOIN `SquadMissions` AS `s1` ON `s`.`Id` = `s1`.`SquadId` WHERE NOT EXISTS ( SELECT 1 FROM `SquadMissions` AS `s0` INNER JOIN `Missions` AS `m` ON `s0`.`MissionId` = `m`.`Id` WHERE (`s`.`Id` = `s0`.`SquadId`) AND (@__unixEpochMilliseconds_0 = (TIMESTAMPDIFF(microsecond, '1970-01-01 00:00:00', `m`.`Timeline`)) DIV (1000))) -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `s`.`Id`, `s1`.`SquadId` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `s`.`Id`, `s1`.`SquadId` """); } @@ -13269,22 +13452,77 @@ public override async Task DateTimeOffset_to_unix_time_seconds(bool async) """ @__unixEpochSeconds_0='0' -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `s1`.`SquadId`, `s1`.`MissionId` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `s`.`Id`, `s`.`Banner`, `s`.`Banner5`, `s`.`InternalNumber`, `s`.`Name`, `s1`.`SquadId`, `s1`.`MissionId` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` -INNER JOIN `Squads` AS `s` ON `t`.`SquadId` = `s`.`Id` +) AS `u` +INNER JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` LEFT JOIN `SquadMissions` AS `s1` ON `s`.`Id` = `s1`.`SquadId` WHERE NOT EXISTS ( SELECT 1 FROM `SquadMissions` AS `s0` INNER JOIN `Missions` AS `m` ON `s0`.`MissionId` = `m`.`Id` WHERE (`s`.`Id` = `s0`.`SquadId`) AND (@__unixEpochSeconds_0 = TIMESTAMPDIFF(second, '1970-01-01 00:00:00', `m`.`Timeline`))) -ORDER BY `t`.`Nickname`, `t`.`SquadId`, `s`.`Id`, `s1`.`SquadId` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `s`.`Id`, `s1`.`SquadId` +"""); + } + + public override async Task Set_operator_with_navigation_in_projection_groupby_aggregate(bool async) + { + await base.Set_operator_with_navigation_in_projection_groupby_aggregate(async); + + AssertSql( +""" +SELECT `s`.`Name`, ( + SELECT COALESCE(SUM(CHAR_LENGTH(`c`.`Location`)), 0) + FROM ( + SELECT `g2`.`SquadId`, `g2`.`CityOfBirthName` + FROM `Gears` AS `g2` + UNION ALL + SELECT `o2`.`SquadId`, `o2`.`CityOfBirthName` + FROM `Officers` AS `o2` + ) AS `u3` + INNER JOIN `Squads` AS `s0` ON `u3`.`SquadId` = `s0`.`Id` + INNER JOIN `Cities` AS `c` ON `u3`.`CityOfBirthName` = `c`.`Name` + WHERE 'Marcus' IN ( + SELECT `g3`.`Nickname` + FROM `Gears` AS `g3` + UNION ALL + SELECT `o3`.`Nickname` + FROM `Officers` AS `o3` + UNION ALL + SELECT `g4`.`Nickname` + FROM `Gears` AS `g4` + UNION ALL + SELECT `o4`.`Nickname` + FROM `Officers` AS `o4` + ) AND ((`s`.`Name` = `s0`.`Name`) OR (`s`.`Name` IS NULL AND (`s0`.`Name` IS NULL)))) AS `SumOfLengths` +FROM ( + SELECT `g`.`SquadId` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`SquadId` + FROM `Officers` AS `o` +) AS `u` +INNER JOIN `Squads` AS `s` ON `u`.`SquadId` = `s`.`Id` +WHERE 'Marcus' IN ( + SELECT `g0`.`Nickname` + FROM `Gears` AS `g0` + UNION ALL + SELECT `o0`.`Nickname` + FROM `Officers` AS `o0` + UNION ALL + SELECT `g1`.`Nickname` + FROM `Gears` AS `g1` + UNION ALL + SELECT `o1`.`Nickname` + FROM `Officers` AS `o1` +) +GROUP BY `s`.`Name` """); } @@ -13299,13 +13537,13 @@ public override async Task Where_subquery_equality_to_null_with_composite_key_sh WHERE NOT EXISTS ( SELECT 1 FROM ( - SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + SELECT `g`.`SquadId`, `g`.`FullName` FROM `Gears` AS `g` UNION ALL - SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + SELECT `o`.`SquadId`, `o`.`FullName` FROM `Officers` AS `o` - ) AS `t` - WHERE (`s`.`Id` = `t`.`SquadId`) AND (`t`.`FullName` = 'Anthony Carmine')) + ) AS `u` + WHERE (`s`.`Id` = `u`.`SquadId`) AND (`u`.`FullName` = 'Anthony Carmine')) """); } @@ -13315,22 +13553,22 @@ public override async Task Where_subquery_equality_to_null_without_composite_key AssertSql( """ -SELECT `t`.`Nickname`, `t`.`SquadId`, `t`.`AssignedCityName`, `t`.`CityOfBirthName`, `t`.`FullName`, `t`.`HasSoulPatch`, `t`.`LeaderNickname`, `t`.`LeaderSquadId`, `t`.`Rank`, `t`.`Discriminator` +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` FROM ( SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` FROM `Gears` AS `g` UNION ALL SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` FROM `Officers` AS `o` -) AS `t` +) AS `u` WHERE NOT EXISTS ( SELECT 1 FROM `Weapons` AS `w` - WHERE (`t`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` = 'Hammer of Dawn')) + WHERE (`u`.`FullName` = `w`.`OwnerFullName`) AND (`w`.`Name` = 'Hammer of Dawn')) """); } - [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed.")] + [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed")] public override async Task Nav_expansion_inside_Contains_argument(bool async) { await base.Nav_expansion_inside_Contains_argument(async); @@ -13355,7 +13593,7 @@ END IN (1, -1) """); } - [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed.")] + [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed")] public override async Task Nav_expansion_with_member_pushdown_inside_Contains_argument(bool async) { await base.Nav_expansion_with_member_pushdown_inside_Contains_argument(async); @@ -13414,6 +13652,368 @@ public override async Task Nav_expansion_inside_ElementAt_correlated_to_source(b AssertSql(""); } + public override async Task Unicode_string_literals_is_used_for_non_unicode_column_with_concat(bool async) + { + await base.Unicode_string_literals_is_used_for_non_unicode_column_with_concat(async); + + AssertSql( +""" +SELECT `c`.`Name`, `c`.`Location`, `c`.`Nation` +FROM `Cities` AS `c` +WHERE CONCAT(COALESCE(`c`.`Location`, ''), 'Added') LIKE '%Add%' +"""); + } + + public override async Task Include_one_to_many_on_composite_key_then_orderby_key_properties(bool async) + { + await base.Include_one_to_many_on_composite_key_then_orderby_key_properties(async); + + AssertSql( +""" +SELECT `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u`.`SquadId`, `u`.`Nickname` +"""); + } + + public override async Task Find_underlying_property_after_GroupJoin_DefaultIfEmpty(bool async) + { + await base.Find_underlying_property_after_GroupJoin_DefaultIfEmpty(async); + + AssertSql( +""" +SELECT `u`.`FullName`, CAST(`u0`.`ThreatLevel` AS signed) AS `ThreatLevel` +FROM ( + SELECT `g`.`Nickname`, `g`.`FullName` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`FullName` + FROM `Officers` AS `o` +) AS `u` +LEFT JOIN ( + SELECT `l`.`ThreatLevel`, `l`.`DefeatedByNickname` + FROM `LocustCommanders` AS `l` +) AS `u0` ON `u`.`Nickname` = `u0`.`DefeatedByNickname` +"""); + } + + public override async Task Join_include_coalesce_simple(bool async) + { + await base.Join_include_coalesce_simple(async); + + AssertSql( +""" +SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u`.`Nickname` = 'Marcus' +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +LEFT JOIN ( + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g0` + UNION ALL + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o0` +) AS `u0` ON `u`.`LeaderNickname` = `u0`.`Nickname` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId` +""", + // + """ +SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u`.`Nickname`, `u`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +LEFT JOIN ( + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g0` + UNION ALL + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o0` +) AS `u0` ON `u`.`LeaderNickname` = `u0`.`Nickname` +LEFT JOIN `Weapons` AS `w` ON `u0`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId` +""", + // + """ +SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u`.`Nickname`, `u`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +LEFT JOIN ( + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g0` + UNION ALL + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o0` +) AS `u0` ON `u`.`LeaderNickname` = `u0`.`Nickname` +LEFT JOIN `Weapons` AS `w` ON `u0`.`FullName` = `w`.`OwnerFullName` +LEFT JOIN `Weapons` AS `w0` ON `u`.`FullName` = `w0`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId`, `w`.`Id` +"""); + } + + public override async Task Join_include_coalesce_nested(bool async) + { + await base.Join_include_coalesce_nested(async); + + AssertSql( +""" +SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u`.`Nickname` = 'Marcus' +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +LEFT JOIN ( + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g0` + UNION ALL + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o0` +) AS `u0` ON `u`.`LeaderNickname` = `u0`.`Nickname` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId` +""", + // + """ +SELECT `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u`.`Nickname`, `u`.`SquadId`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `w0`.`Id`, `w0`.`AmmunitionType`, `w0`.`IsAutomatic`, `w0`.`Name`, `w0`.`OwnerFullName`, `w0`.`SynergyWithId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w1`.`Id`, `w1`.`AmmunitionType`, `w1`.`IsAutomatic`, `w1`.`Name`, `w1`.`OwnerFullName`, `w1`.`SynergyWithId` +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +LEFT JOIN ( + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g0` + UNION ALL + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o0` +) AS `u0` ON `u`.`LeaderNickname` = `u0`.`Nickname` +LEFT JOIN `Weapons` AS `w` ON `u0`.`FullName` = `w`.`OwnerFullName` +LEFT JOIN `Weapons` AS `w0` ON `u0`.`FullName` = `w0`.`OwnerFullName` +LEFT JOIN `Weapons` AS `w1` ON `u0`.`FullName` = `w1`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId`, `w`.`Id`, `w0`.`Id` +"""); + } + + public override async Task Join_include_conditional(bool async) + { + await base.Join_include_conditional(async); + + AssertSql( +""" +SELECT `u0`.`Nickname` IS NOT NULL AND (`u0`.`SquadId` IS NOT NULL), `u0`.`Nickname`, `u0`.`SquadId`, `u0`.`AssignedCityName`, `u0`.`CityOfBirthName`, `u0`.`FullName`, `u0`.`HasSoulPatch`, `u0`.`LeaderNickname`, `u0`.`LeaderSquadId`, `u0`.`Rank`, `u0`.`Discriminator`, `u`.`Nickname`, `u`.`SquadId`, `u`.`AssignedCityName`, `u`.`CityOfBirthName`, `u`.`FullName`, `u`.`HasSoulPatch`, `u`.`LeaderNickname`, `u`.`LeaderSquadId`, `u`.`Rank`, `u`.`Discriminator`, `w`.`Id`, `w`.`AmmunitionType`, `w`.`IsAutomatic`, `w`.`Name`, `w`.`OwnerFullName`, `w`.`SynergyWithId`, `u`.`Nickname` = 'Marcus' +FROM ( + SELECT `g`.`Nickname`, `g`.`SquadId`, `g`.`AssignedCityName`, `g`.`CityOfBirthName`, `g`.`FullName`, `g`.`HasSoulPatch`, `g`.`LeaderNickname`, `g`.`LeaderSquadId`, `g`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId`, `o`.`AssignedCityName`, `o`.`CityOfBirthName`, `o`.`FullName`, `o`.`HasSoulPatch`, `o`.`LeaderNickname`, `o`.`LeaderSquadId`, `o`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o` +) AS `u` +LEFT JOIN ( + SELECT `g0`.`Nickname`, `g0`.`SquadId`, `g0`.`AssignedCityName`, `g0`.`CityOfBirthName`, `g0`.`FullName`, `g0`.`HasSoulPatch`, `g0`.`LeaderNickname`, `g0`.`LeaderSquadId`, `g0`.`Rank`, 'Gear' AS `Discriminator` + FROM `Gears` AS `g0` + UNION ALL + SELECT `o0`.`Nickname`, `o0`.`SquadId`, `o0`.`AssignedCityName`, `o0`.`CityOfBirthName`, `o0`.`FullName`, `o0`.`HasSoulPatch`, `o0`.`LeaderNickname`, `o0`.`LeaderSquadId`, `o0`.`Rank`, 'Officer' AS `Discriminator` + FROM `Officers` AS `o0` +) AS `u0` ON `u`.`LeaderNickname` = `u0`.`Nickname` +LEFT JOIN `Weapons` AS `w` ON `u`.`FullName` = `w`.`OwnerFullName` +ORDER BY `u`.`Nickname`, `u`.`SquadId`, `u0`.`Nickname`, `u0`.`SquadId` +"""); + } + + public override async Task Derived_reference_is_skipped_when_base_type(bool async) + { + await base.Derived_reference_is_skipped_when_base_type(async); + + AssertSql( +""" +SELECT `u`.`Name`, `u`.`LocustHordeId`, `u`.`ThreatLevel`, `u`.`ThreatLevelByte`, `u`.`ThreatLevelNullableByte`, `u`.`DefeatedByNickname`, `u`.`DefeatedBySquadId`, `u`.`HighCommandId`, `u`.`Discriminator`, `l1`.`Id`, `l1`.`IsOperational`, `l1`.`Name` +FROM ( + SELECT `l`.`Name`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, NULL AS `DefeatedByNickname`, NULL AS `DefeatedBySquadId`, NULL AS `HighCommandId`, 'LocustLeader' AS `Discriminator` + FROM `LocustLeaders` AS `l` + UNION ALL + SELECT `l0`.`Name`, `l0`.`LocustHordeId`, `l0`.`ThreatLevel`, `l0`.`ThreatLevelByte`, `l0`.`ThreatLevelNullableByte`, `l0`.`DefeatedByNickname`, `l0`.`DefeatedBySquadId`, `l0`.`HighCommandId`, 'LocustCommander' AS `Discriminator` + FROM `LocustCommanders` AS `l0` +) AS `u` +LEFT JOIN `LocustHighCommands` AS `l1` ON `u`.`HighCommandId` = `l1`.`Id` +"""); + } + + public override async Task Nested_contains_with_enum(bool async) + { + await base.Nested_contains_with_enum(async); + + AssertSql(""); + } + + public override async Task ToString_boolean_computed_nullable(bool async) + { + await base.ToString_boolean_computed_nullable(async); + + AssertSql( +""" +SELECT CASE (`l`.`Eradicated` = TRUE) OR ((`l`.`CommanderName` = 'Unknown') AND `l`.`CommanderName` IS NOT NULL) + WHEN FALSE THEN 'False' + WHEN TRUE THEN 'True' + ELSE '' +END +FROM `LocustHordes` AS `l` +"""); + } + + public override async Task Select_inverted_nullable_boolean(bool async) + { + await base.Select_inverted_nullable_boolean(async); + + AssertSql( +""" +SELECT `l`.`Id`, `l`.`Eradicated` = FALSE AS `Alive` +FROM `LocustHordes` AS `l` +"""); + } + + public override async Task Where_TimeOnly_FromDateTime_compared_to_property(bool async) + { + await base.Where_TimeOnly_FromDateTime_compared_to_property(async); + + AssertSql( +""" +SELECT `t`.`Id` AS `TagId`, `m`.`Id` AS `MissionId` +FROM `Tags` AS `t` +CROSS JOIN `Missions` AS `m` +WHERE TIME(`t`.`IssueDate`) = `m`.`Time`:>time(6) +"""); + } + + public override async Task Where_TimeOnly_FromDateTime_compared_to_parameter(bool async) + { + await base.Where_TimeOnly_FromDateTime_compared_to_parameter(async); + + AssertSql( +""" +@__time_0='02:00' (DbType = Time) + +SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` +FROM `Tags` AS `t` +LEFT JOIN ( + SELECT `g`.`Nickname`, `g`.`SquadId` + FROM `Gears` AS `g` + UNION ALL + SELECT `o`.`Nickname`, `o`.`SquadId` + FROM `Officers` AS `o` +) AS `u` ON (`t`.`GearNickName` = `u`.`Nickname`) AND (`t`.`GearSquadId` = `u`.`SquadId`) +WHERE (`u`.`Nickname` IS NOT NULL AND (`u`.`SquadId` IS NOT NULL)) AND (TIME(DATE_ADD(`t`.`IssueDate`, INTERVAL CAST((`u`.`SquadId` :> double) AS signed) hour)) = @__time_0:>time(6)) +"""); + } + + public override async Task Where_TimeOnly_FromDateTime_compared_to_constant(bool async) + { + await base.Where_TimeOnly_FromDateTime_compared_to_constant(async); + + AssertSql( +""" +SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` +FROM `Tags` AS `t` +WHERE TIME(DATE_ADD(`t`.`IssueDate`, INTERVAL CAST((CHAR_LENGTH(`t`.`Note`) :> double) AS signed) hour)) > '09:00:00' +"""); + } + + public override async Task Where_TimeOnly_FromTimeSpan_compared_to_property(bool async) + { + await base.Where_TimeOnly_FromTimeSpan_compared_to_property(async); + + AssertSql( +""" +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +FROM `Missions` AS `m` +WHERE `m`.`Duration` < `m`.`Time` +"""); + } + + public override async Task Where_TimeOnly_FromTimeSpan_compared_to_parameter(bool async) + { + await base.Where_TimeOnly_FromTimeSpan_compared_to_parameter(async); + + AssertSql( +""" +@__time_0='01:02' (DbType = Time) + +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +FROM `Missions` AS `m` +WHERE `m`.`Duration` = @__time_0:>time(6) +"""); + } + + public override async Task Order_by_TimeOnly_FromTimeSpan(bool async) + { + await base.Order_by_TimeOnly_FromTimeSpan(async); + + AssertSql( +""" +SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` +FROM `Missions` AS `m` +ORDER BY `m`.`Duration` +"""); + } + + public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool async) + { + await base.Where_DateOnly_FromDateTime_compared_to_property(async); + + AssertSql( +""" +SELECT `t`.`Id` AS `TagId`, `m`.`Id` AS `MissionId` +FROM `Tags` AS `t` +CROSS JOIN `Missions` AS `m` +WHERE DATE(`t`.`IssueDate`) > `m`.`Date` +"""); + } + + public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(bool async) + { + await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); + + AssertSql( +""" +@__prm_0='10/11/0002' (DbType = Date) + +SELECT `t`.`Id`, `t`.`GearNickName`, `t`.`GearSquadId`, `t`.`IssueDate`, `t`.`Note` +FROM `Tags` AS `t` +WHERE DATE(`t`.`IssueDate`) IN (@__prm_0, '0015-03-07') +"""); + } + + // TODO: Implement once TimeSpan is translated as ticks instead of TIME. + public override async Task Non_string_concat_uses_appropriate_type_mapping(bool async) + { + var exception = await Assert.ThrowsAsync(() => base.Non_string_concat_uses_appropriate_type_mapping(async)); + Assert.Equal("Unable to cast object of type 'System.Byte[]' to type 'System.TimeSpan'.", exception.Message); + } + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/TPCInheritanceQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/TPCInheritanceQuerySingleStoreTest.cs index 47c723aa9..079c49f86 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/TPCInheritanceQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/TPCInheritanceQuerySingleStoreTest.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Query; @@ -19,9 +20,9 @@ public TPCInheritanceQuerySingleStoreTest( } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore.")] - public override void Setting_foreign_key_to_a_different_type_throws() + public override Task Setting_foreign_key_to_a_different_type_throws() { - base.Setting_foreign_key_to_a_different_type_throws(); + return base.Setting_foreign_key_to_a_different_type_throws(); } protected override void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/TPCManyToManyNoTrackingQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/TPCManyToManyNoTrackingQuerySingleStoreTest.cs index ac838e68b..9f90da61f 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/TPCManyToManyNoTrackingQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/TPCManyToManyNoTrackingQuerySingleStoreTest.cs @@ -16,12 +16,9 @@ public TPCManyToManyNoTrackingQuerySingleStoreTest(TPCManyToManyQuerySingleStore //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - [ConditionalFact] public virtual void Check_all_tests_overridden() - => TestHelpers.AssertAllMethodsOverridden(GetType()); + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); public override async Task Skip_navigation_all(bool async) { @@ -116,13 +113,13 @@ ORDER BY ( SELECT COUNT(*) FROM `JoinOneToBranch` AS `j` INNER JOIN ( - SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, NULL AS `IsGreen`, 'EntityBranch' AS `Discriminator` + SELECT `b`.`Id`, `b`.`Name` FROM `Branches` AS `b` UNION ALL - SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, 'EntityLeaf' AS `Discriminator` + SELECT `l`.`Id`, `l`.`Name` FROM `Leaves` AS `l` - ) AS `t` ON `j`.`EntityBranchId` = `t`.`Id` - WHERE (`e`.`Id` = `j`.`EntityOneId`) AND (`t`.`Name` LIKE 'L%')), `e`.`Id` + ) AS `u` ON `j`.`EntityBranchId` = `u`.`Id` + WHERE (`e`.`Id` = `j`.`EntityOneId`) AND (`u`.`Name` LIKE 'L%')), `e`.`Id` """); } @@ -164,14 +161,14 @@ public override async Task Skip_navigation_select_many_average(bool async) await base.Skip_navigation_select_many_average(async); AssertSql( -$""" -SELECT AVG({SingleStoreTestHelpers.CastAsDouble(@"`t`.`Key1`")}) +""" +SELECT AVG((`s`.`Key1` :> double)) FROM `EntityTwos` AS `e` INNER JOIN ( SELECT `e1`.`Key1`, `e0`.`TwoSkipSharedId` FROM `EntityCompositeKeyEntityTwo` AS `e0` INNER JOIN `EntityCompositeKeys` AS `e1` ON ((`e0`.`CompositeKeySkipSharedKey1` = `e1`.`Key1`) AND (`e0`.`CompositeKeySkipSharedKey2` = `e1`.`Key2`)) AND (`e0`.`CompositeKeySkipSharedKey3` = `e1`.`Key3`) -) AS `t` ON `e`.`Id` = `t`.`TwoSkipSharedId` +) AS `s` ON `e`.`Id` = `s`.`TwoSkipSharedId` """); } @@ -181,13 +178,13 @@ public override async Task Skip_navigation_select_many_max(bool async) AssertSql( """ -SELECT MAX(`t`.`Key1`) +SELECT MAX(`s`.`Key1`) FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `e0`.`Key1`, `j`.`ThreeId` FROM `JoinThreeToCompositeKeyFull` AS `j` INNER JOIN `EntityCompositeKeys` AS `e0` ON ((`j`.`CompositeId1` = `e0`.`Key1`) AND (`j`.`CompositeId2` = `e0`.`Key2`)) AND (`j`.`CompositeId3` = `e0`.`Key3`) -) AS `t` ON `e`.`Id` = `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` """); } @@ -197,10 +194,10 @@ public override async Task Skip_navigation_select_many_min(bool async) AssertSql( """ -SELECT MIN(`t0`.`Id`) +SELECT MIN(`s`.`Id`) FROM `EntityThrees` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `e0`.`ThreeSkipSharedId` + SELECT `u`.`Id`, `e0`.`ThreeSkipSharedId` FROM `EntityRootEntityThree` AS `e0` INNER JOIN ( SELECT `r`.`Id` @@ -214,8 +211,8 @@ UNION ALL UNION ALL SELECT `l0`.`Id` FROM `Leaf2s` AS `l0` - ) AS `t` ON `e0`.`RootSkipSharedId` = `t`.`Id` -) AS `t0` ON `e`.`Id` = `t0`.`ThreeSkipSharedId` + ) AS `u` ON `e0`.`RootSkipSharedId` = `u`.`Id` +) AS `s` ON `e`.`Id` = `s`.`ThreeSkipSharedId` """); } @@ -225,7 +222,7 @@ public override async Task Skip_navigation_select_many_sum(bool async) AssertSql( """ -SELECT COALESCE(SUM(`t0`.`Key1`), 0) +SELECT COALESCE(SUM(`s`.`Key1`), 0) FROM ( SELECT `r`.`Id` FROM `Roots` AS `r` @@ -238,12 +235,12 @@ UNION ALL UNION ALL SELECT `l0`.`Id` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` INNER JOIN ( SELECT `e0`.`Key1`, `e`.`RootSkipSharedId` FROM `EntityCompositeKeyEntityRoot` AS `e` INNER JOIN `EntityCompositeKeys` AS `e0` ON ((`e`.`CompositeKeySkipSharedKey1` = `e0`.`Key1`) AND (`e`.`CompositeKeySkipSharedKey2` = `e0`.`Key2`)) AND (`e`.`CompositeKeySkipSharedKey3` = `e0`.`Key3`) -) AS `t0` ON `t`.`Id` = `t0`.`RootSkipSharedId` +) AS `s` ON `u`.`Id` = `s`.`RootSkipSharedId` """); } @@ -313,17 +310,17 @@ public override async Task Skip_navigation_order_by_first_or_default(bool async) AssertSql( """ -SELECT `t0`.`Id`, `t0`.`Name` +SELECT `s0`.`Id`, `s0`.`Name` FROM `EntityThrees` AS `e` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`ThreeId` + SELECT `s`.`Id`, `s`.`Name`, `s`.`ThreeId` FROM ( SELECT `e0`.`Id`, `e0`.`Name`, `j`.`ThreeId`, ROW_NUMBER() OVER(PARTITION BY `j`.`ThreeId` ORDER BY `e0`.`Id`) AS `row` FROM `JoinOneToThreePayloadFullShared` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `e`.`Id` = `t0`.`ThreeId` + ) AS `s` + WHERE `s`.`row` <= 1 +) AS `s0` ON `e`.`Id` = `s0`.`ThreeId` """); } @@ -333,10 +330,10 @@ public override async Task Skip_navigation_order_by_single_or_default(bool async AssertSql( """ -SELECT `t0`.`Id`, `t0`.`Name` +SELECT `s0`.`Id`, `s0`.`Name` FROM `EntityOnes` AS `e` LEFT JOIN LATERAL ( - SELECT `t`.`Id`, `t`.`Name` + SELECT `s`.`Id`, `s`.`Name` FROM ( SELECT `e0`.`Id`, `e0`.`Name` FROM `JoinOneSelfPayload` AS `j` @@ -344,10 +341,10 @@ LEFT JOIN LATERAL ( WHERE `e`.`Id` = `j`.`LeftId` ORDER BY `e0`.`Id` LIMIT 1 - ) AS `t` - ORDER BY `t`.`Id` + ) AS `s` + ORDER BY `s`.`Id` LIMIT 1 -) AS `t0` ON TRUE +) AS `s0` ON TRUE """); } @@ -357,23 +354,23 @@ public override async Task Skip_navigation_order_by_last_or_default(bool async) AssertSql( """ -SELECT `t0`.`Id`, `t0`.`Name` +SELECT `s0`.`Id`, `s0`.`Name` FROM ( SELECT `b`.`Id` FROM `Branches` AS `b` UNION ALL SELECT `l`.`Id` FROM `Leaves` AS `l` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`Name`, `t1`.`EntityBranchId` + SELECT `s`.`Id`, `s`.`Name`, `s`.`EntityBranchId` FROM ( SELECT `e`.`Id`, `e`.`Name`, `j`.`EntityBranchId`, ROW_NUMBER() OVER(PARTITION BY `j`.`EntityBranchId` ORDER BY `e`.`Id` DESC) AS `row` FROM `JoinOneToBranch` AS `j` INNER JOIN `EntityOnes` AS `e` ON `j`.`EntityOneId` = `e`.`Id` - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`Id` = `t0`.`EntityBranchId` + ) AS `s` + WHERE `s`.`row` <= 1 +) AS `s0` ON `u`.`Id` = `s0`.`EntityBranchId` """); } @@ -383,17 +380,17 @@ public override async Task Skip_navigation_order_by_reverse_first_or_default(boo AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `EntityThrees` AS `e` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`ThreeId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`ThreeId` FROM ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`ThreeId`, ROW_NUMBER() OVER(PARTITION BY `j`.`ThreeId` ORDER BY `e0`.`Id` DESC) AS `row` FROM `JoinTwoToThree` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `e`.`Id` = `t0`.`ThreeId` + ) AS `s` + WHERE `s`.`row` <= 1 +) AS `s0` ON `e`.`Id` = `s0`.`ThreeId` """); } @@ -403,14 +400,14 @@ public override async Task Skip_navigation_cast(bool async) AssertSql( """ -SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3` +SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3` FROM `EntityCompositeKeys` AS `e` LEFT JOIN ( SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3` FROM `JoinCompositeKeyToLeaf` AS `j` INNER JOIN `Leaves` AS `l` ON `j`.`LeafId` = `l`.`Id` -) AS `t` ON ((`e`.`Key1` = `t`.`CompositeId1`) AND (`e`.`Key2` = `t`.`CompositeId2`)) AND (`e`.`Key3` = `t`.`CompositeId3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3` +) AS `s` ON ((`e`.`Key1` = `s`.`CompositeId1`) AND (`e`.`Key2` = `s`.`CompositeId2`)) AND (`e`.`Key3` = `s`.`CompositeId3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3` """); } @@ -419,28 +416,28 @@ public override async Task Skip_navigation_of_type(bool async) await base.Skip_navigation_of_type(async); AssertSql( -$""" -SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`Discriminator`, `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3` +""" +SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `s`.`Discriminator`, `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3` FROM `EntityCompositeKeys` AS `e` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator`, `e0`.`RootSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` + SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `u`.`Discriminator`, `e0`.`RootSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` FROM `EntityCompositeKeyEntityRoot` AS `e0` INNER JOIN ( - SELECT `r`.`Id`, `r`.`Name`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `Number`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsGreen`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'EntityRoot'")} AS `Discriminator` + SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `IsGreen`, 'EntityRoot' AS `Discriminator` FROM `Roots` AS `r` UNION ALL - SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsGreen`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'EntityBranch'")} AS `Discriminator` + SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, NULL AS `IsGreen`, 'EntityBranch' AS `Discriminator` FROM `Branches` AS `b` UNION ALL SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, 'EntityLeaf' AS `Discriminator` FROM `Leaves` AS `l` UNION ALL - SELECT `l0`.`Id`, `l0`.`Name`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `Number`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsGreen`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'EntityLeaf2'")} AS `Discriminator` + SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, NULL AS `IsGreen`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` - ) AS `t` ON `e0`.`RootSkipSharedId` = `t`.`Id` - WHERE `t`.`Discriminator` = 'EntityLeaf' -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `t0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `t0`.`CompositeKeySkipSharedKey3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3` + ) AS `u` ON `e0`.`RootSkipSharedId` = `u`.`Id` + WHERE `u`.`Discriminator` = 'EntityLeaf' +) AS `s` ON ((`e`.`Key1` = `s`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `s`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `s`.`CompositeKeySkipSharedKey3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3` """); } @@ -495,7 +492,7 @@ public override async Task Select_many_over_skip_navigation(bool async) AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `r`.`Id` FROM `Roots` AS `r` @@ -508,12 +505,12 @@ UNION ALL UNION ALL SELECT `l0`.`Id` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` INNER JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `e`.`RootSkipSharedId` FROM `EntityRootEntityThree` AS `e` INNER JOIN `EntityThrees` AS `e0` ON `e`.`ThreeSkipSharedId` = `e0`.`Id` -) AS `t0` ON `t`.`Id` = `t0`.`RootSkipSharedId` +) AS `s` ON `u`.`Id` = `s`.`RootSkipSharedId` """); } @@ -523,13 +520,13 @@ public override async Task Select_many_over_skip_navigation_where(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `EntityOnes` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` -) AS `t` ON `e`.`Id` = `t`.`OneId` +) AS `s` ON `e`.`Id` = `s`.`OneId` """); } @@ -539,17 +536,17 @@ public override async Task Select_many_over_skip_navigation_order_by_skip(bool a AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `EntityOnes` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`OneId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`OneId` FROM ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId`, ROW_NUMBER() OVER(PARTITION BY `j`.`OneId` ORDER BY `e0`.`Id`) AS `row` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityThrees` AS `e0` ON `j`.`ThreeId` = `e0`.`Id` - ) AS `t` - WHERE 2 < `t`.`row` -) AS `t0` ON `e`.`Id` = `t0`.`OneId` + ) AS `s` + WHERE 2 < `s`.`row` +) AS `s0` ON `e`.`Id` = `s0`.`OneId` """); } @@ -559,17 +556,17 @@ public override async Task Select_many_over_skip_navigation_order_by_take(bool a AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `EntityOnes` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`OneSkipSharedId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`OneSkipSharedId` FROM ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `e0`.`OneSkipSharedId`, ROW_NUMBER() OVER(PARTITION BY `e0`.`OneSkipSharedId` ORDER BY `e1`.`Id`) AS `row` FROM `EntityOneEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`TwoSkipSharedId` = `e1`.`Id` - ) AS `t` - WHERE `t`.`row` <= 2 -) AS `t0` ON `e`.`Id` = `t0`.`OneSkipSharedId` + ) AS `s` + WHERE `s`.`row` <= 2 +) AS `s0` ON `e`.`Id` = `s0`.`OneSkipSharedId` """); } @@ -579,17 +576,17 @@ public override async Task Select_many_over_skip_navigation_order_by_skip_take(b AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `EntityOnes` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`OneId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`OneId` FROM ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId`, ROW_NUMBER() OVER(PARTITION BY `j`.`OneId` ORDER BY `e0`.`Id`) AS `row` FROM `JoinOneToThreePayloadFullShared` AS `j` INNER JOIN `EntityThrees` AS `e0` ON `j`.`ThreeId` = `e0`.`Id` - ) AS `t` - WHERE (2 < `t`.`row`) AND (`t`.`row` <= 5) -) AS `t0` ON `e`.`Id` = `t0`.`OneId` + ) AS `s` + WHERE (2 < `s`.`row`) AND (`s`.`row` <= 5) +) AS `s0` ON `e`.`Id` = `s0`.`OneId` """); } @@ -599,10 +596,10 @@ public override async Task Select_many_over_skip_navigation_of_type(bool async) AssertSql( """ -SELECT `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`Discriminator` +SELECT `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `s`.`Discriminator` FROM `EntityThrees` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator`, `e0`.`ThreeSkipSharedId` + SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `u`.`Discriminator`, `e0`.`ThreeSkipSharedId` FROM `EntityRootEntityThree` AS `e0` INNER JOIN ( SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `IsGreen`, 'EntityRoot' AS `Discriminator` @@ -616,9 +613,9 @@ UNION ALL UNION ALL SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, NULL AS `IsGreen`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` - ) AS `t` ON `e0`.`RootSkipSharedId` = `t`.`Id` - WHERE `t`.`Discriminator` IN ('EntityBranch', 'EntityLeaf') -) AS `t0` ON `e`.`Id` = `t0`.`ThreeSkipSharedId` + ) AS `u` ON `e0`.`RootSkipSharedId` = `u`.`Id` + WHERE `u`.`Discriminator` IN ('EntityBranch', 'EntityLeaf') +) AS `s` ON `e`.`Id` = `s`.`ThreeSkipSharedId` """); } @@ -628,10 +625,10 @@ public override async Task Select_many_over_skip_navigation_cast(bool async) AssertSql( """ -SELECT `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`Discriminator` +SELECT `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `s`.`Discriminator` FROM `EntityOnes` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator`, `j`.`EntityOneId` + SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `u`.`Discriminator`, `j`.`EntityOneId` FROM `JoinOneToBranch` AS `j` INNER JOIN ( SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, NULL AS `IsGreen`, 'EntityBranch' AS `Discriminator` @@ -639,8 +636,8 @@ INNER JOIN ( UNION ALL SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, 'EntityLeaf' AS `Discriminator` FROM `Leaves` AS `l` - ) AS `t` ON `j`.`EntityBranchId` = `t`.`Id` -) AS `t0` ON `e`.`Id` = `t0`.`EntityOneId` + ) AS `u` ON `j`.`EntityBranchId` = `u`.`Id` +) AS `s` ON `e`.`Id` = `s`.`EntityOneId` """); } @@ -650,14 +647,14 @@ public override async Task Select_skip_navigation(bool async) AssertSql( """ -SELECT `e`.`Id`, `t`.`Id`, `t`.`Name`, `t`.`LeftId`, `t`.`RightId` +SELECT `e`.`Id`, `s`.`Id`, `s`.`Name`, `s`.`LeftId`, `s`.`RightId` FROM `EntityOnes` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`Name`, `j`.`LeftId`, `j`.`RightId` FROM `JoinOneSelfPayload` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`LeftId` = `e0`.`Id` -) AS `t` ON `e`.`Id` = `t`.`RightId` -ORDER BY `e`.`Id`, `t`.`LeftId`, `t`.`RightId` +) AS `s` ON `e`.`Id` = `s`.`RightId` +ORDER BY `e`.`Id`, `s`.`LeftId`, `s`.`RightId` """); } @@ -667,24 +664,24 @@ public override async Task Select_skip_navigation_multiple(bool async) AssertSql( """ -SELECT `e`.`Id`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`ThreeId`, `t`.`TwoId`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `t0`.`SelfSkipSharedLeftId`, `t0`.`SelfSkipSharedRightId`, `t1`.`Key1`, `t1`.`Key2`, `t1`.`Key3`, `t1`.`Name`, `t1`.`TwoSkipSharedId`, `t1`.`CompositeKeySkipSharedKey1`, `t1`.`CompositeKeySkipSharedKey2`, `t1`.`CompositeKeySkipSharedKey3` +SELECT `e`.`Id`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`ThreeId`, `s`.`TwoId`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`SelfSkipSharedLeftId`, `s0`.`SelfSkipSharedRightId`, `s1`.`Key1`, `s1`.`Key2`, `s1`.`Key3`, `s1`.`Name`, `s1`.`TwoSkipSharedId`, `s1`.`CompositeKeySkipSharedKey1`, `s1`.`CompositeKeySkipSharedKey2`, `s1`.`CompositeKeySkipSharedKey3` FROM `EntityTwos` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`ThreeId`, `j`.`TwoId` FROM `JoinTwoToThree` AS `j` INNER JOIN `EntityThrees` AS `e0` ON `j`.`ThreeId` = `e0`.`Id` -) AS `t` ON `e`.`Id` = `t`.`TwoId` +) AS `s` ON `e`.`Id` = `s`.`TwoId` LEFT JOIN ( SELECT `e2`.`Id`, `e2`.`CollectionInverseId`, `e2`.`ExtraId`, `e2`.`Name`, `e2`.`ReferenceInverseId`, `e1`.`SelfSkipSharedLeftId`, `e1`.`SelfSkipSharedRightId` FROM `EntityTwoEntityTwo` AS `e1` INNER JOIN `EntityTwos` AS `e2` ON `e1`.`SelfSkipSharedLeftId` = `e2`.`Id` -) AS `t0` ON `e`.`Id` = `t0`.`SelfSkipSharedRightId` +) AS `s0` ON `e`.`Id` = `s0`.`SelfSkipSharedRightId` LEFT JOIN ( SELECT `e4`.`Key1`, `e4`.`Key2`, `e4`.`Key3`, `e4`.`Name`, `e3`.`TwoSkipSharedId`, `e3`.`CompositeKeySkipSharedKey1`, `e3`.`CompositeKeySkipSharedKey2`, `e3`.`CompositeKeySkipSharedKey3` FROM `EntityCompositeKeyEntityTwo` AS `e3` INNER JOIN `EntityCompositeKeys` AS `e4` ON ((`e3`.`CompositeKeySkipSharedKey1` = `e4`.`Key1`) AND (`e3`.`CompositeKeySkipSharedKey2` = `e4`.`Key2`)) AND (`e3`.`CompositeKeySkipSharedKey3` = `e4`.`Key3`) -) AS `t1` ON `e`.`Id` = `t1`.`TwoSkipSharedId` -ORDER BY `e`.`Id`, `t`.`ThreeId`, `t`.`TwoId`, `t`.`Id`, `t0`.`SelfSkipSharedLeftId`, `t0`.`SelfSkipSharedRightId`, `t0`.`Id`, `t1`.`TwoSkipSharedId`, `t1`.`CompositeKeySkipSharedKey1`, `t1`.`CompositeKeySkipSharedKey2`, `t1`.`CompositeKeySkipSharedKey3`, `t1`.`Key1`, `t1`.`Key2` +) AS `s1` ON `e`.`Id` = `s1`.`TwoSkipSharedId` +ORDER BY `e`.`Id`, `s`.`ThreeId`, `s`.`TwoId`, `s`.`Id`, `s0`.`SelfSkipSharedLeftId`, `s0`.`SelfSkipSharedRightId`, `s0`.`Id`, `s1`.`TwoSkipSharedId`, `s1`.`CompositeKeySkipSharedKey1`, `s1`.`CompositeKeySkipSharedKey2`, `s1`.`CompositeKeySkipSharedKey3`, `s1`.`Key1`, `s1`.`Key2` """); } @@ -694,17 +691,17 @@ public override async Task Select_skip_navigation_first_or_default(bool async) AssertSql( """ -SELECT `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3`, `t0`.`Name` +SELECT `s0`.`Key1`, `s0`.`Key2`, `s0`.`Key3`, `s0`.`Name` FROM `EntityThrees` AS `e` LEFT JOIN ( - SELECT `t`.`Key1`, `t`.`Key2`, `t`.`Key3`, `t`.`Name`, `t`.`ThreeId` + SELECT `s`.`Key1`, `s`.`Key2`, `s`.`Key3`, `s`.`Name`, `s`.`ThreeId` FROM ( SELECT `e0`.`Key1`, `e0`.`Key2`, `e0`.`Key3`, `e0`.`Name`, `j`.`ThreeId`, ROW_NUMBER() OVER(PARTITION BY `j`.`ThreeId` ORDER BY `e0`.`Key1`, `e0`.`Key2`) AS `row` FROM `JoinThreeToCompositeKeyFull` AS `j` INNER JOIN `EntityCompositeKeys` AS `e0` ON ((`j`.`CompositeId1` = `e0`.`Key1`) AND (`j`.`CompositeId2` = `e0`.`Key2`)) AND (`j`.`CompositeId3` = `e0`.`Key3`) - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `e`.`Id` = `t0`.`ThreeId` + ) AS `s` + WHERE `s`.`row` <= 1 +) AS `s0` ON `e`.`Id` = `s0`.`ThreeId` ORDER BY `e`.`Id` """); } @@ -714,27 +711,27 @@ public override async Task Include_skip_navigation(bool async) await base.Include_skip_navigation(async); AssertSql( -$""" -SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`Slumber`, `t0`.`IsGreen`, `t0`.`IsBrown`, `t0`.`Discriminator`, `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3` +""" +SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`Slumber`, `s`.`IsGreen`, `s`.`IsBrown`, `s`.`Discriminator`, `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3` FROM `EntityCompositeKeys` AS `e` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`Slumber`, `t`.`IsGreen`, `t`.`IsBrown`, `t`.`Discriminator`, `e0`.`RootSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` + SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`Slumber`, `u`.`IsGreen`, `u`.`IsBrown`, `u`.`Discriminator`, `e0`.`RootSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` FROM `EntityCompositeKeyEntityRoot` AS `e0` INNER JOIN ( - SELECT `r`.`Id`, `r`.`Name`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `Number`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `Slumber`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsGreen`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsBrown`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'EntityRoot'")} AS `Discriminator` + SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `Slumber`, NULL AS `IsGreen`, NULL AS `IsBrown`, 'EntityRoot' AS `Discriminator` FROM `Roots` AS `r` UNION ALL - SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `Slumber`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsGreen`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsBrown`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'EntityBranch'")} AS `Discriminator` + SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, NULL AS `Slumber`, NULL AS `IsGreen`, NULL AS `IsBrown`, 'EntityBranch' AS `Discriminator` FROM `Branches` AS `b` UNION ALL SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, NULL AS `Slumber`, `l`.`IsGreen`, NULL AS `IsBrown`, 'EntityLeaf' AS `Discriminator` FROM `Leaves` AS `l` UNION ALL - SELECT `l0`.`Id`, `l0`.`Name`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `Number`, `l0`.`Slumber`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsGreen`, `l0`.`IsBrown`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'EntityLeaf2'")} AS `Discriminator` + SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, `l0`.`Slumber`, NULL AS `IsGreen`, `l0`.`IsBrown`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` - ) AS `t` ON `e0`.`RootSkipSharedId` = `t`.`Id` -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `t0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `t0`.`CompositeKeySkipSharedKey3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3` + ) AS `u` ON `e0`.`RootSkipSharedId` = `u`.`Id` +) AS `s` ON ((`e`.`Key1` = `s`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `s`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `s`.`CompositeKeySkipSharedKey3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3` """); } @@ -744,15 +741,15 @@ public override async Task Include_skip_navigation_then_reference(bool async) AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t`.`Id`, `t`.`Name`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name0`, `t`.`ReferenceInverseId`, `t`.`OneId`, `t`.`TwoId` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s`.`Id`, `s`.`Name`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId`, `s`.`OneId`, `s`.`TwoId` FROM `EntityTwos` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId`, `j`.`OneId`, `j`.`TwoId` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` -) AS `t` ON `e`.`Id` = `t`.`TwoId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id` +) AS `s` ON `e`.`Id` = `s`.`TwoId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id` """); } @@ -762,19 +759,19 @@ public override async Task Include_skip_navigation_then_include_skip_navigation( AssertSql( """ -SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id0`, `t0`.`Name0`, `t0`.`EntityBranchId`, `t0`.`EntityOneId` +SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `s0`.`Id`, `s0`.`Name`, `s0`.`Number`, `s0`.`IsGreen`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id0`, `s0`.`Name0`, `s0`.`EntityBranchId`, `s0`.`EntityOneId` FROM `EntityCompositeKeys` AS `e` LEFT JOIN ( - SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `t`.`Id` AS `Id0`, `t`.`Name` AS `Name0`, `t`.`EntityBranchId`, `t`.`EntityOneId` + SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `s`.`Id` AS `Id0`, `s`.`Name` AS `Name0`, `s`.`EntityBranchId`, `s`.`EntityOneId` FROM `JoinCompositeKeyToLeaf` AS `j` INNER JOIN `Leaves` AS `l` ON `j`.`LeafId` = `l`.`Id` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`Name`, `j0`.`EntityBranchId`, `j0`.`EntityOneId` FROM `JoinOneToBranch` AS `j0` INNER JOIN `EntityOnes` AS `e0` ON `j0`.`EntityOneId` = `e0`.`Id` - ) AS `t` ON `l`.`Id` = `t`.`EntityBranchId` -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeId1`) AND (`e`.`Key2` = `t0`.`CompositeId2`)) AND (`e`.`Key3` = `t0`.`CompositeId3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id`, `t0`.`EntityBranchId`, `t0`.`EntityOneId` + ) AS `s` ON `l`.`Id` = `s`.`EntityBranchId` +) AS `s0` ON ((`e`.`Key1` = `s0`.`CompositeId1`) AND (`e`.`Key2` = `s0`.`CompositeId2`)) AND (`e`.`Key3` = `s0`.`CompositeId3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id`, `s0`.`EntityBranchId`, `s0`.`EntityOneId` """); } @@ -784,10 +781,10 @@ public override async Task Include_skip_navigation_then_include_reference_and_sk AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t0`.`Id`, `t0`.`Name`, `t0`.`Id0`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name0`, `t0`.`ReferenceInverseId`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Id1`, `t0`.`Name1`, `t0`.`LeftId`, `t0`.`RightId` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s0`.`Id`, `s0`.`Name`, `s0`.`Id0`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name0`, `s0`.`ReferenceInverseId`, `s0`.`OneId`, `s0`.`ThreeId`, `s0`.`Id1`, `s0`.`Name1`, `s0`.`LeftId`, `s0`.`RightId` FROM `EntityThrees` AS `e` LEFT JOIN ( - SELECT `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId`, `j`.`OneId`, `j`.`ThreeId`, `t`.`Id` AS `Id1`, `t`.`Name` AS `Name1`, `t`.`LeftId`, `t`.`RightId` + SELECT `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId`, `j`.`OneId`, `j`.`ThreeId`, `s`.`Id` AS `Id1`, `s`.`Name` AS `Name1`, `s`.`LeftId`, `s`.`RightId` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` @@ -795,9 +792,9 @@ LEFT JOIN ( SELECT `e2`.`Id`, `e2`.`Name`, `j0`.`LeftId`, `j0`.`RightId` FROM `JoinOneSelfPayload` AS `j0` INNER JOIN `EntityOnes` AS `e2` ON `j0`.`RightId` = `e2`.`Id` - ) AS `t` ON `e0`.`Id` = `t`.`LeftId` -) AS `t0` ON `e`.`Id` = `t0`.`ThreeId` -ORDER BY `e`.`Id`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Id`, `t0`.`Id0`, `t0`.`LeftId`, `t0`.`RightId` + ) AS `s` ON `e0`.`Id` = `s`.`LeftId` +) AS `s0` ON `e`.`Id` = `s0`.`ThreeId` +ORDER BY `e`.`Id`, `s0`.`OneId`, `s0`.`ThreeId`, `s0`.`Id`, `s0`.`Id0`, `s0`.`LeftId`, `s0`.`RightId` """); } @@ -807,15 +804,15 @@ public override async Task Include_skip_navigation_and_reference(bool async) AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `e0`.`Id`, `t`.`Id`, `t`.`Name`, `t`.`OneSkipSharedId`, `t`.`TwoSkipSharedId`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `e0`.`Id`, `s`.`Id`, `s`.`Name`, `s`.`OneSkipSharedId`, `s`.`TwoSkipSharedId`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId` FROM `EntityTwos` AS `e` LEFT JOIN `EntityThrees` AS `e0` ON `e`.`Id` = `e0`.`ReferenceInverseId` LEFT JOIN ( SELECT `e2`.`Id`, `e2`.`Name`, `e1`.`OneSkipSharedId`, `e1`.`TwoSkipSharedId` FROM `EntityOneEntityTwo` AS `e1` INNER JOIN `EntityOnes` AS `e2` ON `e1`.`OneSkipSharedId` = `e2`.`Id` -) AS `t` ON `e`.`Id` = `t`.`TwoSkipSharedId` -ORDER BY `e`.`Id`, `e0`.`Id`, `t`.`OneSkipSharedId`, `t`.`TwoSkipSharedId` +) AS `s` ON `e`.`Id` = `s`.`TwoSkipSharedId` +ORDER BY `e`.`Id`, `e0`.`Id`, `s`.`OneSkipSharedId`, `s`.`TwoSkipSharedId` """); } @@ -825,15 +822,15 @@ public override async Task Filtered_include_skip_navigation_where(bool async) AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t`.`Id`, `t`.`Name`, `t`.`OneId`, `t`.`ThreeId` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s`.`Id`, `s`.`Name`, `s`.`OneId`, `s`.`ThreeId` FROM `EntityThrees` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`Name`, `j`.`OneId`, `j`.`ThreeId` FROM `JoinOneToThreePayloadFullShared` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId` """); } @@ -843,14 +840,14 @@ public override async Task Filtered_include_skip_navigation_order_by(bool async) AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`ThreeId`, `t`.`TwoId` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`ThreeId`, `s`.`TwoId` FROM `EntityThrees` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`ThreeId`, `j`.`TwoId` FROM `JoinTwoToThree` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` -) AS `t` ON `e`.`Id` = `t`.`ThreeId` -ORDER BY `e`.`Id`, `t`.`Id`, `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`Id`, `s`.`ThreeId` """); } @@ -860,18 +857,18 @@ public override async Task Filtered_include_skip_navigation_order_by_skip(bool a AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `t0`.`SelfSkipSharedLeftId`, `t0`.`SelfSkipSharedRightId` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`SelfSkipSharedLeftId`, `s0`.`SelfSkipSharedRightId` FROM `EntityTwos` AS `e` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`SelfSkipSharedLeftId`, `t`.`SelfSkipSharedRightId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`SelfSkipSharedLeftId`, `s`.`SelfSkipSharedRightId` FROM ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `e0`.`SelfSkipSharedLeftId`, `e0`.`SelfSkipSharedRightId`, ROW_NUMBER() OVER(PARTITION BY `e0`.`SelfSkipSharedLeftId` ORDER BY `e1`.`Id`) AS `row` FROM `EntityTwoEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`SelfSkipSharedRightId` = `e1`.`Id` - ) AS `t` - WHERE 2 < `t`.`row` -) AS `t0` ON `e`.`Id` = `t0`.`SelfSkipSharedLeftId` -ORDER BY `e`.`Id`, `t0`.`SelfSkipSharedLeftId`, `t0`.`Id` + ) AS `s` + WHERE 2 < `s`.`row` +) AS `s0` ON `e`.`Id` = `s0`.`SelfSkipSharedLeftId` +ORDER BY `e`.`Id`, `s0`.`SelfSkipSharedLeftId`, `s0`.`Id` """); } @@ -881,18 +878,18 @@ public override async Task Filtered_include_skip_navigation_order_by_take(bool a AssertSql( """ -SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `t0`.`TwoSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3` +SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`TwoSkipSharedId`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3` FROM `EntityCompositeKeys` AS `e` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`TwoSkipSharedId`, `t`.`CompositeKeySkipSharedKey1`, `t`.`CompositeKeySkipSharedKey2`, `t`.`CompositeKeySkipSharedKey3` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`TwoSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3` FROM ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `e0`.`TwoSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3`, ROW_NUMBER() OVER(PARTITION BY `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` ORDER BY `e1`.`Id`) AS `row` FROM `EntityCompositeKeyEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`TwoSkipSharedId` = `e1`.`Id` - ) AS `t` - WHERE `t`.`row` <= 2 -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `t0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `t0`.`CompositeKeySkipSharedKey3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Id` + ) AS `s` + WHERE `s`.`row` <= 2 +) AS `s0` ON ((`e`.`Key1` = `s0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `s0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `s0`.`CompositeKeySkipSharedKey3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3`, `s0`.`Id` """); } @@ -902,18 +899,18 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take(b AssertSql( """ -SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `t0`.`Id0` +SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`Id0` FROM `EntityCompositeKeys` AS `e` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`Id0`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`Id0`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3` FROM ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`Id` AS `Id0`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, ROW_NUMBER() OVER(PARTITION BY `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3` ORDER BY `e0`.`Id`) AS `row` FROM `JoinThreeToCompositeKeyFull` AS `j` INNER JOIN `EntityThrees` AS `e0` ON `j`.`ThreeId` = `e0`.`Id` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 3) -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeId1`) AND (`e`.`Key2` = `t0`.`CompositeId2`)) AND (`e`.`Key3` = `t0`.`CompositeId3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) +) AS `s0` ON ((`e`.`Key1` = `s0`.`CompositeId1`) AND (`e`.`Key2` = `s0`.`CompositeId2`)) AND (`e`.`Key3` = `s0`.`CompositeId3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id` """); } @@ -923,7 +920,7 @@ public override async Task Filtered_then_include_skip_navigation_where(bool asyn AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`Slumber`, `t`.`IsGreen`, `t`.`IsBrown`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `t0`.`RootSkipSharedId`, `t0`.`ThreeSkipSharedId`, `t0`.`Id0`, `t0`.`Name0`, `t0`.`OneId`, `t0`.`ThreeId` +SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`Slumber`, `u`.`IsGreen`, `u`.`IsBrown`, `u`.`Discriminator`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`RootSkipSharedId`, `s0`.`ThreeSkipSharedId`, `s0`.`Id0`, `s0`.`Name0`, `s0`.`OneId`, `s0`.`ThreeId` FROM ( SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `Slumber`, NULL AS `IsGreen`, NULL AS `IsBrown`, 'EntityRoot' AS `Discriminator` FROM `Roots` AS `r` @@ -936,9 +933,9 @@ UNION ALL UNION ALL SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, `l0`.`Slumber`, NULL AS `IsGreen`, `l0`.`IsBrown`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `e`.`RootSkipSharedId`, `e`.`ThreeSkipSharedId`, `t1`.`Id` AS `Id0`, `t1`.`Name` AS `Name0`, `t1`.`OneId`, `t1`.`ThreeId` + SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `e`.`RootSkipSharedId`, `e`.`ThreeSkipSharedId`, `s`.`Id` AS `Id0`, `s`.`Name` AS `Name0`, `s`.`OneId`, `s`.`ThreeId` FROM `EntityRootEntityThree` AS `e` INNER JOIN `EntityThrees` AS `e0` ON `e`.`ThreeSkipSharedId` = `e0`.`Id` LEFT JOIN ( @@ -946,9 +943,9 @@ LEFT JOIN ( FROM `JoinOneToThreePayloadFullShared` AS `j` INNER JOIN `EntityOnes` AS `e1` ON `j`.`OneId` = `e1`.`Id` WHERE `e1`.`Id` < 10 - ) AS `t1` ON `e0`.`Id` = `t1`.`ThreeId` -) AS `t0` ON `t`.`Id` = `t0`.`RootSkipSharedId` -ORDER BY `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`ThreeSkipSharedId`, `t0`.`Id`, `t0`.`OneId`, `t0`.`ThreeId` + ) AS `s` ON `e0`.`Id` = `s`.`ThreeId` +) AS `s0` ON `u`.`Id` = `s0`.`RootSkipSharedId` +ORDER BY `u`.`Id`, `s0`.`RootSkipSharedId`, `s0`.`ThreeSkipSharedId`, `s0`.`Id`, `s0`.`OneId`, `s0`.`ThreeId` """); } @@ -958,7 +955,7 @@ public override async Task Filtered_then_include_skip_navigation_order_by_skip_t AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`Slumber`, `t`.`IsGreen`, `t`.`IsBrown`, `t`.`Discriminator`, `t1`.`Key1`, `t1`.`Key2`, `t1`.`Key3`, `t1`.`Name`, `t1`.`RootSkipSharedId`, `t1`.`CompositeKeySkipSharedKey1`, `t1`.`CompositeKeySkipSharedKey2`, `t1`.`CompositeKeySkipSharedKey3`, `t1`.`Id`, `t1`.`CollectionInverseId`, `t1`.`Name0`, `t1`.`ReferenceInverseId`, `t1`.`Id0` +SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`Slumber`, `u`.`IsGreen`, `u`.`IsBrown`, `u`.`Discriminator`, `s1`.`Key1`, `s1`.`Key2`, `s1`.`Key3`, `s1`.`Name`, `s1`.`RootSkipSharedId`, `s1`.`CompositeKeySkipSharedKey1`, `s1`.`CompositeKeySkipSharedKey2`, `s1`.`CompositeKeySkipSharedKey3`, `s1`.`Id`, `s1`.`CollectionInverseId`, `s1`.`Name0`, `s1`.`ReferenceInverseId`, `s1`.`Id0` FROM ( SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `Slumber`, NULL AS `IsGreen`, NULL AS `IsBrown`, 'EntityRoot' AS `Discriminator` FROM `Roots` AS `r` @@ -971,22 +968,22 @@ UNION ALL UNION ALL SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, `l0`.`Slumber`, NULL AS `IsGreen`, `l0`.`IsBrown`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `e0`.`Key1`, `e0`.`Key2`, `e0`.`Key3`, `e0`.`Name`, `e`.`RootSkipSharedId`, `e`.`CompositeKeySkipSharedKey1`, `e`.`CompositeKeySkipSharedKey2`, `e`.`CompositeKeySkipSharedKey3`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name` AS `Name0`, `t0`.`ReferenceInverseId`, `t0`.`Id0`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3` + SELECT `e0`.`Key1`, `e0`.`Key2`, `e0`.`Key3`, `e0`.`Name`, `e`.`RootSkipSharedId`, `e`.`CompositeKeySkipSharedKey1`, `e`.`CompositeKeySkipSharedKey2`, `e`.`CompositeKeySkipSharedKey3`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`Name` AS `Name0`, `s0`.`ReferenceInverseId`, `s0`.`Id0`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3` FROM `EntityCompositeKeyEntityRoot` AS `e` INNER JOIN `EntityCompositeKeys` AS `e0` ON ((`e`.`CompositeKeySkipSharedKey1` = `e0`.`Key1`) AND (`e`.`CompositeKeySkipSharedKey2` = `e0`.`Key2`)) AND (`e`.`CompositeKeySkipSharedKey3` = `e0`.`Key3`) LEFT JOIN ( - SELECT `t2`.`Id`, `t2`.`CollectionInverseId`, `t2`.`Name`, `t2`.`ReferenceInverseId`, `t2`.`Id0`, `t2`.`CompositeId1`, `t2`.`CompositeId2`, `t2`.`CompositeId3` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`Id0`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3` FROM ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `j`.`Id` AS `Id0`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, ROW_NUMBER() OVER(PARTITION BY `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3` ORDER BY `e1`.`Id`) AS `row` FROM `JoinThreeToCompositeKeyFull` AS `j` INNER JOIN `EntityThrees` AS `e1` ON `j`.`ThreeId` = `e1`.`Id` - ) AS `t2` - WHERE (1 < `t2`.`row`) AND (`t2`.`row` <= 3) - ) AS `t0` ON ((`e0`.`Key1` = `t0`.`CompositeId1`) AND (`e0`.`Key2` = `t0`.`CompositeId2`)) AND (`e0`.`Key3` = `t0`.`CompositeId3`) -) AS `t1` ON `t`.`Id` = `t1`.`RootSkipSharedId` -ORDER BY `t`.`Id`, `t1`.`RootSkipSharedId`, `t1`.`CompositeKeySkipSharedKey1`, `t1`.`CompositeKeySkipSharedKey2`, `t1`.`CompositeKeySkipSharedKey3`, `t1`.`Key1`, `t1`.`Key2`, `t1`.`Key3`, `t1`.`CompositeId1`, `t1`.`CompositeId2`, `t1`.`CompositeId3`, `t1`.`Id` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) + ) AS `s0` ON ((`e0`.`Key1` = `s0`.`CompositeId1`) AND (`e0`.`Key2` = `s0`.`CompositeId2`)) AND (`e0`.`Key3` = `s0`.`CompositeId3`) +) AS `s1` ON `u`.`Id` = `s1`.`RootSkipSharedId` +ORDER BY `u`.`Id`, `s1`.`RootSkipSharedId`, `s1`.`CompositeKeySkipSharedKey1`, `s1`.`CompositeKeySkipSharedKey2`, `s1`.`CompositeKeySkipSharedKey3`, `s1`.`Key1`, `s1`.`Key2`, `s1`.`Key3`, `s1`.`CompositeId1`, `s1`.`CompositeId2`, `s1`.`CompositeId3`, `s1`.`Id` """); } @@ -996,20 +993,20 @@ public override async Task Filtered_include_skip_navigation_where_then_include_s AssertSql( """ -SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3`, `t0`.`Name`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name0`, `t0`.`ReferenceInverseId`, `t0`.`TwoSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3` +SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, `s0`.`Key1`, `s0`.`Key2`, `s0`.`Key3`, `s0`.`Name`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name0`, `s0`.`ReferenceInverseId`, `s0`.`TwoSkipSharedId`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3` FROM `Leaves` AS `l` LEFT JOIN ( - SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name` AS `Name0`, `t`.`ReferenceInverseId`, `t`.`TwoSkipSharedId`, `t`.`CompositeKeySkipSharedKey1`, `t`.`CompositeKeySkipSharedKey2`, `t`.`CompositeKeySkipSharedKey3` + SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name` AS `Name0`, `s`.`ReferenceInverseId`, `s`.`TwoSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3` FROM `JoinCompositeKeyToLeaf` AS `j` INNER JOIN `EntityCompositeKeys` AS `e` ON ((`j`.`CompositeId1` = `e`.`Key1`) AND (`j`.`CompositeId2` = `e`.`Key2`)) AND (`j`.`CompositeId3` = `e`.`Key3`) LEFT JOIN ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `e0`.`TwoSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` FROM `EntityCompositeKeyEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`TwoSkipSharedId` = `e1`.`Id` - ) AS `t` ON ((`e`.`Key1` = `t`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `t`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `t`.`CompositeKeySkipSharedKey3`) + ) AS `s` ON ((`e`.`Key1` = `s`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `s`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `s`.`CompositeKeySkipSharedKey3`) WHERE `e`.`Key1` < 5 -) AS `t0` ON `l`.`Id` = `t0`.`LeafId` -ORDER BY `l`.`Id`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3`, `t0`.`TwoSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3` +) AS `s0` ON `l`.`Id` = `s0`.`LeafId` +ORDER BY `l`.`Id`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Key1`, `s0`.`Key2`, `s0`.`Key3`, `s0`.`TwoSkipSharedId`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3` """); } @@ -1019,10 +1016,10 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take_t AssertSql( """ -SELECT `e`.`Id`, `e`.`Name`, `t1`.`Id`, `t1`.`CollectionInverseId`, `t1`.`ExtraId`, `t1`.`Name`, `t1`.`ReferenceInverseId`, `t1`.`OneId`, `t1`.`TwoId`, `t1`.`Id0`, `t1`.`CollectionInverseId0`, `t1`.`Name0`, `t1`.`ReferenceInverseId0`, `t1`.`ThreeId`, `t1`.`TwoId0` +SELECT `e`.`Id`, `e`.`Name`, `s1`.`Id`, `s1`.`CollectionInverseId`, `s1`.`ExtraId`, `s1`.`Name`, `s1`.`ReferenceInverseId`, `s1`.`OneId`, `s1`.`TwoId`, `s1`.`Id0`, `s1`.`CollectionInverseId0`, `s1`.`Name0`, `s1`.`ReferenceInverseId0`, `s1`.`ThreeId`, `s1`.`TwoId0` FROM `EntityOnes` AS `e` LEFT JOIN LATERAL ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`OneId`, `t`.`TwoId`, `t0`.`Id` AS `Id0`, `t0`.`CollectionInverseId` AS `CollectionInverseId0`, `t0`.`Name` AS `Name0`, `t0`.`ReferenceInverseId` AS `ReferenceInverseId0`, `t0`.`ThreeId`, `t0`.`TwoId` AS `TwoId0` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`OneId`, `s`.`TwoId`, `s0`.`Id` AS `Id0`, `s0`.`CollectionInverseId` AS `CollectionInverseId0`, `s0`.`Name` AS `Name0`, `s0`.`ReferenceInverseId` AS `ReferenceInverseId0`, `s0`.`ThreeId`, `s0`.`TwoId` AS `TwoId0` FROM ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId`, `j`.`TwoId` FROM `JoinOneToTwo` AS `j` @@ -1030,15 +1027,15 @@ LEFT JOIN LATERAL ( WHERE `e`.`Id` = `j`.`OneId` ORDER BY `e0`.`Id` LIMIT 2 OFFSET 1 - ) AS `t` + ) AS `s` LEFT JOIN ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `j0`.`ThreeId`, `j0`.`TwoId` FROM `JoinTwoToThree` AS `j0` INNER JOIN `EntityThrees` AS `e1` ON `j0`.`ThreeId` = `e1`.`Id` WHERE `e1`.`Id` < 10 - ) AS `t0` ON `t`.`Id` = `t0`.`TwoId` -) AS `t1` ON TRUE -ORDER BY `e`.`Id`, `t1`.`Id`, `t1`.`OneId`, `t1`.`TwoId`, `t1`.`ThreeId`, `t1`.`TwoId0` + ) AS `s0` ON `s`.`Id` = `s0`.`TwoId` +) AS `s1` ON TRUE +ORDER BY `e`.`Id`, `s1`.`Id`, `s1`.`OneId`, `s1`.`TwoId`, `s1`.`ThreeId`, `s1`.`TwoId0` """); } @@ -1048,24 +1045,24 @@ public override async Task Filtered_include_skip_navigation_where_then_include_s AssertSql( """ -SELECT `e`.`Id`, `e`.`Name`, `t1`.`Id`, `t1`.`CollectionInverseId`, `t1`.`ExtraId`, `t1`.`Name`, `t1`.`ReferenceInverseId`, `t1`.`OneId`, `t1`.`TwoId`, `t1`.`Id0`, `t1`.`CollectionInverseId0`, `t1`.`Name0`, `t1`.`ReferenceInverseId0`, `t1`.`ThreeId`, `t1`.`TwoId0` +SELECT `e`.`Id`, `e`.`Name`, `s1`.`Id`, `s1`.`CollectionInverseId`, `s1`.`ExtraId`, `s1`.`Name`, `s1`.`ReferenceInverseId`, `s1`.`OneId`, `s1`.`TwoId`, `s1`.`Id0`, `s1`.`CollectionInverseId0`, `s1`.`Name0`, `s1`.`ReferenceInverseId0`, `s1`.`ThreeId`, `s1`.`TwoId0` FROM `EntityOnes` AS `e` LEFT JOIN ( - SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId`, `j`.`TwoId`, `t0`.`Id` AS `Id0`, `t0`.`CollectionInverseId` AS `CollectionInverseId0`, `t0`.`Name` AS `Name0`, `t0`.`ReferenceInverseId` AS `ReferenceInverseId0`, `t0`.`ThreeId`, `t0`.`TwoId` AS `TwoId0` + SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId`, `j`.`TwoId`, `s0`.`Id` AS `Id0`, `s0`.`CollectionInverseId` AS `CollectionInverseId0`, `s0`.`Name` AS `Name0`, `s0`.`ReferenceInverseId` AS `ReferenceInverseId0`, `s0`.`ThreeId`, `s0`.`TwoId` AS `TwoId0` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`ThreeId`, `t`.`TwoId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`ThreeId`, `s`.`TwoId` FROM ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `j0`.`ThreeId`, `j0`.`TwoId`, ROW_NUMBER() OVER(PARTITION BY `j0`.`TwoId` ORDER BY `e1`.`Id`) AS `row` FROM `JoinTwoToThree` AS `j0` INNER JOIN `EntityThrees` AS `e1` ON `j0`.`ThreeId` = `e1`.`Id` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 3) - ) AS `t0` ON `e0`.`Id` = `t0`.`TwoId` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) + ) AS `s0` ON `e0`.`Id` = `s0`.`TwoId` WHERE `e0`.`Id` < 10 -) AS `t1` ON `e`.`Id` = `t1`.`OneId` -ORDER BY `e`.`Id`, `t1`.`OneId`, `t1`.`TwoId`, `t1`.`Id`, `t1`.`TwoId0`, `t1`.`Id0` +) AS `s1` ON `e`.`Id` = `s1`.`OneId` +ORDER BY `e`.`Id`, `s1`.`OneId`, `s1`.`TwoId`, `s1`.`Id`, `s1`.`TwoId0`, `s1`.`Id0` """); } @@ -1075,7 +1072,7 @@ public override async Task Filter_include_on_skip_navigation_combined(bool async AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t`.`Id`, `t`.`Name`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name0`, `t`.`ReferenceInverseId`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id1`, `t`.`CollectionInverseId0`, `t`.`ExtraId0`, `t`.`Name1`, `t`.`ReferenceInverseId0` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s`.`Id`, `s`.`Name`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id1`, `s`.`CollectionInverseId0`, `s`.`ExtraId0`, `s`.`Name1`, `s`.`ReferenceInverseId0` FROM `EntityTwos` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId`, `j`.`OneId`, `j`.`TwoId`, `e2`.`Id` AS `Id1`, `e2`.`CollectionInverseId` AS `CollectionInverseId0`, `e2`.`ExtraId` AS `ExtraId0`, `e2`.`Name` AS `Name1`, `e2`.`ReferenceInverseId` AS `ReferenceInverseId0` @@ -1084,8 +1081,8 @@ LEFT JOIN ( LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` LEFT JOIN `EntityTwos` AS `e2` ON `e0`.`Id` = `e2`.`CollectionInverseId` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`TwoId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id`, `t`.`Id0` +) AS `s` ON `e`.`Id` = `s`.`TwoId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id`, `s`.`Id0` """); } @@ -1095,23 +1092,23 @@ public override async Task Filter_include_on_skip_navigation_combined_with_filte AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t3`.`Id`, `t3`.`Name`, `t3`.`OneId`, `t3`.`ThreeId`, `t3`.`Id0`, `t3`.`CollectionInverseId`, `t3`.`ExtraId`, `t3`.`Name0`, `t3`.`ReferenceInverseId`, `t3`.`OneId0`, `t3`.`TwoId`, `t3`.`Id1`, `t3`.`Name1`, `t3`.`Number`, `t3`.`IsGreen`, `t3`.`Discriminator`, `t3`.`EntityBranchId`, `t3`.`EntityOneId` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s2`.`Id`, `s2`.`Name`, `s2`.`OneId`, `s2`.`ThreeId`, `s2`.`Id0`, `s2`.`CollectionInverseId`, `s2`.`ExtraId`, `s2`.`Name0`, `s2`.`ReferenceInverseId`, `s2`.`OneId0`, `s2`.`TwoId`, `s2`.`Id1`, `s2`.`Name1`, `s2`.`Number`, `s2`.`IsGreen`, `s2`.`Discriminator`, `s2`.`EntityBranchId`, `s2`.`EntityOneId` FROM `EntityThrees` AS `e` LEFT JOIN ( - SELECT `e0`.`Id`, `e0`.`Name`, `j`.`OneId`, `j`.`ThreeId`, `t0`.`Id` AS `Id0`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name` AS `Name0`, `t0`.`ReferenceInverseId`, `t0`.`OneId` AS `OneId0`, `t0`.`TwoId`, `t1`.`Id` AS `Id1`, `t1`.`Name` AS `Name1`, `t1`.`Number`, `t1`.`IsGreen`, `t1`.`Discriminator`, `t1`.`EntityBranchId`, `t1`.`EntityOneId` + SELECT `e0`.`Id`, `e0`.`Name`, `j`.`OneId`, `j`.`ThreeId`, `s0`.`Id` AS `Id0`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name` AS `Name0`, `s0`.`ReferenceInverseId`, `s0`.`OneId` AS `OneId0`, `s0`.`TwoId`, `s1`.`Id` AS `Id1`, `s1`.`Name` AS `Name1`, `s1`.`Number`, `s1`.`IsGreen`, `s1`.`Discriminator`, `s1`.`EntityBranchId`, `s1`.`EntityOneId` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`OneId`, `t`.`TwoId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`OneId`, `s`.`TwoId` FROM ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `j0`.`OneId`, `j0`.`TwoId`, ROW_NUMBER() OVER(PARTITION BY `j0`.`OneId` ORDER BY `e1`.`Id`) AS `row` FROM `JoinOneToTwo` AS `j0` INNER JOIN `EntityTwos` AS `e1` ON `j0`.`TwoId` = `e1`.`Id` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 3) - ) AS `t0` ON `e0`.`Id` = `t0`.`OneId` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) + ) AS `s0` ON `e0`.`Id` = `s0`.`OneId` LEFT JOIN ( - SELECT `t2`.`Id`, `t2`.`Name`, `t2`.`Number`, `t2`.`IsGreen`, `t2`.`Discriminator`, `j1`.`EntityBranchId`, `j1`.`EntityOneId` + SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `u`.`Discriminator`, `j1`.`EntityBranchId`, `j1`.`EntityOneId` FROM `JoinOneToBranch` AS `j1` INNER JOIN ( SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, NULL AS `IsGreen`, 'EntityBranch' AS `Discriminator` @@ -1119,12 +1116,12 @@ INNER JOIN ( UNION ALL SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, 'EntityLeaf' AS `Discriminator` FROM `Leaves` AS `l` - ) AS `t2` ON `j1`.`EntityBranchId` = `t2`.`Id` - WHERE `t2`.`Id` < 20 - ) AS `t1` ON `e0`.`Id` = `t1`.`EntityOneId` + ) AS `u` ON `j1`.`EntityBranchId` = `u`.`Id` + WHERE `u`.`Id` < 20 + ) AS `s1` ON `e0`.`Id` = `s1`.`EntityOneId` WHERE `e0`.`Id` < 10 -) AS `t3` ON `e`.`Id` = `t3`.`ThreeId` -ORDER BY `e`.`Id`, `t3`.`OneId`, `t3`.`ThreeId`, `t3`.`Id`, `t3`.`OneId0`, `t3`.`Id0`, `t3`.`TwoId`, `t3`.`EntityBranchId`, `t3`.`EntityOneId` +) AS `s2` ON `e`.`Id` = `s2`.`ThreeId` +ORDER BY `e`.`Id`, `s2`.`OneId`, `s2`.`ThreeId`, `s2`.`Id`, `s2`.`OneId0`, `s2`.`Id0`, `s2`.`TwoId`, `s2`.`EntityBranchId`, `s2`.`EntityOneId` """); } @@ -1134,20 +1131,20 @@ public override async Task Filtered_include_on_skip_navigation_then_filtered_inc AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t0`.`Id`, `t0`.`Name`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Id0`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name0`, `t0`.`ReferenceInverseId` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s`.`Id`, `s`.`Name`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId` FROM `EntityThrees` AS `e` LEFT JOIN ( - SELECT `e0`.`Id`, `e0`.`Name`, `j`.`OneId`, `j`.`ThreeId`, `t`.`Id` AS `Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name` AS `Name0`, `t`.`ReferenceInverseId` + SELECT `e0`.`Id`, `e0`.`Name`, `j`.`OneId`, `j`.`ThreeId`, `e2`.`Id` AS `Id0`, `e2`.`CollectionInverseId`, `e2`.`ExtraId`, `e2`.`Name` AS `Name0`, `e2`.`ReferenceInverseId` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId` FROM `EntityTwos` AS `e1` WHERE `e1`.`Id` < 5 - ) AS `t` ON `e0`.`Id` = `t`.`CollectionInverseId` + ) AS `e2` ON `e0`.`Id` = `e2`.`CollectionInverseId` WHERE `e0`.`Id` > 15 -) AS `t0` ON `e`.`Id` = `t0`.`ThreeId` -ORDER BY `e`.`Id`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Id` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` """); } @@ -1157,20 +1154,20 @@ public override async Task Filtered_include_on_navigation_then_filtered_include_ AssertSql( """ -SELECT `e`.`Id`, `e`.`Name`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `t0`.`Id0`, `t0`.`CollectionInverseId0`, `t0`.`Name0`, `t0`.`ReferenceInverseId0`, `t0`.`ThreeId`, `t0`.`TwoId` +SELECT `e`.`Id`, `e`.`Name`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`Id0`, `s0`.`CollectionInverseId0`, `s0`.`Name0`, `s0`.`ReferenceInverseId0`, `s0`.`ThreeId`, `s0`.`TwoId` FROM `EntityOnes` AS `e` LEFT JOIN ( - SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `t`.`Id` AS `Id0`, `t`.`CollectionInverseId` AS `CollectionInverseId0`, `t`.`Name` AS `Name0`, `t`.`ReferenceInverseId` AS `ReferenceInverseId0`, `t`.`ThreeId`, `t`.`TwoId` + SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `s`.`Id` AS `Id0`, `s`.`CollectionInverseId` AS `CollectionInverseId0`, `s`.`Name` AS `Name0`, `s`.`ReferenceInverseId` AS `ReferenceInverseId0`, `s`.`ThreeId`, `s`.`TwoId` FROM `EntityTwos` AS `e0` LEFT JOIN ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `j`.`ThreeId`, `j`.`TwoId` FROM `JoinTwoToThree` AS `j` INNER JOIN `EntityThrees` AS `e1` ON `j`.`ThreeId` = `e1`.`Id` WHERE `e1`.`Id` < 5 - ) AS `t` ON `e0`.`Id` = `t`.`TwoId` + ) AS `s` ON `e0`.`Id` = `s`.`TwoId` WHERE `e0`.`Id` > 15 -) AS `t0` ON `e`.`Id` = `t0`.`CollectionInverseId` -ORDER BY `e`.`Id`, `t0`.`Id`, `t0`.`ThreeId`, `t0`.`TwoId` +) AS `s0` ON `e`.`Id` = `s0`.`CollectionInverseId` +ORDER BY `e`.`Id`, `s0`.`Id`, `s0`.`ThreeId`, `s0`.`TwoId` """); } @@ -1200,10 +1197,10 @@ public override async Task Include_skip_navigation_split(bool async) """, // """ -SELECT `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`Slumber`, `t0`.`IsGreen`, `t0`.`IsBrown`, `t0`.`Discriminator`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3` +SELECT `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`Slumber`, `s`.`IsGreen`, `s`.`IsBrown`, `s`.`Discriminator`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3` FROM `EntityCompositeKeys` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`Slumber`, `t`.`IsGreen`, `t`.`IsBrown`, `t`.`Discriminator`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` + SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`Slumber`, `u`.`IsGreen`, `u`.`IsBrown`, `u`.`Discriminator`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` FROM `EntityCompositeKeyEntityRoot` AS `e0` INNER JOIN ( SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `Slumber`, NULL AS `IsGreen`, NULL AS `IsBrown`, 'EntityRoot' AS `Discriminator` @@ -1217,8 +1214,8 @@ UNION ALL UNION ALL SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, `l0`.`Slumber`, NULL AS `IsGreen`, `l0`.`IsBrown`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` - ) AS `t` ON `e0`.`RootSkipSharedId` = `t`.`Id` -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `t0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `t0`.`CompositeKeySkipSharedKey3`) + ) AS `u` ON `e0`.`RootSkipSharedId` = `u`.`Id` +) AS `s` ON ((`e`.`Key1` = `s`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `s`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `s`.`CompositeKeySkipSharedKey3`) ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3` """); } @@ -1235,14 +1232,14 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name0`, `t`.`ReferenceInverseId`, `e`.`Id` +SELECT `s`.`Id`, `s`.`Name`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId`, `e`.`Id` FROM `EntityTwos` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId`, `j`.`TwoId` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` -) AS `t` ON `e`.`Id` = `t`.`TwoId` +) AS `s` ON `e`.`Id` = `s`.`TwoId` ORDER BY `e`.`Id` """); } @@ -1259,30 +1256,30 @@ public override async Task Include_skip_navigation_then_include_skip_navigation_ """, // """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3` +SELECT `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3` FROM `EntityCompositeKeys` AS `e` INNER JOIN ( SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3` FROM `JoinCompositeKeyToLeaf` AS `j` INNER JOIN `Leaves` AS `l` ON `j`.`LeafId` = `l`.`Id` -) AS `t` ON ((`e`.`Key1` = `t`.`CompositeId1`) AND (`e`.`Key2` = `t`.`CompositeId2`)) AND (`e`.`Key3` = `t`.`CompositeId3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`Id` +) AS `s` ON ((`e`.`Key1` = `s`.`CompositeId1`) AND (`e`.`Key2` = `s`.`CompositeId2`)) AND (`e`.`Key3` = `s`.`CompositeId3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`Id` """, // """ -SELECT `t0`.`Id`, `t0`.`Name`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`Id` +SELECT `s0`.`Id`, `s0`.`Name`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`Id` FROM `EntityCompositeKeys` AS `e` INNER JOIN ( SELECT `l`.`Id`, `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3` FROM `JoinCompositeKeyToLeaf` AS `j` INNER JOIN `Leaves` AS `l` ON `j`.`LeafId` = `l`.`Id` -) AS `t` ON ((`e`.`Key1` = `t`.`CompositeId1`) AND (`e`.`Key2` = `t`.`CompositeId2`)) AND (`e`.`Key3` = `t`.`CompositeId3`) +) AS `s` ON ((`e`.`Key1` = `s`.`CompositeId1`) AND (`e`.`Key2` = `s`.`CompositeId2`)) AND (`e`.`Key3` = `s`.`CompositeId3`) INNER JOIN ( SELECT `e0`.`Id`, `e0`.`Name`, `j0`.`EntityBranchId` FROM `JoinOneToBranch` AS `j0` INNER JOIN `EntityOnes` AS `e0` ON `j0`.`EntityOneId` = `e0`.`Id` -) AS `t0` ON `t`.`Id` = `t0`.`EntityBranchId` -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`Id` +) AS `s0` ON `s`.`Id` = `s0`.`EntityBranchId` +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`Id` """); } @@ -1298,32 +1295,32 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name0`, `t`.`ReferenceInverseId`, `e`.`Id`, `t`.`OneId`, `t`.`ThreeId` +SELECT `s`.`Id`, `s`.`Name`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId`, `e`.`Id`, `s`.`OneId`, `s`.`ThreeId` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId`, `j`.`OneId`, `j`.`ThreeId` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` -) AS `t` ON `e`.`Id` = `t`.`ThreeId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id`, `t`.`Id0` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id`, `s`.`Id0` """, // """ -SELECT `t0`.`Id`, `t0`.`Name`, `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id`, `t`.`Id0` +SELECT `s0`.`Id`, `s0`.`Name`, `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id`, `s`.`Id0` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `e1`.`Id` AS `Id0`, `j`.`OneId`, `j`.`ThreeId` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` -) AS `t` ON `e`.`Id` = `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` INNER JOIN ( SELECT `e2`.`Id`, `e2`.`Name`, `j0`.`LeftId` FROM `JoinOneSelfPayload` AS `j0` INNER JOIN `EntityOnes` AS `e2` ON `j0`.`RightId` = `e2`.`Id` -) AS `t0` ON `t`.`Id` = `t0`.`LeftId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id`, `t`.`Id0` +) AS `s0` ON `s`.`Id` = `s0`.`LeftId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id`, `s`.`Id0` """); } @@ -1340,14 +1337,14 @@ public override async Task Include_skip_navigation_and_reference_split(bool asyn """, // """ -SELECT `t`.`Id`, `t`.`Name`, `e`.`Id`, `e0`.`Id` +SELECT `s`.`Id`, `s`.`Name`, `e`.`Id`, `e0`.`Id` FROM `EntityTwos` AS `e` LEFT JOIN `EntityThrees` AS `e0` ON `e`.`Id` = `e0`.`ReferenceInverseId` INNER JOIN ( SELECT `e2`.`Id`, `e2`.`Name`, `e1`.`TwoSkipSharedId` FROM `EntityOneEntityTwo` AS `e1` INNER JOIN `EntityOnes` AS `e2` ON `e1`.`OneSkipSharedId` = `e2`.`Id` -) AS `t` ON `e`.`Id` = `t`.`TwoSkipSharedId` +) AS `s` ON `e`.`Id` = `s`.`TwoSkipSharedId` ORDER BY `e`.`Id`, `e0`.`Id` """); } @@ -1364,14 +1361,14 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`Id`, `t`.`Name`, `e`.`Id` +SELECT `s`.`Id`, `s`.`Name`, `e`.`Id` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `e0`.`Name`, `j`.`ThreeId` FROM `JoinOneToThreePayloadFullShared` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` ORDER BY `e`.`Id` """); } @@ -1388,14 +1385,14 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `e`.`Id` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `e`.`Id` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`ThreeId` FROM `JoinTwoToThree` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` -) AS `t` ON `e`.`Id` = `t`.`ThreeId` -ORDER BY `e`.`Id`, `t`.`Id` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`Id` """); } @@ -1411,18 +1408,18 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Id` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `e`.`Id` FROM `EntityTwos` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`SelfSkipSharedLeftId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`SelfSkipSharedLeftId` FROM ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `e0`.`SelfSkipSharedLeftId`, ROW_NUMBER() OVER(PARTITION BY `e0`.`SelfSkipSharedLeftId` ORDER BY `e1`.`Id`) AS `row` FROM `EntityTwoEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`SelfSkipSharedRightId` = `e1`.`Id` - ) AS `t` - WHERE 2 < `t`.`row` -) AS `t0` ON `e`.`Id` = `t0`.`SelfSkipSharedLeftId` -ORDER BY `e`.`Id`, `t0`.`SelfSkipSharedLeftId`, `t0`.`Id` + ) AS `s` + WHERE 2 < `s`.`row` +) AS `s0` ON `e`.`Id` = `s0`.`SelfSkipSharedLeftId` +ORDER BY `e`.`Id`, `s0`.`SelfSkipSharedLeftId`, `s0`.`Id` """); } @@ -1438,18 +1435,18 @@ public override async Task Filtered_include_skip_navigation_order_by_take_split( """, // """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3` FROM `EntityCompositeKeys` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`CompositeKeySkipSharedKey1`, `t`.`CompositeKeySkipSharedKey2`, `t`.`CompositeKeySkipSharedKey3` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3` FROM ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3`, ROW_NUMBER() OVER(PARTITION BY `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` ORDER BY `e1`.`Id`) AS `row` FROM `EntityCompositeKeyEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`TwoSkipSharedId` = `e1`.`Id` - ) AS `t` - WHERE `t`.`row` <= 2 -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `t0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `t0`.`CompositeKeySkipSharedKey3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Id` + ) AS `s` + WHERE `s`.`row` <= 2 +) AS `s0` ON ((`e`.`Key1` = `s0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `s0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `s0`.`CompositeKeySkipSharedKey3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3`, `s0`.`Id` """); } @@ -1465,18 +1462,18 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take_s """, // """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3` FROM `EntityCompositeKeys` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3` FROM ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, ROW_NUMBER() OVER(PARTITION BY `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3` ORDER BY `e0`.`Id`) AS `row` FROM `JoinThreeToCompositeKeyFull` AS `j` INNER JOIN `EntityThrees` AS `e0` ON `j`.`ThreeId` = `e0`.`Id` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 3) -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeId1`) AND (`e`.`Key2` = `t0`.`CompositeId2`)) AND (`e`.`Key3` = `t0`.`CompositeId3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) +) AS `s0` ON ((`e`.`Key1` = `s0`.`CompositeId1`) AND (`e`.`Key2` = `s0`.`CompositeId2`)) AND (`e`.`Key3` = `s0`.`CompositeId3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id` """); } @@ -1486,7 +1483,7 @@ public override async Task Filtered_then_include_skip_navigation_where_split(boo AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`Slumber`, `t`.`IsGreen`, `t`.`IsBrown`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`Slumber`, `u`.`IsGreen`, `u`.`IsBrown`, `u`.`Discriminator` FROM ( SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `Slumber`, NULL AS `IsGreen`, NULL AS `IsBrown`, 'EntityRoot' AS `Discriminator` FROM `Roots` AS `r` @@ -1499,12 +1496,12 @@ UNION ALL UNION ALL SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, `l0`.`Slumber`, NULL AS `IsGreen`, `l0`.`IsBrown`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` -) AS `t` -ORDER BY `t`.`Id` +) AS `u` +ORDER BY `u`.`Id` """, // """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`ThreeSkipSharedId` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `u`.`Id`, `s`.`RootSkipSharedId`, `s`.`ThreeSkipSharedId` FROM ( SELECT `r`.`Id` FROM `Roots` AS `r` @@ -1517,17 +1514,17 @@ UNION ALL UNION ALL SELECT `l0`.`Id` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` INNER JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `e`.`RootSkipSharedId`, `e`.`ThreeSkipSharedId` FROM `EntityRootEntityThree` AS `e` INNER JOIN `EntityThrees` AS `e0` ON `e`.`ThreeSkipSharedId` = `e0`.`Id` -) AS `t0` ON `t`.`Id` = `t0`.`RootSkipSharedId` -ORDER BY `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`ThreeSkipSharedId`, `t0`.`Id` +) AS `s` ON `u`.`Id` = `s`.`RootSkipSharedId` +ORDER BY `u`.`Id`, `s`.`RootSkipSharedId`, `s`.`ThreeSkipSharedId`, `s`.`Id` """, // """ -SELECT `t1`.`Id`, `t1`.`Name`, `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`ThreeSkipSharedId`, `t0`.`Id` +SELECT `s0`.`Id`, `s0`.`Name`, `u`.`Id`, `s`.`RootSkipSharedId`, `s`.`ThreeSkipSharedId`, `s`.`Id` FROM ( SELECT `r`.`Id` FROM `Roots` AS `r` @@ -1540,19 +1537,19 @@ UNION ALL UNION ALL SELECT `l0`.`Id` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` INNER JOIN ( SELECT `e0`.`Id`, `e`.`RootSkipSharedId`, `e`.`ThreeSkipSharedId` FROM `EntityRootEntityThree` AS `e` INNER JOIN `EntityThrees` AS `e0` ON `e`.`ThreeSkipSharedId` = `e0`.`Id` -) AS `t0` ON `t`.`Id` = `t0`.`RootSkipSharedId` +) AS `s` ON `u`.`Id` = `s`.`RootSkipSharedId` INNER JOIN ( SELECT `e1`.`Id`, `e1`.`Name`, `j`.`ThreeId` FROM `JoinOneToThreePayloadFullShared` AS `j` INNER JOIN `EntityOnes` AS `e1` ON `j`.`OneId` = `e1`.`Id` WHERE `e1`.`Id` < 10 -) AS `t1` ON `t0`.`Id` = `t1`.`ThreeId` -ORDER BY `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`ThreeSkipSharedId`, `t0`.`Id` +) AS `s0` ON `s`.`Id` = `s0`.`ThreeId` +ORDER BY `u`.`Id`, `s`.`RootSkipSharedId`, `s`.`ThreeSkipSharedId`, `s`.`Id` """); } @@ -1562,7 +1559,7 @@ public override async Task Filtered_then_include_skip_navigation_order_by_skip_t AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`Slumber`, `t`.`IsGreen`, `t`.`IsBrown`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`Slumber`, `u`.`IsGreen`, `u`.`IsBrown`, `u`.`Discriminator` FROM ( SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `Slumber`, NULL AS `IsGreen`, NULL AS `IsBrown`, 'EntityRoot' AS `Discriminator` FROM `Roots` AS `r` @@ -1575,12 +1572,12 @@ UNION ALL UNION ALL SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, `l0`.`Slumber`, NULL AS `IsGreen`, `l0`.`IsBrown`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` -) AS `t` -ORDER BY `t`.`Id` +) AS `u` +ORDER BY `u`.`Id` """, // """ -SELECT `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3`, `t0`.`Name`, `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3` +SELECT `s`.`Key1`, `s`.`Key2`, `s`.`Key3`, `s`.`Name`, `u`.`Id`, `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3` FROM ( SELECT `r`.`Id` FROM `Roots` AS `r` @@ -1593,17 +1590,17 @@ UNION ALL UNION ALL SELECT `l0`.`Id` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` INNER JOIN ( SELECT `e0`.`Key1`, `e0`.`Key2`, `e0`.`Key3`, `e0`.`Name`, `e`.`RootSkipSharedId`, `e`.`CompositeKeySkipSharedKey1`, `e`.`CompositeKeySkipSharedKey2`, `e`.`CompositeKeySkipSharedKey3` FROM `EntityCompositeKeyEntityRoot` AS `e` INNER JOIN `EntityCompositeKeys` AS `e0` ON ((`e`.`CompositeKeySkipSharedKey1` = `e0`.`Key1`) AND (`e`.`CompositeKeySkipSharedKey2` = `e0`.`Key2`)) AND (`e`.`CompositeKeySkipSharedKey3` = `e0`.`Key3`) -) AS `t0` ON `t`.`Id` = `t0`.`RootSkipSharedId` -ORDER BY `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3` +) AS `s` ON `u`.`Id` = `s`.`RootSkipSharedId` +ORDER BY `u`.`Id`, `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3`, `s`.`Key1`, `s`.`Key2`, `s`.`Key3` """, // """ -SELECT `t1`.`Id`, `t1`.`CollectionInverseId`, `t1`.`Name`, `t1`.`ReferenceInverseId`, `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3` +SELECT `s1`.`Id`, `s1`.`CollectionInverseId`, `s1`.`Name`, `s1`.`ReferenceInverseId`, `u`.`Id`, `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3`, `s`.`Key1`, `s`.`Key2`, `s`.`Key3` FROM ( SELECT `r`.`Id` FROM `Roots` AS `r` @@ -1616,22 +1613,22 @@ UNION ALL UNION ALL SELECT `l0`.`Id` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` INNER JOIN ( SELECT `e0`.`Key1`, `e0`.`Key2`, `e0`.`Key3`, `e`.`RootSkipSharedId`, `e`.`CompositeKeySkipSharedKey1`, `e`.`CompositeKeySkipSharedKey2`, `e`.`CompositeKeySkipSharedKey3` FROM `EntityCompositeKeyEntityRoot` AS `e` INNER JOIN `EntityCompositeKeys` AS `e0` ON ((`e`.`CompositeKeySkipSharedKey1` = `e0`.`Key1`) AND (`e`.`CompositeKeySkipSharedKey2` = `e0`.`Key2`)) AND (`e`.`CompositeKeySkipSharedKey3` = `e0`.`Key3`) -) AS `t0` ON `t`.`Id` = `t0`.`RootSkipSharedId` +) AS `s` ON `u`.`Id` = `s`.`RootSkipSharedId` INNER JOIN ( - SELECT `t2`.`Id`, `t2`.`CollectionInverseId`, `t2`.`Name`, `t2`.`ReferenceInverseId`, `t2`.`CompositeId1`, `t2`.`CompositeId2`, `t2`.`CompositeId3` + SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3` FROM ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, ROW_NUMBER() OVER(PARTITION BY `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3` ORDER BY `e1`.`Id`) AS `row` FROM `JoinThreeToCompositeKeyFull` AS `j` INNER JOIN `EntityThrees` AS `e1` ON `j`.`ThreeId` = `e1`.`Id` - ) AS `t2` - WHERE (1 < `t2`.`row`) AND (`t2`.`row` <= 3) -) AS `t1` ON ((`t0`.`Key1` = `t1`.`CompositeId1`) AND (`t0`.`Key2` = `t1`.`CompositeId2`)) AND (`t0`.`Key3` = `t1`.`CompositeId3`) -ORDER BY `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3`, `t1`.`CompositeId1`, `t1`.`CompositeId2`, `t1`.`CompositeId3`, `t1`.`Id` + ) AS `s0` + WHERE (1 < `s0`.`row`) AND (`s0`.`row` <= 3) +) AS `s1` ON ((`s`.`Key1` = `s1`.`CompositeId1`) AND (`s`.`Key2` = `s1`.`CompositeId2`)) AND (`s`.`Key3` = `s1`.`CompositeId3`) +ORDER BY `u`.`Id`, `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3`, `s`.`Key1`, `s`.`Key2`, `s`.`Key3`, `s1`.`CompositeId1`, `s1`.`CompositeId2`, `s1`.`CompositeId3`, `s1`.`Id` """); } @@ -1647,32 +1644,32 @@ ORDER BY `l`.`Id` """, // """ -SELECT `t`.`Key1`, `t`.`Key2`, `t`.`Key3`, `t`.`Name`, `l`.`Id`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3` +SELECT `s`.`Key1`, `s`.`Key2`, `s`.`Key3`, `s`.`Name`, `l`.`Id`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3` FROM `Leaves` AS `l` INNER JOIN ( SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3` FROM `JoinCompositeKeyToLeaf` AS `j` INNER JOIN `EntityCompositeKeys` AS `e` ON ((`j`.`CompositeId1` = `e`.`Key1`) AND (`j`.`CompositeId2` = `e`.`Key2`)) AND (`j`.`CompositeId3` = `e`.`Key3`) WHERE `e`.`Key1` < 5 -) AS `t` ON `l`.`Id` = `t`.`LeafId` -ORDER BY `l`.`Id`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`Key1`, `t`.`Key2`, `t`.`Key3` +) AS `s` ON `l`.`Id` = `s`.`LeafId` +ORDER BY `l`.`Id`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`Key1`, `s`.`Key2`, `s`.`Key3` """, // """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `l`.`Id`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`Key1`, `t`.`Key2`, `t`.`Key3` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `l`.`Id`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`Key1`, `s`.`Key2`, `s`.`Key3` FROM `Leaves` AS `l` INNER JOIN ( SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3` FROM `JoinCompositeKeyToLeaf` AS `j` INNER JOIN `EntityCompositeKeys` AS `e` ON ((`j`.`CompositeId1` = `e`.`Key1`) AND (`j`.`CompositeId2` = `e`.`Key2`)) AND (`j`.`CompositeId3` = `e`.`Key3`) WHERE `e`.`Key1` < 5 -) AS `t` ON `l`.`Id` = `t`.`LeafId` +) AS `s` ON `l`.`Id` = `s`.`LeafId` INNER JOIN ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` FROM `EntityCompositeKeyEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`TwoSkipSharedId` = `e1`.`Id` -) AS `t0` ON ((`t`.`Key1` = `t0`.`CompositeKeySkipSharedKey1`) AND (`t`.`Key2` = `t0`.`CompositeKeySkipSharedKey2`)) AND (`t`.`Key3` = `t0`.`CompositeKeySkipSharedKey3`) -ORDER BY `l`.`Id`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`Key1`, `t`.`Key2`, `t`.`Key3` +) AS `s0` ON ((`s`.`Key1` = `s0`.`CompositeKeySkipSharedKey1`) AND (`s`.`Key2` = `s0`.`CompositeKeySkipSharedKey2`)) AND (`s`.`Key3` = `s0`.`CompositeKeySkipSharedKey3`) +ORDER BY `l`.`Id`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`Key1`, `s`.`Key2`, `s`.`Key3` """); } @@ -1688,39 +1685,39 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Id`, `t0`.`OneId`, `t0`.`TwoId` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `e`.`Id`, `s0`.`OneId`, `s0`.`TwoId` FROM `EntityOnes` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`OneId`, `t`.`TwoId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`OneId`, `s`.`TwoId` FROM ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId`, `j`.`TwoId`, ROW_NUMBER() OVER(PARTITION BY `j`.`OneId` ORDER BY `e0`.`Id`) AS `row` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 3) -) AS `t0` ON `e`.`Id` = `t0`.`OneId` -ORDER BY `e`.`Id`, `t0`.`OneId`, `t0`.`Id`, `t0`.`TwoId` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) +) AS `s0` ON `e`.`Id` = `s0`.`OneId` +ORDER BY `e`.`Id`, `s0`.`OneId`, `s0`.`Id`, `s0`.`TwoId` """, // """ -SELECT `t1`.`Id`, `t1`.`CollectionInverseId`, `t1`.`Name`, `t1`.`ReferenceInverseId`, `e`.`Id`, `t0`.`OneId`, `t0`.`TwoId`, `t0`.`Id` +SELECT `s1`.`Id`, `s1`.`CollectionInverseId`, `s1`.`Name`, `s1`.`ReferenceInverseId`, `e`.`Id`, `s0`.`OneId`, `s0`.`TwoId`, `s0`.`Id` FROM `EntityOnes` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`OneId`, `t`.`TwoId` + SELECT `s`.`Id`, `s`.`OneId`, `s`.`TwoId` FROM ( SELECT `e0`.`Id`, `j`.`OneId`, `j`.`TwoId`, ROW_NUMBER() OVER(PARTITION BY `j`.`OneId` ORDER BY `e0`.`Id`) AS `row` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 3) -) AS `t0` ON `e`.`Id` = `t0`.`OneId` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) +) AS `s0` ON `e`.`Id` = `s0`.`OneId` INNER JOIN ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `j0`.`TwoId` FROM `JoinTwoToThree` AS `j0` INNER JOIN `EntityThrees` AS `e1` ON `j0`.`ThreeId` = `e1`.`Id` WHERE `e1`.`Id` < 10 -) AS `t1` ON `t0`.`Id` = `t1`.`TwoId` -ORDER BY `e`.`Id`, `t0`.`OneId`, `t0`.`Id`, `t0`.`TwoId` +) AS `s1` ON `s0`.`Id` = `s1`.`TwoId` +ORDER BY `e`.`Id`, `s0`.`OneId`, `s0`.`Id`, `s0`.`TwoId` """); } @@ -1736,36 +1733,36 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `e`.`Id`, `t`.`OneId`, `t`.`TwoId` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `e`.`Id`, `s`.`OneId`, `s`.`TwoId` FROM `EntityOnes` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId`, `j`.`TwoId` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`OneId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id` +) AS `s` ON `e`.`Id` = `s`.`OneId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id` """, // """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id` +SELECT `s1`.`Id`, `s1`.`CollectionInverseId`, `s1`.`Name`, `s1`.`ReferenceInverseId`, `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id` FROM `EntityOnes` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `j`.`OneId`, `j`.`TwoId` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`OneId` +) AS `s` ON `e`.`Id` = `s`.`OneId` INNER JOIN ( - SELECT `t1`.`Id`, `t1`.`CollectionInverseId`, `t1`.`Name`, `t1`.`ReferenceInverseId`, `t1`.`TwoId` + SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`TwoId` FROM ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `j0`.`TwoId`, ROW_NUMBER() OVER(PARTITION BY `j0`.`TwoId` ORDER BY `e1`.`Id`) AS `row` FROM `JoinTwoToThree` AS `j0` INNER JOIN `EntityThrees` AS `e1` ON `j0`.`ThreeId` = `e1`.`Id` - ) AS `t1` - WHERE (1 < `t1`.`row`) AND (`t1`.`row` <= 3) -) AS `t0` ON `t`.`Id` = `t0`.`TwoId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id`, `t0`.`TwoId`, `t0`.`Id` + ) AS `s0` + WHERE (1 < `s0`.`row`) AND (`s0`.`row` <= 3) +) AS `s1` ON `s`.`Id` = `s1`.`TwoId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id`, `s1`.`TwoId`, `s1`.`Id` """); } @@ -1781,7 +1778,7 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name0`, `t`.`ReferenceInverseId`, `e`.`Id`, `t`.`OneId`, `t`.`TwoId` +SELECT `s`.`Id`, `s`.`Name`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId`, `e`.`Id`, `s`.`OneId`, `s`.`TwoId` FROM `EntityTwos` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId`, `j`.`OneId`, `j`.`TwoId` @@ -1789,12 +1786,12 @@ INNER JOIN ( INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`TwoId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id`, `t`.`Id0` +) AS `s` ON `e`.`Id` = `s`.`TwoId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id`, `s`.`Id0` """, // """ -SELECT `e2`.`Id`, `e2`.`CollectionInverseId`, `e2`.`ExtraId`, `e2`.`Name`, `e2`.`ReferenceInverseId`, `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id`, `t`.`Id0` +SELECT `e2`.`Id`, `e2`.`CollectionInverseId`, `e2`.`ExtraId`, `e2`.`Name`, `e2`.`ReferenceInverseId`, `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id`, `s`.`Id0` FROM `EntityTwos` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `e1`.`Id` AS `Id0`, `j`.`OneId`, `j`.`TwoId` @@ -1802,9 +1799,9 @@ INNER JOIN ( INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`TwoId` -INNER JOIN `EntityTwos` AS `e2` ON `t`.`Id` = `e2`.`CollectionInverseId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id`, `t`.`Id0` +) AS `s` ON `e`.`Id` = `s`.`TwoId` +INNER JOIN `EntityTwos` AS `e2` ON `s`.`Id` = `e2`.`CollectionInverseId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id`, `s`.`Id0` """); } @@ -1820,60 +1817,60 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`Id`, `t`.`Name`, `e`.`Id`, `t`.`OneId`, `t`.`ThreeId` +SELECT `s`.`Id`, `s`.`Name`, `e`.`Id`, `s`.`OneId`, `s`.`ThreeId` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `e0`.`Name`, `j`.`OneId`, `j`.`ThreeId` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` """, // """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id` +SELECT `s1`.`Id`, `s1`.`CollectionInverseId`, `s1`.`ExtraId`, `s1`.`Name`, `s1`.`ReferenceInverseId`, `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `j`.`OneId`, `j`.`ThreeId` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` INNER JOIN ( - SELECT `t1`.`Id`, `t1`.`CollectionInverseId`, `t1`.`ExtraId`, `t1`.`Name`, `t1`.`ReferenceInverseId`, `t1`.`OneId` + SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`OneId` FROM ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `j0`.`OneId`, ROW_NUMBER() OVER(PARTITION BY `j0`.`OneId` ORDER BY `e1`.`Id`) AS `row` FROM `JoinOneToTwo` AS `j0` INNER JOIN `EntityTwos` AS `e1` ON `j0`.`TwoId` = `e1`.`Id` - ) AS `t1` - WHERE (1 < `t1`.`row`) AND (`t1`.`row` <= 3) -) AS `t0` ON `t`.`Id` = `t0`.`OneId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id`, `t0`.`OneId`, `t0`.`Id` + ) AS `s0` + WHERE (1 < `s0`.`row`) AND (`s0`.`row` <= 3) +) AS `s1` ON `s`.`Id` = `s1`.`OneId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id`, `s1`.`OneId`, `s1`.`Id` """, // """ -SELECT `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`Discriminator`, `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id` +SELECT `s2`.`Id`, `s2`.`Name`, `s2`.`Number`, `s2`.`IsGreen`, `s2`.`Discriminator`, `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `j`.`OneId`, `j`.`ThreeId` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` INNER JOIN ( - SELECT `t1`.`Id`, `t1`.`Name`, `t1`.`Number`, `t1`.`IsGreen`, `t1`.`Discriminator`, `j0`.`EntityOneId` - FROM `JoinOneToBranch` AS `j0` + SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `u`.`Discriminator`, `j1`.`EntityOneId` + FROM `JoinOneToBranch` AS `j1` INNER JOIN ( SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, NULL AS `IsGreen`, 'EntityBranch' AS `Discriminator` FROM `Branches` AS `b` UNION ALL SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, 'EntityLeaf' AS `Discriminator` FROM `Leaves` AS `l` - ) AS `t1` ON `j0`.`EntityBranchId` = `t1`.`Id` - WHERE `t1`.`Id` < 20 -) AS `t0` ON `t`.`Id` = `t0`.`EntityOneId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id` + ) AS `u` ON `j1`.`EntityBranchId` = `u`.`Id` + WHERE `u`.`Id` < 20 +) AS `s2` ON `s`.`Id` = `s2`.`EntityOneId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` """); } @@ -1889,32 +1886,32 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`Id`, `t`.`Name`, `e`.`Id`, `t`.`OneId`, `t`.`ThreeId` +SELECT `s`.`Id`, `s`.`Name`, `e`.`Id`, `s`.`OneId`, `s`.`ThreeId` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `e0`.`Name`, `j`.`OneId`, `j`.`ThreeId` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` > 15 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` """, // """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id` +SELECT `e2`.`Id`, `e2`.`CollectionInverseId`, `e2`.`ExtraId`, `e2`.`Name`, `e2`.`ReferenceInverseId`, `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `j`.`OneId`, `j`.`ThreeId` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` > 15 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` INNER JOIN ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId` FROM `EntityTwos` AS `e1` WHERE `e1`.`Id` < 5 -) AS `t0` ON `t`.`Id` = `t0`.`CollectionInverseId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id` +) AS `e2` ON `s`.`Id` = `e2`.`CollectionInverseId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` """); } @@ -1930,31 +1927,31 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `e`.`Id` +SELECT `e2`.`Id`, `e2`.`CollectionInverseId`, `e2`.`ExtraId`, `e2`.`Name`, `e2`.`ReferenceInverseId`, `e`.`Id` FROM `EntityOnes` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId` FROM `EntityTwos` AS `e0` WHERE `e0`.`Id` > 15 -) AS `t` ON `e`.`Id` = `t`.`CollectionInverseId` -ORDER BY `e`.`Id`, `t`.`Id` +) AS `e2` ON `e`.`Id` = `e2`.`CollectionInverseId` +ORDER BY `e`.`Id`, `e2`.`Id` """, // """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Id`, `t`.`Id` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `e`.`Id`, `e2`.`Id` FROM `EntityOnes` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId` FROM `EntityTwos` AS `e0` WHERE `e0`.`Id` > 15 -) AS `t` ON `e`.`Id` = `t`.`CollectionInverseId` +) AS `e2` ON `e`.`Id` = `e2`.`CollectionInverseId` INNER JOIN ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `j`.`TwoId` FROM `JoinTwoToThree` AS `j` INNER JOIN `EntityThrees` AS `e1` ON `j`.`ThreeId` = `e1`.`Id` WHERE `e1`.`Id` < 5 -) AS `t0` ON `t`.`Id` = `t0`.`TwoId` -ORDER BY `e`.`Id`, `t`.`Id` +) AS `s` ON `e2`.`Id` = `s`.`TwoId` +ORDER BY `e`.`Id`, `e2`.`Id` """); } @@ -1999,13 +1996,13 @@ public override async Task Select_many_over_skip_navigation_where_non_equality(b AssertSql( """ -SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `EntityOnes` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` -) AS `t` ON (`e`.`Id` = `t`.`OneId`) AND (`e`.`Id` <> `t`.`Id`) +) AS `s` ON (`e`.`Id` = `s`.`OneId`) AND (`e`.`Id` <> `s`.`Id`) """); } @@ -2066,14 +2063,14 @@ public override async Task GetType_in_hierarchy_in_querying_base_type(bool async AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `u`.`Discriminator` FROM ( SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, NULL AS `IsGreen`, 'EntityBranch' AS `Discriminator` FROM `Branches` AS `b` UNION ALL SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, 'EntityLeaf' AS `Discriminator` FROM `Leaves` AS `l` -) AS `t` +) AS `u` WHERE FALSE """); } @@ -2084,18 +2081,18 @@ public override async Task Filtered_include_skip_navigation_order_by_take_EF_Pro AssertSql( """ -SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `t0`.`TwoSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3` +SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`TwoSkipSharedId`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3` FROM `EntityCompositeKeys` AS `e` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`TwoSkipSharedId`, `t`.`CompositeKeySkipSharedKey1`, `t`.`CompositeKeySkipSharedKey2`, `t`.`CompositeKeySkipSharedKey3` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`TwoSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3` FROM ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `e0`.`TwoSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3`, ROW_NUMBER() OVER(PARTITION BY `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` ORDER BY `e1`.`Id`) AS `row` FROM `EntityCompositeKeyEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`TwoSkipSharedId` = `e1`.`Id` - ) AS `t` - WHERE `t`.`row` <= 2 -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `t0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `t0`.`CompositeKeySkipSharedKey3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Id` + ) AS `s` + WHERE `s`.`row` <= 2 +) AS `s0` ON ((`e`.`Key1` = `s0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `s0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `s0`.`CompositeKeySkipSharedKey3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3`, `s0`.`Id` """); } @@ -2106,10 +2103,10 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take_t AssertSql( """ -SELECT `e`.`Id`, `e`.`Name`, `t1`.`Id`, `t1`.`CollectionInverseId`, `t1`.`ExtraId`, `t1`.`Name`, `t1`.`ReferenceInverseId`, `t1`.`OneId`, `t1`.`TwoId`, `t1`.`Id0`, `t1`.`CollectionInverseId0`, `t1`.`Name0`, `t1`.`ReferenceInverseId0`, `t1`.`ThreeId`, `t1`.`TwoId0` +SELECT `e`.`Id`, `e`.`Name`, `s1`.`Id`, `s1`.`CollectionInverseId`, `s1`.`ExtraId`, `s1`.`Name`, `s1`.`ReferenceInverseId`, `s1`.`OneId`, `s1`.`TwoId`, `s1`.`Id0`, `s1`.`CollectionInverseId0`, `s1`.`Name0`, `s1`.`ReferenceInverseId0`, `s1`.`ThreeId`, `s1`.`TwoId0` FROM `EntityOnes` AS `e` LEFT JOIN LATERAL ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`OneId`, `t`.`TwoId`, `t0`.`Id` AS `Id0`, `t0`.`CollectionInverseId` AS `CollectionInverseId0`, `t0`.`Name` AS `Name0`, `t0`.`ReferenceInverseId` AS `ReferenceInverseId0`, `t0`.`ThreeId`, `t0`.`TwoId` AS `TwoId0` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`OneId`, `s`.`TwoId`, `s0`.`Id` AS `Id0`, `s0`.`CollectionInverseId` AS `CollectionInverseId0`, `s0`.`Name` AS `Name0`, `s0`.`ReferenceInverseId` AS `ReferenceInverseId0`, `s0`.`ThreeId`, `s0`.`TwoId` AS `TwoId0` FROM ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId`, `j`.`TwoId` FROM `JoinOneToTwo` AS `j` @@ -2117,15 +2114,15 @@ LEFT JOIN LATERAL ( WHERE `e`.`Id` = `j`.`OneId` ORDER BY `e0`.`Id` LIMIT 2 OFFSET 1 - ) AS `t` + ) AS `s` LEFT JOIN ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `j0`.`ThreeId`, `j0`.`TwoId` FROM `JoinTwoToThree` AS `j0` INNER JOIN `EntityThrees` AS `e1` ON `j0`.`ThreeId` = `e1`.`Id` WHERE `e1`.`Id` < 10 - ) AS `t0` ON `t`.`Id` = `t0`.`TwoId` -) AS `t1` ON TRUE -ORDER BY `e`.`Id`, `t1`.`Id`, `t1`.`OneId`, `t1`.`TwoId`, `t1`.`ThreeId`, `t1`.`TwoId0` + ) AS `s0` ON `s`.`Id` = `s0`.`TwoId` +) AS `s1` ON TRUE +ORDER BY `e`.`Id`, `s1`.`Id`, `s1`.`OneId`, `s1`.`TwoId`, `s1`.`ThreeId`, `s1`.`TwoId0` """); } @@ -2213,13 +2210,13 @@ ORDER BY ( SELECT COUNT(*) FROM `UnidirectionalJoinOneToBranch` AS `u0` INNER JOIN ( - SELECT `u1`.`Id`, `u1`.`Name`, `u1`.`Number`, NULL AS `IsGreen`, 'UnidirectionalEntityBranch' AS `Discriminator` + SELECT `u1`.`Id`, `u1`.`Name` FROM `UnidirectionalBranches` AS `u1` UNION ALL - SELECT `u2`.`Id`, `u2`.`Name`, `u2`.`Number`, `u2`.`IsGreen`, 'UnidirectionalEntityLeaf' AS `Discriminator` + SELECT `u2`.`Id`, `u2`.`Name` FROM `UnidirectionalLeaves` AS `u2` - ) AS `t` ON `u0`.`UnidirectionalEntityBranchId` = `t`.`Id` - WHERE (`u`.`Id` = `u0`.`UnidirectionalEntityOneId`) AND (`t`.`Name` LIKE 'L%')), `u`.`Id` + ) AS `u3` ON `u0`.`UnidirectionalEntityBranchId` = `u3`.`Id` + WHERE (`u`.`Id` = `u0`.`UnidirectionalEntityOneId`) AND (`u3`.`Name` LIKE 'L%')), `u`.`Id` """); } @@ -2244,17 +2241,17 @@ public override async Task Skip_navigation_order_by_reverse_first_or_default_uni AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `UnidirectionalEntityThrees` AS `u` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`ThreeId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`ThreeId` FROM ( SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`ThreeId`, ROW_NUMBER() OVER(PARTITION BY `u0`.`ThreeId` ORDER BY `u1`.`Id` DESC) AS `row` FROM `UnidirectionalJoinTwoToThree` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoId` = `u1`.`Id` - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `u`.`Id` = `t0`.`ThreeId` + ) AS `s` + WHERE `s`.`row` <= 1 +) AS `s0` ON `u`.`Id` = `s0`.`ThreeId` """); } @@ -2263,11 +2260,11 @@ public override async Task Skip_navigation_of_type_unidirectional(bool async) await base.Skip_navigation_of_type_unidirectional(async); AssertSql( -$""" -SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`Discriminator`, `t0`.`RootSkipSharedId`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3` +""" +SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `s`.`Discriminator`, `s`.`RootSkipSharedId`, `s`.`UnidirectionalEntityCompositeKeyKey1`, `s`.`UnidirectionalEntityCompositeKeyKey2`, `s`.`UnidirectionalEntityCompositeKeyKey3` FROM `UnidirectionalEntityCompositeKeys` AS `u` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator`, `u0`.`RootSkipSharedId`, `u0`.`UnidirectionalEntityCompositeKeyKey1`, `u0`.`UnidirectionalEntityCompositeKeyKey2`, `u0`.`UnidirectionalEntityCompositeKeyKey3` + SELECT `u4`.`Id`, `u4`.`Name`, `u4`.`Number`, `u4`.`IsGreen`, `u4`.`Discriminator`, `u0`.`RootSkipSharedId`, `u0`.`UnidirectionalEntityCompositeKeyKey1`, `u0`.`UnidirectionalEntityCompositeKeyKey2`, `u0`.`UnidirectionalEntityCompositeKeyKey3` FROM `UnidirectionalEntityCompositeKeyUnidirectionalEntityRoot` AS `u0` INNER JOIN ( SELECT `u1`.`Id`, `u1`.`Name`, NULL AS `Number`, NULL AS `IsGreen`, 'UnidirectionalEntityRoot' AS `Discriminator` @@ -2276,12 +2273,12 @@ UNION ALL SELECT `u2`.`Id`, `u2`.`Name`, `u2`.`Number`, NULL AS `IsGreen`, 'UnidirectionalEntityBranch' AS `Discriminator` FROM `UnidirectionalBranches` AS `u2` UNION ALL - SELECT `u3`.`Id`, `u3`.`Name`, `u3`.`Number`, `u3`.`IsGreen`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'UnidirectionalEntityLeaf'")} AS `Discriminator` + SELECT `u3`.`Id`, `u3`.`Name`, `u3`.`Number`, `u3`.`IsGreen`, 'UnidirectionalEntityLeaf' AS `Discriminator` FROM `UnidirectionalLeaves` AS `u3` - ) AS `t` ON `u0`.`RootSkipSharedId` = `t`.`Id` - WHERE `t`.`Discriminator` = 'UnidirectionalEntityLeaf' -) AS `t0` ON ((`u`.`Key1` = `t0`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u`.`Key2` = `t0`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u`.`Key3` = `t0`.`UnidirectionalEntityCompositeKeyKey3`) -ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `t0`.`RootSkipSharedId`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3` + ) AS `u4` ON `u0`.`RootSkipSharedId` = `u4`.`Id` + WHERE `u4`.`Discriminator` = 'UnidirectionalEntityLeaf' +) AS `s` ON ((`u`.`Key1` = `s`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u`.`Key2` = `s`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u`.`Key3` = `s`.`UnidirectionalEntityCompositeKeyKey3`) +ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `s`.`RootSkipSharedId`, `s`.`UnidirectionalEntityCompositeKeyKey1`, `s`.`UnidirectionalEntityCompositeKeyKey2`, `s`.`UnidirectionalEntityCompositeKeyKey3` """); } @@ -2304,7 +2301,7 @@ ORDER BY `u2`.`Id` """); } - [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore")] + [ConditionalTheory(Skip = "Feature 'Correlated subselect that can not be transformed and does not match on shard keys' is not supported by SingleStore Distributed")] public override async Task Left_join_with_skip_navigation_unidirectional(bool async) { await base.Left_join_with_skip_navigation_unidirectional(async); @@ -2336,22 +2333,22 @@ public override async Task Select_many_over_skip_navigation_unidirectional(bool AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( - SELECT `u1`.`Id` - FROM `UnidirectionalRoots` AS `u1` + SELECT `u`.`Id` + FROM `UnidirectionalRoots` AS `u` UNION ALL - SELECT `u2`.`Id` - FROM `UnidirectionalBranches` AS `u2` + SELECT `u0`.`Id` + FROM `UnidirectionalBranches` AS `u0` UNION ALL - SELECT `u3`.`Id` - FROM `UnidirectionalLeaves` AS `u3` -) AS `t` + SELECT `u1`.`Id` + FROM `UnidirectionalLeaves` AS `u1` +) AS `u2` INNER JOIN ( - SELECT `u0`.`Id`, `u0`.`CollectionInverseId`, `u0`.`Name`, `u0`.`ReferenceInverseId`, `u`.`UnidirectionalEntityRootId` - FROM `UnidirectionalEntityRootUnidirectionalEntityThree` AS `u` - INNER JOIN `UnidirectionalEntityThrees` AS `u0` ON `u`.`ThreeSkipSharedId` = `u0`.`Id` -) AS `t0` ON `t`.`Id` = `t0`.`UnidirectionalEntityRootId` + SELECT `u4`.`Id`, `u4`.`CollectionInverseId`, `u4`.`Name`, `u4`.`ReferenceInverseId`, `u3`.`UnidirectionalEntityRootId` + FROM `UnidirectionalEntityRootUnidirectionalEntityThree` AS `u3` + INNER JOIN `UnidirectionalEntityThrees` AS `u4` ON `u3`.`ThreeSkipSharedId` = `u4`.`Id` +) AS `s` ON `u2`.`Id` = `s`.`UnidirectionalEntityRootId` """); } @@ -2361,13 +2358,13 @@ public override async Task Select_many_over_skip_navigation_where_unidirectional AssertSql( """ -SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `UnidirectionalEntityOnes` AS `u` LEFT JOIN ( SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`OneId` FROM `UnidirectionalJoinOneToTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoId` = `u1`.`Id` -) AS `t` ON `u`.`Id` = `t`.`OneId` +) AS `s` ON `u`.`Id` = `s`.`OneId` """); } @@ -2377,17 +2374,17 @@ public override async Task Select_many_over_skip_navigation_order_by_take_unidir AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `UnidirectionalEntityOnes` AS `u` INNER JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`UnidirectionalEntityOneId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`UnidirectionalEntityOneId` FROM ( SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`UnidirectionalEntityOneId`, ROW_NUMBER() OVER(PARTITION BY `u0`.`UnidirectionalEntityOneId` ORDER BY `u1`.`Id`) AS `row` FROM `UnidirectionalEntityOneUnidirectionalEntityTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoSkipSharedId` = `u1`.`Id` - ) AS `t` - WHERE `t`.`row` <= 2 -) AS `t0` ON `u`.`Id` = `t0`.`UnidirectionalEntityOneId` + ) AS `s` + WHERE `s`.`row` <= 2 +) AS `s0` ON `u`.`Id` = `s0`.`UnidirectionalEntityOneId` """); } @@ -2397,17 +2394,17 @@ public override async Task Select_many_over_skip_navigation_order_by_skip_take_u AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `UnidirectionalEntityOnes` AS `u` INNER JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`OneId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`OneId` FROM ( SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`OneId`, ROW_NUMBER() OVER(PARTITION BY `u0`.`OneId` ORDER BY `u1`.`Id`) AS `row` FROM `UnidirectionalJoinOneToThreePayloadFullShared` AS `u0` INNER JOIN `UnidirectionalEntityThrees` AS `u1` ON `u0`.`ThreeId` = `u1`.`Id` - ) AS `t` - WHERE (2 < `t`.`row`) AND (`t`.`row` <= 5) -) AS `t0` ON `u`.`Id` = `t0`.`OneId` + ) AS `s` + WHERE (2 < `s`.`row`) AND (`s`.`row` <= 5) +) AS `s0` ON `u`.`Id` = `s0`.`OneId` """); } @@ -2417,10 +2414,10 @@ public override async Task Select_many_over_skip_navigation_cast_unidirectional( AssertSql( """ -SELECT `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`Discriminator` +SELECT `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `s`.`Discriminator` FROM `UnidirectionalEntityOnes` AS `u` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator`, `u0`.`UnidirectionalEntityOneId` + SELECT `u3`.`Id`, `u3`.`Name`, `u3`.`Number`, `u3`.`IsGreen`, `u3`.`Discriminator`, `u0`.`UnidirectionalEntityOneId` FROM `UnidirectionalJoinOneToBranch` AS `u0` INNER JOIN ( SELECT `u1`.`Id`, `u1`.`Name`, `u1`.`Number`, NULL AS `IsGreen`, 'UnidirectionalEntityBranch' AS `Discriminator` @@ -2428,8 +2425,8 @@ INNER JOIN ( UNION ALL SELECT `u2`.`Id`, `u2`.`Name`, `u2`.`Number`, `u2`.`IsGreen`, 'UnidirectionalEntityLeaf' AS `Discriminator` FROM `UnidirectionalLeaves` AS `u2` - ) AS `t` ON `u0`.`UnidirectionalEntityBranchId` = `t`.`Id` -) AS `t0` ON `u`.`Id` = `t0`.`UnidirectionalEntityOneId` + ) AS `u3` ON `u0`.`UnidirectionalEntityBranchId` = `u3`.`Id` +) AS `s` ON `u`.`Id` = `s`.`UnidirectionalEntityOneId` """); } @@ -2439,14 +2436,14 @@ public override async Task Select_skip_navigation_unidirectional(bool async) AssertSql( """ -SELECT `u`.`Id`, `t`.`Id`, `t`.`Name`, `t`.`LeftId`, `t`.`RightId` +SELECT `u`.`Id`, `s`.`Id`, `s`.`Name`, `s`.`LeftId`, `s`.`RightId` FROM `UnidirectionalEntityOnes` AS `u` LEFT JOIN ( SELECT `u1`.`Id`, `u1`.`Name`, `u0`.`LeftId`, `u0`.`RightId` FROM `UnidirectionalJoinOneSelfPayload` AS `u0` INNER JOIN `UnidirectionalEntityOnes` AS `u1` ON `u0`.`LeftId` = `u1`.`Id` -) AS `t` ON `u`.`Id` = `t`.`RightId` -ORDER BY `u`.`Id`, `t`.`LeftId`, `t`.`RightId` +) AS `s` ON `u`.`Id` = `s`.`RightId` +ORDER BY `u`.`Id`, `s`.`LeftId`, `s`.`RightId` """); } @@ -2455,11 +2452,11 @@ public override async Task Include_skip_navigation_unidirectional(bool async) await base.Include_skip_navigation_unidirectional(async); AssertSql( -$""" -SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`Discriminator`, `t0`.`RootSkipSharedId`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3` +""" +SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `s`.`Discriminator`, `s`.`RootSkipSharedId`, `s`.`UnidirectionalEntityCompositeKeyKey1`, `s`.`UnidirectionalEntityCompositeKeyKey2`, `s`.`UnidirectionalEntityCompositeKeyKey3` FROM `UnidirectionalEntityCompositeKeys` AS `u` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator`, `u0`.`RootSkipSharedId`, `u0`.`UnidirectionalEntityCompositeKeyKey1`, `u0`.`UnidirectionalEntityCompositeKeyKey2`, `u0`.`UnidirectionalEntityCompositeKeyKey3` + SELECT `u4`.`Id`, `u4`.`Name`, `u4`.`Number`, `u4`.`IsGreen`, `u4`.`Discriminator`, `u0`.`RootSkipSharedId`, `u0`.`UnidirectionalEntityCompositeKeyKey1`, `u0`.`UnidirectionalEntityCompositeKeyKey2`, `u0`.`UnidirectionalEntityCompositeKeyKey3` FROM `UnidirectionalEntityCompositeKeyUnidirectionalEntityRoot` AS `u0` INNER JOIN ( SELECT `u1`.`Id`, `u1`.`Name`, NULL AS `Number`, NULL AS `IsGreen`, 'UnidirectionalEntityRoot' AS `Discriminator` @@ -2468,11 +2465,11 @@ UNION ALL SELECT `u2`.`Id`, `u2`.`Name`, `u2`.`Number`, NULL AS `IsGreen`, 'UnidirectionalEntityBranch' AS `Discriminator` FROM `UnidirectionalBranches` AS `u2` UNION ALL - SELECT `u3`.`Id`, `u3`.`Name`, `u3`.`Number`, `u3`.`IsGreen`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'UnidirectionalEntityLeaf'")} AS `Discriminator` + SELECT `u3`.`Id`, `u3`.`Name`, `u3`.`Number`, `u3`.`IsGreen`, 'UnidirectionalEntityLeaf' AS `Discriminator` FROM `UnidirectionalLeaves` AS `u3` - ) AS `t` ON `u0`.`RootSkipSharedId` = `t`.`Id` -) AS `t0` ON ((`u`.`Key1` = `t0`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u`.`Key2` = `t0`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u`.`Key3` = `t0`.`UnidirectionalEntityCompositeKeyKey3`) -ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `t0`.`RootSkipSharedId`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3` + ) AS `u4` ON `u0`.`RootSkipSharedId` = `u4`.`Id` +) AS `s` ON ((`u`.`Key1` = `s`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u`.`Key2` = `s`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u`.`Key3` = `s`.`UnidirectionalEntityCompositeKeyKey3`) +ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `s`.`RootSkipSharedId`, `s`.`UnidirectionalEntityCompositeKeyKey1`, `s`.`UnidirectionalEntityCompositeKeyKey2`, `s`.`UnidirectionalEntityCompositeKeyKey3` """); } @@ -2482,15 +2479,15 @@ public override async Task Include_skip_navigation_then_reference_unidirectional AssertSql( """ -SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`ExtraId`, `u`.`Name`, `u`.`ReferenceInverseId`, `t`.`Id`, `t`.`Name`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name0`, `t`.`ReferenceInverseId`, `t`.`OneId`, `t`.`TwoId` +SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`ExtraId`, `u`.`Name`, `u`.`ReferenceInverseId`, `s`.`Id`, `s`.`Name`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId`, `s`.`OneId`, `s`.`TwoId` FROM `UnidirectionalEntityTwos` AS `u` LEFT JOIN ( SELECT `u1`.`Id`, `u1`.`Name`, `u2`.`Id` AS `Id0`, `u2`.`CollectionInverseId`, `u2`.`ExtraId`, `u2`.`Name` AS `Name0`, `u2`.`ReferenceInverseId`, `u0`.`OneId`, `u0`.`TwoId` FROM `UnidirectionalJoinOneToTwo` AS `u0` INNER JOIN `UnidirectionalEntityOnes` AS `u1` ON `u0`.`OneId` = `u1`.`Id` LEFT JOIN `UnidirectionalEntityTwos` AS `u2` ON `u1`.`Id` = `u2`.`ReferenceInverseId` -) AS `t` ON `u`.`Id` = `t`.`TwoId` -ORDER BY `u`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id` +) AS `s` ON `u`.`Id` = `s`.`TwoId` +ORDER BY `u`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id` """); } @@ -2500,19 +2497,19 @@ public override async Task Include_skip_navigation_then_include_skip_navigation_ AssertSql( """ -SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id0`, `t0`.`Name0`, `t0`.`UnidirectionalEntityBranchId`, `t0`.`UnidirectionalEntityOneId` +SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `s0`.`Id`, `s0`.`Name`, `s0`.`Number`, `s0`.`IsGreen`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id0`, `s0`.`Name0`, `s0`.`UnidirectionalEntityBranchId`, `s0`.`UnidirectionalEntityOneId` FROM `UnidirectionalEntityCompositeKeys` AS `u` LEFT JOIN ( - SELECT `u1`.`Id`, `u1`.`Name`, `u1`.`Number`, `u1`.`IsGreen`, `u0`.`LeafId`, `u0`.`CompositeId1`, `u0`.`CompositeId2`, `u0`.`CompositeId3`, `t`.`Id` AS `Id0`, `t`.`Name` AS `Name0`, `t`.`UnidirectionalEntityBranchId`, `t`.`UnidirectionalEntityOneId` + SELECT `u1`.`Id`, `u1`.`Name`, `u1`.`Number`, `u1`.`IsGreen`, `u0`.`LeafId`, `u0`.`CompositeId1`, `u0`.`CompositeId2`, `u0`.`CompositeId3`, `s`.`Id` AS `Id0`, `s`.`Name` AS `Name0`, `s`.`UnidirectionalEntityBranchId`, `s`.`UnidirectionalEntityOneId` FROM `UnidirectionalJoinCompositeKeyToLeaf` AS `u0` INNER JOIN `UnidirectionalLeaves` AS `u1` ON `u0`.`LeafId` = `u1`.`Id` LEFT JOIN ( SELECT `u3`.`Id`, `u3`.`Name`, `u2`.`UnidirectionalEntityBranchId`, `u2`.`UnidirectionalEntityOneId` FROM `UnidirectionalJoinOneToBranch` AS `u2` INNER JOIN `UnidirectionalEntityOnes` AS `u3` ON `u2`.`UnidirectionalEntityOneId` = `u3`.`Id` - ) AS `t` ON `u1`.`Id` = `t`.`UnidirectionalEntityBranchId` -) AS `t0` ON ((`u`.`Key1` = `t0`.`CompositeId1`) AND (`u`.`Key2` = `t0`.`CompositeId2`)) AND (`u`.`Key3` = `t0`.`CompositeId3`) -ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id`, `t0`.`UnidirectionalEntityBranchId`, `t0`.`UnidirectionalEntityOneId` + ) AS `s` ON `u1`.`Id` = `s`.`UnidirectionalEntityBranchId` +) AS `s0` ON ((`u`.`Key1` = `s0`.`CompositeId1`) AND (`u`.`Key2` = `s0`.`CompositeId2`)) AND (`u`.`Key3` = `s0`.`CompositeId3`) +ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id`, `s0`.`UnidirectionalEntityBranchId`, `s0`.`UnidirectionalEntityOneId` """); } @@ -2522,10 +2519,10 @@ public override async Task Include_skip_navigation_then_include_reference_and_sk AssertSql( """ -SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`Name`, `u`.`ReferenceInverseId`, `t0`.`Id`, `t0`.`Name`, `t0`.`Id0`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name0`, `t0`.`ReferenceInverseId`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Id1`, `t0`.`Name1`, `t0`.`LeftId`, `t0`.`RightId` +SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`Name`, `u`.`ReferenceInverseId`, `s0`.`Id`, `s0`.`Name`, `s0`.`Id0`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name0`, `s0`.`ReferenceInverseId`, `s0`.`OneId`, `s0`.`ThreeId`, `s0`.`Id1`, `s0`.`Name1`, `s0`.`LeftId`, `s0`.`RightId` FROM `UnidirectionalEntityThrees` AS `u` LEFT JOIN ( - SELECT `u1`.`Id`, `u1`.`Name`, `u2`.`Id` AS `Id0`, `u2`.`CollectionInverseId`, `u2`.`ExtraId`, `u2`.`Name` AS `Name0`, `u2`.`ReferenceInverseId`, `u0`.`OneId`, `u0`.`ThreeId`, `t`.`Id` AS `Id1`, `t`.`Name` AS `Name1`, `t`.`LeftId`, `t`.`RightId` + SELECT `u1`.`Id`, `u1`.`Name`, `u2`.`Id` AS `Id0`, `u2`.`CollectionInverseId`, `u2`.`ExtraId`, `u2`.`Name` AS `Name0`, `u2`.`ReferenceInverseId`, `u0`.`OneId`, `u0`.`ThreeId`, `s`.`Id` AS `Id1`, `s`.`Name` AS `Name1`, `s`.`LeftId`, `s`.`RightId` FROM `UnidirectionalJoinOneToThreePayloadFull` AS `u0` INNER JOIN `UnidirectionalEntityOnes` AS `u1` ON `u0`.`OneId` = `u1`.`Id` LEFT JOIN `UnidirectionalEntityTwos` AS `u2` ON `u1`.`Id` = `u2`.`ReferenceInverseId` @@ -2533,9 +2530,9 @@ LEFT JOIN ( SELECT `u4`.`Id`, `u4`.`Name`, `u3`.`LeftId`, `u3`.`RightId` FROM `UnidirectionalJoinOneSelfPayload` AS `u3` INNER JOIN `UnidirectionalEntityOnes` AS `u4` ON `u3`.`RightId` = `u4`.`Id` - ) AS `t` ON `u1`.`Id` = `t`.`LeftId` -) AS `t0` ON `u`.`Id` = `t0`.`ThreeId` -ORDER BY `u`.`Id`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Id`, `t0`.`Id0`, `t0`.`LeftId`, `t0`.`RightId` + ) AS `s` ON `u1`.`Id` = `s`.`LeftId` +) AS `s0` ON `u`.`Id` = `s0`.`ThreeId` +ORDER BY `u`.`Id`, `s0`.`OneId`, `s0`.`ThreeId`, `s0`.`Id`, `s0`.`Id0`, `s0`.`LeftId`, `s0`.`RightId` """); } @@ -2545,15 +2542,15 @@ public override async Task Include_skip_navigation_and_reference_unidirectional( AssertSql( """ -SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`ExtraId`, `u`.`Name`, `u`.`ReferenceInverseId`, `u0`.`Id`, `t`.`Id`, `t`.`Name`, `t`.`TwoSkipSharedId`, `t`.`UnidirectionalEntityOneId`, `u0`.`CollectionInverseId`, `u0`.`Name`, `u0`.`ReferenceInverseId` +SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`ExtraId`, `u`.`Name`, `u`.`ReferenceInverseId`, `u0`.`Id`, `s`.`Id`, `s`.`Name`, `s`.`TwoSkipSharedId`, `s`.`UnidirectionalEntityOneId`, `u0`.`CollectionInverseId`, `u0`.`Name`, `u0`.`ReferenceInverseId` FROM `UnidirectionalEntityTwos` AS `u` LEFT JOIN `UnidirectionalEntityThrees` AS `u0` ON `u`.`Id` = `u0`.`ReferenceInverseId` LEFT JOIN ( SELECT `u2`.`Id`, `u2`.`Name`, `u1`.`TwoSkipSharedId`, `u1`.`UnidirectionalEntityOneId` FROM `UnidirectionalEntityOneUnidirectionalEntityTwo` AS `u1` INNER JOIN `UnidirectionalEntityOnes` AS `u2` ON `u1`.`UnidirectionalEntityOneId` = `u2`.`Id` -) AS `t` ON `u`.`Id` = `t`.`TwoSkipSharedId` -ORDER BY `u`.`Id`, `u0`.`Id`, `t`.`TwoSkipSharedId`, `t`.`UnidirectionalEntityOneId` +) AS `s` ON `u`.`Id` = `s`.`TwoSkipSharedId` +ORDER BY `u`.`Id`, `u0`.`Id`, `s`.`TwoSkipSharedId`, `s`.`UnidirectionalEntityOneId` """); } @@ -2563,15 +2560,15 @@ public override async Task Filtered_include_skip_navigation_where_unidirectional AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t`.`Id`, `t`.`Name`, `t`.`OneId`, `t`.`ThreeId` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s`.`Id`, `s`.`Name`, `s`.`OneId`, `s`.`ThreeId` FROM `EntityThrees` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`Name`, `j`.`OneId`, `j`.`ThreeId` FROM `JoinOneToThreePayloadFullShared` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId` """); } @@ -2581,14 +2578,14 @@ public override async Task Filtered_include_skip_navigation_order_by_unidirectio AssertSql( """ -SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`Name`, `u`.`ReferenceInverseId`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`ThreeId`, `t`.`TwoId` +SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`Name`, `u`.`ReferenceInverseId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`ThreeId`, `s`.`TwoId` FROM `UnidirectionalEntityThrees` AS `u` LEFT JOIN ( SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`ThreeId`, `u0`.`TwoId` FROM `UnidirectionalJoinTwoToThree` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoId` = `u1`.`Id` -) AS `t` ON `u`.`Id` = `t`.`ThreeId` -ORDER BY `u`.`Id`, `t`.`Id`, `t`.`ThreeId` +) AS `s` ON `u`.`Id` = `s`.`ThreeId` +ORDER BY `u`.`Id`, `s`.`Id`, `s`.`ThreeId` """); } @@ -2598,18 +2595,18 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_unidir AssertSql( """ -SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`ExtraId`, `u`.`Name`, `u`.`ReferenceInverseId`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `t0`.`SelfSkipSharedRightId`, `t0`.`UnidirectionalEntityTwoId` +SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`ExtraId`, `u`.`Name`, `u`.`ReferenceInverseId`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`SelfSkipSharedRightId`, `s0`.`UnidirectionalEntityTwoId` FROM `UnidirectionalEntityTwos` AS `u` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`SelfSkipSharedRightId`, `t`.`UnidirectionalEntityTwoId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`SelfSkipSharedRightId`, `s`.`UnidirectionalEntityTwoId` FROM ( SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`SelfSkipSharedRightId`, `u0`.`UnidirectionalEntityTwoId`, ROW_NUMBER() OVER(PARTITION BY `u0`.`UnidirectionalEntityTwoId` ORDER BY `u1`.`Id`) AS `row` FROM `UnidirectionalEntityTwoUnidirectionalEntityTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`SelfSkipSharedRightId` = `u1`.`Id` - ) AS `t` - WHERE 2 < `t`.`row` -) AS `t0` ON `u`.`Id` = `t0`.`UnidirectionalEntityTwoId` -ORDER BY `u`.`Id`, `t0`.`UnidirectionalEntityTwoId`, `t0`.`Id` + ) AS `s` + WHERE 2 < `s`.`row` +) AS `s0` ON `u`.`Id` = `s0`.`UnidirectionalEntityTwoId` +ORDER BY `u`.`Id`, `s0`.`UnidirectionalEntityTwoId`, `s0`.`Id` """); } @@ -2619,18 +2616,18 @@ public override async Task Filtered_include_skip_navigation_order_by_take_unidir AssertSql( """ -SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `t0`.`TwoSkipSharedId`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3` +SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`TwoSkipSharedId`, `s0`.`UnidirectionalEntityCompositeKeyKey1`, `s0`.`UnidirectionalEntityCompositeKeyKey2`, `s0`.`UnidirectionalEntityCompositeKeyKey3` FROM `UnidirectionalEntityCompositeKeys` AS `u` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`TwoSkipSharedId`, `t`.`UnidirectionalEntityCompositeKeyKey1`, `t`.`UnidirectionalEntityCompositeKeyKey2`, `t`.`UnidirectionalEntityCompositeKeyKey3` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`TwoSkipSharedId`, `s`.`UnidirectionalEntityCompositeKeyKey1`, `s`.`UnidirectionalEntityCompositeKeyKey2`, `s`.`UnidirectionalEntityCompositeKeyKey3` FROM ( SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`TwoSkipSharedId`, `u0`.`UnidirectionalEntityCompositeKeyKey1`, `u0`.`UnidirectionalEntityCompositeKeyKey2`, `u0`.`UnidirectionalEntityCompositeKeyKey3`, ROW_NUMBER() OVER(PARTITION BY `u0`.`UnidirectionalEntityCompositeKeyKey1`, `u0`.`UnidirectionalEntityCompositeKeyKey2`, `u0`.`UnidirectionalEntityCompositeKeyKey3` ORDER BY `u1`.`Id`) AS `row` FROM `UnidirectionalEntityCompositeKeyUnidirectionalEntityTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoSkipSharedId` = `u1`.`Id` - ) AS `t` - WHERE `t`.`row` <= 2 -) AS `t0` ON ((`u`.`Key1` = `t0`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u`.`Key2` = `t0`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u`.`Key3` = `t0`.`UnidirectionalEntityCompositeKeyKey3`) -ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3`, `t0`.`Id` + ) AS `s` + WHERE `s`.`row` <= 2 +) AS `s0` ON ((`u`.`Key1` = `s0`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u`.`Key2` = `s0`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u`.`Key3` = `s0`.`UnidirectionalEntityCompositeKeyKey3`) +ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `s0`.`UnidirectionalEntityCompositeKeyKey1`, `s0`.`UnidirectionalEntityCompositeKeyKey2`, `s0`.`UnidirectionalEntityCompositeKeyKey3`, `s0`.`Id` """); } @@ -2639,18 +2636,18 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take_u await base.Filtered_include_skip_navigation_order_by_skip_take_unidirectional(async); AssertSql( """ -SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `t0`.`Id0` +SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`Id0` FROM `UnidirectionalEntityCompositeKeys` AS `u` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`Id0`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`Id0`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3` FROM ( SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`Id` AS `Id0`, `u0`.`CompositeId1`, `u0`.`CompositeId2`, `u0`.`CompositeId3`, ROW_NUMBER() OVER(PARTITION BY `u0`.`CompositeId1`, `u0`.`CompositeId2`, `u0`.`CompositeId3` ORDER BY `u1`.`Id`) AS `row` FROM `UnidirectionalJoinThreeToCompositeKeyFull` AS `u0` INNER JOIN `UnidirectionalEntityThrees` AS `u1` ON `u0`.`ThreeId` = `u1`.`Id` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 3) -) AS `t0` ON ((`u`.`Key1` = `t0`.`CompositeId1`) AND (`u`.`Key2` = `t0`.`CompositeId2`)) AND (`u`.`Key3` = `t0`.`CompositeId3`) -ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) +) AS `s0` ON ((`u`.`Key1` = `s0`.`CompositeId1`) AND (`u`.`Key2` = `s0`.`CompositeId2`)) AND (`u`.`Key3` = `s0`.`CompositeId3`) +ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id` """); } @@ -2660,20 +2657,20 @@ public override async Task Filtered_include_skip_navigation_where_then_include_s AssertSql( """ -SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3`, `t0`.`Name`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name0`, `t0`.`ReferenceInverseId`, `t0`.`TwoSkipSharedId`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3` +SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `s0`.`Key1`, `s0`.`Key2`, `s0`.`Key3`, `s0`.`Name`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name0`, `s0`.`ReferenceInverseId`, `s0`.`TwoSkipSharedId`, `s0`.`UnidirectionalEntityCompositeKeyKey1`, `s0`.`UnidirectionalEntityCompositeKeyKey2`, `s0`.`UnidirectionalEntityCompositeKeyKey3` FROM `UnidirectionalLeaves` AS `u` LEFT JOIN ( - SELECT `u1`.`Key1`, `u1`.`Key2`, `u1`.`Key3`, `u1`.`Name`, `u0`.`LeafId`, `u0`.`CompositeId1`, `u0`.`CompositeId2`, `u0`.`CompositeId3`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name` AS `Name0`, `t`.`ReferenceInverseId`, `t`.`TwoSkipSharedId`, `t`.`UnidirectionalEntityCompositeKeyKey1`, `t`.`UnidirectionalEntityCompositeKeyKey2`, `t`.`UnidirectionalEntityCompositeKeyKey3` + SELECT `u1`.`Key1`, `u1`.`Key2`, `u1`.`Key3`, `u1`.`Name`, `u0`.`LeafId`, `u0`.`CompositeId1`, `u0`.`CompositeId2`, `u0`.`CompositeId3`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name` AS `Name0`, `s`.`ReferenceInverseId`, `s`.`TwoSkipSharedId`, `s`.`UnidirectionalEntityCompositeKeyKey1`, `s`.`UnidirectionalEntityCompositeKeyKey2`, `s`.`UnidirectionalEntityCompositeKeyKey3` FROM `UnidirectionalJoinCompositeKeyToLeaf` AS `u0` INNER JOIN `UnidirectionalEntityCompositeKeys` AS `u1` ON ((`u0`.`CompositeId1` = `u1`.`Key1`) AND (`u0`.`CompositeId2` = `u1`.`Key2`)) AND (`u0`.`CompositeId3` = `u1`.`Key3`) LEFT JOIN ( SELECT `u3`.`Id`, `u3`.`CollectionInverseId`, `u3`.`ExtraId`, `u3`.`Name`, `u3`.`ReferenceInverseId`, `u2`.`TwoSkipSharedId`, `u2`.`UnidirectionalEntityCompositeKeyKey1`, `u2`.`UnidirectionalEntityCompositeKeyKey2`, `u2`.`UnidirectionalEntityCompositeKeyKey3` FROM `UnidirectionalEntityCompositeKeyUnidirectionalEntityTwo` AS `u2` INNER JOIN `UnidirectionalEntityTwos` AS `u3` ON `u2`.`TwoSkipSharedId` = `u3`.`Id` - ) AS `t` ON ((`u1`.`Key1` = `t`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u1`.`Key2` = `t`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u1`.`Key3` = `t`.`UnidirectionalEntityCompositeKeyKey3`) + ) AS `s` ON ((`u1`.`Key1` = `s`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u1`.`Key2` = `s`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u1`.`Key3` = `s`.`UnidirectionalEntityCompositeKeyKey3`) WHERE `u1`.`Key1` < 5 -) AS `t0` ON `u`.`Id` = `t0`.`LeafId` -ORDER BY `u`.`Id`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3`, `t0`.`TwoSkipSharedId`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3` +) AS `s0` ON `u`.`Id` = `s0`.`LeafId` +ORDER BY `u`.`Id`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Key1`, `s0`.`Key2`, `s0`.`Key3`, `s0`.`TwoSkipSharedId`, `s0`.`UnidirectionalEntityCompositeKeyKey1`, `s0`.`UnidirectionalEntityCompositeKeyKey2`, `s0`.`UnidirectionalEntityCompositeKeyKey3` """); } @@ -2683,7 +2680,7 @@ public override async Task Filter_include_on_skip_navigation_combined_unidirecti AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t`.`Id`, `t`.`Name`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name0`, `t`.`ReferenceInverseId`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id1`, `t`.`CollectionInverseId0`, `t`.`ExtraId0`, `t`.`Name1`, `t`.`ReferenceInverseId0` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s`.`Id`, `s`.`Name`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id1`, `s`.`CollectionInverseId0`, `s`.`ExtraId0`, `s`.`Name1`, `s`.`ReferenceInverseId0` FROM `EntityTwos` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId`, `j`.`OneId`, `j`.`TwoId`, `e2`.`Id` AS `Id1`, `e2`.`CollectionInverseId` AS `CollectionInverseId0`, `e2`.`ExtraId` AS `ExtraId0`, `e2`.`Name` AS `Name1`, `e2`.`ReferenceInverseId` AS `ReferenceInverseId0` @@ -2692,8 +2689,8 @@ LEFT JOIN ( LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` LEFT JOIN `EntityTwos` AS `e2` ON `e0`.`Id` = `e2`.`CollectionInverseId` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`TwoId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id`, `t`.`Id0` +) AS `s` ON `e`.`Id` = `s`.`TwoId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id`, `s`.`Id0` """); } @@ -2731,13 +2728,13 @@ public override async Task Select_many_over_skip_navigation_where_non_equality_u AssertSql( """ -SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `UnidirectionalEntityOnes` AS `u` LEFT JOIN ( SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`OneId` FROM `UnidirectionalJoinOneToTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoId` = `u1`.`Id` -) AS `t` ON (`u`.`Id` = `t`.`OneId`) AND (`u`.`Id` <> `t`.`Id`) +) AS `s` ON (`u`.`Id` = `s`.`OneId`) AND (`u`.`Id` <> `s`.`Id`) """); } @@ -2797,14 +2794,14 @@ public override async Task GetType_in_hierarchy_in_querying_base_type_unidirecti AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator` +SELECT `u1`.`Id`, `u1`.`Name`, `u1`.`Number`, `u1`.`IsGreen`, `u1`.`Discriminator` FROM ( SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, NULL AS `IsGreen`, 'UnidirectionalEntityBranch' AS `Discriminator` FROM `UnidirectionalBranches` AS `u` UNION ALL SELECT `u0`.`Id`, `u0`.`Name`, `u0`.`Number`, `u0`.`IsGreen`, 'UnidirectionalEntityLeaf' AS `Discriminator` FROM `UnidirectionalLeaves` AS `u0` -) AS `t` +) AS `u1` WHERE FALSE """); } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/TPCManyToManyQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/TPCManyToManyQuerySingleStoreTest.cs index 621dc84e7..06c1541c2 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/TPCManyToManyQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/TPCManyToManyQuerySingleStoreTest.cs @@ -16,12 +16,9 @@ public TPCManyToManyQuerySingleStoreTest(TPCManyToManyQuerySingleStoreFixture fi //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - [ConditionalFact] public virtual void Check_all_tests_overridden() - => TestHelpers.AssertAllMethodsOverridden(GetType()); + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); public override async Task Skip_navigation_all(bool async) { @@ -116,13 +113,13 @@ ORDER BY ( SELECT COUNT(*) FROM `JoinOneToBranch` AS `j` INNER JOIN ( - SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, NULL AS `IsGreen`, 'EntityBranch' AS `Discriminator` + SELECT `b`.`Id`, `b`.`Name` FROM `Branches` AS `b` UNION ALL - SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, 'EntityLeaf' AS `Discriminator` + SELECT `l`.`Id`, `l`.`Name` FROM `Leaves` AS `l` - ) AS `t` ON `j`.`EntityBranchId` = `t`.`Id` - WHERE (`e`.`Id` = `j`.`EntityOneId`) AND (`t`.`Name` LIKE 'L%')), `e`.`Id` + ) AS `u` ON `j`.`EntityBranchId` = `u`.`Id` + WHERE (`e`.`Id` = `j`.`EntityOneId`) AND (`u`.`Name` LIKE 'L%')), `e`.`Id` """); } @@ -164,14 +161,14 @@ public override async Task Skip_navigation_select_many_average(bool async) await base.Skip_navigation_select_many_average(async); AssertSql( -$""" -SELECT AVG({SingleStoreTestHelpers.CastAsDouble(@"`t`.`Key1`")}) +""" +SELECT AVG((`s`.`Key1` :> double)) FROM `EntityTwos` AS `e` INNER JOIN ( SELECT `e1`.`Key1`, `e0`.`TwoSkipSharedId` FROM `EntityCompositeKeyEntityTwo` AS `e0` INNER JOIN `EntityCompositeKeys` AS `e1` ON ((`e0`.`CompositeKeySkipSharedKey1` = `e1`.`Key1`) AND (`e0`.`CompositeKeySkipSharedKey2` = `e1`.`Key2`)) AND (`e0`.`CompositeKeySkipSharedKey3` = `e1`.`Key3`) -) AS `t` ON `e`.`Id` = `t`.`TwoSkipSharedId` +) AS `s` ON `e`.`Id` = `s`.`TwoSkipSharedId` """); } @@ -181,13 +178,13 @@ public override async Task Skip_navigation_select_many_max(bool async) AssertSql( """ -SELECT MAX(`t`.`Key1`) +SELECT MAX(`s`.`Key1`) FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `e0`.`Key1`, `j`.`ThreeId` FROM `JoinThreeToCompositeKeyFull` AS `j` INNER JOIN `EntityCompositeKeys` AS `e0` ON ((`j`.`CompositeId1` = `e0`.`Key1`) AND (`j`.`CompositeId2` = `e0`.`Key2`)) AND (`j`.`CompositeId3` = `e0`.`Key3`) -) AS `t` ON `e`.`Id` = `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` """); } @@ -197,10 +194,10 @@ public override async Task Skip_navigation_select_many_min(bool async) AssertSql( """ -SELECT MIN(`t0`.`Id`) +SELECT MIN(`s`.`Id`) FROM `EntityThrees` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `e0`.`ThreeSkipSharedId` + SELECT `u`.`Id`, `e0`.`ThreeSkipSharedId` FROM `EntityRootEntityThree` AS `e0` INNER JOIN ( SELECT `r`.`Id` @@ -214,8 +211,8 @@ UNION ALL UNION ALL SELECT `l0`.`Id` FROM `Leaf2s` AS `l0` - ) AS `t` ON `e0`.`RootSkipSharedId` = `t`.`Id` -) AS `t0` ON `e`.`Id` = `t0`.`ThreeSkipSharedId` + ) AS `u` ON `e0`.`RootSkipSharedId` = `u`.`Id` +) AS `s` ON `e`.`Id` = `s`.`ThreeSkipSharedId` """); } @@ -225,7 +222,7 @@ public override async Task Skip_navigation_select_many_sum(bool async) AssertSql( """ -SELECT COALESCE(SUM(`t0`.`Key1`), 0) +SELECT COALESCE(SUM(`s`.`Key1`), 0) FROM ( SELECT `r`.`Id` FROM `Roots` AS `r` @@ -238,12 +235,12 @@ UNION ALL UNION ALL SELECT `l0`.`Id` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` INNER JOIN ( SELECT `e0`.`Key1`, `e`.`RootSkipSharedId` FROM `EntityCompositeKeyEntityRoot` AS `e` INNER JOIN `EntityCompositeKeys` AS `e0` ON ((`e`.`CompositeKeySkipSharedKey1` = `e0`.`Key1`) AND (`e`.`CompositeKeySkipSharedKey2` = `e0`.`Key2`)) AND (`e`.`CompositeKeySkipSharedKey3` = `e0`.`Key3`) -) AS `t0` ON `t`.`Id` = `t0`.`RootSkipSharedId` +) AS `s` ON `u`.`Id` = `s`.`RootSkipSharedId` """); } @@ -313,17 +310,17 @@ public override async Task Skip_navigation_order_by_first_or_default(bool async) AssertSql( """ -SELECT `t0`.`Id`, `t0`.`Name` +SELECT `s0`.`Id`, `s0`.`Name` FROM `EntityThrees` AS `e` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`ThreeId` + SELECT `s`.`Id`, `s`.`Name`, `s`.`ThreeId` FROM ( SELECT `e0`.`Id`, `e0`.`Name`, `j`.`ThreeId`, ROW_NUMBER() OVER(PARTITION BY `j`.`ThreeId` ORDER BY `e0`.`Id`) AS `row` FROM `JoinOneToThreePayloadFullShared` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `e`.`Id` = `t0`.`ThreeId` + ) AS `s` + WHERE `s`.`row` <= 1 +) AS `s0` ON `e`.`Id` = `s0`.`ThreeId` """); } @@ -333,10 +330,10 @@ public override async Task Skip_navigation_order_by_single_or_default(bool async AssertSql( """ -SELECT `t0`.`Id`, `t0`.`Name` +SELECT `s0`.`Id`, `s0`.`Name` FROM `EntityOnes` AS `e` LEFT JOIN LATERAL ( - SELECT `t`.`Id`, `t`.`Name` + SELECT `s`.`Id`, `s`.`Name` FROM ( SELECT `e0`.`Id`, `e0`.`Name` FROM `JoinOneSelfPayload` AS `j` @@ -344,10 +341,10 @@ LEFT JOIN LATERAL ( WHERE `e`.`Id` = `j`.`LeftId` ORDER BY `e0`.`Id` LIMIT 1 - ) AS `t` - ORDER BY `t`.`Id` + ) AS `s` + ORDER BY `s`.`Id` LIMIT 1 -) AS `t0` ON TRUE +) AS `s0` ON TRUE """); } @@ -357,23 +354,23 @@ public override async Task Skip_navigation_order_by_last_or_default(bool async) AssertSql( """ -SELECT `t0`.`Id`, `t0`.`Name` +SELECT `s0`.`Id`, `s0`.`Name` FROM ( SELECT `b`.`Id` FROM `Branches` AS `b` UNION ALL SELECT `l`.`Id` FROM `Leaves` AS `l` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `t1`.`Id`, `t1`.`Name`, `t1`.`EntityBranchId` + SELECT `s`.`Id`, `s`.`Name`, `s`.`EntityBranchId` FROM ( SELECT `e`.`Id`, `e`.`Name`, `j`.`EntityBranchId`, ROW_NUMBER() OVER(PARTITION BY `j`.`EntityBranchId` ORDER BY `e`.`Id` DESC) AS `row` FROM `JoinOneToBranch` AS `j` INNER JOIN `EntityOnes` AS `e` ON `j`.`EntityOneId` = `e`.`Id` - ) AS `t1` - WHERE `t1`.`row` <= 1 -) AS `t0` ON `t`.`Id` = `t0`.`EntityBranchId` + ) AS `s` + WHERE `s`.`row` <= 1 +) AS `s0` ON `u`.`Id` = `s0`.`EntityBranchId` """); } @@ -383,17 +380,17 @@ public override async Task Skip_navigation_order_by_reverse_first_or_default(boo AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `EntityThrees` AS `e` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`ThreeId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`ThreeId` FROM ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`ThreeId`, ROW_NUMBER() OVER(PARTITION BY `j`.`ThreeId` ORDER BY `e0`.`Id` DESC) AS `row` FROM `JoinTwoToThree` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `e`.`Id` = `t0`.`ThreeId` + ) AS `s` + WHERE `s`.`row` <= 1 +) AS `s0` ON `e`.`Id` = `s0`.`ThreeId` """); } @@ -403,14 +400,14 @@ public override async Task Skip_navigation_cast(bool async) AssertSql( """ -SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3` +SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3` FROM `EntityCompositeKeys` AS `e` LEFT JOIN ( SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3` FROM `JoinCompositeKeyToLeaf` AS `j` INNER JOIN `Leaves` AS `l` ON `j`.`LeafId` = `l`.`Id` -) AS `t` ON ((`e`.`Key1` = `t`.`CompositeId1`) AND (`e`.`Key2` = `t`.`CompositeId2`)) AND (`e`.`Key3` = `t`.`CompositeId3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3` +) AS `s` ON ((`e`.`Key1` = `s`.`CompositeId1`) AND (`e`.`Key2` = `s`.`CompositeId2`)) AND (`e`.`Key3` = `s`.`CompositeId3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3` """); } @@ -419,28 +416,28 @@ public override async Task Skip_navigation_of_type(bool async) await base.Skip_navigation_of_type(async); AssertSql( -$""" -SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`Discriminator`, `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3` +""" +SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `s`.`Discriminator`, `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3` FROM `EntityCompositeKeys` AS `e` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator`, `e0`.`RootSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` + SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `u`.`Discriminator`, `e0`.`RootSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` FROM `EntityCompositeKeyEntityRoot` AS `e0` INNER JOIN ( - SELECT `r`.`Id`, `r`.`Name`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `Number`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsGreen`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'EntityRoot'")} AS `Discriminator` + SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `IsGreen`, 'EntityRoot' AS `Discriminator` FROM `Roots` AS `r` UNION ALL - SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsGreen`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'EntityBranch'")} AS `Discriminator` + SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, NULL AS `IsGreen`, 'EntityBranch' AS `Discriminator` FROM `Branches` AS `b` UNION ALL SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, 'EntityLeaf' AS `Discriminator` FROM `Leaves` AS `l` UNION ALL - SELECT `l0`.`Id`, `l0`.`Name`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `Number`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsGreen`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'EntityLeaf2'")} AS `Discriminator` + SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, NULL AS `IsGreen`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` - ) AS `t` ON `e0`.`RootSkipSharedId` = `t`.`Id` - WHERE `t`.`Discriminator` = 'EntityLeaf' -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `t0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `t0`.`CompositeKeySkipSharedKey3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3` + ) AS `u` ON `e0`.`RootSkipSharedId` = `u`.`Id` + WHERE `u`.`Discriminator` = 'EntityLeaf' +) AS `s` ON ((`e`.`Key1` = `s`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `s`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `s`.`CompositeKeySkipSharedKey3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3` """); } @@ -495,7 +492,7 @@ public override async Task Select_many_over_skip_navigation(bool async) AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `r`.`Id` FROM `Roots` AS `r` @@ -508,12 +505,12 @@ UNION ALL UNION ALL SELECT `l0`.`Id` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` INNER JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `e`.`RootSkipSharedId` FROM `EntityRootEntityThree` AS `e` INNER JOIN `EntityThrees` AS `e0` ON `e`.`ThreeSkipSharedId` = `e0`.`Id` -) AS `t0` ON `t`.`Id` = `t0`.`RootSkipSharedId` +) AS `s` ON `u`.`Id` = `s`.`RootSkipSharedId` """); } @@ -523,13 +520,13 @@ public override async Task Select_many_over_skip_navigation_where(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `EntityOnes` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` -) AS `t` ON `e`.`Id` = `t`.`OneId` +) AS `s` ON `e`.`Id` = `s`.`OneId` """); } @@ -539,17 +536,17 @@ public override async Task Select_many_over_skip_navigation_order_by_skip(bool a AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `EntityOnes` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`OneId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`OneId` FROM ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId`, ROW_NUMBER() OVER(PARTITION BY `j`.`OneId` ORDER BY `e0`.`Id`) AS `row` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityThrees` AS `e0` ON `j`.`ThreeId` = `e0`.`Id` - ) AS `t` - WHERE 2 < `t`.`row` -) AS `t0` ON `e`.`Id` = `t0`.`OneId` + ) AS `s` + WHERE 2 < `s`.`row` +) AS `s0` ON `e`.`Id` = `s0`.`OneId` """); } @@ -559,17 +556,17 @@ public override async Task Select_many_over_skip_navigation_order_by_take(bool a AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `EntityOnes` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`OneSkipSharedId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`OneSkipSharedId` FROM ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, `e0`.`OneSkipSharedId`, ROW_NUMBER() OVER(PARTITION BY `e0`.`OneSkipSharedId` ORDER BY `e1`.`Id`) AS `row` FROM `EntityOneEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`TwoSkipSharedId` = `e1`.`Id` - ) AS `t` - WHERE `t`.`row` <= 2 -) AS `t0` ON `e`.`Id` = `t0`.`OneSkipSharedId` + ) AS `s` + WHERE `s`.`row` <= 2 +) AS `s0` ON `e`.`Id` = `s0`.`OneSkipSharedId` """); } @@ -579,17 +576,17 @@ public override async Task Select_many_over_skip_navigation_order_by_skip_take(b AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `EntityOnes` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`OneId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`OneId` FROM ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId`, ROW_NUMBER() OVER(PARTITION BY `j`.`OneId` ORDER BY `e0`.`Id`) AS `row` FROM `JoinOneToThreePayloadFullShared` AS `j` INNER JOIN `EntityThrees` AS `e0` ON `j`.`ThreeId` = `e0`.`Id` - ) AS `t` - WHERE (2 < `t`.`row`) AND (`t`.`row` <= 5) -) AS `t0` ON `e`.`Id` = `t0`.`OneId` + ) AS `s` + WHERE (2 < `s`.`row`) AND (`s`.`row` <= 5) +) AS `s0` ON `e`.`Id` = `s0`.`OneId` """); } @@ -599,10 +596,10 @@ public override async Task Select_many_over_skip_navigation_of_type(bool async) AssertSql( """ -SELECT `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`Discriminator` +SELECT `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `s`.`Discriminator` FROM `EntityThrees` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator`, `e0`.`ThreeSkipSharedId` + SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `u`.`Discriminator`, `e0`.`ThreeSkipSharedId` FROM `EntityRootEntityThree` AS `e0` INNER JOIN ( SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `IsGreen`, 'EntityRoot' AS `Discriminator` @@ -616,9 +613,9 @@ UNION ALL UNION ALL SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, NULL AS `IsGreen`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` - ) AS `t` ON `e0`.`RootSkipSharedId` = `t`.`Id` - WHERE `t`.`Discriminator` IN ('EntityBranch', 'EntityLeaf') -) AS `t0` ON `e`.`Id` = `t0`.`ThreeSkipSharedId` + ) AS `u` ON `e0`.`RootSkipSharedId` = `u`.`Id` + WHERE `u`.`Discriminator` IN ('EntityBranch', 'EntityLeaf') +) AS `s` ON `e`.`Id` = `s`.`ThreeSkipSharedId` """); } @@ -628,10 +625,10 @@ public override async Task Select_many_over_skip_navigation_cast(bool async) AssertSql( """ -SELECT `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`Discriminator` +SELECT `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `s`.`Discriminator` FROM `EntityOnes` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator`, `j`.`EntityOneId` + SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `u`.`Discriminator`, `j`.`EntityOneId` FROM `JoinOneToBranch` AS `j` INNER JOIN ( SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, NULL AS `IsGreen`, 'EntityBranch' AS `Discriminator` @@ -639,8 +636,8 @@ INNER JOIN ( UNION ALL SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, 'EntityLeaf' AS `Discriminator` FROM `Leaves` AS `l` - ) AS `t` ON `j`.`EntityBranchId` = `t`.`Id` -) AS `t0` ON `e`.`Id` = `t0`.`EntityOneId` + ) AS `u` ON `j`.`EntityBranchId` = `u`.`Id` +) AS `s` ON `e`.`Id` = `s`.`EntityOneId` """); } @@ -650,14 +647,14 @@ public override async Task Select_skip_navigation(bool async) AssertSql( """ -SELECT `e`.`Id`, `t`.`Id`, `t`.`Name`, `t`.`LeftId`, `t`.`RightId` +SELECT `e`.`Id`, `s`.`Id`, `s`.`Name`, `s`.`LeftId`, `s`.`RightId` FROM `EntityOnes` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`Name`, `j`.`LeftId`, `j`.`RightId` FROM `JoinOneSelfPayload` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`LeftId` = `e0`.`Id` -) AS `t` ON `e`.`Id` = `t`.`RightId` -ORDER BY `e`.`Id`, `t`.`LeftId`, `t`.`RightId` +) AS `s` ON `e`.`Id` = `s`.`RightId` +ORDER BY `e`.`Id`, `s`.`LeftId`, `s`.`RightId` """); } @@ -667,24 +664,24 @@ public override async Task Select_skip_navigation_multiple(bool async) AssertSql( """ -SELECT `e`.`Id`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`ThreeId`, `t`.`TwoId`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `t0`.`SelfSkipSharedLeftId`, `t0`.`SelfSkipSharedRightId`, `t1`.`Key1`, `t1`.`Key2`, `t1`.`Key3`, `t1`.`Name`, `t1`.`TwoSkipSharedId`, `t1`.`CompositeKeySkipSharedKey1`, `t1`.`CompositeKeySkipSharedKey2`, `t1`.`CompositeKeySkipSharedKey3` +SELECT `e`.`Id`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`ThreeId`, `s`.`TwoId`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`SelfSkipSharedLeftId`, `s0`.`SelfSkipSharedRightId`, `s1`.`Key1`, `s1`.`Key2`, `s1`.`Key3`, `s1`.`Name`, `s1`.`TwoSkipSharedId`, `s1`.`CompositeKeySkipSharedKey1`, `s1`.`CompositeKeySkipSharedKey2`, `s1`.`CompositeKeySkipSharedKey3` FROM `EntityTwos` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`ThreeId`, `j`.`TwoId` FROM `JoinTwoToThree` AS `j` INNER JOIN `EntityThrees` AS `e0` ON `j`.`ThreeId` = `e0`.`Id` -) AS `t` ON `e`.`Id` = `t`.`TwoId` +) AS `s` ON `e`.`Id` = `s`.`TwoId` LEFT JOIN ( SELECT `e2`.`Id`, `e2`.`CollectionInverseId`, `e2`.`ExtraId`, `e2`.`Name`, `e2`.`ReferenceInverseId`, `e1`.`SelfSkipSharedLeftId`, `e1`.`SelfSkipSharedRightId` FROM `EntityTwoEntityTwo` AS `e1` INNER JOIN `EntityTwos` AS `e2` ON `e1`.`SelfSkipSharedLeftId` = `e2`.`Id` -) AS `t0` ON `e`.`Id` = `t0`.`SelfSkipSharedRightId` +) AS `s0` ON `e`.`Id` = `s0`.`SelfSkipSharedRightId` LEFT JOIN ( SELECT `e4`.`Key1`, `e4`.`Key2`, `e4`.`Key3`, `e4`.`Name`, `e3`.`TwoSkipSharedId`, `e3`.`CompositeKeySkipSharedKey1`, `e3`.`CompositeKeySkipSharedKey2`, `e3`.`CompositeKeySkipSharedKey3` FROM `EntityCompositeKeyEntityTwo` AS `e3` INNER JOIN `EntityCompositeKeys` AS `e4` ON ((`e3`.`CompositeKeySkipSharedKey1` = `e4`.`Key1`) AND (`e3`.`CompositeKeySkipSharedKey2` = `e4`.`Key2`)) AND (`e3`.`CompositeKeySkipSharedKey3` = `e4`.`Key3`) -) AS `t1` ON `e`.`Id` = `t1`.`TwoSkipSharedId` -ORDER BY `e`.`Id`, `t`.`ThreeId`, `t`.`TwoId`, `t`.`Id`, `t0`.`SelfSkipSharedLeftId`, `t0`.`SelfSkipSharedRightId`, `t0`.`Id`, `t1`.`TwoSkipSharedId`, `t1`.`CompositeKeySkipSharedKey1`, `t1`.`CompositeKeySkipSharedKey2`, `t1`.`CompositeKeySkipSharedKey3`, `t1`.`Key1`, `t1`.`Key2` +) AS `s1` ON `e`.`Id` = `s1`.`TwoSkipSharedId` +ORDER BY `e`.`Id`, `s`.`ThreeId`, `s`.`TwoId`, `s`.`Id`, `s0`.`SelfSkipSharedLeftId`, `s0`.`SelfSkipSharedRightId`, `s0`.`Id`, `s1`.`TwoSkipSharedId`, `s1`.`CompositeKeySkipSharedKey1`, `s1`.`CompositeKeySkipSharedKey2`, `s1`.`CompositeKeySkipSharedKey3`, `s1`.`Key1`, `s1`.`Key2` """); } @@ -694,17 +691,17 @@ public override async Task Select_skip_navigation_first_or_default(bool async) AssertSql( """ -SELECT `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3`, `t0`.`Name` +SELECT `s0`.`Key1`, `s0`.`Key2`, `s0`.`Key3`, `s0`.`Name` FROM `EntityThrees` AS `e` LEFT JOIN ( - SELECT `t`.`Key1`, `t`.`Key2`, `t`.`Key3`, `t`.`Name`, `t`.`ThreeId` + SELECT `s`.`Key1`, `s`.`Key2`, `s`.`Key3`, `s`.`Name`, `s`.`ThreeId` FROM ( SELECT `e0`.`Key1`, `e0`.`Key2`, `e0`.`Key3`, `e0`.`Name`, `j`.`ThreeId`, ROW_NUMBER() OVER(PARTITION BY `j`.`ThreeId` ORDER BY `e0`.`Key1`, `e0`.`Key2`) AS `row` FROM `JoinThreeToCompositeKeyFull` AS `j` INNER JOIN `EntityCompositeKeys` AS `e0` ON ((`j`.`CompositeId1` = `e0`.`Key1`) AND (`j`.`CompositeId2` = `e0`.`Key2`)) AND (`j`.`CompositeId3` = `e0`.`Key3`) - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `e`.`Id` = `t0`.`ThreeId` + ) AS `s` + WHERE `s`.`row` <= 1 +) AS `s0` ON `e`.`Id` = `s0`.`ThreeId` ORDER BY `e`.`Id` """); } @@ -714,27 +711,27 @@ public override async Task Include_skip_navigation(bool async) await base.Include_skip_navigation(async); AssertSql( -$""" -SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`Slumber`, `t0`.`IsGreen`, `t0`.`IsBrown`, `t0`.`Discriminator` +""" +SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3`, `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`Slumber`, `s`.`IsGreen`, `s`.`IsBrown`, `s`.`Discriminator` FROM `EntityCompositeKeys` AS `e` LEFT JOIN ( - SELECT `e0`.`RootSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3`, `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`Slumber`, `t`.`IsGreen`, `t`.`IsBrown`, `t`.`Discriminator` + SELECT `e0`.`RootSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3`, `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`Slumber`, `u`.`IsGreen`, `u`.`IsBrown`, `u`.`Discriminator` FROM `EntityCompositeKeyEntityRoot` AS `e0` INNER JOIN ( - SELECT `r`.`Id`, `r`.`Name`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `Number`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `Slumber`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsGreen`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsBrown`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'EntityRoot'")} AS `Discriminator` + SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `Slumber`, NULL AS `IsGreen`, NULL AS `IsBrown`, 'EntityRoot' AS `Discriminator` FROM `Roots` AS `r` UNION ALL - SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `Slumber`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsGreen`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsBrown`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'EntityBranch'")} AS `Discriminator` + SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, NULL AS `Slumber`, NULL AS `IsGreen`, NULL AS `IsBrown`, 'EntityBranch' AS `Discriminator` FROM `Branches` AS `b` UNION ALL SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, NULL AS `Slumber`, `l`.`IsGreen`, NULL AS `IsBrown`, 'EntityLeaf' AS `Discriminator` FROM `Leaves` AS `l` UNION ALL - SELECT `l0`.`Id`, `l0`.`Name`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `Number`, `l0`.`Slumber`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `IsGreen`, `l0`.`IsBrown`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'EntityLeaf2'")} AS `Discriminator` + SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, `l0`.`Slumber`, NULL AS `IsGreen`, `l0`.`IsBrown`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` - ) AS `t` ON `e0`.`RootSkipSharedId` = `t`.`Id` -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `t0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `t0`.`CompositeKeySkipSharedKey3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3` + ) AS `u` ON `e0`.`RootSkipSharedId` = `u`.`Id` +) AS `s` ON ((`e`.`Key1` = `s`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `s`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `s`.`CompositeKeySkipSharedKey3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3` """); } @@ -744,15 +741,15 @@ public override async Task Include_skip_navigation_then_reference(bool async) AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t`.`OneId`, `t`.`TwoId`, `t`.`JoinOneToTwoExtraId`, `t`.`Id`, `t`.`Name`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name0`, `t`.`ReferenceInverseId` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s`.`OneId`, `s`.`TwoId`, `s`.`JoinOneToTwoExtraId`, `s`.`Id`, `s`.`Name`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId` FROM `EntityTwos` AS `e` LEFT JOIN ( SELECT `j`.`OneId`, `j`.`TwoId`, `j`.`JoinOneToTwoExtraId`, `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` -) AS `t` ON `e`.`Id` = `t`.`TwoId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id` +) AS `s` ON `e`.`Id` = `s`.`TwoId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id` """); } @@ -762,19 +759,19 @@ public override async Task Include_skip_navigation_then_include_skip_navigation( AssertSql( """ -SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`EntityBranchId`, `t0`.`EntityOneId`, `t0`.`Id0`, `t0`.`Name0` +SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id`, `s0`.`Name`, `s0`.`Number`, `s0`.`IsGreen`, `s0`.`EntityBranchId`, `s0`.`EntityOneId`, `s0`.`Id0`, `s0`.`Name0` FROM `EntityCompositeKeys` AS `e` LEFT JOIN ( - SELECT `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, `t`.`EntityBranchId`, `t`.`EntityOneId`, `t`.`Id` AS `Id0`, `t`.`Name` AS `Name0` + SELECT `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, `s`.`EntityBranchId`, `s`.`EntityOneId`, `s`.`Id` AS `Id0`, `s`.`Name` AS `Name0` FROM `JoinCompositeKeyToLeaf` AS `j` INNER JOIN `Leaves` AS `l` ON `j`.`LeafId` = `l`.`Id` LEFT JOIN ( SELECT `j0`.`EntityBranchId`, `j0`.`EntityOneId`, `e0`.`Id`, `e0`.`Name` FROM `JoinOneToBranch` AS `j0` INNER JOIN `EntityOnes` AS `e0` ON `j0`.`EntityOneId` = `e0`.`Id` - ) AS `t` ON `l`.`Id` = `t`.`EntityBranchId` -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeId1`) AND (`e`.`Key2` = `t0`.`CompositeId2`)) AND (`e`.`Key3` = `t0`.`CompositeId3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id`, `t0`.`EntityBranchId`, `t0`.`EntityOneId` + ) AS `s` ON `l`.`Id` = `s`.`EntityBranchId` +) AS `s0` ON ((`e`.`Key1` = `s0`.`CompositeId1`) AND (`e`.`Key2` = `s0`.`CompositeId2`)) AND (`e`.`Key3` = `s0`.`CompositeId3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id`, `s0`.`EntityBranchId`, `s0`.`EntityOneId` """); } @@ -784,10 +781,10 @@ public override async Task Include_skip_navigation_then_include_reference_and_sk AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Payload`, `t0`.`Id`, `t0`.`Name`, `t0`.`Id0`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name0`, `t0`.`ReferenceInverseId`, `t0`.`LeftId`, `t0`.`RightId`, `t0`.`Payload0`, `t0`.`Id1`, `t0`.`Name1` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s0`.`OneId`, `s0`.`ThreeId`, `s0`.`Payload`, `s0`.`Id`, `s0`.`Name`, `s0`.`Id0`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name0`, `s0`.`ReferenceInverseId`, `s0`.`LeftId`, `s0`.`RightId`, `s0`.`Payload0`, `s0`.`Id1`, `s0`.`Name1` FROM `EntityThrees` AS `e` LEFT JOIN ( - SELECT `j`.`OneId`, `j`.`ThreeId`, `j`.`Payload`, `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId`, `t`.`LeftId`, `t`.`RightId`, `t`.`Payload` AS `Payload0`, `t`.`Id` AS `Id1`, `t`.`Name` AS `Name1` + SELECT `j`.`OneId`, `j`.`ThreeId`, `j`.`Payload`, `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId`, `s`.`LeftId`, `s`.`RightId`, `s`.`Payload` AS `Payload0`, `s`.`Id` AS `Id1`, `s`.`Name` AS `Name1` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` @@ -795,9 +792,9 @@ LEFT JOIN ( SELECT `j0`.`LeftId`, `j0`.`RightId`, `j0`.`Payload`, `e2`.`Id`, `e2`.`Name` FROM `JoinOneSelfPayload` AS `j0` INNER JOIN `EntityOnes` AS `e2` ON `j0`.`RightId` = `e2`.`Id` - ) AS `t` ON `e0`.`Id` = `t`.`LeftId` -) AS `t0` ON `e`.`Id` = `t0`.`ThreeId` -ORDER BY `e`.`Id`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Id`, `t0`.`Id0`, `t0`.`LeftId`, `t0`.`RightId` + ) AS `s` ON `e0`.`Id` = `s`.`LeftId` +) AS `s0` ON `e`.`Id` = `s0`.`ThreeId` +ORDER BY `e`.`Id`, `s0`.`OneId`, `s0`.`ThreeId`, `s0`.`Id`, `s0`.`Id0`, `s0`.`LeftId`, `s0`.`RightId` """); } @@ -807,15 +804,15 @@ public override async Task Include_skip_navigation_and_reference(bool async) AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `e0`.`Id`, `t`.`OneSkipSharedId`, `t`.`TwoSkipSharedId`, `t`.`Id`, `t`.`Name`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `e0`.`Id`, `s`.`OneSkipSharedId`, `s`.`TwoSkipSharedId`, `s`.`Id`, `s`.`Name`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId` FROM `EntityTwos` AS `e` LEFT JOIN `EntityThrees` AS `e0` ON `e`.`Id` = `e0`.`ReferenceInverseId` LEFT JOIN ( SELECT `e1`.`OneSkipSharedId`, `e1`.`TwoSkipSharedId`, `e2`.`Id`, `e2`.`Name` FROM `EntityOneEntityTwo` AS `e1` INNER JOIN `EntityOnes` AS `e2` ON `e1`.`OneSkipSharedId` = `e2`.`Id` -) AS `t` ON `e`.`Id` = `t`.`TwoSkipSharedId` -ORDER BY `e`.`Id`, `e0`.`Id`, `t`.`OneSkipSharedId`, `t`.`TwoSkipSharedId` +) AS `s` ON `e`.`Id` = `s`.`TwoSkipSharedId` +ORDER BY `e`.`Id`, `e0`.`Id`, `s`.`OneSkipSharedId`, `s`.`TwoSkipSharedId` """); } @@ -825,15 +822,15 @@ public override async Task Filtered_include_skip_navigation_where(bool async) AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Payload`, `t`.`Id`, `t`.`Name` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Payload`, `s`.`Id`, `s`.`Name` FROM `EntityThrees` AS `e` LEFT JOIN ( SELECT `j`.`OneId`, `j`.`ThreeId`, `j`.`Payload`, `e0`.`Id`, `e0`.`Name` FROM `JoinOneToThreePayloadFullShared` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId` """); } @@ -843,14 +840,14 @@ public override async Task Filtered_include_skip_navigation_order_by(bool async) AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t`.`ThreeId`, `t`.`TwoId`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s`.`ThreeId`, `s`.`TwoId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `EntityThrees` AS `e` LEFT JOIN ( SELECT `j`.`ThreeId`, `j`.`TwoId`, `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId` FROM `JoinTwoToThree` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` -) AS `t` ON `e`.`Id` = `t`.`ThreeId` -ORDER BY `e`.`Id`, `t`.`Id`, `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`Id`, `s`.`ThreeId` """); } @@ -860,18 +857,18 @@ public override async Task Filtered_include_skip_navigation_order_by_skip(bool a AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t0`.`SelfSkipSharedLeftId`, `t0`.`SelfSkipSharedRightId`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s0`.`SelfSkipSharedLeftId`, `s0`.`SelfSkipSharedRightId`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `EntityTwos` AS `e` LEFT JOIN ( - SELECT `t`.`SelfSkipSharedLeftId`, `t`.`SelfSkipSharedRightId`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` + SELECT `s`.`SelfSkipSharedLeftId`, `s`.`SelfSkipSharedRightId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `e0`.`SelfSkipSharedLeftId`, `e0`.`SelfSkipSharedRightId`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `e0`.`SelfSkipSharedLeftId` ORDER BY `e1`.`Id`) AS `row` FROM `EntityTwoEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`SelfSkipSharedRightId` = `e1`.`Id` - ) AS `t` - WHERE 2 < `t`.`row` -) AS `t0` ON `e`.`Id` = `t0`.`SelfSkipSharedLeftId` -ORDER BY `e`.`Id`, `t0`.`SelfSkipSharedLeftId`, `t0`.`Id` + ) AS `s` + WHERE 2 < `s`.`row` +) AS `s0` ON `e`.`Id` = `s0`.`SelfSkipSharedLeftId` +ORDER BY `e`.`Id`, `s0`.`SelfSkipSharedLeftId`, `s0`.`Id` """); } @@ -881,18 +878,18 @@ public override async Task Filtered_include_skip_navigation_order_by_take(bool a AssertSql( """ -SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `t0`.`TwoSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `s0`.`TwoSkipSharedId`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `EntityCompositeKeys` AS `e` LEFT JOIN ( - SELECT `t`.`TwoSkipSharedId`, `t`.`CompositeKeySkipSharedKey1`, `t`.`CompositeKeySkipSharedKey2`, `t`.`CompositeKeySkipSharedKey3`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` + SELECT `s`.`TwoSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `e0`.`TwoSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` ORDER BY `e1`.`Id`) AS `row` FROM `EntityCompositeKeyEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`TwoSkipSharedId` = `e1`.`Id` - ) AS `t` - WHERE `t`.`row` <= 2 -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `t0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `t0`.`CompositeKeySkipSharedKey3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Id` + ) AS `s` + WHERE `s`.`row` <= 2 +) AS `s0` ON ((`e`.`Key1` = `s0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `s0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `s0`.`CompositeKeySkipSharedKey3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3`, `s0`.`Id` """); } @@ -902,18 +899,18 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take(b AssertSql( """ -SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `t0`.`Id`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`ThreeId`, `t0`.`Id0`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `s0`.`Id`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`ThreeId`, `s0`.`Id0`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `EntityCompositeKeys` AS `e` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`ThreeId`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId` + SELECT `s`.`Id`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`ThreeId`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `j`.`Id`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `j`.`ThreeId`, `e0`.`Id` AS `Id0`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3` ORDER BY `e0`.`Id`) AS `row` FROM `JoinThreeToCompositeKeyFull` AS `j` INNER JOIN `EntityThrees` AS `e0` ON `j`.`ThreeId` = `e0`.`Id` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 3) -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeId1`) AND (`e`.`Key2` = `t0`.`CompositeId2`)) AND (`e`.`Key3` = `t0`.`CompositeId3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id0` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) +) AS `s0` ON ((`e`.`Key1` = `s0`.`CompositeId1`) AND (`e`.`Key2` = `s0`.`CompositeId2`)) AND (`e`.`Key3` = `s0`.`CompositeId3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id0` """); } @@ -923,7 +920,7 @@ public override async Task Filtered_then_include_skip_navigation_where(bool asyn AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`Slumber`, `t`.`IsGreen`, `t`.`IsBrown`, `t`.`Discriminator`, `t0`.`RootSkipSharedId`, `t0`.`ThreeSkipSharedId`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Payload`, `t0`.`Id0`, `t0`.`Name0` +SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`Slumber`, `u`.`IsGreen`, `u`.`IsBrown`, `u`.`Discriminator`, `s0`.`RootSkipSharedId`, `s0`.`ThreeSkipSharedId`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`OneId`, `s0`.`ThreeId`, `s0`.`Payload`, `s0`.`Id0`, `s0`.`Name0` FROM ( SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `Slumber`, NULL AS `IsGreen`, NULL AS `IsBrown`, 'EntityRoot' AS `Discriminator` FROM `Roots` AS `r` @@ -936,9 +933,9 @@ UNION ALL UNION ALL SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, `l0`.`Slumber`, NULL AS `IsGreen`, `l0`.`IsBrown`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `e`.`RootSkipSharedId`, `e`.`ThreeSkipSharedId`, `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `t1`.`OneId`, `t1`.`ThreeId`, `t1`.`Payload`, `t1`.`Id` AS `Id0`, `t1`.`Name` AS `Name0` + SELECT `e`.`RootSkipSharedId`, `e`.`ThreeSkipSharedId`, `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Payload`, `s`.`Id` AS `Id0`, `s`.`Name` AS `Name0` FROM `EntityRootEntityThree` AS `e` INNER JOIN `EntityThrees` AS `e0` ON `e`.`ThreeSkipSharedId` = `e0`.`Id` LEFT JOIN ( @@ -946,9 +943,9 @@ LEFT JOIN ( FROM `JoinOneToThreePayloadFullShared` AS `j` INNER JOIN `EntityOnes` AS `e1` ON `j`.`OneId` = `e1`.`Id` WHERE `e1`.`Id` < 10 - ) AS `t1` ON `e0`.`Id` = `t1`.`ThreeId` -) AS `t0` ON `t`.`Id` = `t0`.`RootSkipSharedId` -ORDER BY `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`ThreeSkipSharedId`, `t0`.`Id`, `t0`.`OneId`, `t0`.`ThreeId` + ) AS `s` ON `e0`.`Id` = `s`.`ThreeId` +) AS `s0` ON `u`.`Id` = `s0`.`RootSkipSharedId` +ORDER BY `u`.`Id`, `s0`.`RootSkipSharedId`, `s0`.`ThreeSkipSharedId`, `s0`.`Id`, `s0`.`OneId`, `s0`.`ThreeId` """); } @@ -958,7 +955,7 @@ public override async Task Filtered_then_include_skip_navigation_order_by_skip_t AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`Slumber`, `t`.`IsGreen`, `t`.`IsBrown`, `t`.`Discriminator`, `t1`.`RootSkipSharedId`, `t1`.`CompositeKeySkipSharedKey1`, `t1`.`CompositeKeySkipSharedKey2`, `t1`.`CompositeKeySkipSharedKey3`, `t1`.`Key1`, `t1`.`Key2`, `t1`.`Key3`, `t1`.`Name`, `t1`.`Id`, `t1`.`CompositeId1`, `t1`.`CompositeId2`, `t1`.`CompositeId3`, `t1`.`ThreeId`, `t1`.`Id0`, `t1`.`CollectionInverseId`, `t1`.`Name0`, `t1`.`ReferenceInverseId` +SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`Slumber`, `u`.`IsGreen`, `u`.`IsBrown`, `u`.`Discriminator`, `s1`.`RootSkipSharedId`, `s1`.`CompositeKeySkipSharedKey1`, `s1`.`CompositeKeySkipSharedKey2`, `s1`.`CompositeKeySkipSharedKey3`, `s1`.`Key1`, `s1`.`Key2`, `s1`.`Key3`, `s1`.`Name`, `s1`.`Id`, `s1`.`CompositeId1`, `s1`.`CompositeId2`, `s1`.`CompositeId3`, `s1`.`ThreeId`, `s1`.`Id0`, `s1`.`CollectionInverseId`, `s1`.`Name0`, `s1`.`ReferenceInverseId` FROM ( SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `Slumber`, NULL AS `IsGreen`, NULL AS `IsBrown`, 'EntityRoot' AS `Discriminator` FROM `Roots` AS `r` @@ -971,22 +968,22 @@ UNION ALL UNION ALL SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, `l0`.`Slumber`, NULL AS `IsGreen`, `l0`.`IsBrown`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` LEFT JOIN ( - SELECT `e`.`RootSkipSharedId`, `e`.`CompositeKeySkipSharedKey1`, `e`.`CompositeKeySkipSharedKey2`, `e`.`CompositeKeySkipSharedKey3`, `e0`.`Key1`, `e0`.`Key2`, `e0`.`Key3`, `e0`.`Name`, `t0`.`Id`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`ThreeId`, `t0`.`Id0`, `t0`.`CollectionInverseId`, `t0`.`Name` AS `Name0`, `t0`.`ReferenceInverseId` + SELECT `e`.`RootSkipSharedId`, `e`.`CompositeKeySkipSharedKey1`, `e`.`CompositeKeySkipSharedKey2`, `e`.`CompositeKeySkipSharedKey3`, `e0`.`Key1`, `e0`.`Key2`, `e0`.`Key3`, `e0`.`Name`, `s0`.`Id`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`ThreeId`, `s0`.`Id0`, `s0`.`CollectionInverseId`, `s0`.`Name` AS `Name0`, `s0`.`ReferenceInverseId` FROM `EntityCompositeKeyEntityRoot` AS `e` INNER JOIN `EntityCompositeKeys` AS `e0` ON ((`e`.`CompositeKeySkipSharedKey1` = `e0`.`Key1`) AND (`e`.`CompositeKeySkipSharedKey2` = `e0`.`Key2`)) AND (`e`.`CompositeKeySkipSharedKey3` = `e0`.`Key3`) LEFT JOIN ( - SELECT `t2`.`Id`, `t2`.`CompositeId1`, `t2`.`CompositeId2`, `t2`.`CompositeId3`, `t2`.`ThreeId`, `t2`.`Id0`, `t2`.`CollectionInverseId`, `t2`.`Name`, `t2`.`ReferenceInverseId` + SELECT `s`.`Id`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`ThreeId`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `j`.`Id`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `j`.`ThreeId`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3` ORDER BY `e1`.`Id`) AS `row` FROM `JoinThreeToCompositeKeyFull` AS `j` INNER JOIN `EntityThrees` AS `e1` ON `j`.`ThreeId` = `e1`.`Id` - ) AS `t2` - WHERE (1 < `t2`.`row`) AND (`t2`.`row` <= 3) - ) AS `t0` ON ((`e0`.`Key1` = `t0`.`CompositeId1`) AND (`e0`.`Key2` = `t0`.`CompositeId2`)) AND (`e0`.`Key3` = `t0`.`CompositeId3`) -) AS `t1` ON `t`.`Id` = `t1`.`RootSkipSharedId` -ORDER BY `t`.`Id`, `t1`.`RootSkipSharedId`, `t1`.`CompositeKeySkipSharedKey1`, `t1`.`CompositeKeySkipSharedKey2`, `t1`.`CompositeKeySkipSharedKey3`, `t1`.`Key1`, `t1`.`Key2`, `t1`.`Key3`, `t1`.`CompositeId1`, `t1`.`CompositeId2`, `t1`.`CompositeId3`, `t1`.`Id0` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) + ) AS `s0` ON ((`e0`.`Key1` = `s0`.`CompositeId1`) AND (`e0`.`Key2` = `s0`.`CompositeId2`)) AND (`e0`.`Key3` = `s0`.`CompositeId3`) +) AS `s1` ON `u`.`Id` = `s1`.`RootSkipSharedId` +ORDER BY `u`.`Id`, `s1`.`RootSkipSharedId`, `s1`.`CompositeKeySkipSharedKey1`, `s1`.`CompositeKeySkipSharedKey2`, `s1`.`CompositeKeySkipSharedKey3`, `s1`.`Key1`, `s1`.`Key2`, `s1`.`Key3`, `s1`.`CompositeId1`, `s1`.`CompositeId2`, `s1`.`CompositeId3`, `s1`.`Id0` """); } @@ -996,20 +993,20 @@ public override async Task Filtered_include_skip_navigation_where_then_include_s AssertSql( """ -SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3`, `t0`.`Name`, `t0`.`TwoSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name0`, `t0`.`ReferenceInverseId` +SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Key1`, `s0`.`Key2`, `s0`.`Key3`, `s0`.`Name`, `s0`.`TwoSkipSharedId`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name0`, `s0`.`ReferenceInverseId` FROM `Leaves` AS `l` LEFT JOIN ( - SELECT `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `t`.`TwoSkipSharedId`, `t`.`CompositeKeySkipSharedKey1`, `t`.`CompositeKeySkipSharedKey2`, `t`.`CompositeKeySkipSharedKey3`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name` AS `Name0`, `t`.`ReferenceInverseId` + SELECT `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `s`.`TwoSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name` AS `Name0`, `s`.`ReferenceInverseId` FROM `JoinCompositeKeyToLeaf` AS `j` INNER JOIN `EntityCompositeKeys` AS `e` ON ((`j`.`CompositeId1` = `e`.`Key1`) AND (`j`.`CompositeId2` = `e`.`Key2`)) AND (`j`.`CompositeId3` = `e`.`Key3`) LEFT JOIN ( SELECT `e0`.`TwoSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId` FROM `EntityCompositeKeyEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`TwoSkipSharedId` = `e1`.`Id` - ) AS `t` ON ((`e`.`Key1` = `t`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `t`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `t`.`CompositeKeySkipSharedKey3`) + ) AS `s` ON ((`e`.`Key1` = `s`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `s`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `s`.`CompositeKeySkipSharedKey3`) WHERE `e`.`Key1` < 5 -) AS `t0` ON `l`.`Id` = `t0`.`LeafId` -ORDER BY `l`.`Id`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3`, `t0`.`TwoSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3` +) AS `s0` ON `l`.`Id` = `s0`.`LeafId` +ORDER BY `l`.`Id`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Key1`, `s0`.`Key2`, `s0`.`Key3`, `s0`.`TwoSkipSharedId`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3` """); } @@ -1019,10 +1016,10 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take_t AssertSql( """ -SELECT `e`.`Id`, `e`.`Name`, `t1`.`OneId`, `t1`.`TwoId`, `t1`.`JoinOneToTwoExtraId`, `t1`.`Id`, `t1`.`CollectionInverseId`, `t1`.`ExtraId`, `t1`.`Name`, `t1`.`ReferenceInverseId`, `t1`.`ThreeId`, `t1`.`TwoId0`, `t1`.`Id0`, `t1`.`CollectionInverseId0`, `t1`.`Name0`, `t1`.`ReferenceInverseId0` +SELECT `e`.`Id`, `e`.`Name`, `s1`.`OneId`, `s1`.`TwoId`, `s1`.`JoinOneToTwoExtraId`, `s1`.`Id`, `s1`.`CollectionInverseId`, `s1`.`ExtraId`, `s1`.`Name`, `s1`.`ReferenceInverseId`, `s1`.`ThreeId`, `s1`.`TwoId0`, `s1`.`Id0`, `s1`.`CollectionInverseId0`, `s1`.`Name0`, `s1`.`ReferenceInverseId0` FROM `EntityOnes` AS `e` LEFT JOIN LATERAL ( - SELECT `t`.`OneId`, `t`.`TwoId`, `t`.`JoinOneToTwoExtraId`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t0`.`ThreeId`, `t0`.`TwoId` AS `TwoId0`, `t0`.`Id` AS `Id0`, `t0`.`CollectionInverseId` AS `CollectionInverseId0`, `t0`.`Name` AS `Name0`, `t0`.`ReferenceInverseId` AS `ReferenceInverseId0` + SELECT `s`.`OneId`, `s`.`TwoId`, `s`.`JoinOneToTwoExtraId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s0`.`ThreeId`, `s0`.`TwoId` AS `TwoId0`, `s0`.`Id` AS `Id0`, `s0`.`CollectionInverseId` AS `CollectionInverseId0`, `s0`.`Name` AS `Name0`, `s0`.`ReferenceInverseId` AS `ReferenceInverseId0` FROM ( SELECT `j`.`OneId`, `j`.`TwoId`, `j`.`JoinOneToTwoExtraId`, `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId` FROM `JoinOneToTwo` AS `j` @@ -1030,15 +1027,15 @@ LEFT JOIN LATERAL ( WHERE `e`.`Id` = `j`.`OneId` ORDER BY `e0`.`Id` LIMIT 2 OFFSET 1 - ) AS `t` + ) AS `s` LEFT JOIN ( SELECT `j0`.`ThreeId`, `j0`.`TwoId`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId` FROM `JoinTwoToThree` AS `j0` INNER JOIN `EntityThrees` AS `e1` ON `j0`.`ThreeId` = `e1`.`Id` WHERE `e1`.`Id` < 10 - ) AS `t0` ON `t`.`Id` = `t0`.`TwoId` -) AS `t1` ON TRUE -ORDER BY `e`.`Id`, `t1`.`Id`, `t1`.`OneId`, `t1`.`TwoId`, `t1`.`ThreeId`, `t1`.`TwoId0` + ) AS `s0` ON `s`.`Id` = `s0`.`TwoId` +) AS `s1` ON TRUE +ORDER BY `e`.`Id`, `s1`.`Id`, `s1`.`OneId`, `s1`.`TwoId`, `s1`.`ThreeId`, `s1`.`TwoId0` """); } @@ -1048,24 +1045,24 @@ public override async Task Filtered_include_skip_navigation_where_then_include_s AssertSql( """ -SELECT `e`.`Id`, `e`.`Name`, `t1`.`OneId`, `t1`.`TwoId`, `t1`.`JoinOneToTwoExtraId`, `t1`.`Id`, `t1`.`CollectionInverseId`, `t1`.`ExtraId`, `t1`.`Name`, `t1`.`ReferenceInverseId`, `t1`.`ThreeId`, `t1`.`TwoId0`, `t1`.`Id0`, `t1`.`CollectionInverseId0`, `t1`.`Name0`, `t1`.`ReferenceInverseId0` +SELECT `e`.`Id`, `e`.`Name`, `s1`.`OneId`, `s1`.`TwoId`, `s1`.`JoinOneToTwoExtraId`, `s1`.`Id`, `s1`.`CollectionInverseId`, `s1`.`ExtraId`, `s1`.`Name`, `s1`.`ReferenceInverseId`, `s1`.`ThreeId`, `s1`.`TwoId0`, `s1`.`Id0`, `s1`.`CollectionInverseId0`, `s1`.`Name0`, `s1`.`ReferenceInverseId0` FROM `EntityOnes` AS `e` LEFT JOIN ( - SELECT `j`.`OneId`, `j`.`TwoId`, `j`.`JoinOneToTwoExtraId`, `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `t0`.`ThreeId`, `t0`.`TwoId` AS `TwoId0`, `t0`.`Id` AS `Id0`, `t0`.`CollectionInverseId` AS `CollectionInverseId0`, `t0`.`Name` AS `Name0`, `t0`.`ReferenceInverseId` AS `ReferenceInverseId0` + SELECT `j`.`OneId`, `j`.`TwoId`, `j`.`JoinOneToTwoExtraId`, `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `s0`.`ThreeId`, `s0`.`TwoId` AS `TwoId0`, `s0`.`Id` AS `Id0`, `s0`.`CollectionInverseId` AS `CollectionInverseId0`, `s0`.`Name` AS `Name0`, `s0`.`ReferenceInverseId` AS `ReferenceInverseId0` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` LEFT JOIN ( - SELECT `t`.`ThreeId`, `t`.`TwoId`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId` + SELECT `s`.`ThreeId`, `s`.`TwoId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `j0`.`ThreeId`, `j0`.`TwoId`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `j0`.`TwoId` ORDER BY `e1`.`Id`) AS `row` FROM `JoinTwoToThree` AS `j0` INNER JOIN `EntityThrees` AS `e1` ON `j0`.`ThreeId` = `e1`.`Id` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 3) - ) AS `t0` ON `e0`.`Id` = `t0`.`TwoId` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) + ) AS `s0` ON `e0`.`Id` = `s0`.`TwoId` WHERE `e0`.`Id` < 10 -) AS `t1` ON `e`.`Id` = `t1`.`OneId` -ORDER BY `e`.`Id`, `t1`.`OneId`, `t1`.`TwoId`, `t1`.`Id`, `t1`.`TwoId0`, `t1`.`Id0` +) AS `s1` ON `e`.`Id` = `s1`.`OneId` +ORDER BY `e`.`Id`, `s1`.`OneId`, `s1`.`TwoId`, `s1`.`Id`, `s1`.`TwoId0`, `s1`.`Id0` """); } @@ -1075,7 +1072,7 @@ public override async Task Filter_include_on_skip_navigation_combined(bool async AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t`.`OneId`, `t`.`TwoId`, `t`.`JoinOneToTwoExtraId`, `t`.`Id`, `t`.`Name`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name0`, `t`.`ReferenceInverseId`, `t`.`Id1`, `t`.`CollectionInverseId0`, `t`.`ExtraId0`, `t`.`Name1`, `t`.`ReferenceInverseId0` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s`.`OneId`, `s`.`TwoId`, `s`.`JoinOneToTwoExtraId`, `s`.`Id`, `s`.`Name`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId`, `s`.`Id1`, `s`.`CollectionInverseId0`, `s`.`ExtraId0`, `s`.`Name1`, `s`.`ReferenceInverseId0` FROM `EntityTwos` AS `e` LEFT JOIN ( SELECT `j`.`OneId`, `j`.`TwoId`, `j`.`JoinOneToTwoExtraId`, `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId`, `e2`.`Id` AS `Id1`, `e2`.`CollectionInverseId` AS `CollectionInverseId0`, `e2`.`ExtraId` AS `ExtraId0`, `e2`.`Name` AS `Name1`, `e2`.`ReferenceInverseId` AS `ReferenceInverseId0` @@ -1084,8 +1081,8 @@ LEFT JOIN ( LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` LEFT JOIN `EntityTwos` AS `e2` ON `e0`.`Id` = `e2`.`CollectionInverseId` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`TwoId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id`, `t`.`Id0` +) AS `s` ON `e`.`Id` = `s`.`TwoId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id`, `s`.`Id0` """); } @@ -1095,23 +1092,23 @@ public override async Task Filter_include_on_skip_navigation_combined_with_filte AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t3`.`OneId`, `t3`.`ThreeId`, `t3`.`Payload`, `t3`.`Id`, `t3`.`Name`, `t3`.`OneId0`, `t3`.`TwoId`, `t3`.`JoinOneToTwoExtraId`, `t3`.`Id0`, `t3`.`CollectionInverseId`, `t3`.`ExtraId`, `t3`.`Name0`, `t3`.`ReferenceInverseId`, `t3`.`EntityBranchId`, `t3`.`EntityOneId`, `t3`.`Id1`, `t3`.`Name1`, `t3`.`Number`, `t3`.`IsGreen`, `t3`.`Discriminator` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s2`.`OneId`, `s2`.`ThreeId`, `s2`.`Payload`, `s2`.`Id`, `s2`.`Name`, `s2`.`OneId0`, `s2`.`TwoId`, `s2`.`JoinOneToTwoExtraId`, `s2`.`Id0`, `s2`.`CollectionInverseId`, `s2`.`ExtraId`, `s2`.`Name0`, `s2`.`ReferenceInverseId`, `s2`.`EntityBranchId`, `s2`.`EntityOneId`, `s2`.`Id1`, `s2`.`Name1`, `s2`.`Number`, `s2`.`IsGreen`, `s2`.`Discriminator` FROM `EntityThrees` AS `e` LEFT JOIN ( - SELECT `j`.`OneId`, `j`.`ThreeId`, `j`.`Payload`, `e0`.`Id`, `e0`.`Name`, `t0`.`OneId` AS `OneId0`, `t0`.`TwoId`, `t0`.`JoinOneToTwoExtraId`, `t0`.`Id` AS `Id0`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name` AS `Name0`, `t0`.`ReferenceInverseId`, `t1`.`EntityBranchId`, `t1`.`EntityOneId`, `t1`.`Id` AS `Id1`, `t1`.`Name` AS `Name1`, `t1`.`Number`, `t1`.`IsGreen`, `t1`.`Discriminator` + SELECT `j`.`OneId`, `j`.`ThreeId`, `j`.`Payload`, `e0`.`Id`, `e0`.`Name`, `s0`.`OneId` AS `OneId0`, `s0`.`TwoId`, `s0`.`JoinOneToTwoExtraId`, `s0`.`Id` AS `Id0`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name` AS `Name0`, `s0`.`ReferenceInverseId`, `s1`.`EntityBranchId`, `s1`.`EntityOneId`, `s1`.`Id` AS `Id1`, `s1`.`Name` AS `Name1`, `s1`.`Number`, `s1`.`IsGreen`, `s1`.`Discriminator` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN ( - SELECT `t`.`OneId`, `t`.`TwoId`, `t`.`JoinOneToTwoExtraId`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` + SELECT `s`.`OneId`, `s`.`TwoId`, `s`.`JoinOneToTwoExtraId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `j0`.`OneId`, `j0`.`TwoId`, `j0`.`JoinOneToTwoExtraId`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `j0`.`OneId` ORDER BY `e1`.`Id`) AS `row` FROM `JoinOneToTwo` AS `j0` INNER JOIN `EntityTwos` AS `e1` ON `j0`.`TwoId` = `e1`.`Id` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 3) - ) AS `t0` ON `e0`.`Id` = `t0`.`OneId` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) + ) AS `s0` ON `e0`.`Id` = `s0`.`OneId` LEFT JOIN ( - SELECT `j1`.`EntityBranchId`, `j1`.`EntityOneId`, `t2`.`Id`, `t2`.`Name`, `t2`.`Number`, `t2`.`IsGreen`, `t2`.`Discriminator` + SELECT `j1`.`EntityBranchId`, `j1`.`EntityOneId`, `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `u`.`Discriminator` FROM `JoinOneToBranch` AS `j1` INNER JOIN ( SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, NULL AS `IsGreen`, 'EntityBranch' AS `Discriminator` @@ -1119,12 +1116,12 @@ INNER JOIN ( UNION ALL SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, 'EntityLeaf' AS `Discriminator` FROM `Leaves` AS `l` - ) AS `t2` ON `j1`.`EntityBranchId` = `t2`.`Id` - WHERE `t2`.`Id` < 20 - ) AS `t1` ON `e0`.`Id` = `t1`.`EntityOneId` + ) AS `u` ON `j1`.`EntityBranchId` = `u`.`Id` + WHERE `u`.`Id` < 20 + ) AS `s1` ON `e0`.`Id` = `s1`.`EntityOneId` WHERE `e0`.`Id` < 10 -) AS `t3` ON `e`.`Id` = `t3`.`ThreeId` -ORDER BY `e`.`Id`, `t3`.`OneId`, `t3`.`ThreeId`, `t3`.`Id`, `t3`.`OneId0`, `t3`.`Id0`, `t3`.`TwoId`, `t3`.`EntityBranchId`, `t3`.`EntityOneId` +) AS `s2` ON `e`.`Id` = `s2`.`ThreeId` +ORDER BY `e`.`Id`, `s2`.`OneId`, `s2`.`ThreeId`, `s2`.`Id`, `s2`.`OneId0`, `s2`.`Id0`, `s2`.`TwoId`, `s2`.`EntityBranchId`, `s2`.`EntityOneId` """); } @@ -1134,20 +1131,20 @@ public override async Task Filtered_include_on_skip_navigation_then_filtered_inc AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Payload`, `t0`.`Id`, `t0`.`Name`, `t0`.`Id0`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name0`, `t0`.`ReferenceInverseId` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Payload`, `s`.`Id`, `s`.`Name`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId` FROM `EntityThrees` AS `e` LEFT JOIN ( - SELECT `j`.`OneId`, `j`.`ThreeId`, `j`.`Payload`, `e0`.`Id`, `e0`.`Name`, `t`.`Id` AS `Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name` AS `Name0`, `t`.`ReferenceInverseId` + SELECT `j`.`OneId`, `j`.`ThreeId`, `j`.`Payload`, `e0`.`Id`, `e0`.`Name`, `e2`.`Id` AS `Id0`, `e2`.`CollectionInverseId`, `e2`.`ExtraId`, `e2`.`Name` AS `Name0`, `e2`.`ReferenceInverseId` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId` FROM `EntityTwos` AS `e1` WHERE `e1`.`Id` < 5 - ) AS `t` ON `e0`.`Id` = `t`.`CollectionInverseId` + ) AS `e2` ON `e0`.`Id` = `e2`.`CollectionInverseId` WHERE `e0`.`Id` > 15 -) AS `t0` ON `e`.`Id` = `t0`.`ThreeId` -ORDER BY `e`.`Id`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Id` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` """); } @@ -1157,20 +1154,20 @@ public override async Task Filtered_include_on_navigation_then_filtered_include_ AssertSql( """ -SELECT `e`.`Id`, `e`.`Name`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `t0`.`ThreeId`, `t0`.`TwoId`, `t0`.`Id0`, `t0`.`CollectionInverseId0`, `t0`.`Name0`, `t0`.`ReferenceInverseId0` +SELECT `e`.`Id`, `e`.`Name`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `s0`.`ThreeId`, `s0`.`TwoId`, `s0`.`Id0`, `s0`.`CollectionInverseId0`, `s0`.`Name0`, `s0`.`ReferenceInverseId0` FROM `EntityOnes` AS `e` LEFT JOIN ( - SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `t`.`ThreeId`, `t`.`TwoId`, `t`.`Id` AS `Id0`, `t`.`CollectionInverseId` AS `CollectionInverseId0`, `t`.`Name` AS `Name0`, `t`.`ReferenceInverseId` AS `ReferenceInverseId0` + SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `s`.`ThreeId`, `s`.`TwoId`, `s`.`Id` AS `Id0`, `s`.`CollectionInverseId` AS `CollectionInverseId0`, `s`.`Name` AS `Name0`, `s`.`ReferenceInverseId` AS `ReferenceInverseId0` FROM `EntityTwos` AS `e0` LEFT JOIN ( SELECT `j`.`ThreeId`, `j`.`TwoId`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId` FROM `JoinTwoToThree` AS `j` INNER JOIN `EntityThrees` AS `e1` ON `j`.`ThreeId` = `e1`.`Id` WHERE `e1`.`Id` < 5 - ) AS `t` ON `e0`.`Id` = `t`.`TwoId` + ) AS `s` ON `e0`.`Id` = `s`.`TwoId` WHERE `e0`.`Id` > 15 -) AS `t0` ON `e`.`Id` = `t0`.`CollectionInverseId` -ORDER BY `e`.`Id`, `t0`.`Id`, `t0`.`ThreeId`, `t0`.`TwoId` +) AS `s0` ON `e`.`Id` = `s0`.`CollectionInverseId` +ORDER BY `e`.`Id`, `s0`.`Id`, `s0`.`ThreeId`, `s0`.`TwoId` """); } @@ -1200,10 +1197,10 @@ public override async Task Include_skip_navigation_split(bool async) """, // """ -SELECT `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`Slumber`, `t0`.`IsGreen`, `t0`.`IsBrown`, `t0`.`Discriminator`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3` +SELECT `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3`, `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`Slumber`, `s`.`IsGreen`, `s`.`IsBrown`, `s`.`Discriminator`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3` FROM `EntityCompositeKeys` AS `e` INNER JOIN ( - SELECT `e0`.`RootSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3`, `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`Slumber`, `t`.`IsGreen`, `t`.`IsBrown`, `t`.`Discriminator` + SELECT `e0`.`RootSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3`, `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`Slumber`, `u`.`IsGreen`, `u`.`IsBrown`, `u`.`Discriminator` FROM `EntityCompositeKeyEntityRoot` AS `e0` INNER JOIN ( SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `Slumber`, NULL AS `IsGreen`, NULL AS `IsBrown`, 'EntityRoot' AS `Discriminator` @@ -1217,8 +1214,8 @@ UNION ALL UNION ALL SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, `l0`.`Slumber`, NULL AS `IsGreen`, `l0`.`IsBrown`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` - ) AS `t` ON `e0`.`RootSkipSharedId` = `t`.`Id` -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `t0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `t0`.`CompositeKeySkipSharedKey3`) + ) AS `u` ON `e0`.`RootSkipSharedId` = `u`.`Id` +) AS `s` ON ((`e`.`Key1` = `s`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `s`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `s`.`CompositeKeySkipSharedKey3`) ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3` """); } @@ -1235,14 +1232,14 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`OneId`, `t`.`TwoId`, `t`.`JoinOneToTwoExtraId`, `t`.`Id`, `t`.`Name`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name0`, `t`.`ReferenceInverseId`, `e`.`Id` +SELECT `s`.`OneId`, `s`.`TwoId`, `s`.`JoinOneToTwoExtraId`, `s`.`Id`, `s`.`Name`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId`, `e`.`Id` FROM `EntityTwos` AS `e` INNER JOIN ( SELECT `j`.`OneId`, `j`.`TwoId`, `j`.`JoinOneToTwoExtraId`, `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` -) AS `t` ON `e`.`Id` = `t`.`TwoId` +) AS `s` ON `e`.`Id` = `s`.`TwoId` ORDER BY `e`.`Id` """); } @@ -1259,30 +1256,30 @@ public override async Task Include_skip_navigation_then_include_skip_navigation_ """, // """ -SELECT `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3` +SELECT `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3` FROM `EntityCompositeKeys` AS `e` INNER JOIN ( SELECT `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen` FROM `JoinCompositeKeyToLeaf` AS `j` INNER JOIN `Leaves` AS `l` ON `j`.`LeafId` = `l`.`Id` -) AS `t` ON ((`e`.`Key1` = `t`.`CompositeId1`) AND (`e`.`Key2` = `t`.`CompositeId2`)) AND (`e`.`Key3` = `t`.`CompositeId3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`Id` +) AS `s` ON ((`e`.`Key1` = `s`.`CompositeId1`) AND (`e`.`Key2` = `s`.`CompositeId2`)) AND (`e`.`Key3` = `s`.`CompositeId3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`Id` """, // """ -SELECT `t0`.`EntityBranchId`, `t0`.`EntityOneId`, `t0`.`Id`, `t0`.`Name`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`Id` +SELECT `s0`.`EntityBranchId`, `s0`.`EntityOneId`, `s0`.`Id`, `s0`.`Name`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`Id` FROM `EntityCompositeKeys` AS `e` INNER JOIN ( SELECT `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `l`.`Id` FROM `JoinCompositeKeyToLeaf` AS `j` INNER JOIN `Leaves` AS `l` ON `j`.`LeafId` = `l`.`Id` -) AS `t` ON ((`e`.`Key1` = `t`.`CompositeId1`) AND (`e`.`Key2` = `t`.`CompositeId2`)) AND (`e`.`Key3` = `t`.`CompositeId3`) +) AS `s` ON ((`e`.`Key1` = `s`.`CompositeId1`) AND (`e`.`Key2` = `s`.`CompositeId2`)) AND (`e`.`Key3` = `s`.`CompositeId3`) INNER JOIN ( SELECT `j0`.`EntityBranchId`, `j0`.`EntityOneId`, `e0`.`Id`, `e0`.`Name` FROM `JoinOneToBranch` AS `j0` INNER JOIN `EntityOnes` AS `e0` ON `j0`.`EntityOneId` = `e0`.`Id` -) AS `t0` ON `t`.`Id` = `t0`.`EntityBranchId` -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`Id` +) AS `s0` ON `s`.`Id` = `s0`.`EntityBranchId` +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`Id` """); } @@ -1298,32 +1295,32 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`OneId`, `t`.`ThreeId`, `t`.`Payload`, `t`.`Id`, `t`.`Name`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name0`, `t`.`ReferenceInverseId`, `e`.`Id` +SELECT `s`.`OneId`, `s`.`ThreeId`, `s`.`Payload`, `s`.`Id`, `s`.`Name`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId`, `e`.`Id` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `j`.`OneId`, `j`.`ThreeId`, `j`.`Payload`, `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` -) AS `t` ON `e`.`Id` = `t`.`ThreeId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id`, `t`.`Id0` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id`, `s`.`Id0` """, // """ -SELECT `t0`.`LeftId`, `t0`.`RightId`, `t0`.`Payload`, `t0`.`Id`, `t0`.`Name`, `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id`, `t`.`Id0` +SELECT `s0`.`LeftId`, `s0`.`RightId`, `s0`.`Payload`, `s0`.`Id`, `s0`.`Name`, `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id`, `s`.`Id0` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `j`.`OneId`, `j`.`ThreeId`, `e0`.`Id`, `e1`.`Id` AS `Id0` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` -) AS `t` ON `e`.`Id` = `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` INNER JOIN ( SELECT `j0`.`LeftId`, `j0`.`RightId`, `j0`.`Payload`, `e2`.`Id`, `e2`.`Name` FROM `JoinOneSelfPayload` AS `j0` INNER JOIN `EntityOnes` AS `e2` ON `j0`.`RightId` = `e2`.`Id` -) AS `t0` ON `t`.`Id` = `t0`.`LeftId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id`, `t`.`Id0` +) AS `s0` ON `s`.`Id` = `s0`.`LeftId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id`, `s`.`Id0` """); } @@ -1340,14 +1337,14 @@ public override async Task Include_skip_navigation_and_reference_split(bool asyn """, // """ -SELECT `t`.`OneSkipSharedId`, `t`.`TwoSkipSharedId`, `t`.`Id`, `t`.`Name`, `e`.`Id`, `e0`.`Id` +SELECT `s`.`OneSkipSharedId`, `s`.`TwoSkipSharedId`, `s`.`Id`, `s`.`Name`, `e`.`Id`, `e0`.`Id` FROM `EntityTwos` AS `e` LEFT JOIN `EntityThrees` AS `e0` ON `e`.`Id` = `e0`.`ReferenceInverseId` INNER JOIN ( SELECT `e1`.`OneSkipSharedId`, `e1`.`TwoSkipSharedId`, `e2`.`Id`, `e2`.`Name` FROM `EntityOneEntityTwo` AS `e1` INNER JOIN `EntityOnes` AS `e2` ON `e1`.`OneSkipSharedId` = `e2`.`Id` -) AS `t` ON `e`.`Id` = `t`.`TwoSkipSharedId` +) AS `s` ON `e`.`Id` = `s`.`TwoSkipSharedId` ORDER BY `e`.`Id`, `e0`.`Id` """); } @@ -1364,14 +1361,14 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`OneId`, `t`.`ThreeId`, `t`.`Payload`, `t`.`Id`, `t`.`Name`, `e`.`Id` +SELECT `s`.`OneId`, `s`.`ThreeId`, `s`.`Payload`, `s`.`Id`, `s`.`Name`, `e`.`Id` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `j`.`OneId`, `j`.`ThreeId`, `j`.`Payload`, `e0`.`Id`, `e0`.`Name` FROM `JoinOneToThreePayloadFullShared` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` ORDER BY `e`.`Id` """); } @@ -1388,14 +1385,14 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`ThreeId`, `t`.`TwoId`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `e`.`Id` +SELECT `s`.`ThreeId`, `s`.`TwoId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `e`.`Id` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `j`.`ThreeId`, `j`.`TwoId`, `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId` FROM `JoinTwoToThree` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` -) AS `t` ON `e`.`Id` = `t`.`ThreeId` -ORDER BY `e`.`Id`, `t`.`Id` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`Id` """); } @@ -1411,18 +1408,18 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t0`.`SelfSkipSharedLeftId`, `t0`.`SelfSkipSharedRightId`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Id` +SELECT `s0`.`SelfSkipSharedLeftId`, `s0`.`SelfSkipSharedRightId`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `e`.`Id` FROM `EntityTwos` AS `e` INNER JOIN ( - SELECT `t`.`SelfSkipSharedLeftId`, `t`.`SelfSkipSharedRightId`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` + SELECT `s`.`SelfSkipSharedLeftId`, `s`.`SelfSkipSharedRightId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `e0`.`SelfSkipSharedLeftId`, `e0`.`SelfSkipSharedRightId`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `e0`.`SelfSkipSharedLeftId` ORDER BY `e1`.`Id`) AS `row` FROM `EntityTwoEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`SelfSkipSharedRightId` = `e1`.`Id` - ) AS `t` - WHERE 2 < `t`.`row` -) AS `t0` ON `e`.`Id` = `t0`.`SelfSkipSharedLeftId` -ORDER BY `e`.`Id`, `t0`.`SelfSkipSharedLeftId`, `t0`.`Id` + ) AS `s` + WHERE 2 < `s`.`row` +) AS `s0` ON `e`.`Id` = `s0`.`SelfSkipSharedLeftId` +ORDER BY `e`.`Id`, `s0`.`SelfSkipSharedLeftId`, `s0`.`Id` """); } @@ -1438,18 +1435,18 @@ public override async Task Filtered_include_skip_navigation_order_by_take_split( """, // """ -SELECT `t0`.`TwoSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3` +SELECT `s0`.`TwoSkipSharedId`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3` FROM `EntityCompositeKeys` AS `e` INNER JOIN ( - SELECT `t`.`TwoSkipSharedId`, `t`.`CompositeKeySkipSharedKey1`, `t`.`CompositeKeySkipSharedKey2`, `t`.`CompositeKeySkipSharedKey3`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` + SELECT `s`.`TwoSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `e0`.`TwoSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` ORDER BY `e1`.`Id`) AS `row` FROM `EntityCompositeKeyEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`TwoSkipSharedId` = `e1`.`Id` - ) AS `t` - WHERE `t`.`row` <= 2 -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `t0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `t0`.`CompositeKeySkipSharedKey3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Id` + ) AS `s` + WHERE `s`.`row` <= 2 +) AS `s0` ON ((`e`.`Key1` = `s0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `s0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `s0`.`CompositeKeySkipSharedKey3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3`, `s0`.`Id` """); } @@ -1465,18 +1462,18 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take_s """, // """ -SELECT `t0`.`Id`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`ThreeId`, `t0`.`Id0`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3` +SELECT `s0`.`Id`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`ThreeId`, `s0`.`Id0`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3` FROM `EntityCompositeKeys` AS `e` INNER JOIN ( - SELECT `t`.`Id`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`ThreeId`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId` + SELECT `s`.`Id`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`ThreeId`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `j`.`Id`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `j`.`ThreeId`, `e0`.`Id` AS `Id0`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3` ORDER BY `e0`.`Id`) AS `row` FROM `JoinThreeToCompositeKeyFull` AS `j` INNER JOIN `EntityThrees` AS `e0` ON `j`.`ThreeId` = `e0`.`Id` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 3) -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeId1`) AND (`e`.`Key2` = `t0`.`CompositeId2`)) AND (`e`.`Key3` = `t0`.`CompositeId3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id0` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) +) AS `s0` ON ((`e`.`Key1` = `s0`.`CompositeId1`) AND (`e`.`Key2` = `s0`.`CompositeId2`)) AND (`e`.`Key3` = `s0`.`CompositeId3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id0` """); } @@ -1486,7 +1483,7 @@ public override async Task Filtered_then_include_skip_navigation_where_split(boo AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`Slumber`, `t`.`IsGreen`, `t`.`IsBrown`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`Slumber`, `u`.`IsGreen`, `u`.`IsBrown`, `u`.`Discriminator` FROM ( SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `Slumber`, NULL AS `IsGreen`, NULL AS `IsBrown`, 'EntityRoot' AS `Discriminator` FROM `Roots` AS `r` @@ -1499,12 +1496,12 @@ UNION ALL UNION ALL SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, `l0`.`Slumber`, NULL AS `IsGreen`, `l0`.`IsBrown`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` -) AS `t` -ORDER BY `t`.`Id` +) AS `u` +ORDER BY `u`.`Id` """, // """ -SELECT `t0`.`RootSkipSharedId`, `t0`.`ThreeSkipSharedId`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `t`.`Id` +SELECT `s`.`RootSkipSharedId`, `s`.`ThreeSkipSharedId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `u`.`Id` FROM ( SELECT `r`.`Id` FROM `Roots` AS `r` @@ -1517,17 +1514,17 @@ UNION ALL UNION ALL SELECT `l0`.`Id` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` INNER JOIN ( SELECT `e`.`RootSkipSharedId`, `e`.`ThreeSkipSharedId`, `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`Name`, `e0`.`ReferenceInverseId` FROM `EntityRootEntityThree` AS `e` INNER JOIN `EntityThrees` AS `e0` ON `e`.`ThreeSkipSharedId` = `e0`.`Id` -) AS `t0` ON `t`.`Id` = `t0`.`RootSkipSharedId` -ORDER BY `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`ThreeSkipSharedId`, `t0`.`Id` +) AS `s` ON `u`.`Id` = `s`.`RootSkipSharedId` +ORDER BY `u`.`Id`, `s`.`RootSkipSharedId`, `s`.`ThreeSkipSharedId`, `s`.`Id` """, // """ -SELECT `t1`.`OneId`, `t1`.`ThreeId`, `t1`.`Payload`, `t1`.`Id`, `t1`.`Name`, `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`ThreeSkipSharedId`, `t0`.`Id` +SELECT `s0`.`OneId`, `s0`.`ThreeId`, `s0`.`Payload`, `s0`.`Id`, `s0`.`Name`, `u`.`Id`, `s`.`RootSkipSharedId`, `s`.`ThreeSkipSharedId`, `s`.`Id` FROM ( SELECT `r`.`Id` FROM `Roots` AS `r` @@ -1540,19 +1537,19 @@ UNION ALL UNION ALL SELECT `l0`.`Id` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` INNER JOIN ( SELECT `e`.`RootSkipSharedId`, `e`.`ThreeSkipSharedId`, `e0`.`Id` FROM `EntityRootEntityThree` AS `e` INNER JOIN `EntityThrees` AS `e0` ON `e`.`ThreeSkipSharedId` = `e0`.`Id` -) AS `t0` ON `t`.`Id` = `t0`.`RootSkipSharedId` +) AS `s` ON `u`.`Id` = `s`.`RootSkipSharedId` INNER JOIN ( SELECT `j`.`OneId`, `j`.`ThreeId`, `j`.`Payload`, `e1`.`Id`, `e1`.`Name` FROM `JoinOneToThreePayloadFullShared` AS `j` INNER JOIN `EntityOnes` AS `e1` ON `j`.`OneId` = `e1`.`Id` WHERE `e1`.`Id` < 10 -) AS `t1` ON `t0`.`Id` = `t1`.`ThreeId` -ORDER BY `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`ThreeSkipSharedId`, `t0`.`Id` +) AS `s0` ON `s`.`Id` = `s0`.`ThreeId` +ORDER BY `u`.`Id`, `s`.`RootSkipSharedId`, `s`.`ThreeSkipSharedId`, `s`.`Id` """); } @@ -1562,7 +1559,7 @@ public override async Task Filtered_then_include_skip_navigation_order_by_skip_t AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`Slumber`, `t`.`IsGreen`, `t`.`IsBrown`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`Slumber`, `u`.`IsGreen`, `u`.`IsBrown`, `u`.`Discriminator` FROM ( SELECT `r`.`Id`, `r`.`Name`, NULL AS `Number`, NULL AS `Slumber`, NULL AS `IsGreen`, NULL AS `IsBrown`, 'EntityRoot' AS `Discriminator` FROM `Roots` AS `r` @@ -1575,12 +1572,12 @@ UNION ALL UNION ALL SELECT `l0`.`Id`, `l0`.`Name`, NULL AS `Number`, `l0`.`Slumber`, NULL AS `IsGreen`, `l0`.`IsBrown`, 'EntityLeaf2' AS `Discriminator` FROM `Leaf2s` AS `l0` -) AS `t` -ORDER BY `t`.`Id` +) AS `u` +ORDER BY `u`.`Id` """, // """ -SELECT `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3`, `t0`.`Name`, `t`.`Id` +SELECT `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3`, `s`.`Key1`, `s`.`Key2`, `s`.`Key3`, `s`.`Name`, `u`.`Id` FROM ( SELECT `r`.`Id` FROM `Roots` AS `r` @@ -1593,17 +1590,17 @@ UNION ALL UNION ALL SELECT `l0`.`Id` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` INNER JOIN ( SELECT `e`.`RootSkipSharedId`, `e`.`CompositeKeySkipSharedKey1`, `e`.`CompositeKeySkipSharedKey2`, `e`.`CompositeKeySkipSharedKey3`, `e0`.`Key1`, `e0`.`Key2`, `e0`.`Key3`, `e0`.`Name` FROM `EntityCompositeKeyEntityRoot` AS `e` INNER JOIN `EntityCompositeKeys` AS `e0` ON ((`e`.`CompositeKeySkipSharedKey1` = `e0`.`Key1`) AND (`e`.`CompositeKeySkipSharedKey2` = `e0`.`Key2`)) AND (`e`.`CompositeKeySkipSharedKey3` = `e0`.`Key3`) -) AS `t0` ON `t`.`Id` = `t0`.`RootSkipSharedId` -ORDER BY `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3` +) AS `s` ON `u`.`Id` = `s`.`RootSkipSharedId` +ORDER BY `u`.`Id`, `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3`, `s`.`Key1`, `s`.`Key2`, `s`.`Key3` """, // """ -SELECT `t1`.`Id`, `t1`.`CompositeId1`, `t1`.`CompositeId2`, `t1`.`CompositeId3`, `t1`.`ThreeId`, `t1`.`Id0`, `t1`.`CollectionInverseId`, `t1`.`Name`, `t1`.`ReferenceInverseId`, `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3` +SELECT `s1`.`Id`, `s1`.`CompositeId1`, `s1`.`CompositeId2`, `s1`.`CompositeId3`, `s1`.`ThreeId`, `s1`.`Id0`, `s1`.`CollectionInverseId`, `s1`.`Name`, `s1`.`ReferenceInverseId`, `u`.`Id`, `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3`, `s`.`Key1`, `s`.`Key2`, `s`.`Key3` FROM ( SELECT `r`.`Id` FROM `Roots` AS `r` @@ -1616,22 +1613,22 @@ UNION ALL UNION ALL SELECT `l0`.`Id` FROM `Leaf2s` AS `l0` -) AS `t` +) AS `u` INNER JOIN ( SELECT `e`.`RootSkipSharedId`, `e`.`CompositeKeySkipSharedKey1`, `e`.`CompositeKeySkipSharedKey2`, `e`.`CompositeKeySkipSharedKey3`, `e0`.`Key1`, `e0`.`Key2`, `e0`.`Key3` FROM `EntityCompositeKeyEntityRoot` AS `e` INNER JOIN `EntityCompositeKeys` AS `e0` ON ((`e`.`CompositeKeySkipSharedKey1` = `e0`.`Key1`) AND (`e`.`CompositeKeySkipSharedKey2` = `e0`.`Key2`)) AND (`e`.`CompositeKeySkipSharedKey3` = `e0`.`Key3`) -) AS `t0` ON `t`.`Id` = `t0`.`RootSkipSharedId` +) AS `s` ON `u`.`Id` = `s`.`RootSkipSharedId` INNER JOIN ( - SELECT `t2`.`Id`, `t2`.`CompositeId1`, `t2`.`CompositeId2`, `t2`.`CompositeId3`, `t2`.`ThreeId`, `t2`.`Id0`, `t2`.`CollectionInverseId`, `t2`.`Name`, `t2`.`ReferenceInverseId` + SELECT `s0`.`Id`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`ThreeId`, `s0`.`Id0`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM ( SELECT `j`.`Id`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `j`.`ThreeId`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3` ORDER BY `e1`.`Id`) AS `row` FROM `JoinThreeToCompositeKeyFull` AS `j` INNER JOIN `EntityThrees` AS `e1` ON `j`.`ThreeId` = `e1`.`Id` - ) AS `t2` - WHERE (1 < `t2`.`row`) AND (`t2`.`row` <= 3) -) AS `t1` ON ((`t0`.`Key1` = `t1`.`CompositeId1`) AND (`t0`.`Key2` = `t1`.`CompositeId2`)) AND (`t0`.`Key3` = `t1`.`CompositeId3`) -ORDER BY `t`.`Id`, `t0`.`RootSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3`, `t1`.`CompositeId1`, `t1`.`CompositeId2`, `t1`.`CompositeId3`, `t1`.`Id0` + ) AS `s0` + WHERE (1 < `s0`.`row`) AND (`s0`.`row` <= 3) +) AS `s1` ON ((`s`.`Key1` = `s1`.`CompositeId1`) AND (`s`.`Key2` = `s1`.`CompositeId2`)) AND (`s`.`Key3` = `s1`.`CompositeId3`) +ORDER BY `u`.`Id`, `s`.`RootSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3`, `s`.`Key1`, `s`.`Key2`, `s`.`Key3`, `s1`.`CompositeId1`, `s1`.`CompositeId2`, `s1`.`CompositeId3`, `s1`.`Id0` """); } @@ -1647,32 +1644,32 @@ ORDER BY `l`.`Id` """, // """ -SELECT `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`Key1`, `t`.`Key2`, `t`.`Key3`, `t`.`Name`, `l`.`Id` +SELECT `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`Key1`, `s`.`Key2`, `s`.`Key3`, `s`.`Name`, `l`.`Id` FROM `Leaves` AS `l` INNER JOIN ( SELECT `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name` FROM `JoinCompositeKeyToLeaf` AS `j` INNER JOIN `EntityCompositeKeys` AS `e` ON ((`j`.`CompositeId1` = `e`.`Key1`) AND (`j`.`CompositeId2` = `e`.`Key2`)) AND (`j`.`CompositeId3` = `e`.`Key3`) WHERE `e`.`Key1` < 5 -) AS `t` ON `l`.`Id` = `t`.`LeafId` -ORDER BY `l`.`Id`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`Key1`, `t`.`Key2`, `t`.`Key3` +) AS `s` ON `l`.`Id` = `s`.`LeafId` +ORDER BY `l`.`Id`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`Key1`, `s`.`Key2`, `s`.`Key3` """, // """ -SELECT `t0`.`TwoSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `l`.`Id`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`Key1`, `t`.`Key2`, `t`.`Key3` +SELECT `s0`.`TwoSkipSharedId`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `l`.`Id`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`Key1`, `s`.`Key2`, `s`.`Key3` FROM `Leaves` AS `l` INNER JOIN ( SELECT `j`.`LeafId`, `j`.`CompositeId1`, `j`.`CompositeId2`, `j`.`CompositeId3`, `e`.`Key1`, `e`.`Key2`, `e`.`Key3` FROM `JoinCompositeKeyToLeaf` AS `j` INNER JOIN `EntityCompositeKeys` AS `e` ON ((`j`.`CompositeId1` = `e`.`Key1`) AND (`j`.`CompositeId2` = `e`.`Key2`)) AND (`j`.`CompositeId3` = `e`.`Key3`) WHERE `e`.`Key1` < 5 -) AS `t` ON `l`.`Id` = `t`.`LeafId` +) AS `s` ON `l`.`Id` = `s`.`LeafId` INNER JOIN ( SELECT `e0`.`TwoSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId` FROM `EntityCompositeKeyEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`TwoSkipSharedId` = `e1`.`Id` -) AS `t0` ON ((`t`.`Key1` = `t0`.`CompositeKeySkipSharedKey1`) AND (`t`.`Key2` = `t0`.`CompositeKeySkipSharedKey2`)) AND (`t`.`Key3` = `t0`.`CompositeKeySkipSharedKey3`) -ORDER BY `l`.`Id`, `t`.`LeafId`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`Key1`, `t`.`Key2`, `t`.`Key3` +) AS `s0` ON ((`s`.`Key1` = `s0`.`CompositeKeySkipSharedKey1`) AND (`s`.`Key2` = `s0`.`CompositeKeySkipSharedKey2`)) AND (`s`.`Key3` = `s0`.`CompositeKeySkipSharedKey3`) +ORDER BY `l`.`Id`, `s`.`LeafId`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`Key1`, `s`.`Key2`, `s`.`Key3` """); } @@ -1688,39 +1685,39 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t0`.`OneId`, `t0`.`TwoId`, `t0`.`JoinOneToTwoExtraId`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Id` +SELECT `s0`.`OneId`, `s0`.`TwoId`, `s0`.`JoinOneToTwoExtraId`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId`, `e`.`Id` FROM `EntityOnes` AS `e` INNER JOIN ( - SELECT `t`.`OneId`, `t`.`TwoId`, `t`.`JoinOneToTwoExtraId`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` + SELECT `s`.`OneId`, `s`.`TwoId`, `s`.`JoinOneToTwoExtraId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `j`.`OneId`, `j`.`TwoId`, `j`.`JoinOneToTwoExtraId`, `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `j`.`OneId` ORDER BY `e0`.`Id`) AS `row` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 3) -) AS `t0` ON `e`.`Id` = `t0`.`OneId` -ORDER BY `e`.`Id`, `t0`.`OneId`, `t0`.`Id`, `t0`.`TwoId` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) +) AS `s0` ON `e`.`Id` = `s0`.`OneId` +ORDER BY `e`.`Id`, `s0`.`OneId`, `s0`.`Id`, `s0`.`TwoId` """, // """ -SELECT `t1`.`ThreeId`, `t1`.`TwoId`, `t1`.`Id`, `t1`.`CollectionInverseId`, `t1`.`Name`, `t1`.`ReferenceInverseId`, `e`.`Id`, `t0`.`OneId`, `t0`.`TwoId`, `t0`.`Id` +SELECT `s1`.`ThreeId`, `s1`.`TwoId`, `s1`.`Id`, `s1`.`CollectionInverseId`, `s1`.`Name`, `s1`.`ReferenceInverseId`, `e`.`Id`, `s0`.`OneId`, `s0`.`TwoId`, `s0`.`Id` FROM `EntityOnes` AS `e` INNER JOIN ( - SELECT `t`.`OneId`, `t`.`TwoId`, `t`.`Id` + SELECT `s`.`OneId`, `s`.`TwoId`, `s`.`Id` FROM ( SELECT `j`.`OneId`, `j`.`TwoId`, `e0`.`Id`, ROW_NUMBER() OVER(PARTITION BY `j`.`OneId` ORDER BY `e0`.`Id`) AS `row` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 3) -) AS `t0` ON `e`.`Id` = `t0`.`OneId` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) +) AS `s0` ON `e`.`Id` = `s0`.`OneId` INNER JOIN ( SELECT `j0`.`ThreeId`, `j0`.`TwoId`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId` FROM `JoinTwoToThree` AS `j0` INNER JOIN `EntityThrees` AS `e1` ON `j0`.`ThreeId` = `e1`.`Id` WHERE `e1`.`Id` < 10 -) AS `t1` ON `t0`.`Id` = `t1`.`TwoId` -ORDER BY `e`.`Id`, `t0`.`OneId`, `t0`.`Id`, `t0`.`TwoId` +) AS `s1` ON `s0`.`Id` = `s1`.`TwoId` +ORDER BY `e`.`Id`, `s0`.`OneId`, `s0`.`Id`, `s0`.`TwoId` """); } @@ -1736,36 +1733,36 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`OneId`, `t`.`TwoId`, `t`.`JoinOneToTwoExtraId`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `e`.`Id` +SELECT `s`.`OneId`, `s`.`TwoId`, `s`.`JoinOneToTwoExtraId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `e`.`Id` FROM `EntityOnes` AS `e` INNER JOIN ( SELECT `j`.`OneId`, `j`.`TwoId`, `j`.`JoinOneToTwoExtraId`, `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`OneId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id` +) AS `s` ON `e`.`Id` = `s`.`OneId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id` """, // """ -SELECT `t0`.`ThreeId`, `t0`.`TwoId`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id` +SELECT `s1`.`ThreeId`, `s1`.`TwoId`, `s1`.`Id`, `s1`.`CollectionInverseId`, `s1`.`Name`, `s1`.`ReferenceInverseId`, `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id` FROM `EntityOnes` AS `e` INNER JOIN ( SELECT `j`.`OneId`, `j`.`TwoId`, `e0`.`Id` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`OneId` +) AS `s` ON `e`.`Id` = `s`.`OneId` INNER JOIN ( - SELECT `t1`.`ThreeId`, `t1`.`TwoId`, `t1`.`Id`, `t1`.`CollectionInverseId`, `t1`.`Name`, `t1`.`ReferenceInverseId` + SELECT `s0`.`ThreeId`, `s0`.`TwoId`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM ( SELECT `j0`.`ThreeId`, `j0`.`TwoId`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `j0`.`TwoId` ORDER BY `e1`.`Id`) AS `row` FROM `JoinTwoToThree` AS `j0` INNER JOIN `EntityThrees` AS `e1` ON `j0`.`ThreeId` = `e1`.`Id` - ) AS `t1` - WHERE (1 < `t1`.`row`) AND (`t1`.`row` <= 3) -) AS `t0` ON `t`.`Id` = `t0`.`TwoId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id`, `t0`.`TwoId`, `t0`.`Id` + ) AS `s0` + WHERE (1 < `s0`.`row`) AND (`s0`.`row` <= 3) +) AS `s1` ON `s`.`Id` = `s1`.`TwoId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id`, `s1`.`TwoId`, `s1`.`Id` """); } @@ -1781,7 +1778,7 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`OneId`, `t`.`TwoId`, `t`.`JoinOneToTwoExtraId`, `t`.`Id`, `t`.`Name`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name0`, `t`.`ReferenceInverseId`, `e`.`Id` +SELECT `s`.`OneId`, `s`.`TwoId`, `s`.`JoinOneToTwoExtraId`, `s`.`Id`, `s`.`Name`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId`, `e`.`Id` FROM `EntityTwos` AS `e` INNER JOIN ( SELECT `j`.`OneId`, `j`.`TwoId`, `j`.`JoinOneToTwoExtraId`, `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId` @@ -1789,12 +1786,12 @@ INNER JOIN ( INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`TwoId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id`, `t`.`Id0` +) AS `s` ON `e`.`Id` = `s`.`TwoId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id`, `s`.`Id0` """, // """ -SELECT `e2`.`Id`, `e2`.`CollectionInverseId`, `e2`.`ExtraId`, `e2`.`Name`, `e2`.`ReferenceInverseId`, `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id`, `t`.`Id0` +SELECT `e2`.`Id`, `e2`.`CollectionInverseId`, `e2`.`ExtraId`, `e2`.`Name`, `e2`.`ReferenceInverseId`, `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id`, `s`.`Id0` FROM `EntityTwos` AS `e` INNER JOIN ( SELECT `j`.`OneId`, `j`.`TwoId`, `e0`.`Id`, `e1`.`Id` AS `Id0` @@ -1802,9 +1799,9 @@ INNER JOIN ( INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`TwoId` -INNER JOIN `EntityTwos` AS `e2` ON `t`.`Id` = `e2`.`CollectionInverseId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id`, `t`.`Id0` +) AS `s` ON `e`.`Id` = `s`.`TwoId` +INNER JOIN `EntityTwos` AS `e2` ON `s`.`Id` = `e2`.`CollectionInverseId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id`, `s`.`Id0` """); } @@ -1820,60 +1817,60 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`OneId`, `t`.`ThreeId`, `t`.`Payload`, `t`.`Id`, `t`.`Name`, `e`.`Id` +SELECT `s`.`OneId`, `s`.`ThreeId`, `s`.`Payload`, `s`.`Id`, `s`.`Name`, `e`.`Id` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `j`.`OneId`, `j`.`ThreeId`, `j`.`Payload`, `e0`.`Id`, `e0`.`Name` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` """, // """ -SELECT `t0`.`OneId`, `t0`.`TwoId`, `t0`.`JoinOneToTwoExtraId`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id` +SELECT `s1`.`OneId`, `s1`.`TwoId`, `s1`.`JoinOneToTwoExtraId`, `s1`.`Id`, `s1`.`CollectionInverseId`, `s1`.`ExtraId`, `s1`.`Name`, `s1`.`ReferenceInverseId`, `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `j`.`OneId`, `j`.`ThreeId`, `e0`.`Id` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` INNER JOIN ( - SELECT `t1`.`OneId`, `t1`.`TwoId`, `t1`.`JoinOneToTwoExtraId`, `t1`.`Id`, `t1`.`CollectionInverseId`, `t1`.`ExtraId`, `t1`.`Name`, `t1`.`ReferenceInverseId` + SELECT `s0`.`OneId`, `s0`.`TwoId`, `s0`.`JoinOneToTwoExtraId`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM ( SELECT `j0`.`OneId`, `j0`.`TwoId`, `j0`.`JoinOneToTwoExtraId`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `j0`.`OneId` ORDER BY `e1`.`Id`) AS `row` FROM `JoinOneToTwo` AS `j0` INNER JOIN `EntityTwos` AS `e1` ON `j0`.`TwoId` = `e1`.`Id` - ) AS `t1` - WHERE (1 < `t1`.`row`) AND (`t1`.`row` <= 3) -) AS `t0` ON `t`.`Id` = `t0`.`OneId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id`, `t0`.`OneId`, `t0`.`Id` + ) AS `s0` + WHERE (1 < `s0`.`row`) AND (`s0`.`row` <= 3) +) AS `s1` ON `s`.`Id` = `s1`.`OneId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id`, `s1`.`OneId`, `s1`.`Id` """, // """ -SELECT `t0`.`EntityBranchId`, `t0`.`EntityOneId`, `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`Discriminator`, `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id` +SELECT `s2`.`EntityBranchId`, `s2`.`EntityOneId`, `s2`.`Id`, `s2`.`Name`, `s2`.`Number`, `s2`.`IsGreen`, `s2`.`Discriminator`, `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `j`.`OneId`, `j`.`ThreeId`, `e0`.`Id` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` INNER JOIN ( - SELECT `j0`.`EntityBranchId`, `j0`.`EntityOneId`, `t1`.`Id`, `t1`.`Name`, `t1`.`Number`, `t1`.`IsGreen`, `t1`.`Discriminator` - FROM `JoinOneToBranch` AS `j0` + SELECT `j1`.`EntityBranchId`, `j1`.`EntityOneId`, `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `u`.`Discriminator` + FROM `JoinOneToBranch` AS `j1` INNER JOIN ( SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, NULL AS `IsGreen`, 'EntityBranch' AS `Discriminator` FROM `Branches` AS `b` UNION ALL SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, 'EntityLeaf' AS `Discriminator` FROM `Leaves` AS `l` - ) AS `t1` ON `j0`.`EntityBranchId` = `t1`.`Id` - WHERE `t1`.`Id` < 20 -) AS `t0` ON `t`.`Id` = `t0`.`EntityOneId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id` + ) AS `u` ON `j1`.`EntityBranchId` = `u`.`Id` + WHERE `u`.`Id` < 20 +) AS `s2` ON `s`.`Id` = `s2`.`EntityOneId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` """); } @@ -1889,32 +1886,32 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`OneId`, `t`.`ThreeId`, `t`.`Payload`, `t`.`Id`, `t`.`Name`, `e`.`Id` +SELECT `s`.`OneId`, `s`.`ThreeId`, `s`.`Payload`, `s`.`Id`, `s`.`Name`, `e`.`Id` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `j`.`OneId`, `j`.`ThreeId`, `j`.`Payload`, `e0`.`Id`, `e0`.`Name` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` > 15 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` """, // """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id` +SELECT `e2`.`Id`, `e2`.`CollectionInverseId`, `e2`.`ExtraId`, `e2`.`Name`, `e2`.`ReferenceInverseId`, `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` FROM `EntityThrees` AS `e` INNER JOIN ( SELECT `j`.`OneId`, `j`.`ThreeId`, `e0`.`Id` FROM `JoinOneToThreePayloadFull` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` > 15 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` INNER JOIN ( SELECT `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId` FROM `EntityTwos` AS `e1` WHERE `e1`.`Id` < 5 -) AS `t0` ON `t`.`Id` = `t0`.`CollectionInverseId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Id` +) AS `e2` ON `s`.`Id` = `e2`.`CollectionInverseId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Id` """); } @@ -1930,31 +1927,31 @@ ORDER BY `e`.`Id` """, // """ -SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `e`.`Id` +SELECT `e2`.`Id`, `e2`.`CollectionInverseId`, `e2`.`ExtraId`, `e2`.`Name`, `e2`.`ReferenceInverseId`, `e`.`Id` FROM `EntityOnes` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId` FROM `EntityTwos` AS `e0` WHERE `e0`.`Id` > 15 -) AS `t` ON `e`.`Id` = `t`.`CollectionInverseId` -ORDER BY `e`.`Id`, `t`.`Id` +) AS `e2` ON `e`.`Id` = `e2`.`CollectionInverseId` +ORDER BY `e`.`Id`, `e2`.`Id` """, // """ -SELECT `t0`.`ThreeId`, `t0`.`TwoId`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId`, `e`.`Id`, `t`.`Id` +SELECT `s`.`ThreeId`, `s`.`TwoId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `e`.`Id`, `e2`.`Id` FROM `EntityOnes` AS `e` INNER JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId` FROM `EntityTwos` AS `e0` WHERE `e0`.`Id` > 15 -) AS `t` ON `e`.`Id` = `t`.`CollectionInverseId` +) AS `e2` ON `e`.`Id` = `e2`.`CollectionInverseId` INNER JOIN ( SELECT `j`.`ThreeId`, `j`.`TwoId`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId` FROM `JoinTwoToThree` AS `j` INNER JOIN `EntityThrees` AS `e1` ON `j`.`ThreeId` = `e1`.`Id` WHERE `e1`.`Id` < 5 -) AS `t0` ON `t`.`Id` = `t0`.`TwoId` -ORDER BY `e`.`Id`, `t`.`Id` +) AS `s` ON `e2`.`Id` = `s`.`TwoId` +ORDER BY `e`.`Id`, `e2`.`Id` """); } @@ -1964,19 +1961,19 @@ public override async Task Include_skip_navigation_then_include_inverse_works_fo AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Payload`, `t0`.`Id`, `t0`.`Name`, `t0`.`OneId0`, `t0`.`ThreeId0`, `t0`.`Payload0`, `t0`.`Id0`, `t0`.`CollectionInverseId`, `t0`.`Name0`, `t0`.`ReferenceInverseId` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s0`.`OneId`, `s0`.`ThreeId`, `s0`.`Payload`, `s0`.`Id`, `s0`.`Name`, `s0`.`OneId0`, `s0`.`ThreeId0`, `s0`.`Payload0`, `s0`.`Id0`, `s0`.`CollectionInverseId`, `s0`.`Name0`, `s0`.`ReferenceInverseId` FROM `EntityThrees` AS `e` LEFT JOIN ( - SELECT `j`.`OneId`, `j`.`ThreeId`, `j`.`Payload`, `e0`.`Id`, `e0`.`Name`, `t`.`OneId` AS `OneId0`, `t`.`ThreeId` AS `ThreeId0`, `t`.`Payload` AS `Payload0`, `t`.`Id` AS `Id0`, `t`.`CollectionInverseId`, `t`.`Name` AS `Name0`, `t`.`ReferenceInverseId` + SELECT `j`.`OneId`, `j`.`ThreeId`, `j`.`Payload`, `e0`.`Id`, `e0`.`Name`, `s`.`OneId` AS `OneId0`, `s`.`ThreeId` AS `ThreeId0`, `s`.`Payload` AS `Payload0`, `s`.`Id` AS `Id0`, `s`.`CollectionInverseId`, `s`.`Name` AS `Name0`, `s`.`ReferenceInverseId` FROM `JoinOneToThreePayloadFullShared` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` LEFT JOIN ( SELECT `j0`.`OneId`, `j0`.`ThreeId`, `j0`.`Payload`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId` FROM `JoinOneToThreePayloadFullShared` AS `j0` INNER JOIN `EntityThrees` AS `e1` ON `j0`.`ThreeId` = `e1`.`Id` - ) AS `t` ON `e0`.`Id` = `t`.`OneId` -) AS `t0` ON `e`.`Id` = `t0`.`ThreeId` -ORDER BY `e`.`Id`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Id`, `t0`.`OneId0`, `t0`.`ThreeId0` + ) AS `s` ON `e0`.`Id` = `s`.`OneId` +) AS `s0` ON `e`.`Id` = `s0`.`ThreeId` +ORDER BY `e`.`Id`, `s0`.`OneId`, `s0`.`ThreeId`, `s0`.`Id`, `s0`.`OneId0`, `s0`.`ThreeId0` """); } @@ -2007,13 +2004,13 @@ public override async Task Select_many_over_skip_navigation_where_non_equality(b AssertSql( """ -SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `EntityOnes` AS `e` LEFT JOIN ( SELECT `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId`, `j`.`OneId` FROM `JoinOneToTwo` AS `j` INNER JOIN `EntityTwos` AS `e0` ON `j`.`TwoId` = `e0`.`Id` -) AS `t` ON (`e`.`Id` = `t`.`OneId`) AND (`e`.`Id` <> `t`.`Id`) +) AS `s` ON (`e`.`Id` = `s`.`OneId`) AND (`e`.`Id` <> `s`.`Id`) """); } @@ -2074,14 +2071,14 @@ public override async Task GetType_in_hierarchy_in_querying_base_type(bool async AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator` +SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `u`.`Discriminator` FROM ( SELECT `b`.`Id`, `b`.`Name`, `b`.`Number`, NULL AS `IsGreen`, 'EntityBranch' AS `Discriminator` FROM `Branches` AS `b` UNION ALL SELECT `l`.`Id`, `l`.`Name`, `l`.`Number`, `l`.`IsGreen`, 'EntityLeaf' AS `Discriminator` FROM `Leaves` AS `l` -) AS `t` +) AS `u` WHERE FALSE """); } @@ -2092,18 +2089,18 @@ public override async Task Filtered_include_skip_navigation_order_by_take_EF_Pro AssertSql( """ -SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `t0`.`TwoSkipSharedId`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `e`.`Name`, `s0`.`TwoSkipSharedId`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `EntityCompositeKeys` AS `e` LEFT JOIN ( - SELECT `t`.`TwoSkipSharedId`, `t`.`CompositeKeySkipSharedKey1`, `t`.`CompositeKeySkipSharedKey2`, `t`.`CompositeKeySkipSharedKey3`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` + SELECT `s`.`TwoSkipSharedId`, `s`.`CompositeKeySkipSharedKey1`, `s`.`CompositeKeySkipSharedKey2`, `s`.`CompositeKeySkipSharedKey3`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `e0`.`TwoSkipSharedId`, `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name`, `e1`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `e0`.`CompositeKeySkipSharedKey1`, `e0`.`CompositeKeySkipSharedKey2`, `e0`.`CompositeKeySkipSharedKey3` ORDER BY `e1`.`Id`) AS `row` FROM `EntityCompositeKeyEntityTwo` AS `e0` INNER JOIN `EntityTwos` AS `e1` ON `e0`.`TwoSkipSharedId` = `e1`.`Id` - ) AS `t` - WHERE `t`.`row` <= 2 -) AS `t0` ON ((`e`.`Key1` = `t0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `t0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `t0`.`CompositeKeySkipSharedKey3`) -ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `t0`.`CompositeKeySkipSharedKey1`, `t0`.`CompositeKeySkipSharedKey2`, `t0`.`CompositeKeySkipSharedKey3`, `t0`.`Id` + ) AS `s` + WHERE `s`.`row` <= 2 +) AS `s0` ON ((`e`.`Key1` = `s0`.`CompositeKeySkipSharedKey1`) AND (`e`.`Key2` = `s0`.`CompositeKeySkipSharedKey2`)) AND (`e`.`Key3` = `s0`.`CompositeKeySkipSharedKey3`) +ORDER BY `e`.`Key1`, `e`.`Key2`, `e`.`Key3`, `s0`.`CompositeKeySkipSharedKey1`, `s0`.`CompositeKeySkipSharedKey2`, `s0`.`CompositeKeySkipSharedKey3`, `s0`.`Id` """); } @@ -2114,10 +2111,10 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take_t AssertSql( """ -SELECT `e`.`Id`, `e`.`Name`, `t1`.`OneId`, `t1`.`TwoId`, `t1`.`JoinOneToTwoExtraId`, `t1`.`Id`, `t1`.`CollectionInverseId`, `t1`.`ExtraId`, `t1`.`Name`, `t1`.`ReferenceInverseId`, `t1`.`ThreeId`, `t1`.`TwoId0`, `t1`.`Id0`, `t1`.`CollectionInverseId0`, `t1`.`Name0`, `t1`.`ReferenceInverseId0` +SELECT `e`.`Id`, `e`.`Name`, `s1`.`OneId`, `s1`.`TwoId`, `s1`.`JoinOneToTwoExtraId`, `s1`.`Id`, `s1`.`CollectionInverseId`, `s1`.`ExtraId`, `s1`.`Name`, `s1`.`ReferenceInverseId`, `s1`.`ThreeId`, `s1`.`TwoId0`, `s1`.`Id0`, `s1`.`CollectionInverseId0`, `s1`.`Name0`, `s1`.`ReferenceInverseId0` FROM `EntityOnes` AS `e` LEFT JOIN LATERAL ( - SELECT `t`.`OneId`, `t`.`TwoId`, `t`.`JoinOneToTwoExtraId`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t0`.`ThreeId`, `t0`.`TwoId` AS `TwoId0`, `t0`.`Id` AS `Id0`, `t0`.`CollectionInverseId` AS `CollectionInverseId0`, `t0`.`Name` AS `Name0`, `t0`.`ReferenceInverseId` AS `ReferenceInverseId0` + SELECT `s`.`OneId`, `s`.`TwoId`, `s`.`JoinOneToTwoExtraId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s0`.`ThreeId`, `s0`.`TwoId` AS `TwoId0`, `s0`.`Id` AS `Id0`, `s0`.`CollectionInverseId` AS `CollectionInverseId0`, `s0`.`Name` AS `Name0`, `s0`.`ReferenceInverseId` AS `ReferenceInverseId0` FROM ( SELECT `j`.`OneId`, `j`.`TwoId`, `j`.`JoinOneToTwoExtraId`, `e0`.`Id`, `e0`.`CollectionInverseId`, `e0`.`ExtraId`, `e0`.`Name`, `e0`.`ReferenceInverseId` FROM `JoinOneToTwo` AS `j` @@ -2125,15 +2122,15 @@ LEFT JOIN LATERAL ( WHERE `e`.`Id` = `j`.`OneId` ORDER BY `e0`.`Id` LIMIT 2 OFFSET 1 - ) AS `t` + ) AS `s` LEFT JOIN ( SELECT `j0`.`ThreeId`, `j0`.`TwoId`, `e1`.`Id`, `e1`.`CollectionInverseId`, `e1`.`Name`, `e1`.`ReferenceInverseId` FROM `JoinTwoToThree` AS `j0` INNER JOIN `EntityThrees` AS `e1` ON `j0`.`ThreeId` = `e1`.`Id` WHERE `e1`.`Id` < 10 - ) AS `t0` ON `t`.`Id` = `t0`.`TwoId` -) AS `t1` ON TRUE -ORDER BY `e`.`Id`, `t1`.`Id`, `t1`.`OneId`, `t1`.`TwoId`, `t1`.`ThreeId`, `t1`.`TwoId0` + ) AS `s0` ON `s`.`Id` = `s0`.`TwoId` +) AS `s1` ON TRUE +ORDER BY `e`.`Id`, `s1`.`Id`, `s1`.`OneId`, `s1`.`TwoId`, `s1`.`ThreeId`, `s1`.`TwoId0` """); } @@ -2214,13 +2211,13 @@ ORDER BY ( SELECT COUNT(*) FROM `UnidirectionalJoinOneToBranch` AS `u0` INNER JOIN ( - SELECT `u1`.`Id`, `u1`.`Name`, `u1`.`Number`, NULL AS `IsGreen`, 'UnidirectionalEntityBranch' AS `Discriminator` + SELECT `u1`.`Id`, `u1`.`Name` FROM `UnidirectionalBranches` AS `u1` UNION ALL - SELECT `u2`.`Id`, `u2`.`Name`, `u2`.`Number`, `u2`.`IsGreen`, 'UnidirectionalEntityLeaf' AS `Discriminator` + SELECT `u2`.`Id`, `u2`.`Name` FROM `UnidirectionalLeaves` AS `u2` - ) AS `t` ON `u0`.`UnidirectionalEntityBranchId` = `t`.`Id` - WHERE (`u`.`Id` = `u0`.`UnidirectionalEntityOneId`) AND (`t`.`Name` LIKE 'L%')), `u`.`Id` + ) AS `u3` ON `u0`.`UnidirectionalEntityBranchId` = `u3`.`Id` + WHERE (`u`.`Id` = `u0`.`UnidirectionalEntityOneId`) AND (`u3`.`Name` LIKE 'L%')), `u`.`Id` """); } @@ -2245,17 +2242,17 @@ public override async Task Skip_navigation_order_by_reverse_first_or_default_uni AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `UnidirectionalEntityThrees` AS `u` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`ThreeId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`ThreeId` FROM ( SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`ThreeId`, ROW_NUMBER() OVER(PARTITION BY `u0`.`ThreeId` ORDER BY `u1`.`Id` DESC) AS `row` FROM `UnidirectionalJoinTwoToThree` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoId` = `u1`.`Id` - ) AS `t` - WHERE `t`.`row` <= 1 -) AS `t0` ON `u`.`Id` = `t0`.`ThreeId` + ) AS `s` + WHERE `s`.`row` <= 1 +) AS `s0` ON `u`.`Id` = `s0`.`ThreeId` """); } @@ -2264,11 +2261,11 @@ public override async Task Skip_navigation_of_type_unidirectional(bool async) await base.Skip_navigation_of_type_unidirectional(async); AssertSql( -$""" -SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`Discriminator`, `t0`.`RootSkipSharedId`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3` +""" +SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `s`.`Discriminator`, `s`.`RootSkipSharedId`, `s`.`UnidirectionalEntityCompositeKeyKey1`, `s`.`UnidirectionalEntityCompositeKeyKey2`, `s`.`UnidirectionalEntityCompositeKeyKey3` FROM `UnidirectionalEntityCompositeKeys` AS `u` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator`, `u0`.`RootSkipSharedId`, `u0`.`UnidirectionalEntityCompositeKeyKey1`, `u0`.`UnidirectionalEntityCompositeKeyKey2`, `u0`.`UnidirectionalEntityCompositeKeyKey3` + SELECT `u4`.`Id`, `u4`.`Name`, `u4`.`Number`, `u4`.`IsGreen`, `u4`.`Discriminator`, `u0`.`RootSkipSharedId`, `u0`.`UnidirectionalEntityCompositeKeyKey1`, `u0`.`UnidirectionalEntityCompositeKeyKey2`, `u0`.`UnidirectionalEntityCompositeKeyKey3` FROM `UnidirectionalEntityCompositeKeyUnidirectionalEntityRoot` AS `u0` INNER JOIN ( SELECT `u1`.`Id`, `u1`.`Name`, NULL AS `Number`, NULL AS `IsGreen`, 'UnidirectionalEntityRoot' AS `Discriminator` @@ -2277,12 +2274,12 @@ UNION ALL SELECT `u2`.`Id`, `u2`.`Name`, `u2`.`Number`, NULL AS `IsGreen`, 'UnidirectionalEntityBranch' AS `Discriminator` FROM `UnidirectionalBranches` AS `u2` UNION ALL - SELECT `u3`.`Id`, `u3`.`Name`, `u3`.`Number`, `u3`.`IsGreen`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'UnidirectionalEntityLeaf'")} AS `Discriminator` + SELECT `u3`.`Id`, `u3`.`Name`, `u3`.`Number`, `u3`.`IsGreen`, 'UnidirectionalEntityLeaf' AS `Discriminator` FROM `UnidirectionalLeaves` AS `u3` - ) AS `t` ON `u0`.`RootSkipSharedId` = `t`.`Id` - WHERE `t`.`Discriminator` = 'UnidirectionalEntityLeaf' -) AS `t0` ON ((`u`.`Key1` = `t0`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u`.`Key2` = `t0`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u`.`Key3` = `t0`.`UnidirectionalEntityCompositeKeyKey3`) -ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `t0`.`RootSkipSharedId`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3` + ) AS `u4` ON `u0`.`RootSkipSharedId` = `u4`.`Id` + WHERE `u4`.`Discriminator` = 'UnidirectionalEntityLeaf' +) AS `s` ON ((`u`.`Key1` = `s`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u`.`Key2` = `s`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u`.`Key3` = `s`.`UnidirectionalEntityCompositeKeyKey3`) +ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `s`.`RootSkipSharedId`, `s`.`UnidirectionalEntityCompositeKeyKey1`, `s`.`UnidirectionalEntityCompositeKeyKey2`, `s`.`UnidirectionalEntityCompositeKeyKey3` """); } @@ -2337,22 +2334,22 @@ public override async Task Select_many_over_skip_navigation_unidirectional(bool AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( - SELECT `u1`.`Id` - FROM `UnidirectionalRoots` AS `u1` + SELECT `u`.`Id` + FROM `UnidirectionalRoots` AS `u` UNION ALL - SELECT `u2`.`Id` - FROM `UnidirectionalBranches` AS `u2` + SELECT `u0`.`Id` + FROM `UnidirectionalBranches` AS `u0` UNION ALL - SELECT `u3`.`Id` - FROM `UnidirectionalLeaves` AS `u3` -) AS `t` + SELECT `u1`.`Id` + FROM `UnidirectionalLeaves` AS `u1` +) AS `u2` INNER JOIN ( - SELECT `u0`.`Id`, `u0`.`CollectionInverseId`, `u0`.`Name`, `u0`.`ReferenceInverseId`, `u`.`UnidirectionalEntityRootId` - FROM `UnidirectionalEntityRootUnidirectionalEntityThree` AS `u` - INNER JOIN `UnidirectionalEntityThrees` AS `u0` ON `u`.`ThreeSkipSharedId` = `u0`.`Id` -) AS `t0` ON `t`.`Id` = `t0`.`UnidirectionalEntityRootId` + SELECT `u4`.`Id`, `u4`.`CollectionInverseId`, `u4`.`Name`, `u4`.`ReferenceInverseId`, `u3`.`UnidirectionalEntityRootId` + FROM `UnidirectionalEntityRootUnidirectionalEntityThree` AS `u3` + INNER JOIN `UnidirectionalEntityThrees` AS `u4` ON `u3`.`ThreeSkipSharedId` = `u4`.`Id` +) AS `s` ON `u2`.`Id` = `s`.`UnidirectionalEntityRootId` """); } @@ -2362,13 +2359,13 @@ public override async Task Select_many_over_skip_navigation_where_unidirectional AssertSql( """ -SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `UnidirectionalEntityOnes` AS `u` LEFT JOIN ( SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`OneId` FROM `UnidirectionalJoinOneToTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoId` = `u1`.`Id` -) AS `t` ON `u`.`Id` = `t`.`OneId` +) AS `s` ON `u`.`Id` = `s`.`OneId` """); } @@ -2378,17 +2375,17 @@ public override async Task Select_many_over_skip_navigation_order_by_take_unidir AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `UnidirectionalEntityOnes` AS `u` INNER JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`UnidirectionalEntityOneId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`UnidirectionalEntityOneId` FROM ( SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`UnidirectionalEntityOneId`, ROW_NUMBER() OVER(PARTITION BY `u0`.`UnidirectionalEntityOneId` ORDER BY `u1`.`Id`) AS `row` FROM `UnidirectionalEntityOneUnidirectionalEntityTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoSkipSharedId` = `u1`.`Id` - ) AS `t` - WHERE `t`.`row` <= 2 -) AS `t0` ON `u`.`Id` = `t0`.`UnidirectionalEntityOneId` + ) AS `s` + WHERE `s`.`row` <= 2 +) AS `s0` ON `u`.`Id` = `s0`.`UnidirectionalEntityOneId` """); } @@ -2398,17 +2395,17 @@ public override async Task Select_many_over_skip_navigation_order_by_skip_take_u AssertSql( """ -SELECT `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `UnidirectionalEntityOnes` AS `u` INNER JOIN ( - SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId`, `t`.`OneId` + SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId`, `s`.`OneId` FROM ( SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`OneId`, ROW_NUMBER() OVER(PARTITION BY `u0`.`OneId` ORDER BY `u1`.`Id`) AS `row` FROM `UnidirectionalJoinOneToThreePayloadFullShared` AS `u0` INNER JOIN `UnidirectionalEntityThrees` AS `u1` ON `u0`.`ThreeId` = `u1`.`Id` - ) AS `t` - WHERE (2 < `t`.`row`) AND (`t`.`row` <= 5) -) AS `t0` ON `u`.`Id` = `t0`.`OneId` + ) AS `s` + WHERE (2 < `s`.`row`) AND (`s`.`row` <= 5) +) AS `s0` ON `u`.`Id` = `s0`.`OneId` """); } @@ -2418,10 +2415,10 @@ public override async Task Select_many_over_skip_navigation_cast_unidirectional( AssertSql( """ -SELECT `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`Discriminator` +SELECT `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `s`.`Discriminator` FROM `UnidirectionalEntityOnes` AS `u` INNER JOIN ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator`, `u0`.`UnidirectionalEntityOneId` + SELECT `u3`.`Id`, `u3`.`Name`, `u3`.`Number`, `u3`.`IsGreen`, `u3`.`Discriminator`, `u0`.`UnidirectionalEntityOneId` FROM `UnidirectionalJoinOneToBranch` AS `u0` INNER JOIN ( SELECT `u1`.`Id`, `u1`.`Name`, `u1`.`Number`, NULL AS `IsGreen`, 'UnidirectionalEntityBranch' AS `Discriminator` @@ -2429,8 +2426,8 @@ INNER JOIN ( UNION ALL SELECT `u2`.`Id`, `u2`.`Name`, `u2`.`Number`, `u2`.`IsGreen`, 'UnidirectionalEntityLeaf' AS `Discriminator` FROM `UnidirectionalLeaves` AS `u2` - ) AS `t` ON `u0`.`UnidirectionalEntityBranchId` = `t`.`Id` -) AS `t0` ON `u`.`Id` = `t0`.`UnidirectionalEntityOneId` + ) AS `u3` ON `u0`.`UnidirectionalEntityBranchId` = `u3`.`Id` +) AS `s` ON `u`.`Id` = `s`.`UnidirectionalEntityOneId` """); } @@ -2439,14 +2436,14 @@ public override async Task Select_skip_navigation_unidirectional(bool async) await base.Select_skip_navigation_unidirectional(async); AssertSql( """ -SELECT `u`.`Id`, `t`.`Id`, `t`.`Name`, `t`.`LeftId`, `t`.`RightId` +SELECT `u`.`Id`, `s`.`Id`, `s`.`Name`, `s`.`LeftId`, `s`.`RightId` FROM `UnidirectionalEntityOnes` AS `u` LEFT JOIN ( SELECT `u1`.`Id`, `u1`.`Name`, `u0`.`LeftId`, `u0`.`RightId` FROM `UnidirectionalJoinOneSelfPayload` AS `u0` INNER JOIN `UnidirectionalEntityOnes` AS `u1` ON `u0`.`LeftId` = `u1`.`Id` -) AS `t` ON `u`.`Id` = `t`.`RightId` -ORDER BY `u`.`Id`, `t`.`LeftId`, `t`.`RightId` +) AS `s` ON `u`.`Id` = `s`.`RightId` +ORDER BY `u`.`Id`, `s`.`LeftId`, `s`.`RightId` """); } @@ -2455,11 +2452,11 @@ public override async Task Include_skip_navigation_unidirectional(bool async) await base.Include_skip_navigation_unidirectional(async); AssertSql( -$""" -SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `t0`.`RootSkipSharedId`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3`, `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`Discriminator` +""" +SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `s`.`RootSkipSharedId`, `s`.`UnidirectionalEntityCompositeKeyKey1`, `s`.`UnidirectionalEntityCompositeKeyKey2`, `s`.`UnidirectionalEntityCompositeKeyKey3`, `s`.`Id`, `s`.`Name`, `s`.`Number`, `s`.`IsGreen`, `s`.`Discriminator` FROM `UnidirectionalEntityCompositeKeys` AS `u` LEFT JOIN ( - SELECT `u0`.`RootSkipSharedId`, `u0`.`UnidirectionalEntityCompositeKeyKey1`, `u0`.`UnidirectionalEntityCompositeKeyKey2`, `u0`.`UnidirectionalEntityCompositeKeyKey3`, `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator` + SELECT `u0`.`RootSkipSharedId`, `u0`.`UnidirectionalEntityCompositeKeyKey1`, `u0`.`UnidirectionalEntityCompositeKeyKey2`, `u0`.`UnidirectionalEntityCompositeKeyKey3`, `u4`.`Id`, `u4`.`Name`, `u4`.`Number`, `u4`.`IsGreen`, `u4`.`Discriminator` FROM `UnidirectionalEntityCompositeKeyUnidirectionalEntityRoot` AS `u0` INNER JOIN ( SELECT `u1`.`Id`, `u1`.`Name`, NULL AS `Number`, NULL AS `IsGreen`, 'UnidirectionalEntityRoot' AS `Discriminator` @@ -2468,11 +2465,11 @@ UNION ALL SELECT `u2`.`Id`, `u2`.`Name`, `u2`.`Number`, NULL AS `IsGreen`, 'UnidirectionalEntityBranch' AS `Discriminator` FROM `UnidirectionalBranches` AS `u2` UNION ALL - SELECT `u3`.`Id`, `u3`.`Name`, `u3`.`Number`, `u3`.`IsGreen`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'UnidirectionalEntityLeaf'")} AS `Discriminator` + SELECT `u3`.`Id`, `u3`.`Name`, `u3`.`Number`, `u3`.`IsGreen`, 'UnidirectionalEntityLeaf' AS `Discriminator` FROM `UnidirectionalLeaves` AS `u3` - ) AS `t` ON `u0`.`RootSkipSharedId` = `t`.`Id` -) AS `t0` ON ((`u`.`Key1` = `t0`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u`.`Key2` = `t0`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u`.`Key3` = `t0`.`UnidirectionalEntityCompositeKeyKey3`) -ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `t0`.`RootSkipSharedId`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3` + ) AS `u4` ON `u0`.`RootSkipSharedId` = `u4`.`Id` +) AS `s` ON ((`u`.`Key1` = `s`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u`.`Key2` = `s`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u`.`Key3` = `s`.`UnidirectionalEntityCompositeKeyKey3`) +ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `s`.`RootSkipSharedId`, `s`.`UnidirectionalEntityCompositeKeyKey1`, `s`.`UnidirectionalEntityCompositeKeyKey2`, `s`.`UnidirectionalEntityCompositeKeyKey3` """); } @@ -2482,15 +2479,15 @@ public override async Task Include_skip_navigation_then_reference_unidirectional AssertSql( """ -SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`ExtraId`, `u`.`Name`, `u`.`ReferenceInverseId`, `t`.`OneId`, `t`.`TwoId`, `t`.`UnidirectionalJoinOneToTwoExtraId`, `t`.`Id`, `t`.`Name`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name0`, `t`.`ReferenceInverseId` +SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`ExtraId`, `u`.`Name`, `u`.`ReferenceInverseId`, `s`.`OneId`, `s`.`TwoId`, `s`.`UnidirectionalJoinOneToTwoExtraId`, `s`.`Id`, `s`.`Name`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId` FROM `UnidirectionalEntityTwos` AS `u` LEFT JOIN ( SELECT `u0`.`OneId`, `u0`.`TwoId`, `u0`.`UnidirectionalJoinOneToTwoExtraId`, `u1`.`Id`, `u1`.`Name`, `u2`.`Id` AS `Id0`, `u2`.`CollectionInverseId`, `u2`.`ExtraId`, `u2`.`Name` AS `Name0`, `u2`.`ReferenceInverseId` FROM `UnidirectionalJoinOneToTwo` AS `u0` INNER JOIN `UnidirectionalEntityOnes` AS `u1` ON `u0`.`OneId` = `u1`.`Id` LEFT JOIN `UnidirectionalEntityTwos` AS `u2` ON `u1`.`Id` = `u2`.`ReferenceInverseId` -) AS `t` ON `u`.`Id` = `t`.`TwoId` -ORDER BY `u`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id` +) AS `s` ON `u`.`Id` = `s`.`TwoId` +ORDER BY `u`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id` """); } @@ -2500,19 +2497,19 @@ public override async Task Include_skip_navigation_then_include_skip_navigation_ AssertSql( """ -SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id`, `t0`.`Name`, `t0`.`Number`, `t0`.`IsGreen`, `t0`.`UnidirectionalEntityBranchId`, `t0`.`UnidirectionalEntityOneId`, `t0`.`Id0`, `t0`.`Name0` +SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id`, `s0`.`Name`, `s0`.`Number`, `s0`.`IsGreen`, `s0`.`UnidirectionalEntityBranchId`, `s0`.`UnidirectionalEntityOneId`, `s0`.`Id0`, `s0`.`Name0` FROM `UnidirectionalEntityCompositeKeys` AS `u` LEFT JOIN ( - SELECT `u0`.`LeafId`, `u0`.`CompositeId1`, `u0`.`CompositeId2`, `u0`.`CompositeId3`, `u1`.`Id`, `u1`.`Name`, `u1`.`Number`, `u1`.`IsGreen`, `t`.`UnidirectionalEntityBranchId`, `t`.`UnidirectionalEntityOneId`, `t`.`Id` AS `Id0`, `t`.`Name` AS `Name0` + SELECT `u0`.`LeafId`, `u0`.`CompositeId1`, `u0`.`CompositeId2`, `u0`.`CompositeId3`, `u1`.`Id`, `u1`.`Name`, `u1`.`Number`, `u1`.`IsGreen`, `s`.`UnidirectionalEntityBranchId`, `s`.`UnidirectionalEntityOneId`, `s`.`Id` AS `Id0`, `s`.`Name` AS `Name0` FROM `UnidirectionalJoinCompositeKeyToLeaf` AS `u0` INNER JOIN `UnidirectionalLeaves` AS `u1` ON `u0`.`LeafId` = `u1`.`Id` LEFT JOIN ( SELECT `u2`.`UnidirectionalEntityBranchId`, `u2`.`UnidirectionalEntityOneId`, `u3`.`Id`, `u3`.`Name` FROM `UnidirectionalJoinOneToBranch` AS `u2` INNER JOIN `UnidirectionalEntityOnes` AS `u3` ON `u2`.`UnidirectionalEntityOneId` = `u3`.`Id` - ) AS `t` ON `u1`.`Id` = `t`.`UnidirectionalEntityBranchId` -) AS `t0` ON ((`u`.`Key1` = `t0`.`CompositeId1`) AND (`u`.`Key2` = `t0`.`CompositeId2`)) AND (`u`.`Key3` = `t0`.`CompositeId3`) -ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id`, `t0`.`UnidirectionalEntityBranchId`, `t0`.`UnidirectionalEntityOneId` + ) AS `s` ON `u1`.`Id` = `s`.`UnidirectionalEntityBranchId` +) AS `s0` ON ((`u`.`Key1` = `s0`.`CompositeId1`) AND (`u`.`Key2` = `s0`.`CompositeId2`)) AND (`u`.`Key3` = `s0`.`CompositeId3`) +ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id`, `s0`.`UnidirectionalEntityBranchId`, `s0`.`UnidirectionalEntityOneId` """); } @@ -2522,10 +2519,10 @@ public override async Task Include_skip_navigation_then_include_reference_and_sk AssertSql( """ -SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`Name`, `u`.`ReferenceInverseId`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Payload`, `t0`.`Id`, `t0`.`Name`, `t0`.`Id0`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name0`, `t0`.`ReferenceInverseId`, `t0`.`LeftId`, `t0`.`RightId`, `t0`.`Payload0`, `t0`.`Id1`, `t0`.`Name1` +SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`Name`, `u`.`ReferenceInverseId`, `s0`.`OneId`, `s0`.`ThreeId`, `s0`.`Payload`, `s0`.`Id`, `s0`.`Name`, `s0`.`Id0`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name0`, `s0`.`ReferenceInverseId`, `s0`.`LeftId`, `s0`.`RightId`, `s0`.`Payload0`, `s0`.`Id1`, `s0`.`Name1` FROM `UnidirectionalEntityThrees` AS `u` LEFT JOIN ( - SELECT `u0`.`OneId`, `u0`.`ThreeId`, `u0`.`Payload`, `u1`.`Id`, `u1`.`Name`, `u2`.`Id` AS `Id0`, `u2`.`CollectionInverseId`, `u2`.`ExtraId`, `u2`.`Name` AS `Name0`, `u2`.`ReferenceInverseId`, `t`.`LeftId`, `t`.`RightId`, `t`.`Payload` AS `Payload0`, `t`.`Id` AS `Id1`, `t`.`Name` AS `Name1` + SELECT `u0`.`OneId`, `u0`.`ThreeId`, `u0`.`Payload`, `u1`.`Id`, `u1`.`Name`, `u2`.`Id` AS `Id0`, `u2`.`CollectionInverseId`, `u2`.`ExtraId`, `u2`.`Name` AS `Name0`, `u2`.`ReferenceInverseId`, `s`.`LeftId`, `s`.`RightId`, `s`.`Payload` AS `Payload0`, `s`.`Id` AS `Id1`, `s`.`Name` AS `Name1` FROM `UnidirectionalJoinOneToThreePayloadFull` AS `u0` INNER JOIN `UnidirectionalEntityOnes` AS `u1` ON `u0`.`OneId` = `u1`.`Id` LEFT JOIN `UnidirectionalEntityTwos` AS `u2` ON `u1`.`Id` = `u2`.`ReferenceInverseId` @@ -2533,9 +2530,9 @@ LEFT JOIN ( SELECT `u3`.`LeftId`, `u3`.`RightId`, `u3`.`Payload`, `u4`.`Id`, `u4`.`Name` FROM `UnidirectionalJoinOneSelfPayload` AS `u3` INNER JOIN `UnidirectionalEntityOnes` AS `u4` ON `u3`.`RightId` = `u4`.`Id` - ) AS `t` ON `u1`.`Id` = `t`.`LeftId` -) AS `t0` ON `u`.`Id` = `t0`.`ThreeId` -ORDER BY `u`.`Id`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Id`, `t0`.`Id0`, `t0`.`LeftId`, `t0`.`RightId` + ) AS `s` ON `u1`.`Id` = `s`.`LeftId` +) AS `s0` ON `u`.`Id` = `s0`.`ThreeId` +ORDER BY `u`.`Id`, `s0`.`OneId`, `s0`.`ThreeId`, `s0`.`Id`, `s0`.`Id0`, `s0`.`LeftId`, `s0`.`RightId` """); } @@ -2545,15 +2542,15 @@ public override async Task Include_skip_navigation_and_reference_unidirectional( AssertSql( """ -SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`ExtraId`, `u`.`Name`, `u`.`ReferenceInverseId`, `u0`.`Id`, `t`.`TwoSkipSharedId`, `t`.`UnidirectionalEntityOneId`, `t`.`Id`, `t`.`Name`, `u0`.`CollectionInverseId`, `u0`.`Name`, `u0`.`ReferenceInverseId` +SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`ExtraId`, `u`.`Name`, `u`.`ReferenceInverseId`, `u0`.`Id`, `s`.`TwoSkipSharedId`, `s`.`UnidirectionalEntityOneId`, `s`.`Id`, `s`.`Name`, `u0`.`CollectionInverseId`, `u0`.`Name`, `u0`.`ReferenceInverseId` FROM `UnidirectionalEntityTwos` AS `u` LEFT JOIN `UnidirectionalEntityThrees` AS `u0` ON `u`.`Id` = `u0`.`ReferenceInverseId` LEFT JOIN ( SELECT `u1`.`TwoSkipSharedId`, `u1`.`UnidirectionalEntityOneId`, `u2`.`Id`, `u2`.`Name` FROM `UnidirectionalEntityOneUnidirectionalEntityTwo` AS `u1` INNER JOIN `UnidirectionalEntityOnes` AS `u2` ON `u1`.`UnidirectionalEntityOneId` = `u2`.`Id` -) AS `t` ON `u`.`Id` = `t`.`TwoSkipSharedId` -ORDER BY `u`.`Id`, `u0`.`Id`, `t`.`TwoSkipSharedId`, `t`.`UnidirectionalEntityOneId` +) AS `s` ON `u`.`Id` = `s`.`TwoSkipSharedId` +ORDER BY `u`.`Id`, `u0`.`Id`, `s`.`TwoSkipSharedId`, `s`.`UnidirectionalEntityOneId` """); } @@ -2563,19 +2560,19 @@ public override async Task Include_skip_navigation_then_include_inverse_works_fo AssertSql( """ -SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`Name`, `u`.`ReferenceInverseId`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Payload`, `t0`.`Id`, `t0`.`Name`, `t0`.`OneId0`, `t0`.`ThreeId0`, `t0`.`Payload0`, `t0`.`Id0`, `t0`.`CollectionInverseId`, `t0`.`Name0`, `t0`.`ReferenceInverseId` +SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`Name`, `u`.`ReferenceInverseId`, `s0`.`OneId`, `s0`.`ThreeId`, `s0`.`Payload`, `s0`.`Id`, `s0`.`Name`, `s0`.`OneId0`, `s0`.`ThreeId0`, `s0`.`Payload0`, `s0`.`Id0`, `s0`.`CollectionInverseId`, `s0`.`Name0`, `s0`.`ReferenceInverseId` FROM `UnidirectionalEntityThrees` AS `u` LEFT JOIN ( - SELECT `u0`.`OneId`, `u0`.`ThreeId`, `u0`.`Payload`, `u1`.`Id`, `u1`.`Name`, `t`.`OneId` AS `OneId0`, `t`.`ThreeId` AS `ThreeId0`, `t`.`Payload` AS `Payload0`, `t`.`Id` AS `Id0`, `t`.`CollectionInverseId`, `t`.`Name` AS `Name0`, `t`.`ReferenceInverseId` + SELECT `u0`.`OneId`, `u0`.`ThreeId`, `u0`.`Payload`, `u1`.`Id`, `u1`.`Name`, `s`.`OneId` AS `OneId0`, `s`.`ThreeId` AS `ThreeId0`, `s`.`Payload` AS `Payload0`, `s`.`Id` AS `Id0`, `s`.`CollectionInverseId`, `s`.`Name` AS `Name0`, `s`.`ReferenceInverseId` FROM `UnidirectionalJoinOneToThreePayloadFullShared` AS `u0` INNER JOIN `UnidirectionalEntityOnes` AS `u1` ON `u0`.`OneId` = `u1`.`Id` LEFT JOIN ( SELECT `u2`.`OneId`, `u2`.`ThreeId`, `u2`.`Payload`, `u3`.`Id`, `u3`.`CollectionInverseId`, `u3`.`Name`, `u3`.`ReferenceInverseId` FROM `UnidirectionalJoinOneToThreePayloadFullShared` AS `u2` INNER JOIN `UnidirectionalEntityThrees` AS `u3` ON `u2`.`ThreeId` = `u3`.`Id` - ) AS `t` ON `u1`.`Id` = `t`.`OneId` -) AS `t0` ON `u`.`Id` = `t0`.`ThreeId` -ORDER BY `u`.`Id`, `t0`.`OneId`, `t0`.`ThreeId`, `t0`.`Id`, `t0`.`OneId0`, `t0`.`ThreeId0` + ) AS `s` ON `u1`.`Id` = `s`.`OneId` +) AS `s0` ON `u`.`Id` = `s0`.`ThreeId` +ORDER BY `u`.`Id`, `s0`.`OneId`, `s0`.`ThreeId`, `s0`.`Id`, `s0`.`OneId0`, `s0`.`ThreeId0` """); } @@ -2585,15 +2582,15 @@ public override async Task Filtered_include_skip_navigation_where_unidirectional AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t`.`OneId`, `t`.`ThreeId`, `t`.`Payload`, `t`.`Id`, `t`.`Name` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s`.`OneId`, `s`.`ThreeId`, `s`.`Payload`, `s`.`Id`, `s`.`Name` FROM `EntityThrees` AS `e` LEFT JOIN ( SELECT `j`.`OneId`, `j`.`ThreeId`, `j`.`Payload`, `e0`.`Id`, `e0`.`Name` FROM `JoinOneToThreePayloadFullShared` AS `j` INNER JOIN `EntityOnes` AS `e0` ON `j`.`OneId` = `e0`.`Id` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`ThreeId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`ThreeId` +) AS `s` ON `e`.`Id` = `s`.`ThreeId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`ThreeId` """); } @@ -2603,14 +2600,14 @@ public override async Task Filtered_include_skip_navigation_order_by_unidirectio AssertSql( """ -SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`Name`, `u`.`ReferenceInverseId`, `t`.`ThreeId`, `t`.`TwoId`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` +SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`Name`, `u`.`ReferenceInverseId`, `s`.`ThreeId`, `s`.`TwoId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `UnidirectionalEntityThrees` AS `u` LEFT JOIN ( SELECT `u0`.`ThreeId`, `u0`.`TwoId`, `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId` FROM `UnidirectionalJoinTwoToThree` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoId` = `u1`.`Id` -) AS `t` ON `u`.`Id` = `t`.`ThreeId` -ORDER BY `u`.`Id`, `t`.`Id`, `t`.`ThreeId` +) AS `s` ON `u`.`Id` = `s`.`ThreeId` +ORDER BY `u`.`Id`, `s`.`Id`, `s`.`ThreeId` """); } @@ -2620,18 +2617,18 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_unidir AssertSql( """ -SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`ExtraId`, `u`.`Name`, `u`.`ReferenceInverseId`, `t0`.`SelfSkipSharedRightId`, `t0`.`UnidirectionalEntityTwoId`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `u`.`Id`, `u`.`CollectionInverseId`, `u`.`ExtraId`, `u`.`Name`, `u`.`ReferenceInverseId`, `s0`.`SelfSkipSharedRightId`, `s0`.`UnidirectionalEntityTwoId`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `UnidirectionalEntityTwos` AS `u` LEFT JOIN ( - SELECT `t`.`SelfSkipSharedRightId`, `t`.`UnidirectionalEntityTwoId`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` + SELECT `s`.`SelfSkipSharedRightId`, `s`.`UnidirectionalEntityTwoId`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `u0`.`SelfSkipSharedRightId`, `u0`.`UnidirectionalEntityTwoId`, `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `u0`.`UnidirectionalEntityTwoId` ORDER BY `u1`.`Id`) AS `row` FROM `UnidirectionalEntityTwoUnidirectionalEntityTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`SelfSkipSharedRightId` = `u1`.`Id` - ) AS `t` - WHERE 2 < `t`.`row` -) AS `t0` ON `u`.`Id` = `t0`.`UnidirectionalEntityTwoId` -ORDER BY `u`.`Id`, `t0`.`UnidirectionalEntityTwoId`, `t0`.`Id` + ) AS `s` + WHERE 2 < `s`.`row` +) AS `s0` ON `u`.`Id` = `s0`.`UnidirectionalEntityTwoId` +ORDER BY `u`.`Id`, `s0`.`UnidirectionalEntityTwoId`, `s0`.`Id` """); } @@ -2641,18 +2638,18 @@ public override async Task Filtered_include_skip_navigation_order_by_take_unidir AssertSql( """ -SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `t0`.`TwoSkipSharedId`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `s0`.`TwoSkipSharedId`, `s0`.`UnidirectionalEntityCompositeKeyKey1`, `s0`.`UnidirectionalEntityCompositeKeyKey2`, `s0`.`UnidirectionalEntityCompositeKeyKey3`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `UnidirectionalEntityCompositeKeys` AS `u` LEFT JOIN ( - SELECT `t`.`TwoSkipSharedId`, `t`.`UnidirectionalEntityCompositeKeyKey1`, `t`.`UnidirectionalEntityCompositeKeyKey2`, `t`.`UnidirectionalEntityCompositeKeyKey3`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` + SELECT `s`.`TwoSkipSharedId`, `s`.`UnidirectionalEntityCompositeKeyKey1`, `s`.`UnidirectionalEntityCompositeKeyKey2`, `s`.`UnidirectionalEntityCompositeKeyKey3`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `u0`.`TwoSkipSharedId`, `u0`.`UnidirectionalEntityCompositeKeyKey1`, `u0`.`UnidirectionalEntityCompositeKeyKey2`, `u0`.`UnidirectionalEntityCompositeKeyKey3`, `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `u0`.`UnidirectionalEntityCompositeKeyKey1`, `u0`.`UnidirectionalEntityCompositeKeyKey2`, `u0`.`UnidirectionalEntityCompositeKeyKey3` ORDER BY `u1`.`Id`) AS `row` FROM `UnidirectionalEntityCompositeKeyUnidirectionalEntityTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoSkipSharedId` = `u1`.`Id` - ) AS `t` - WHERE `t`.`row` <= 2 -) AS `t0` ON ((`u`.`Key1` = `t0`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u`.`Key2` = `t0`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u`.`Key3` = `t0`.`UnidirectionalEntityCompositeKeyKey3`) -ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3`, `t0`.`Id` + ) AS `s` + WHERE `s`.`row` <= 2 +) AS `s0` ON ((`u`.`Key1` = `s0`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u`.`Key2` = `s0`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u`.`Key3` = `s0`.`UnidirectionalEntityCompositeKeyKey3`) +ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `s0`.`UnidirectionalEntityCompositeKeyKey1`, `s0`.`UnidirectionalEntityCompositeKeyKey2`, `s0`.`UnidirectionalEntityCompositeKeyKey3`, `s0`.`Id` """); } @@ -2662,18 +2659,18 @@ public override async Task Filtered_include_skip_navigation_order_by_skip_take_u AssertSql( """ -SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `t0`.`Id`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`ThreeId`, `t0`.`Id0`, `t0`.`CollectionInverseId`, `t0`.`Name`, `t0`.`ReferenceInverseId` +SELECT `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `u`.`Name`, `s0`.`Id`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`ThreeId`, `s0`.`Id0`, `s0`.`CollectionInverseId`, `s0`.`Name`, `s0`.`ReferenceInverseId` FROM `UnidirectionalEntityCompositeKeys` AS `u` LEFT JOIN ( - SELECT `t`.`Id`, `t`.`CompositeId1`, `t`.`CompositeId2`, `t`.`CompositeId3`, `t`.`ThreeId`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`Name`, `t`.`ReferenceInverseId` + SELECT `s`.`Id`, `s`.`CompositeId1`, `s`.`CompositeId2`, `s`.`CompositeId3`, `s`.`ThreeId`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM ( SELECT `u0`.`Id`, `u0`.`CompositeId1`, `u0`.`CompositeId2`, `u0`.`CompositeId3`, `u0`.`ThreeId`, `u1`.`Id` AS `Id0`, `u1`.`CollectionInverseId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, ROW_NUMBER() OVER(PARTITION BY `u0`.`CompositeId1`, `u0`.`CompositeId2`, `u0`.`CompositeId3` ORDER BY `u1`.`Id`) AS `row` FROM `UnidirectionalJoinThreeToCompositeKeyFull` AS `u0` INNER JOIN `UnidirectionalEntityThrees` AS `u1` ON `u0`.`ThreeId` = `u1`.`Id` - ) AS `t` - WHERE (1 < `t`.`row`) AND (`t`.`row` <= 3) -) AS `t0` ON ((`u`.`Key1` = `t0`.`CompositeId1`) AND (`u`.`Key2` = `t0`.`CompositeId2`)) AND (`u`.`Key3` = `t0`.`CompositeId3`) -ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Id0` + ) AS `s` + WHERE (1 < `s`.`row`) AND (`s`.`row` <= 3) +) AS `s0` ON ((`u`.`Key1` = `s0`.`CompositeId1`) AND (`u`.`Key2` = `s0`.`CompositeId2`)) AND (`u`.`Key3` = `s0`.`CompositeId3`) +ORDER BY `u`.`Key1`, `u`.`Key2`, `u`.`Key3`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Id0` """); } @@ -2683,20 +2680,20 @@ public override async Task Filtered_include_skip_navigation_where_then_include_s AssertSql( """ -SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3`, `t0`.`Name`, `t0`.`TwoSkipSharedId`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3`, `t0`.`Id`, `t0`.`CollectionInverseId`, `t0`.`ExtraId`, `t0`.`Name0`, `t0`.`ReferenceInverseId` +SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, `u`.`IsGreen`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Key1`, `s0`.`Key2`, `s0`.`Key3`, `s0`.`Name`, `s0`.`TwoSkipSharedId`, `s0`.`UnidirectionalEntityCompositeKeyKey1`, `s0`.`UnidirectionalEntityCompositeKeyKey2`, `s0`.`UnidirectionalEntityCompositeKeyKey3`, `s0`.`Id`, `s0`.`CollectionInverseId`, `s0`.`ExtraId`, `s0`.`Name0`, `s0`.`ReferenceInverseId` FROM `UnidirectionalLeaves` AS `u` LEFT JOIN ( - SELECT `u0`.`LeafId`, `u0`.`CompositeId1`, `u0`.`CompositeId2`, `u0`.`CompositeId3`, `u1`.`Key1`, `u1`.`Key2`, `u1`.`Key3`, `u1`.`Name`, `t`.`TwoSkipSharedId`, `t`.`UnidirectionalEntityCompositeKeyKey1`, `t`.`UnidirectionalEntityCompositeKeyKey2`, `t`.`UnidirectionalEntityCompositeKeyKey3`, `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name` AS `Name0`, `t`.`ReferenceInverseId` + SELECT `u0`.`LeafId`, `u0`.`CompositeId1`, `u0`.`CompositeId2`, `u0`.`CompositeId3`, `u1`.`Key1`, `u1`.`Key2`, `u1`.`Key3`, `u1`.`Name`, `s`.`TwoSkipSharedId`, `s`.`UnidirectionalEntityCompositeKeyKey1`, `s`.`UnidirectionalEntityCompositeKeyKey2`, `s`.`UnidirectionalEntityCompositeKeyKey3`, `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name` AS `Name0`, `s`.`ReferenceInverseId` FROM `UnidirectionalJoinCompositeKeyToLeaf` AS `u0` INNER JOIN `UnidirectionalEntityCompositeKeys` AS `u1` ON ((`u0`.`CompositeId1` = `u1`.`Key1`) AND (`u0`.`CompositeId2` = `u1`.`Key2`)) AND (`u0`.`CompositeId3` = `u1`.`Key3`) LEFT JOIN ( SELECT `u2`.`TwoSkipSharedId`, `u2`.`UnidirectionalEntityCompositeKeyKey1`, `u2`.`UnidirectionalEntityCompositeKeyKey2`, `u2`.`UnidirectionalEntityCompositeKeyKey3`, `u3`.`Id`, `u3`.`CollectionInverseId`, `u3`.`ExtraId`, `u3`.`Name`, `u3`.`ReferenceInverseId` FROM `UnidirectionalEntityCompositeKeyUnidirectionalEntityTwo` AS `u2` INNER JOIN `UnidirectionalEntityTwos` AS `u3` ON `u2`.`TwoSkipSharedId` = `u3`.`Id` - ) AS `t` ON ((`u1`.`Key1` = `t`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u1`.`Key2` = `t`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u1`.`Key3` = `t`.`UnidirectionalEntityCompositeKeyKey3`) + ) AS `s` ON ((`u1`.`Key1` = `s`.`UnidirectionalEntityCompositeKeyKey1`) AND (`u1`.`Key2` = `s`.`UnidirectionalEntityCompositeKeyKey2`)) AND (`u1`.`Key3` = `s`.`UnidirectionalEntityCompositeKeyKey3`) WHERE `u1`.`Key1` < 5 -) AS `t0` ON `u`.`Id` = `t0`.`LeafId` -ORDER BY `u`.`Id`, `t0`.`LeafId`, `t0`.`CompositeId1`, `t0`.`CompositeId2`, `t0`.`CompositeId3`, `t0`.`Key1`, `t0`.`Key2`, `t0`.`Key3`, `t0`.`TwoSkipSharedId`, `t0`.`UnidirectionalEntityCompositeKeyKey1`, `t0`.`UnidirectionalEntityCompositeKeyKey2`, `t0`.`UnidirectionalEntityCompositeKeyKey3` +) AS `s0` ON `u`.`Id` = `s0`.`LeafId` +ORDER BY `u`.`Id`, `s0`.`LeafId`, `s0`.`CompositeId1`, `s0`.`CompositeId2`, `s0`.`CompositeId3`, `s0`.`Key1`, `s0`.`Key2`, `s0`.`Key3`, `s0`.`TwoSkipSharedId`, `s0`.`UnidirectionalEntityCompositeKeyKey1`, `s0`.`UnidirectionalEntityCompositeKeyKey2`, `s0`.`UnidirectionalEntityCompositeKeyKey3` """); } @@ -2706,7 +2703,7 @@ public override async Task Filter_include_on_skip_navigation_combined_unidirecti AssertSql( """ -SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `t`.`OneId`, `t`.`TwoId`, `t`.`JoinOneToTwoExtraId`, `t`.`Id`, `t`.`Name`, `t`.`Id0`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name0`, `t`.`ReferenceInverseId`, `t`.`Id1`, `t`.`CollectionInverseId0`, `t`.`ExtraId0`, `t`.`Name1`, `t`.`ReferenceInverseId0` +SELECT `e`.`Id`, `e`.`CollectionInverseId`, `e`.`ExtraId`, `e`.`Name`, `e`.`ReferenceInverseId`, `s`.`OneId`, `s`.`TwoId`, `s`.`JoinOneToTwoExtraId`, `s`.`Id`, `s`.`Name`, `s`.`Id0`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name0`, `s`.`ReferenceInverseId`, `s`.`Id1`, `s`.`CollectionInverseId0`, `s`.`ExtraId0`, `s`.`Name1`, `s`.`ReferenceInverseId0` FROM `EntityTwos` AS `e` LEFT JOIN ( SELECT `j`.`OneId`, `j`.`TwoId`, `j`.`JoinOneToTwoExtraId`, `e0`.`Id`, `e0`.`Name`, `e1`.`Id` AS `Id0`, `e1`.`CollectionInverseId`, `e1`.`ExtraId`, `e1`.`Name` AS `Name0`, `e1`.`ReferenceInverseId`, `e2`.`Id` AS `Id1`, `e2`.`CollectionInverseId` AS `CollectionInverseId0`, `e2`.`ExtraId` AS `ExtraId0`, `e2`.`Name` AS `Name1`, `e2`.`ReferenceInverseId` AS `ReferenceInverseId0` @@ -2715,8 +2712,8 @@ LEFT JOIN ( LEFT JOIN `EntityTwos` AS `e1` ON `e0`.`Id` = `e1`.`ReferenceInverseId` LEFT JOIN `EntityTwos` AS `e2` ON `e0`.`Id` = `e2`.`CollectionInverseId` WHERE `e0`.`Id` < 10 -) AS `t` ON `e`.`Id` = `t`.`TwoId` -ORDER BY `e`.`Id`, `t`.`OneId`, `t`.`TwoId`, `t`.`Id`, `t`.`Id0` +) AS `s` ON `e`.`Id` = `s`.`TwoId` +ORDER BY `e`.`Id`, `s`.`OneId`, `s`.`TwoId`, `s`.`Id`, `s`.`Id0` """); } @@ -2755,13 +2752,13 @@ public override async Task Select_many_over_skip_navigation_where_non_equality_u AssertSql( """ -SELECT `t`.`Id`, `t`.`CollectionInverseId`, `t`.`ExtraId`, `t`.`Name`, `t`.`ReferenceInverseId` +SELECT `s`.`Id`, `s`.`CollectionInverseId`, `s`.`ExtraId`, `s`.`Name`, `s`.`ReferenceInverseId` FROM `UnidirectionalEntityOnes` AS `u` LEFT JOIN ( SELECT `u1`.`Id`, `u1`.`CollectionInverseId`, `u1`.`ExtraId`, `u1`.`Name`, `u1`.`ReferenceInverseId`, `u0`.`OneId` FROM `UnidirectionalJoinOneToTwo` AS `u0` INNER JOIN `UnidirectionalEntityTwos` AS `u1` ON `u0`.`TwoId` = `u1`.`Id` -) AS `t` ON (`u`.`Id` = `t`.`OneId`) AND (`u`.`Id` <> `t`.`Id`) +) AS `s` ON (`u`.`Id` = `s`.`OneId`) AND (`u`.`Id` <> `s`.`Id`) """); } @@ -2821,14 +2818,14 @@ public override async Task GetType_in_hierarchy_in_querying_base_type_unidirecti AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`Number`, `t`.`IsGreen`, `t`.`Discriminator` +SELECT `u1`.`Id`, `u1`.`Name`, `u1`.`Number`, `u1`.`IsGreen`, `u1`.`Discriminator` FROM ( SELECT `u`.`Id`, `u`.`Name`, `u`.`Number`, NULL AS `IsGreen`, 'UnidirectionalEntityBranch' AS `Discriminator` FROM `UnidirectionalBranches` AS `u` UNION ALL SELECT `u0`.`Id`, `u0`.`Name`, `u0`.`Number`, `u0`.`IsGreen`, 'UnidirectionalEntityLeaf' AS `Discriminator` FROM `UnidirectionalLeaves` AS `u0` -) AS `t` +) AS `u1` WHERE FALSE """); } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/TPCRelationshipsQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/TPCRelationshipsQuerySingleStoreTest.cs index 03f6d360e..b00b60be1 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/TPCRelationshipsQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/TPCRelationshipsQuerySingleStoreTest.cs @@ -21,7 +21,7 @@ public TPCRelationshipsQuerySingleStoreTest( [ConditionalFact] public virtual void Check_all_tests_overridden() - => TestHelpers.AssertAllMethodsOverridden(GetType()); + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); public override void Changes_in_derived_related_entities_are_detected() { @@ -29,31 +29,31 @@ public override void Changes_in_derived_related_entities_are_detected() AssertSql( """ -SELECT `t0`.`Id`, `t0`.`Name`, `t0`.`BaseId`, `t0`.`Discriminator`, `t0`.`BaseInheritanceRelationshipEntityId`, `t0`.`Id1`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `t0`.`Id0`, `t0`.`Name0`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `t0`.`OwnedReferenceOnDerived_Id`, `t0`.`OwnedReferenceOnDerived_Name`, `t1`.`Id`, `t1`.`BaseParentId`, `t1`.`Name`, `t1`.`DerivedProperty`, `t1`.`Discriminator` +SELECT `s`.`Id`, `s`.`Name`, `s`.`BaseId`, `s`.`Discriminator`, `s`.`BaseInheritanceRelationshipEntityId`, `s`.`Id1`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `s`.`Id0`, `s`.`Name0`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `s`.`OwnedReferenceOnDerived_Id`, `s`.`OwnedReferenceOnDerived_Name`, `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`DerivedProperty`, `u0`.`Discriminator` FROM ( - SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `o`.`Id` AS `Id0`, `o`.`Name` AS `Name0`, `d`.`Id` AS `Id1`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` + SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `o`.`Id` AS `Id0`, `o`.`Name` AS `Name0`, `d0`.`Id` AS `Id1`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM ( - SELECT `b0`.`Id`, `b0`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` - FROM `BaseEntities` AS `b0` + SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` + FROM `BaseEntities` AS `b` UNION ALL - SELECT `d2`.`Id`, `d2`.`Name`, `d2`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d2` - ) AS `t` - LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` - LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` - WHERE `t`.`Name` = 'Derived1(4)' + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` + ) AS `u` + LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` + LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` + WHERE `u`.`Name` = 'Derived1(4)' LIMIT 2 -) AS `t0` -LEFT JOIN `OwnedCollections` AS `o0` ON `t0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t0`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` +) AS `s` +LEFT JOIN `OwnedCollections` AS `o0` ON `s`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `s`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` LEFT JOIN ( - SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` - FROM `BaseCollectionsOnBase` AS `b` + SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` + FROM `BaseCollectionsOnBase` AS `b0` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, `d1`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` - FROM `DerivedCollectionsOnBase` AS `d1` -) AS `t1` ON `t0`.`Id` = `t1`.`BaseParentId` -ORDER BY `t0`.`Id`, `t0`.`BaseInheritanceRelationshipEntityId`, `t0`.`Id1`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id` + SELECT `d2`.`Id`, `d2`.`BaseParentId`, `d2`.`Name`, `d2`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` + FROM `DerivedCollectionsOnBase` AS `d2` +) AS `u0` ON `s`.`Id` = `u0`.`BaseParentId` +ORDER BY `s`.`Id`, `s`.`BaseInheritanceRelationshipEntityId`, `s`.`Id1`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id` """); } @@ -63,20 +63,20 @@ public override async Task Include_collection_without_inheritance(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `c`.`Id`, `c`.`Name`, `c`.`ParentId` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name`, `c`.`Id`, `c`.`Name`, `c`.`ParentId` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -LEFT JOIN `CollectionsOnBase` AS `c` ON `t`.`Id` = `c`.`ParentId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `u`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +LEFT JOIN `CollectionsOnBase` AS `c` ON `u`.`Id` = `c`.`ParentId` +ORDER BY `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id` """); } @@ -86,20 +86,20 @@ public override async Task Include_collection_without_inheritance_reverse(bool a AssertSql( """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`ParentId`, `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `c`.`Id`, `c`.`Name`, `c`.`ParentId`, `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM `CollectionsOnBase` AS `c` LEFT JOIN ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` ON `c`.`ParentId` = `t`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `c`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` ON `c`.`ParentId` = `u`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `u`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `c`.`Id`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId` """); } @@ -109,21 +109,21 @@ public override async Task Include_collection_without_inheritance_with_filter(bo AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `c`.`Id`, `c`.`Name`, `c`.`ParentId` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name`, `c`.`Id`, `c`.`Name`, `c`.`ParentId` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -LEFT JOIN `CollectionsOnBase` AS `c` ON `t`.`Id` = `c`.`ParentId` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `u`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +LEFT JOIN `CollectionsOnBase` AS `c` ON `u`.`Id` = `c`.`ParentId` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id` """); } @@ -133,21 +133,21 @@ public override async Task Include_collection_without_inheritance_with_filter_re AssertSql( """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`ParentId`, `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `c`.`Id`, `c`.`Name`, `c`.`ParentId`, `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM `CollectionsOnBase` AS `c` LEFT JOIN ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` ON `c`.`ParentId` = `t`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` ON `c`.`ParentId` = `u`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `u`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` WHERE (`c`.`Name` <> 'Bar') OR `c`.`Name` IS NULL -ORDER BY `c`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `c`.`Id`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId` """); } @@ -157,26 +157,26 @@ public override async Task Include_collection_with_inheritance(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`DerivedProperty`, `t0`.`Discriminator` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name`, `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`DerivedProperty`, `u0`.`Discriminator` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `u`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b0` UNION ALL SELECT `d2`.`Id`, `d2`.`BaseParentId`, `d2`.`Name`, `d2`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` FROM `DerivedCollectionsOnBase` AS `d2` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` +ORDER BY `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id` """); } @@ -186,7 +186,7 @@ public override async Task Include_collection_with_inheritance_on_derived1(bool AssertSql( """ -SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t`.`Id`, `t`.`BaseParentId`, `t`.`Name`, `t`.`DerivedProperty`, `t`.`Discriminator` +SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `u`.`Id`, `u`.`BaseParentId`, `u`.`Name`, `u`.`DerivedProperty`, `u`.`Discriminator` FROM `DerivedEntities` AS `d` LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` LEFT JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` @@ -197,7 +197,7 @@ LEFT JOIN ( UNION ALL SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, `d1`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` FROM `DerivedCollectionsOnBase` AS `d1` -) AS `t` ON `d`.`Id` = `t`.`BaseParentId` +) AS `u` ON `d`.`Id` = `u`.`BaseParentId` ORDER BY `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id` """); } @@ -208,7 +208,7 @@ public override async Task Include_collection_with_inheritance_on_derived2(bool AssertSql( """ -SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t`.`Id`, `t`.`Name`, `t`.`ParentId`, `t`.`DerivedInheritanceRelationshipEntityId`, `t`.`Discriminator` +SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `u`.`Id`, `u`.`Name`, `u`.`ParentId`, `u`.`DerivedInheritanceRelationshipEntityId`, `u`.`Discriminator` FROM `DerivedEntities` AS `d` LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` LEFT JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` @@ -219,7 +219,7 @@ LEFT JOIN ( UNION ALL SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`ParentId`, `d1`.`DerivedInheritanceRelationshipEntityId`, 'DerivedCollectionOnDerived' AS `Discriminator` FROM `DerivedCollectionsOnDerived` AS `d1` -) AS `t` ON `d`.`Id` = `t`.`ParentId` +) AS `u` ON `d`.`Id` = `u`.`ParentId` ORDER BY `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id` """); } @@ -246,19 +246,19 @@ public override async Task Include_collection_with_inheritance_on_derived_revers AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`ParentId`, `t`.`DerivedInheritanceRelationshipEntityId`, `t`.`Discriminator`, `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`ParentId`, `u`.`DerivedInheritanceRelationshipEntityId`, `u`.`Discriminator`, `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`Name`, `b`.`ParentId`, NULL AS `DerivedInheritanceRelationshipEntityId`, 'BaseCollectionOnDerived' AS `Discriminator` FROM `BaseCollectionsOnDerived` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`ParentId`, `d1`.`DerivedInheritanceRelationshipEntityId`, 'DerivedCollectionOnDerived' AS `Discriminator` - FROM `DerivedCollectionsOnDerived` AS `d1` -) AS `t` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`ParentId` = `d`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `d`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`Name`, `d`.`ParentId`, `d`.`DerivedInheritanceRelationshipEntityId`, 'DerivedCollectionOnDerived' AS `Discriminator` + FROM `DerivedCollectionsOnDerived` AS `d` +) AS `u` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`ParentId` = `d0`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `d0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `OwnedCollections` AS `o0` ON `d0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `d0`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `d0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId` """); } @@ -268,26 +268,26 @@ public override async Task Include_collection_with_inheritance_reverse(bool asyn AssertSql( """ -SELECT `t`.`Id`, `t`.`BaseParentId`, `t`.`Name`, `t`.`DerivedProperty`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`Name`, `t0`.`BaseId`, `t0`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`BaseParentId`, `u`.`Name`, `u`.`DerivedProperty`, `u`.`Discriminator`, `u0`.`Id`, `u0`.`Name`, `u0`.`BaseId`, `u0`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, `d1`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` - FROM `DerivedCollectionsOnBase` AS `d1` -) AS `t` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name`, `d`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d2`.`Id`, `d2`.`Name`, `d2`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d2` -) AS `t0` ON `t`.`BaseParentId` = `t0`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t0`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t0`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d0` +) AS `u0` ON `u`.`BaseParentId` = `u0`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u0`.`Id` = `d1`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u0`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId` """); } @@ -297,27 +297,27 @@ public override async Task Include_collection_with_inheritance_with_filter(bool AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`DerivedProperty`, `t0`.`Discriminator` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name`, `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`DerivedProperty`, `u0`.`Discriminator` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `u`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b0` UNION ALL SELECT `d2`.`Id`, `d2`.`BaseParentId`, `d2`.`Name`, `d2`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` FROM `DerivedCollectionsOnBase` AS `d2` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id` """); } @@ -327,27 +327,27 @@ public override async Task Include_collection_with_inheritance_with_filter_rever AssertSql( """ -SELECT `t`.`Id`, `t`.`BaseParentId`, `t`.`Name`, `t`.`DerivedProperty`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`Name`, `t0`.`BaseId`, `t0`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`BaseParentId`, `u`.`Name`, `u`.`DerivedProperty`, `u`.`Discriminator`, `u0`.`Id`, `u0`.`Name`, `u0`.`BaseId`, `u0`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, `d1`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` - FROM `DerivedCollectionsOnBase` AS `d1` -) AS `t` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name`, `d`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d2`.`Id`, `d2`.`Name`, `d2`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d2` -) AS `t0` ON `t`.`BaseParentId` = `t0`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t0`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t0`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d0` +) AS `u0` ON `u`.`BaseParentId` = `u0`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u0`.`Id` = `d1`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u0`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId` """); } @@ -357,20 +357,20 @@ public override async Task Include_reference_without_inheritance(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `r`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `r`.`Name`, `r`.`ParentId` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `r`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name`, `r`.`Name`, `r`.`ParentId` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `ReferencesOnBase` AS `r` ON `t`.`Id` = `r`.`ParentId` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `r`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `ReferencesOnBase` AS `r` ON `u`.`Id` = `r`.`ParentId` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `u`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `r`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId` """); } @@ -428,20 +428,20 @@ public override async Task Include_reference_without_inheritance_reverse(bool as AssertSql( """ -SELECT `r`.`Id`, `r`.`Name`, `r`.`ParentId`, `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `r`.`Id`, `r`.`Name`, `r`.`ParentId`, `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM `ReferencesOnBase` AS `r` LEFT JOIN ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` ON `r`.`ParentId` = `t`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `r`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` ON `r`.`ParentId` = `u`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `u`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `r`.`Id`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId` """); } @@ -451,21 +451,21 @@ public override async Task Include_reference_without_inheritance_with_filter(boo AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `r`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `r`.`Name`, `r`.`ParentId` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `r`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name`, `r`.`Name`, `r`.`ParentId` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `ReferencesOnBase` AS `r` ON `t`.`Id` = `r`.`ParentId` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `r`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `ReferencesOnBase` AS `r` ON `u`.`Id` = `r`.`ParentId` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `u`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `r`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId` """); } @@ -475,21 +475,21 @@ public override async Task Include_reference_without_inheritance_with_filter_rev AssertSql( """ -SELECT `r`.`Id`, `r`.`Name`, `r`.`ParentId`, `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `r`.`Id`, `r`.`Name`, `r`.`ParentId`, `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM `ReferencesOnBase` AS `r` LEFT JOIN ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` ON `r`.`ParentId` = `t`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` ON `r`.`ParentId` = `u`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `u`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` WHERE (`r`.`Name` <> 'Bar') OR `r`.`Name` IS NULL -ORDER BY `r`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `r`.`Id`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId` """); } @@ -499,26 +499,26 @@ public override async Task Include_reference_with_inheritance(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`Discriminator` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`Discriminator` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, 'BaseReferenceOnBase' AS `Discriminator` FROM `BaseReferencesOnBase` AS `b0` UNION ALL - SELECT `d2`.`Id`, `d2`.`BaseParentId`, `d2`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` - FROM `DerivedReferencesOnBase` AS `d2` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` + FROM `DerivedReferencesOnBase` AS `d0` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId` """); } @@ -528,19 +528,19 @@ public override async Task Include_reference_with_inheritance_on_derived1(bool a AssertSql( """ -SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t`.`BaseParentId`, `t`.`Name`, `t`.`Discriminator` +SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `u`.`BaseParentId`, `u`.`Name`, `u`.`Discriminator` FROM `DerivedEntities` AS `d` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, 'BaseReferenceOnBase' AS `Discriminator` FROM `BaseReferencesOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` - FROM `DerivedReferencesOnBase` AS `d1` -) AS `t` ON `d`.`Id` = `t`.`BaseParentId` + SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` + FROM `DerivedReferencesOnBase` AS `d0` +) AS `u` ON `d`.`Id` = `u`.`BaseParentId` LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` LEFT JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `d`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `d`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `d`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId` """); } @@ -550,19 +550,19 @@ public override async Task Include_reference_with_inheritance_on_derived2(bool a AssertSql( """ -SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t`.`BaseParentId`, `t`.`Name`, `t`.`DerivedInheritanceRelationshipEntityId`, `t`.`Discriminator` +SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `u`.`BaseParentId`, `u`.`Name`, `u`.`DerivedInheritanceRelationshipEntityId`, `u`.`Discriminator` FROM `DerivedEntities` AS `d` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, NULL AS `DerivedInheritanceRelationshipEntityId`, 'BaseReferenceOnDerived' AS `Discriminator` FROM `BaseReferencesOnDerived` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, 'DerivedReferenceOnDerived' AS `Discriminator` - FROM `DerivedReferencesOnDerived` AS `d1` -) AS `t` ON `d`.`Id` = `t`.`BaseParentId` + SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, 'DerivedReferenceOnDerived' AS `Discriminator` + FROM `DerivedReferencesOnDerived` AS `d0` +) AS `u` ON `d`.`Id` = `u`.`BaseParentId` LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` LEFT JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `d`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `d`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `d`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId` """); } @@ -588,19 +588,19 @@ public override async Task Include_reference_with_inheritance_on_derived_reverse AssertSql( """ -SELECT `t`.`Id`, `t`.`BaseParentId`, `t`.`Name`, `t`.`DerivedInheritanceRelationshipEntityId`, `t`.`Discriminator`, `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`BaseParentId`, `u`.`Name`, `u`.`DerivedInheritanceRelationshipEntityId`, `u`.`Discriminator`, `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, NULL AS `DerivedInheritanceRelationshipEntityId`, 'BaseReferenceOnDerived' AS `Discriminator` FROM `BaseReferencesOnDerived` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, 'DerivedReferenceOnDerived' AS `Discriminator` - FROM `DerivedReferencesOnDerived` AS `d1` -) AS `t` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`BaseParentId` = `d`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `d`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name`, `d`.`DerivedInheritanceRelationshipEntityId`, 'DerivedReferenceOnDerived' AS `Discriminator` + FROM `DerivedReferencesOnDerived` AS `d` +) AS `u` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`BaseParentId` = `d0`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `d0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `OwnedCollections` AS `o0` ON `d0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `d0`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `d0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId` """); } @@ -610,20 +610,20 @@ public override async Task Include_reference_with_inheritance_on_derived_with_fi AssertSql( """ -SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t`.`BaseParentId`, `t`.`Name`, `t`.`Discriminator` +SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `u`.`BaseParentId`, `u`.`Name`, `u`.`Discriminator` FROM `DerivedEntities` AS `d` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, 'BaseReferenceOnBase' AS `Discriminator` FROM `BaseReferencesOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` - FROM `DerivedReferencesOnBase` AS `d1` -) AS `t` ON `d`.`Id` = `t`.`BaseParentId` + SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` + FROM `DerivedReferencesOnBase` AS `d0` +) AS `u` ON `d`.`Id` = `u`.`BaseParentId` LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` LEFT JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `d`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `d`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` WHERE (`d`.`Name` <> 'Bar') OR `d`.`Name` IS NULL -ORDER BY `d`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId` """); } @@ -633,20 +633,20 @@ public override async Task Include_reference_with_inheritance_on_derived_with_fi AssertSql( """ -SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t`.`BaseParentId`, `t`.`Name`, `t`.`DerivedInheritanceRelationshipEntityId`, `t`.`Discriminator` +SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `u`.`BaseParentId`, `u`.`Name`, `u`.`DerivedInheritanceRelationshipEntityId`, `u`.`Discriminator` FROM `DerivedEntities` AS `d` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, NULL AS `DerivedInheritanceRelationshipEntityId`, 'BaseReferenceOnDerived' AS `Discriminator` FROM `BaseReferencesOnDerived` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, 'DerivedReferenceOnDerived' AS `Discriminator` - FROM `DerivedReferencesOnDerived` AS `d1` -) AS `t` ON `d`.`Id` = `t`.`BaseParentId` + SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, 'DerivedReferenceOnDerived' AS `Discriminator` + FROM `DerivedReferencesOnDerived` AS `d0` +) AS `u` ON `d`.`Id` = `u`.`BaseParentId` LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` LEFT JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `d`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `d`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` WHERE (`d`.`Name` <> 'Bar') OR `d`.`Name` IS NULL -ORDER BY `d`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId` """); } @@ -673,20 +673,20 @@ public override async Task Include_reference_with_inheritance_on_derived_with_fi AssertSql( """ -SELECT `t`.`Id`, `t`.`BaseParentId`, `t`.`Name`, `t`.`DerivedInheritanceRelationshipEntityId`, `t`.`Discriminator`, `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`BaseParentId`, `u`.`Name`, `u`.`DerivedInheritanceRelationshipEntityId`, `u`.`Discriminator`, `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, NULL AS `DerivedInheritanceRelationshipEntityId`, 'BaseReferenceOnDerived' AS `Discriminator` FROM `BaseReferencesOnDerived` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, 'DerivedReferenceOnDerived' AS `Discriminator` - FROM `DerivedReferencesOnDerived` AS `d1` -) AS `t` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`BaseParentId` = `d`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `d`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name`, `d`.`DerivedInheritanceRelationshipEntityId`, 'DerivedReferenceOnDerived' AS `Discriminator` + FROM `DerivedReferencesOnDerived` AS `d` +) AS `u` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`BaseParentId` = `d0`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `d0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `OwnedCollections` AS `o0` ON `d0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `d0`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `d0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId` """); } @@ -696,26 +696,26 @@ public override async Task Include_reference_with_inheritance_reverse(bool async AssertSql( """ -SELECT `t`.`Id`, `t`.`BaseParentId`, `t`.`Name`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`Name`, `t0`.`BaseId`, `t0`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`BaseParentId`, `u`.`Name`, `u`.`Discriminator`, `u0`.`Id`, `u0`.`Name`, `u0`.`BaseId`, `u0`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, 'BaseReferenceOnBase' AS `Discriminator` FROM `BaseReferencesOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` - FROM `DerivedReferencesOnBase` AS `d1` -) AS `t` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` + FROM `DerivedReferencesOnBase` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d2`.`Id`, `d2`.`Name`, `d2`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d2` -) AS `t0` ON `t`.`BaseParentId` = `t0`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t0`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t0`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d0` +) AS `u0` ON `u`.`BaseParentId` = `u0`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u0`.`Id` = `d1`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u0`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId` """); } @@ -725,27 +725,27 @@ public override async Task Include_reference_with_inheritance_with_filter(bool a AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`Discriminator` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`Discriminator` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, 'BaseReferenceOnBase' AS `Discriminator` FROM `BaseReferencesOnBase` AS `b0` UNION ALL - SELECT `d2`.`Id`, `d2`.`BaseParentId`, `d2`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` - FROM `DerivedReferencesOnBase` AS `d2` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` + FROM `DerivedReferencesOnBase` AS `d0` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId` """); } @@ -755,27 +755,27 @@ public override async Task Include_reference_with_inheritance_with_filter_revers AssertSql( """ -SELECT `t`.`Id`, `t`.`BaseParentId`, `t`.`Name`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`Name`, `t0`.`BaseId`, `t0`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`BaseParentId`, `u`.`Name`, `u`.`Discriminator`, `u0`.`Id`, `u0`.`Name`, `u0`.`BaseId`, `u0`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, 'BaseReferenceOnBase' AS `Discriminator` FROM `BaseReferencesOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` - FROM `DerivedReferencesOnBase` AS `d1` -) AS `t` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` + FROM `DerivedReferencesOnBase` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d2`.`Id`, `d2`.`Name`, `d2`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d2` -) AS `t0` ON `t`.`BaseParentId` = `t0`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t0`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t0`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d0` +) AS `u0` ON `u`.`BaseParentId` = `u0`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u0`.`Id` = `d1`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u0`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId` """); } @@ -785,23 +785,23 @@ public override async Task Include_self_reference_with_inheritance(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name`, `d`.`Name`, `d`.`BaseId`, `o2`.`BaseInheritanceRelationshipEntityId`, `o2`.`Id`, `o2`.`Name`, `o0`.`Id`, `o0`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `d0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `o`.`Id`, `o`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name`, `d0`.`Name`, `d0`.`BaseId`, `o2`.`BaseInheritanceRelationshipEntityId`, `o2`.`Id`, `o2`.`Name`, `o0`.`Id`, `o0`.`Name`, `d3`.`DerivedInheritanceRelationshipEntityId`, `d3`.`Id`, `d3`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d3`.`Id`, `d3`.`Name`, `d3`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d3` -) AS `t` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`BaseId` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d0` ON `t`.`Id` = `d0`.`Id` -LEFT JOIN `OwnedReferences` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `OwnedCollections` AS `o1` ON `t`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `t`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` -LEFT JOIN `OwnedCollections` AS `o2` ON `d`.`Id` = `o2`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `d`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `o2`.`BaseInheritanceRelationshipEntityId`, `o2`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`BaseId` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `d0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `OwnedCollections` AS `o1` ON `u`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +LEFT JOIN `OwnedCollections` AS `o2` ON `d0`.`Id` = `o2`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d3` ON `d0`.`Id` = `d3`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `d0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `o2`.`BaseInheritanceRelationshipEntityId`, `o2`.`Id`, `d3`.`DerivedInheritanceRelationshipEntityId` """); } @@ -811,23 +811,23 @@ public override async Task Include_self_reference_with_inheritance_reverse(bool AssertSql( """ -SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o2`.`BaseInheritanceRelationshipEntityId`, `o2`.`Id`, `o2`.`Name`, `o0`.`Id`, `o0`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` +SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `o`.`Id`, `o`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o2`.`BaseInheritanceRelationshipEntityId`, `o2`.`Id`, `o2`.`Name`, `o0`.`Id`, `o0`.`Name`, `d3`.`DerivedInheritanceRelationshipEntityId`, `d3`.`Id`, `d3`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name` FROM `DerivedEntities` AS `d` LEFT JOIN ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d3`.`Id`, `d3`.`Name`, `d3`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d3` -) AS `t` ON `d`.`BaseId` = `t`.`Id` + SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d0` +) AS `u` ON `d`.`BaseId` = `u`.`Id` LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `OwnedReferences` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d0` ON `t`.`Id` = `d0`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` LEFT JOIN `OwnedCollections` AS `o1` ON `d`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `d`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` -LEFT JOIN `OwnedCollections` AS `o2` ON `t`.`Id` = `o2`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `t`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `d`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `o2`.`BaseInheritanceRelationshipEntityId`, `o2`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `d`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +LEFT JOIN `OwnedCollections` AS `o2` ON `u`.`Id` = `o2`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d3` ON `u`.`Id` = `d3`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `o2`.`BaseInheritanceRelationshipEntityId`, `o2`.`Id`, `d3`.`DerivedInheritanceRelationshipEntityId` """); } @@ -837,14 +837,14 @@ public override async Task Nested_include_collection_reference_on_non_entity_bas AssertSql( """ -SELECT `r`.`Id`, `r`.`Name`, `t`.`Id`, `t`.`Name`, `t`.`ReferenceId`, `t`.`ReferencedEntityId`, `t`.`Id0`, `t`.`Name0` +SELECT `r`.`Id`, `r`.`Name`, `s`.`Id`, `s`.`Name`, `s`.`ReferenceId`, `s`.`ReferencedEntityId`, `s`.`Id0`, `s`.`Name0` FROM `ReferencedEntities` AS `r` LEFT JOIN ( SELECT `p`.`Id`, `p`.`Name`, `p`.`ReferenceId`, `p`.`ReferencedEntityId`, `r0`.`Id` AS `Id0`, `r0`.`Name` AS `Name0` FROM `PrincipalEntities` AS `p` LEFT JOIN `ReferencedEntities` AS `r0` ON `p`.`ReferenceId` = `r0`.`Id` -) AS `t` ON `r`.`Id` = `t`.`ReferencedEntityId` -ORDER BY `r`.`Id`, `t`.`Id` +) AS `s` ON `r`.`Id` = `s`.`ReferencedEntityId` +ORDER BY `r`.`Id`, `s`.`Id` """); } @@ -853,37 +853,37 @@ public override async Task Nested_include_with_inheritance_collection_collection await base.Nested_include_with_inheritance_collection_collection(async); AssertSql( -$""" -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t1`.`Id`, `t1`.`BaseParentId`, `t1`.`Name`, `t1`.`DerivedProperty`, `t1`.`Discriminator`, `t1`.`Id0`, `t1`.`Name0`, `t1`.`ParentCollectionId`, `t1`.`ParentReferenceId`, `t1`.`Discriminator0` +""" +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name`, `s`.`Id`, `s`.`BaseParentId`, `s`.`Name`, `s`.`DerivedProperty`, `s`.`Discriminator`, `s`.`Id0`, `s`.`Name0`, `s`.`ParentCollectionId`, `s`.`ParentReferenceId`, `s`.`Discriminator0` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `u`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` LEFT JOIN ( - SELECT `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`DerivedProperty`, `t0`.`Discriminator`, `t2`.`Id` AS `Id0`, `t2`.`Name` AS `Name0`, `t2`.`ParentCollectionId`, `t2`.`ParentReferenceId`, `t2`.`Discriminator` AS `Discriminator0` + SELECT `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`DerivedProperty`, `u0`.`Discriminator`, `u1`.`Id` AS `Id0`, `u1`.`Name` AS `Name0`, `u1`.`ParentCollectionId`, `u1`.`ParentReferenceId`, `u1`.`Discriminator` AS `Discriminator0` FROM ( - SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `DerivedProperty`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'BaseCollectionOnBase'")} AS `Discriminator` + SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b0` UNION ALL - SELECT `d2`.`Id`, `d2`.`BaseParentId`, `d2`.`Name`, `d2`.`DerivedProperty`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'DerivedCollectionOnBase'")} AS `Discriminator` + SELECT `d2`.`Id`, `d2`.`BaseParentId`, `d2`.`Name`, `d2`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` FROM `DerivedCollectionsOnBase` AS `d2` - ) AS `t0` + ) AS `u0` LEFT JOIN ( - SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'NestedCollectionBase'")} AS `Discriminator` + SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedCollectionBase' AS `Discriminator` FROM `NestedCollections` AS `n` UNION ALL - SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'NestedCollectionDerived'")} AS `Discriminator` + SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedCollectionDerived' AS `Discriminator` FROM `NestedCollectionsDerived` AS `n0` - ) AS `t2` ON `t0`.`Id` = `t2`.`ParentCollectionId` -) AS `t1` ON `t`.`Id` = `t1`.`BaseParentId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `t1`.`Id` + ) AS `u1` ON `u0`.`Id` = `u1`.`ParentCollectionId` +) AS `s` ON `u`.`Id` = `s`.`BaseParentId` +ORDER BY `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `s`.`Id` """); } @@ -892,34 +892,34 @@ public override async Task Nested_include_with_inheritance_collection_collection await base.Nested_include_with_inheritance_collection_collection_reverse(async); AssertSql( -$""" -SELECT `t`.`Id`, `t`.`Name`, `t`.`ParentCollectionId`, `t`.`ParentReferenceId`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`DerivedProperty`, `t0`.`Discriminator`, `t1`.`Id`, `t1`.`Name`, `t1`.`BaseId`, `t1`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +""" +SELECT `u`.`Id`, `u`.`Name`, `u`.`ParentCollectionId`, `u`.`ParentReferenceId`, `u`.`Discriminator`, `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`DerivedProperty`, `u0`.`Discriminator`, `u1`.`Id`, `u1`.`Name`, `u1`.`BaseId`, `u1`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedCollectionBase' AS `Discriminator` FROM `NestedCollections` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedCollectionDerived' AS `Discriminator` FROM `NestedCollectionsDerived` AS `n0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, `d1`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` - FROM `DerivedCollectionsOnBase` AS `d1` -) AS `t0` ON `t`.`ParentCollectionId` = `t0`.`Id` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name`, `d`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u0` ON `u`.`ParentCollectionId` = `u0`.`Id` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d2`.`Id`, `d2`.`Name`, `d2`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d2` -) AS `t1` ON `t0`.`BaseParentId` = `t1`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t1`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t1`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d0` +) AS `u1` ON `u0`.`BaseParentId` = `u1`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u1`.`Id` = `d1`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u1`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId` """); } @@ -928,37 +928,37 @@ public override async Task Nested_include_with_inheritance_collection_reference( await base.Nested_include_with_inheritance_collection_reference(async); AssertSql( -$""" -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t1`.`Id`, `t1`.`BaseParentId`, `t1`.`Name`, `t1`.`DerivedProperty`, `t1`.`Discriminator`, `t1`.`Id0`, `t1`.`Name0`, `t1`.`ParentCollectionId`, `t1`.`ParentReferenceId`, `t1`.`Discriminator0` +""" +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name`, `s`.`Id`, `s`.`BaseParentId`, `s`.`Name`, `s`.`DerivedProperty`, `s`.`Discriminator`, `s`.`Id0`, `s`.`Name0`, `s`.`ParentCollectionId`, `s`.`ParentReferenceId`, `s`.`Discriminator0` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `u`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` LEFT JOIN ( - SELECT `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`DerivedProperty`, `t0`.`Discriminator`, `t2`.`Id` AS `Id0`, `t2`.`Name` AS `Name0`, `t2`.`ParentCollectionId`, `t2`.`ParentReferenceId`, `t2`.`Discriminator` AS `Discriminator0` + SELECT `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`DerivedProperty`, `u0`.`Discriminator`, `u1`.`Id` AS `Id0`, `u1`.`Name` AS `Name0`, `u1`.`ParentCollectionId`, `u1`.`ParentReferenceId`, `u1`.`Discriminator` AS `Discriminator0` FROM ( - SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"NULL", "signed")} AS `DerivedProperty`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'BaseCollectionOnBase'")} AS `Discriminator` + SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b0` UNION ALL - SELECT `d2`.`Id`, `d2`.`BaseParentId`, `d2`.`Name`, `d2`.`DerivedProperty`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'DerivedCollectionOnBase'")} AS `Discriminator` + SELECT `d2`.`Id`, `d2`.`BaseParentId`, `d2`.`Name`, `d2`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` FROM `DerivedCollectionsOnBase` AS `d2` - ) AS `t0` + ) AS `u0` LEFT JOIN ( - SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'NestedReferenceBase'")} AS `Discriminator` + SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedReferenceBase' AS `Discriminator` FROM `NestedReferences` AS `n` UNION ALL - SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, {SingleStoreTestHelpers.SingleStoreBug96947Workaround(@"'NestedReferenceDerived'")} AS `Discriminator` + SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedReferenceDerived' AS `Discriminator` FROM `NestedReferencesDerived` AS `n0` - ) AS `t2` ON `t0`.`Id` = `t2`.`ParentCollectionId` -) AS `t1` ON `t`.`Id` = `t1`.`BaseParentId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `t1`.`Id` + ) AS `u1` ON `u0`.`Id` = `u1`.`ParentCollectionId` +) AS `s` ON `u`.`Id` = `s`.`BaseParentId` +ORDER BY `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `s`.`Id` """); } @@ -968,33 +968,33 @@ public override async Task Nested_include_with_inheritance_collection_reference_ AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`ParentCollectionId`, `t`.`ParentReferenceId`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`DerivedProperty`, `t0`.`Discriminator`, `t1`.`Id`, `t1`.`Name`, `t1`.`BaseId`, `t1`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`ParentCollectionId`, `u`.`ParentReferenceId`, `u`.`Discriminator`, `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`DerivedProperty`, `u0`.`Discriminator`, `u1`.`Id`, `u1`.`Name`, `u1`.`BaseId`, `u1`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedReferenceBase' AS `Discriminator` FROM `NestedReferences` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedReferenceDerived' AS `Discriminator` FROM `NestedReferencesDerived` AS `n0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, `d1`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` - FROM `DerivedCollectionsOnBase` AS `d1` -) AS `t0` ON `t`.`ParentCollectionId` = `t0`.`Id` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name`, `d`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u0` ON `u`.`ParentCollectionId` = `u0`.`Id` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d2`.`Id`, `d2`.`Name`, `d2`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d2` -) AS `t1` ON `t0`.`BaseParentId` = `t1`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t1`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t1`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d0` +) AS `u1` ON `u0`.`BaseParentId` = `u1`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u1`.`Id` = `d1`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u1`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId` """); } @@ -1004,33 +1004,33 @@ public override async Task Nested_include_with_inheritance_reference_collection( AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`Discriminator`, `t1`.`Id`, `t1`.`Name`, `t1`.`ParentCollectionId`, `t1`.`ParentReferenceId`, `t1`.`Discriminator` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`Discriminator`, `u1`.`Id`, `u1`.`Name`, `u1`.`ParentCollectionId`, `u1`.`ParentReferenceId`, `u1`.`Discriminator` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, 'BaseReferenceOnBase' AS `Discriminator` FROM `BaseReferencesOnBase` AS `b0` UNION ALL - SELECT `d2`.`Id`, `d2`.`BaseParentId`, `d2`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` - FROM `DerivedReferencesOnBase` AS `d2` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` + FROM `DerivedReferencesOnBase` AS `d0` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` LEFT JOIN ( SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedCollectionBase' AS `Discriminator` FROM `NestedCollections` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedCollectionDerived' AS `Discriminator` FROM `NestedCollectionsDerived` AS `n0` -) AS `t1` ON `t0`.`Id` = `t1`.`ParentReferenceId` -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id` +) AS `u1` ON `u0`.`Id` = `u1`.`ParentReferenceId` +ORDER BY `u`.`Id`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id` """); } @@ -1040,26 +1040,26 @@ public override async Task Nested_include_with_inheritance_reference_collection_ AssertSql( """ -SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t`.`BaseParentId`, `t`.`Name`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`Name`, `t0`.`ParentCollectionId`, `t0`.`ParentReferenceId`, `t0`.`Discriminator` +SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `u`.`BaseParentId`, `u`.`Name`, `u`.`Discriminator`, `u0`.`Id`, `u0`.`Name`, `u0`.`ParentCollectionId`, `u0`.`ParentReferenceId`, `u0`.`Discriminator` FROM `DerivedEntities` AS `d` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, 'BaseReferenceOnBase' AS `Discriminator` FROM `BaseReferencesOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` - FROM `DerivedReferencesOnBase` AS `d1` -) AS `t` ON `d`.`Id` = `t`.`BaseParentId` + SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` + FROM `DerivedReferencesOnBase` AS `d0` +) AS `u` ON `d`.`Id` = `u`.`BaseParentId` LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` LEFT JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `d`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `d`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` LEFT JOIN ( SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedCollectionBase' AS `Discriminator` FROM `NestedCollections` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedCollectionDerived' AS `Discriminator` FROM `NestedCollectionsDerived` AS `n0` -) AS `t0` ON `t`.`Id` = `t0`.`ParentReferenceId` -ORDER BY `d`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id` +) AS `u0` ON `u`.`Id` = `u0`.`ParentReferenceId` +ORDER BY `d`.`Id`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id` """); } @@ -1069,33 +1069,33 @@ public override async Task Nested_include_with_inheritance_reference_collection_ AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`ParentCollectionId`, `t`.`ParentReferenceId`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`Discriminator`, `t1`.`Id`, `t1`.`Name`, `t1`.`BaseId`, `t1`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`ParentCollectionId`, `u`.`ParentReferenceId`, `u`.`Discriminator`, `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`Discriminator`, `u1`.`Id`, `u1`.`Name`, `u1`.`BaseId`, `u1`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedCollectionBase' AS `Discriminator` FROM `NestedCollections` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedCollectionDerived' AS `Discriminator` FROM `NestedCollectionsDerived` AS `n0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, 'BaseReferenceOnBase' AS `Discriminator` FROM `BaseReferencesOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` - FROM `DerivedReferencesOnBase` AS `d1` -) AS `t0` ON `t`.`ParentReferenceId` = `t0`.`Id` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` + FROM `DerivedReferencesOnBase` AS `d` +) AS `u0` ON `u`.`ParentReferenceId` = `u0`.`Id` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d2`.`Id`, `d2`.`Name`, `d2`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d2` -) AS `t1` ON `t0`.`BaseParentId` = `t1`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t1`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t1`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d0` +) AS `u1` ON `u0`.`BaseParentId` = `u1`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u1`.`Id` = `d1`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u1`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId` """); } @@ -1105,33 +1105,33 @@ public override async Task Nested_include_with_inheritance_reference_reference(b AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`Discriminator`, `t1`.`Name`, `t1`.`ParentCollectionId`, `t1`.`ParentReferenceId`, `t1`.`Discriminator` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `u0`.`Id`, `u1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`Discriminator`, `u1`.`Name`, `u1`.`ParentCollectionId`, `u1`.`ParentReferenceId`, `u1`.`Discriminator` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, 'BaseReferenceOnBase' AS `Discriminator` FROM `BaseReferencesOnBase` AS `b0` UNION ALL - SELECT `d2`.`Id`, `d2`.`BaseParentId`, `d2`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` - FROM `DerivedReferencesOnBase` AS `d2` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` + SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` + FROM `DerivedReferencesOnBase` AS `d0` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` LEFT JOIN ( SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedReferenceBase' AS `Discriminator` FROM `NestedReferences` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedReferenceDerived' AS `Discriminator` FROM `NestedReferencesDerived` AS `n0` -) AS `t1` ON `t0`.`Id` = `t1`.`ParentReferenceId` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` +) AS `u1` ON `u0`.`Id` = `u1`.`ParentReferenceId` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId` """); } @@ -1141,26 +1141,26 @@ public override async Task Nested_include_with_inheritance_reference_reference_o AssertSql( """ -SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t`.`BaseParentId`, `t`.`Name`, `t`.`Discriminator`, `t0`.`Name`, `t0`.`ParentCollectionId`, `t0`.`ParentReferenceId`, `t0`.`Discriminator` +SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `u`.`Id`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `u`.`BaseParentId`, `u`.`Name`, `u`.`Discriminator`, `u0`.`Name`, `u0`.`ParentCollectionId`, `u0`.`ParentReferenceId`, `u0`.`Discriminator` FROM `DerivedEntities` AS `d` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, 'BaseReferenceOnBase' AS `Discriminator` FROM `BaseReferencesOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` - FROM `DerivedReferencesOnBase` AS `d1` -) AS `t` ON `d`.`Id` = `t`.`BaseParentId` + SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` + FROM `DerivedReferencesOnBase` AS `d0` +) AS `u` ON `d`.`Id` = `u`.`BaseParentId` LEFT JOIN ( SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedReferenceBase' AS `Discriminator` FROM `NestedReferences` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedReferenceDerived' AS `Discriminator` FROM `NestedReferencesDerived` AS `n0` -) AS `t0` ON `t`.`Id` = `t0`.`ParentReferenceId` +) AS `u0` ON `u`.`Id` = `u0`.`ParentReferenceId` LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` LEFT JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `d`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `d`.`Id`, `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `d`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `u`.`Id`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId` """); } @@ -1170,33 +1170,33 @@ public override async Task Nested_include_with_inheritance_reference_reference_r AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`ParentCollectionId`, `t`.`ParentReferenceId`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`Discriminator`, `t1`.`Id`, `t1`.`Name`, `t1`.`BaseId`, `t1`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`ParentCollectionId`, `u`.`ParentReferenceId`, `u`.`Discriminator`, `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`Discriminator`, `u1`.`Id`, `u1`.`Name`, `u1`.`BaseId`, `u1`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedReferenceBase' AS `Discriminator` FROM `NestedReferences` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedReferenceDerived' AS `Discriminator` FROM `NestedReferencesDerived` AS `n0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, 'BaseReferenceOnBase' AS `Discriminator` FROM `BaseReferencesOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` - FROM `DerivedReferencesOnBase` AS `d1` -) AS `t0` ON `t`.`ParentReferenceId` = `t0`.`Id` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` + FROM `DerivedReferencesOnBase` AS `d` +) AS `u0` ON `u`.`ParentReferenceId` = `u0`.`Id` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d2`.`Id`, `d2`.`Name`, `d2`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d2` -) AS `t1` ON `t0`.`BaseParentId` = `t1`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t1`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t1`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d0` +) AS `u1` ON `u0`.`BaseParentId` = `u1`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u1`.`Id` = `d1`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u1`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d2`.`DerivedInheritanceRelationshipEntityId` """); } @@ -1206,22 +1206,22 @@ public override async Task Collection_projection_on_base_type(bool async) AssertSql( """ -SELECT `t`.`Id`, `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`DerivedProperty`, `t0`.`Discriminator` +SELECT `u`.`Id`, `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`DerivedProperty`, `u0`.`Discriminator` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL SELECT `d`.`Id` FROM `DerivedEntities` AS `d` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b0` UNION ALL SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, `d0`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` FROM `DerivedCollectionsOnBase` AS `d0` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` -ORDER BY `t`.`Id` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` +ORDER BY `u`.`Id` """); } @@ -1231,21 +1231,21 @@ public override async Task Include_on_derived_type_with_queryable_Cast(bool asyn AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `d1`.`Id`, `d1`.`Name`, `d1`.`ParentId`, `d1`.`DerivedInheritanceRelationshipEntityId` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `o`.`Id`, `o`.`Name`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name`, `d2`.`Id`, `d2`.`Name`, `d2`.`ParentId`, `d2`.`DerivedInheritanceRelationshipEntityId` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d2`.`Id`, `d2`.`Name`, `d2`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d2` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -LEFT JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -LEFT JOIN `DerivedCollectionsOnDerived` AS `d1` ON `t`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` -WHERE `t`.`Id` >= 4 -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +LEFT JOIN `OwnedCollections` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `u`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +LEFT JOIN `DerivedCollectionsOnDerived` AS `d2` ON `u`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +WHERE `u`.`Id` >= 4 +ORDER BY `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id` """); } @@ -1255,68 +1255,68 @@ public override async Task Include_collection_with_inheritance_split(bool async) AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o`.`Id`, `o`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +ORDER BY `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `OwnedCollections` AS `o1` ON `u`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`DerivedProperty`, `t0`.`Discriminator`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`DerivedProperty`, `u0`.`Discriminator`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` INNER JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b0` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, `d1`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` - FROM `DerivedCollectionsOnBase` AS `d1` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d3`.`Id`, `d3`.`BaseParentId`, `d3`.`Name`, `d3`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` + FROM `DerivedCollectionsOnBase` AS `d3` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """); } @@ -1326,68 +1326,68 @@ public override async Task Include_collection_with_inheritance_reverse_split(boo AssertSql( """ -SELECT `t`.`Id`, `t`.`BaseParentId`, `t`.`Name`, `t`.`DerivedProperty`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`Name`, `t0`.`BaseId`, `t0`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`BaseParentId`, `u`.`Name`, `u`.`DerivedProperty`, `u`.`Discriminator`, `u0`.`Id`, `u0`.`Name`, `u0`.`BaseId`, `u0`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o`.`Id`, `o`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, `d0`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` - FROM `DerivedCollectionsOnBase` AS `d0` -) AS `t` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name`, `d`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t0` ON `t`.`BaseParentId` = `t0`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t0`.`Id` = `d`.`Id` -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d0` +) AS `u0` ON `u`.`BaseParentId` = `u0`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u0`.`Id` = `d1`.`Id` +ORDER BY `u`.`Id`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `u`.`Id`, `u0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` FROM ( SELECT `b`.`Id`, `b`.`BaseParentId` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`BaseParentId` - FROM `DerivedCollectionsOnBase` AS `d0` -) AS `t` + SELECT `d`.`Id`, `d`.`BaseParentId` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d1`.`Id` - FROM `DerivedEntities` AS `d1` -) AS `t0` ON `t`.`BaseParentId` = `t0`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t0`.`Id` = `d`.`Id` -INNER JOIN `OwnedCollections` AS `o0` ON `t0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id` + FROM `DerivedEntities` AS `d0` +) AS `u0` ON `u`.`BaseParentId` = `u0`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `u0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d2` ON `u0`.`Id` = `d2`.`Id` +INNER JOIN `OwnedCollections` AS `o1` ON `u0`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d3`.`DerivedInheritanceRelationshipEntityId`, `d3`.`Id`, `d3`.`Name`, `u`.`Id`, `u0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` FROM ( SELECT `b`.`Id`, `b`.`BaseParentId` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId` - FROM `DerivedCollectionsOnBase` AS `d1` -) AS `t` + SELECT `d`.`Id`, `d`.`BaseParentId` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d2`.`Id` - FROM `DerivedEntities` AS `d2` -) AS `t0` ON `t`.`BaseParentId` = `t0`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t0`.`Id` = `d`.`Id` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t0`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id` + FROM `DerivedEntities` AS `d0` +) AS `u0` ON `u`.`BaseParentId` = `u0`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `u0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d2` ON `u0`.`Id` = `d2`.`Id` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d3` ON `u0`.`Id` = `d3`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` """); } @@ -1397,72 +1397,72 @@ public override async Task Include_collection_with_inheritance_with_filter_split AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o`.`Id`, `o`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id`, `b`.`Name` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id`, `d`.`Name` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `OwnedCollections` AS `o1` ON `u`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id`, `b`.`Name` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id`, `d`.`Name` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`DerivedProperty`, `t0`.`Discriminator`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`DerivedProperty`, `u0`.`Discriminator`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id`, `b`.`Name` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` + SELECT `d`.`Id`, `d`.`Name` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` INNER JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b0` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, `d1`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` - FROM `DerivedCollectionsOnBase` AS `d1` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d3`.`Id`, `d3`.`BaseParentId`, `d3`.`Name`, `d3`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` + FROM `DerivedCollectionsOnBase` AS `d3` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """); } @@ -1472,71 +1472,71 @@ public override async Task Include_collection_with_inheritance_with_filter_rever AssertSql( """ -SELECT `t`.`Id`, `t`.`BaseParentId`, `t`.`Name`, `t`.`DerivedProperty`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`Name`, `t0`.`BaseId`, `t0`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`BaseParentId`, `u`.`Name`, `u`.`DerivedProperty`, `u`.`Discriminator`, `u0`.`Id`, `u0`.`Name`, `u0`.`BaseId`, `u0`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o`.`Id`, `o`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, `d0`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` - FROM `DerivedCollectionsOnBase` AS `d0` -) AS `t` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name`, `d`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t0` ON `t`.`BaseParentId` = `t0`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t0`.`Id` = `d`.`Id` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d0` +) AS `u0` ON `u`.`BaseParentId` = `u0`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u0`.`Id` = `d1`.`Id` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `u`.`Id`, `u0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` FROM ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name` - FROM `DerivedCollectionsOnBase` AS `d0` -) AS `t` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d1`.`Id` - FROM `DerivedEntities` AS `d1` -) AS `t0` ON `t`.`BaseParentId` = `t0`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t0`.`Id` = `d`.`Id` -INNER JOIN `OwnedCollections` AS `o0` ON `t0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id` + FROM `DerivedEntities` AS `d0` +) AS `u0` ON `u`.`BaseParentId` = `u0`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `u0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d2` ON `u0`.`Id` = `d2`.`Id` +INNER JOIN `OwnedCollections` AS `o1` ON `u0`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `u0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d3`.`DerivedInheritanceRelationshipEntityId`, `d3`.`Id`, `d3`.`Name`, `u`.`Id`, `u0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` FROM ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name` - FROM `DerivedCollectionsOnBase` AS `d1` -) AS `t` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d2`.`Id` - FROM `DerivedEntities` AS `d2` -) AS `t0` ON `t`.`BaseParentId` = `t0`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t0`.`Id` = `d`.`Id` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t0`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id` + FROM `DerivedEntities` AS `d0` +) AS `u0` ON `u`.`BaseParentId` = `u0`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `u0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d2` ON `u0`.`Id` = `d2`.`Id` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d3` ON `u0`.`Id` = `d3`.`DerivedInheritanceRelationshipEntityId` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `u0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` """); } @@ -1546,62 +1546,62 @@ public override async Task Include_collection_without_inheritance_split(bool asy AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o`.`Id`, `o`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +ORDER BY `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `OwnedCollections` AS `o1` ON `u`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`ParentId`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `c`.`Id`, `c`.`Name`, `c`.`ParentId`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `CollectionsOnBase` AS `c` ON `t`.`Id` = `c`.`ParentId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `CollectionsOnBase` AS `c` ON `u`.`Id` = `c`.`ParentId` +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """); } @@ -1611,50 +1611,50 @@ public override async Task Include_collection_without_inheritance_reverse_split( AssertSql( """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`ParentId`, `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `c`.`Id`, `c`.`Name`, `c`.`ParentId`, `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o`.`Id`, `o`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM `CollectionsOnBase` AS `c` LEFT JOIN ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d0` -) AS `t` ON `c`.`ParentId` = `t`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -ORDER BY `c`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` ON `c`.`ParentId` = `u`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +ORDER BY `c`.`Id`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `c`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `c`.`Id`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM `CollectionsOnBase` AS `c` LEFT JOIN ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id` - FROM `DerivedEntities` AS `d0` -) AS `t` ON `c`.`ParentId` = `t`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -ORDER BY `c`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` ON `c`.`ParentId` = `u`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `OwnedCollections` AS `o1` ON `u`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +ORDER BY `c`.`Id`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `c`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `c`.`Id`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM `CollectionsOnBase` AS `c` LEFT JOIN ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id` - FROM `DerivedEntities` AS `d1` -) AS `t` ON `c`.`ParentId` = `t`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `c`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` ON `c`.`ParentId` = `u`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `c`.`Id`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """); } @@ -1664,66 +1664,66 @@ public override async Task Include_collection_without_inheritance_with_filter_sp AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o`.`Id`, `o`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id`, `b`.`Name` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id`, `d`.`Name` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `OwnedCollections` AS `o1` ON `u`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id`, `b`.`Name` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id`, `d`.`Name` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`ParentId`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `c`.`Id`, `c`.`Name`, `c`.`ParentId`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id`, `b`.`Name` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `CollectionsOnBase` AS `c` ON `t`.`Id` = `c`.`ParentId` -WHERE (`t`.`Name` <> 'Bar') OR `t`.`Name` IS NULL -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id`, `d`.`Name` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `CollectionsOnBase` AS `c` ON `u`.`Id` = `c`.`ParentId` +WHERE (`u`.`Name` <> 'Bar') OR `u`.`Name` IS NULL +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """); } @@ -1733,53 +1733,53 @@ public override async Task Include_collection_without_inheritance_with_filter_re AssertSql( """ -SELECT `c`.`Id`, `c`.`Name`, `c`.`ParentId`, `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `c`.`Id`, `c`.`Name`, `c`.`ParentId`, `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o`.`Id`, `o`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM `CollectionsOnBase` AS `c` LEFT JOIN ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d0` -) AS `t` ON `c`.`ParentId` = `t`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` ON `c`.`ParentId` = `u`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` WHERE (`c`.`Name` <> 'Bar') OR `c`.`Name` IS NULL -ORDER BY `c`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +ORDER BY `c`.`Id`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `c`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `c`.`Id`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM `CollectionsOnBase` AS `c` LEFT JOIN ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id` - FROM `DerivedEntities` AS `d0` -) AS `t` ON `c`.`ParentId` = `t`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` ON `c`.`ParentId` = `u`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `OwnedCollections` AS `o1` ON `u`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` WHERE (`c`.`Name` <> 'Bar') OR `c`.`Name` IS NULL -ORDER BY `c`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +ORDER BY `c`.`Id`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `c`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `c`.`Id`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM `CollectionsOnBase` AS `c` LEFT JOIN ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id` - FROM `DerivedEntities` AS `d1` -) AS `t` ON `c`.`ParentId` = `t`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` ON `c`.`ParentId` = `u`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` WHERE (`c`.`Name` <> 'Bar') OR `c`.`Name` IS NULL -ORDER BY `c`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +ORDER BY `c`.`Id`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """); } @@ -1796,33 +1796,33 @@ public override async Task Include_collection_with_inheritance_on_derived1_split """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` FROM `DerivedEntities` AS `d` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -INNER JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -ORDER BY `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `OwnedReferences` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +INNER JOIN `OwnedCollections` AS `o1` ON `d`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +SELECT `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` FROM `DerivedEntities` AS `d` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `d`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `OwnedReferences` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `d`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` """, // """ -SELECT `t`.`Id`, `t`.`BaseParentId`, `t`.`Name`, `t`.`DerivedProperty`, `t`.`Discriminator`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +SELECT `u`.`Id`, `u`.`BaseParentId`, `u`.`Name`, `u`.`DerivedProperty`, `u`.`Discriminator`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` FROM `DerivedEntities` AS `d` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `OwnedReferences` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` INNER JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, `d0`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` - FROM `DerivedCollectionsOnBase` AS `d0` -) AS `t` ON `d`.`Id` = `t`.`BaseParentId` -ORDER BY `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` + SELECT `d2`.`Id`, `d2`.`BaseParentId`, `d2`.`Name`, `d2`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` + FROM `DerivedCollectionsOnBase` AS `d2` +) AS `u` ON `d`.`Id` = `u`.`BaseParentId` +ORDER BY `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` """); } @@ -1838,33 +1838,33 @@ public override async Task Include_collection_with_inheritance_on_derived2_split """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` FROM `DerivedEntities` AS `d` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -INNER JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -ORDER BY `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `OwnedReferences` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +INNER JOIN `OwnedCollections` AS `o1` ON `d`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +SELECT `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` FROM `DerivedEntities` AS `d` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `d`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `OwnedReferences` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `d`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` """, // """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`ParentId`, `t`.`DerivedInheritanceRelationshipEntityId`, `t`.`Discriminator`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +SELECT `u`.`Id`, `u`.`Name`, `u`.`ParentId`, `u`.`DerivedInheritanceRelationshipEntityId`, `u`.`Discriminator`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` FROM `DerivedEntities` AS `d` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `OwnedReferences` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` INNER JOIN ( SELECT `b`.`Id`, `b`.`Name`, `b`.`ParentId`, NULL AS `DerivedInheritanceRelationshipEntityId`, 'BaseCollectionOnDerived' AS `Discriminator` FROM `BaseCollectionsOnDerived` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`ParentId`, `d0`.`DerivedInheritanceRelationshipEntityId`, 'DerivedCollectionOnDerived' AS `Discriminator` - FROM `DerivedCollectionsOnDerived` AS `d0` -) AS `t` ON `d`.`Id` = `t`.`ParentId` -ORDER BY `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` + SELECT `d2`.`Id`, `d2`.`Name`, `d2`.`ParentId`, `d2`.`DerivedInheritanceRelationshipEntityId`, 'DerivedCollectionOnDerived' AS `Discriminator` + FROM `DerivedCollectionsOnDerived` AS `d2` +) AS `u` ON `d`.`Id` = `u`.`ParentId` +ORDER BY `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` """); } @@ -1881,27 +1881,27 @@ public override async Task Include_collection_with_inheritance_on_derived3_split """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` FROM `DerivedEntities` AS `d` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -INNER JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -ORDER BY `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `OwnedReferences` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +INNER JOIN `OwnedCollections` AS `o1` ON `d`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +SELECT `d1`.`DerivedInheritanceRelationshipEntityId`, `d1`.`Id`, `d1`.`Name`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` FROM `DerivedEntities` AS `d` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `d`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `OwnedReferences` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d1` ON `d`.`Id` = `d1`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` """, // """ -SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`ParentId`, `d0`.`DerivedInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +SELECT `d2`.`Id`, `d2`.`Name`, `d2`.`ParentId`, `d2`.`DerivedInheritanceRelationshipEntityId`, `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` FROM `DerivedEntities` AS `d` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -INNER JOIN `DerivedCollectionsOnDerived` AS `d0` ON `d`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `OwnedReferences` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +INNER JOIN `DerivedCollectionsOnDerived` AS `d2` ON `d`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` """); } @@ -1911,47 +1911,47 @@ public override async Task Include_collection_with_inheritance_on_derived_revers AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`ParentId`, `t`.`DerivedInheritanceRelationshipEntityId`, `t`.`Discriminator`, `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `o`.`BaseInheritanceRelationshipEntityId`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`ParentId`, `u`.`DerivedInheritanceRelationshipEntityId`, `u`.`Discriminator`, `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, `o`.`BaseInheritanceRelationshipEntityId`, `o`.`Id`, `o`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`Name`, `b`.`ParentId`, NULL AS `DerivedInheritanceRelationshipEntityId`, 'BaseCollectionOnDerived' AS `Discriminator` FROM `BaseCollectionsOnDerived` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`ParentId`, `d0`.`DerivedInheritanceRelationshipEntityId`, 'DerivedCollectionOnDerived' AS `Discriminator` - FROM `DerivedCollectionsOnDerived` AS `d0` -) AS `t` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`ParentId` = `d`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`Name`, `d`.`ParentId`, `d`.`DerivedInheritanceRelationshipEntityId`, 'DerivedCollectionOnDerived' AS `Discriminator` + FROM `DerivedCollectionsOnDerived` AS `d` +) AS `u` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`ParentId` = `d0`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `d0`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `d0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `t`.`Id`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `u`.`Id`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` FROM ( SELECT `b`.`Id`, `b`.`ParentId` FROM `BaseCollectionsOnDerived` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`ParentId` - FROM `DerivedCollectionsOnDerived` AS `d0` -) AS `t` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`ParentId` = `d`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -INNER JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`ParentId` + FROM `DerivedCollectionsOnDerived` AS `d` +) AS `u` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`ParentId` = `d0`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `d0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +INNER JOIN `OwnedCollections` AS `o1` ON `d0`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `t`.`Id`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +SELECT `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `u`.`Id`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` FROM ( SELECT `b`.`Id`, `b`.`ParentId` FROM `BaseCollectionsOnDerived` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`ParentId` - FROM `DerivedCollectionsOnDerived` AS `d1` -) AS `t` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`ParentId` = `d`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `d`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `d`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` + SELECT `d`.`Id`, `d`.`ParentId` + FROM `DerivedCollectionsOnDerived` AS `d` +) AS `u` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`ParentId` = `d0`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `d0`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `d0`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `d0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` """); } @@ -1961,96 +1961,96 @@ public override async Task Nested_include_with_inheritance_reference_collection_ AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`Discriminator` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o`.`Id`, `o`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`Discriminator` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d0` -) AS `t` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, 'BaseReferenceOnBase' AS `Discriminator` FROM `BaseReferencesOnBase` AS `b0` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` - FROM `DerivedReferencesOnBase` AS `d1` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` + FROM `DerivedReferencesOnBase` AS `d0` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +ORDER BY `u`.`Id`, `u0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `u`.`Id`, `u0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id` - FROM `DerivedEntities` AS `d0` -) AS `t` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId` FROM `BaseReferencesOnBase` AS `b0` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId` - FROM `DerivedReferencesOnBase` AS `d1` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id`, `d0`.`BaseParentId` + FROM `DerivedReferencesOnBase` AS `d0` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d2` ON `u`.`Id` = `d2`.`Id` +INNER JOIN `OwnedCollections` AS `o1` ON `u`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d3`.`DerivedInheritanceRelationshipEntityId`, `d3`.`Id`, `d3`.`Name`, `u`.`Id`, `u0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id` - FROM `DerivedEntities` AS `d1` -) AS `t` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId` FROM `BaseReferencesOnBase` AS `b0` UNION ALL - SELECT `d2`.`Id`, `d2`.`BaseParentId` - FROM `DerivedReferencesOnBase` AS `d2` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id`, `d0`.`BaseParentId` + FROM `DerivedReferencesOnBase` AS `d0` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d2` ON `u`.`Id` = `d2`.`Id` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d3` ON `u`.`Id` = `d3`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` """, // """ -SELECT `t1`.`Id`, `t1`.`Name`, `t1`.`ParentCollectionId`, `t1`.`ParentReferenceId`, `t1`.`Discriminator`, `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `u1`.`Id`, `u1`.`Name`, `u1`.`ParentCollectionId`, `u1`.`ParentReferenceId`, `u1`.`Discriminator`, `u`.`Id`, `u0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id` - FROM `DerivedEntities` AS `d0` -) AS `t` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId` FROM `BaseReferencesOnBase` AS `b0` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId` - FROM `DerivedReferencesOnBase` AS `d1` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` + SELECT `d0`.`Id`, `d0`.`BaseParentId` + FROM `DerivedReferencesOnBase` AS `d0` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d2` ON `u`.`Id` = `d2`.`Id` INNER JOIN ( SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedCollectionBase' AS `Discriminator` FROM `NestedCollections` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedCollectionDerived' AS `Discriminator` FROM `NestedCollectionsDerived` AS `n0` -) AS `t1` ON `t0`.`Id` = `t1`.`ParentReferenceId` -ORDER BY `t`.`Id`, `t0`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +) AS `u1` ON `u0`.`Id` = `u1`.`ParentReferenceId` +ORDER BY `u`.`Id`, `u0`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` """); } @@ -2060,7 +2060,7 @@ public override async Task Nested_include_with_inheritance_reference_collection_ AssertSql( """ -SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o`.`Id`, `o`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `t`.`BaseParentId`, `t`.`Name`, `t`.`Discriminator` +SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `o`.`Id`, `o`.`Name`, `d`.`Id`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name`, `u`.`BaseParentId`, `u`.`Name`, `u`.`Discriminator` FROM `DerivedEntities` AS `d` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, 'BaseReferenceOnBase' AS `Discriminator` @@ -2068,13 +2068,13 @@ LEFT JOIN ( UNION ALL SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` FROM `DerivedReferencesOnBase` AS `d0` -) AS `t` ON `d`.`Id` = `t`.`BaseParentId` +) AS `u` ON `d`.`Id` = `u`.`BaseParentId` LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -ORDER BY `d`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `d`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `d`.`Id`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` FROM `DerivedEntities` AS `d` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId` @@ -2082,29 +2082,29 @@ LEFT JOIN ( UNION ALL SELECT `d0`.`Id`, `d0`.`BaseParentId` FROM `DerivedReferencesOnBase` AS `d0` -) AS `t` ON `d`.`Id` = `t`.`BaseParentId` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -INNER JOIN `OwnedCollections` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -ORDER BY `d`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +) AS `u` ON `d`.`Id` = `u`.`BaseParentId` +LEFT JOIN `OwnedReferences` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +INNER JOIN `OwnedCollections` AS `o1` ON `d`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `d`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +SELECT `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `d`.`Id`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` FROM `DerivedEntities` AS `d` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId` FROM `BaseReferencesOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId` - FROM `DerivedReferencesOnBase` AS `d1` -) AS `t` ON `d`.`Id` = `t`.`BaseParentId` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `d`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `d`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` + SELECT `d0`.`Id`, `d0`.`BaseParentId` + FROM `DerivedReferencesOnBase` AS `d0` +) AS `u` ON `d`.`Id` = `u`.`BaseParentId` +LEFT JOIN `OwnedReferences` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `d`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `d`.`Id`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` """, // """ -SELECT `t0`.`Id`, `t0`.`Name`, `t0`.`ParentCollectionId`, `t0`.`ParentReferenceId`, `t0`.`Discriminator`, `d`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +SELECT `u0`.`Id`, `u0`.`Name`, `u0`.`ParentCollectionId`, `u0`.`ParentReferenceId`, `u0`.`Discriminator`, `d`.`Id`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` FROM `DerivedEntities` AS `d` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId` @@ -2112,16 +2112,16 @@ LEFT JOIN ( UNION ALL SELECT `d0`.`Id`, `d0`.`BaseParentId` FROM `DerivedReferencesOnBase` AS `d0` -) AS `t` ON `d`.`Id` = `t`.`BaseParentId` -LEFT JOIN `OwnedReferences` AS `o` ON `d`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +) AS `u` ON `d`.`Id` = `u`.`BaseParentId` +LEFT JOIN `OwnedReferences` AS `o0` ON `d`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` INNER JOIN ( SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedCollectionBase' AS `Discriminator` FROM `NestedCollections` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedCollectionDerived' AS `Discriminator` FROM `NestedCollectionsDerived` AS `n0` -) AS `t0` ON `t`.`Id` = `t0`.`ParentReferenceId` -ORDER BY `d`.`Id`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId` +) AS `u0` ON `u`.`Id` = `u0`.`ParentReferenceId` +ORDER BY `d`.`Id`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId` """); } @@ -2131,89 +2131,89 @@ public override async Task Nested_include_with_inheritance_reference_collection_ AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`ParentCollectionId`, `t`.`ParentReferenceId`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`Discriminator`, `t1`.`Id`, `t1`.`Name`, `t1`.`BaseId`, `t1`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`ParentCollectionId`, `u`.`ParentReferenceId`, `u`.`Discriminator`, `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`Discriminator`, `u1`.`Id`, `u1`.`Name`, `u1`.`BaseId`, `u1`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o`.`Id`, `o`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedCollectionBase' AS `Discriminator` FROM `NestedCollections` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedCollectionDerived' AS `Discriminator` FROM `NestedCollectionsDerived` AS `n0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, 'BaseReferenceOnBase' AS `Discriminator` FROM `BaseReferencesOnBase` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` - FROM `DerivedReferencesOnBase` AS `d0` -) AS `t0` ON `t`.`ParentReferenceId` = `t0`.`Id` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name`, 'DerivedReferenceOnBase' AS `Discriminator` + FROM `DerivedReferencesOnBase` AS `d` +) AS `u0` ON `u`.`ParentReferenceId` = `u0`.`Id` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t1` ON `t0`.`BaseParentId` = `t1`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t1`.`Id` = `d`.`Id` -ORDER BY `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d0` +) AS `u1` ON `u0`.`BaseParentId` = `u1`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u1`.`Id` = `d1`.`Id` +ORDER BY `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` FROM ( SELECT `n`.`Id`, `n`.`ParentReferenceId` FROM `NestedCollections` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`ParentReferenceId` FROM `NestedCollectionsDerived` AS `n0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId` FROM `BaseReferencesOnBase` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`BaseParentId` - FROM `DerivedReferencesOnBase` AS `d0` -) AS `t0` ON `t`.`ParentReferenceId` = `t0`.`Id` + SELECT `d`.`Id`, `d`.`BaseParentId` + FROM `DerivedReferencesOnBase` AS `d` +) AS `u0` ON `u`.`ParentReferenceId` = `u0`.`Id` LEFT JOIN ( SELECT `b0`.`Id` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d1`.`Id` - FROM `DerivedEntities` AS `d1` -) AS `t1` ON `t0`.`BaseParentId` = `t1`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t1`.`Id` = `d`.`Id` -INNER JOIN `OwnedCollections` AS `o0` ON `t1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id` + FROM `DerivedEntities` AS `d0` +) AS `u1` ON `u0`.`BaseParentId` = `u1`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `u1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d2` ON `u1`.`Id` = `d2`.`Id` +INNER JOIN `OwnedCollections` AS `o1` ON `u1`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d3`.`DerivedInheritanceRelationshipEntityId`, `d3`.`Id`, `d3`.`Name`, `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` FROM ( SELECT `n`.`Id`, `n`.`ParentReferenceId` FROM `NestedCollections` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`ParentReferenceId` FROM `NestedCollectionsDerived` AS `n0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId` FROM `BaseReferencesOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId` - FROM `DerivedReferencesOnBase` AS `d1` -) AS `t0` ON `t`.`ParentReferenceId` = `t0`.`Id` + SELECT `d`.`Id`, `d`.`BaseParentId` + FROM `DerivedReferencesOnBase` AS `d` +) AS `u0` ON `u`.`ParentReferenceId` = `u0`.`Id` LEFT JOIN ( SELECT `b0`.`Id` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d2`.`Id` - FROM `DerivedEntities` AS `d2` -) AS `t1` ON `t0`.`BaseParentId` = `t1`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t1`.`Id` = `d`.`Id` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t1`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id` + FROM `DerivedEntities` AS `d0` +) AS `u1` ON `u0`.`BaseParentId` = `u1`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `u1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d2` ON `u1`.`Id` = `d2`.`Id` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d3` ON `u1`.`Id` = `d3`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` """); } @@ -2223,78 +2223,78 @@ public override async Task Nested_include_with_inheritance_collection_reference_ AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o`.`Id`, `o`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +ORDER BY `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `OwnedCollections` AS `o1` ON `u`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `t1`.`Id`, `t1`.`BaseParentId`, `t1`.`Name`, `t1`.`DerivedProperty`, `t1`.`Discriminator`, `t1`.`Id0`, `t1`.`Name0`, `t1`.`ParentCollectionId`, `t1`.`ParentReferenceId`, `t1`.`Discriminator0` AS `Discriminator`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `s`.`Id`, `s`.`BaseParentId`, `s`.`Name`, `s`.`DerivedProperty`, `s`.`Discriminator`, `s`.`Id0`, `s`.`Name0`, `s`.`ParentCollectionId`, `s`.`ParentReferenceId`, `s`.`Discriminator0` AS `Discriminator`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` INNER JOIN ( - SELECT `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`DerivedProperty`, `t0`.`Discriminator`, `t2`.`Id` AS `Id0`, `t2`.`Name` AS `Name0`, `t2`.`ParentCollectionId`, `t2`.`ParentReferenceId`, `t2`.`Discriminator` AS `Discriminator0` + SELECT `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`DerivedProperty`, `u0`.`Discriminator`, `u1`.`Id` AS `Id0`, `u1`.`Name` AS `Name0`, `u1`.`ParentCollectionId`, `u1`.`ParentReferenceId`, `u1`.`Discriminator` AS `Discriminator0` FROM ( SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b0` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, `d1`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` - FROM `DerivedCollectionsOnBase` AS `d1` - ) AS `t0` + SELECT `d3`.`Id`, `d3`.`BaseParentId`, `d3`.`Name`, `d3`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` + FROM `DerivedCollectionsOnBase` AS `d3` + ) AS `u0` LEFT JOIN ( SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedReferenceBase' AS `Discriminator` FROM `NestedReferences` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedReferenceDerived' AS `Discriminator` FROM `NestedReferencesDerived` AS `n0` - ) AS `t2` ON `t0`.`Id` = `t2`.`ParentCollectionId` -) AS `t1` ON `t`.`Id` = `t1`.`BaseParentId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + ) AS `u1` ON `u0`.`Id` = `u1`.`ParentCollectionId` +) AS `s` ON `u`.`Id` = `s`.`BaseParentId` +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """); } @@ -2304,89 +2304,89 @@ public override async Task Nested_include_with_inheritance_collection_reference_ AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`ParentCollectionId`, `t`.`ParentReferenceId`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`DerivedProperty`, `t0`.`Discriminator`, `t1`.`Id`, `t1`.`Name`, `t1`.`BaseId`, `t1`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`ParentCollectionId`, `u`.`ParentReferenceId`, `u`.`Discriminator`, `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`DerivedProperty`, `u0`.`Discriminator`, `u1`.`Id`, `u1`.`Name`, `u1`.`BaseId`, `u1`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o`.`Id`, `o`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedReferenceBase' AS `Discriminator` FROM `NestedReferences` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedReferenceDerived' AS `Discriminator` FROM `NestedReferencesDerived` AS `n0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, `d0`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` - FROM `DerivedCollectionsOnBase` AS `d0` -) AS `t0` ON `t`.`ParentCollectionId` = `t0`.`Id` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name`, `d`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u0` ON `u`.`ParentCollectionId` = `u0`.`Id` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t1` ON `t0`.`BaseParentId` = `t1`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t1`.`Id` = `d`.`Id` -ORDER BY `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d0` +) AS `u1` ON `u0`.`BaseParentId` = `u1`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u1`.`Id` = `d1`.`Id` +ORDER BY `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` FROM ( SELECT `n`.`Id`, `n`.`ParentCollectionId` FROM `NestedReferences` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`ParentCollectionId` FROM `NestedReferencesDerived` AS `n0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`BaseParentId` - FROM `DerivedCollectionsOnBase` AS `d0` -) AS `t0` ON `t`.`ParentCollectionId` = `t0`.`Id` + SELECT `d`.`Id`, `d`.`BaseParentId` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u0` ON `u`.`ParentCollectionId` = `u0`.`Id` LEFT JOIN ( SELECT `b0`.`Id` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d1`.`Id` - FROM `DerivedEntities` AS `d1` -) AS `t1` ON `t0`.`BaseParentId` = `t1`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t1`.`Id` = `d`.`Id` -INNER JOIN `OwnedCollections` AS `o0` ON `t1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id` + FROM `DerivedEntities` AS `d0` +) AS `u1` ON `u0`.`BaseParentId` = `u1`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `u1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d2` ON `u1`.`Id` = `d2`.`Id` +INNER JOIN `OwnedCollections` AS `o1` ON `u1`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d3`.`DerivedInheritanceRelationshipEntityId`, `d3`.`Id`, `d3`.`Name`, `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` FROM ( SELECT `n`.`Id`, `n`.`ParentCollectionId` FROM `NestedReferences` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`ParentCollectionId` FROM `NestedReferencesDerived` AS `n0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId` - FROM `DerivedCollectionsOnBase` AS `d1` -) AS `t0` ON `t`.`ParentCollectionId` = `t0`.`Id` + SELECT `d`.`Id`, `d`.`BaseParentId` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u0` ON `u`.`ParentCollectionId` = `u0`.`Id` LEFT JOIN ( SELECT `b0`.`Id` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d2`.`Id` - FROM `DerivedEntities` AS `d2` -) AS `t1` ON `t0`.`BaseParentId` = `t1`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t1`.`Id` = `d`.`Id` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t1`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id` + FROM `DerivedEntities` AS `d0` +) AS `u1` ON `u0`.`BaseParentId` = `u1`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `u1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d2` ON `u1`.`Id` = `d2`.`Id` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d3` ON `u1`.`Id` = `d3`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` """); } @@ -2396,96 +2396,96 @@ public override async Task Nested_include_with_inheritance_collection_collection AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o`.`Id`, `o`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +ORDER BY `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `OwnedCollections` AS `o1` ON `u`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`DerivedProperty`, `t0`.`Discriminator`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`DerivedProperty`, `u0`.`Discriminator`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` INNER JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b0` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId`, `d1`.`Name`, `d1`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` - FROM `DerivedCollectionsOnBase` AS `d1` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `t0`.`Id` + SELECT `d3`.`Id`, `d3`.`BaseParentId`, `d3`.`Name`, `d3`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` + FROM `DerivedCollectionsOnBase` AS `d3` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `u0`.`Id` """, // """ -SELECT `t1`.`Id`, `t1`.`Name`, `t1`.`ParentCollectionId`, `t1`.`ParentReferenceId`, `t1`.`Discriminator`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `t0`.`Id` +SELECT `u1`.`Id`, `u1`.`Name`, `u1`.`ParentCollectionId`, `u1`.`ParentReferenceId`, `u1`.`Discriminator`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `u0`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` INNER JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId` FROM `BaseCollectionsOnBase` AS `b0` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId` - FROM `DerivedCollectionsOnBase` AS `d1` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` + SELECT `d3`.`Id`, `d3`.`BaseParentId` + FROM `DerivedCollectionsOnBase` AS `d3` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` INNER JOIN ( SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedCollectionBase' AS `Discriminator` FROM `NestedCollections` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedCollectionDerived' AS `Discriminator` FROM `NestedCollectionsDerived` AS `n0` -) AS `t1` ON `t0`.`Id` = `t1`.`ParentCollectionId` -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `t0`.`Id` +) AS `u1` ON `u0`.`Id` = `u1`.`ParentCollectionId` +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `u0`.`Id` """); } @@ -2495,89 +2495,89 @@ public override async Task Nested_include_with_inheritance_collection_collection AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`ParentCollectionId`, `t`.`ParentReferenceId`, `t`.`Discriminator`, `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`DerivedProperty`, `t0`.`Discriminator`, `t1`.`Id`, `t1`.`Name`, `t1`.`BaseId`, `t1`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`ParentCollectionId`, `u`.`ParentReferenceId`, `u`.`Discriminator`, `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`DerivedProperty`, `u0`.`Discriminator`, `u1`.`Id`, `u1`.`Name`, `u1`.`BaseId`, `u1`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id`, `o`.`Id`, `o`.`Name`, `d1`.`OwnedReferenceOnDerived_Id`, `d1`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `n`.`Id`, `n`.`Name`, `n`.`ParentCollectionId`, `n`.`ParentReferenceId`, 'NestedCollectionBase' AS `Discriminator` FROM `NestedCollections` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`Name`, `n0`.`ParentCollectionId`, `n0`.`ParentReferenceId`, 'NestedCollectionDerived' AS `Discriminator` FROM `NestedCollectionsDerived` AS `n0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId`, `b`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, `d0`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` - FROM `DerivedCollectionsOnBase` AS `d0` -) AS `t0` ON `t`.`ParentCollectionId` = `t0`.`Id` + SELECT `d`.`Id`, `d`.`BaseParentId`, `d`.`Name`, `d`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u0` ON `u`.`ParentCollectionId` = `u0`.`Id` LEFT JOIN ( SELECT `b0`.`Id`, `b0`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d1`.`Id`, `d1`.`Name`, `d1`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d1` -) AS `t1` ON `t0`.`BaseParentId` = `t1`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t1`.`Id` = `d`.`Id` -ORDER BY `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d0` +) AS `u1` ON `u0`.`BaseParentId` = `u1`.`Id` +LEFT JOIN `OwnedReferences` AS `o` ON `u1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u1`.`Id` = `d1`.`Id` +ORDER BY `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` FROM ( SELECT `n`.`Id`, `n`.`ParentCollectionId` FROM `NestedCollections` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`ParentCollectionId` FROM `NestedCollectionsDerived` AS `n0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`BaseParentId` - FROM `DerivedCollectionsOnBase` AS `d0` -) AS `t0` ON `t`.`ParentCollectionId` = `t0`.`Id` + SELECT `d`.`Id`, `d`.`BaseParentId` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u0` ON `u`.`ParentCollectionId` = `u0`.`Id` LEFT JOIN ( SELECT `b0`.`Id` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d1`.`Id` - FROM `DerivedEntities` AS `d1` -) AS `t1` ON `t0`.`BaseParentId` = `t1`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t1`.`Id` = `d`.`Id` -INNER JOIN `OwnedCollections` AS `o0` ON `t1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id` + FROM `DerivedEntities` AS `d0` +) AS `u1` ON `u0`.`BaseParentId` = `u1`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `u1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d2` ON `u1`.`Id` = `d2`.`Id` +INNER JOIN `OwnedCollections` AS `o1` ON `u1`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d3`.`DerivedInheritanceRelationshipEntityId`, `d3`.`Id`, `d3`.`Name`, `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` FROM ( SELECT `n`.`Id`, `n`.`ParentCollectionId` FROM `NestedCollections` AS `n` UNION ALL SELECT `n0`.`Id`, `n0`.`ParentCollectionId` FROM `NestedCollectionsDerived` AS `n0` -) AS `t` +) AS `u` LEFT JOIN ( SELECT `b`.`Id`, `b`.`BaseParentId` FROM `BaseCollectionsOnBase` AS `b` UNION ALL - SELECT `d1`.`Id`, `d1`.`BaseParentId` - FROM `DerivedCollectionsOnBase` AS `d1` -) AS `t0` ON `t`.`ParentCollectionId` = `t0`.`Id` + SELECT `d`.`Id`, `d`.`BaseParentId` + FROM `DerivedCollectionsOnBase` AS `d` +) AS `u0` ON `u`.`ParentCollectionId` = `u0`.`Id` LEFT JOIN ( SELECT `b0`.`Id` FROM `BaseEntities` AS `b0` UNION ALL - SELECT `d2`.`Id` - FROM `DerivedEntities` AS `d2` -) AS `t1` ON `t0`.`BaseParentId` = `t1`.`Id` -LEFT JOIN `OwnedReferences` AS `o` ON `t1`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t1`.`Id` = `d`.`Id` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t1`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -ORDER BY `t`.`Id`, `t0`.`Id`, `t1`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d0`.`Id` + FROM `DerivedEntities` AS `d0` +) AS `u1` ON `u0`.`BaseParentId` = `u1`.`Id` +LEFT JOIN `OwnedReferences` AS `o0` ON `u1`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d2` ON `u1`.`Id` = `d2`.`Id` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d3` ON `u1`.`Id` = `d3`.`DerivedInheritanceRelationshipEntityId` +ORDER BY `u`.`Id`, `u0`.`Id`, `u1`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d2`.`Id` """); } @@ -2593,13 +2593,13 @@ ORDER BY `r`.`Id` """, // """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`ReferenceId`, `t`.`ReferencedEntityId`, `t`.`Id0`, `t`.`Name0`, `r`.`Id` +SELECT `s`.`Id`, `s`.`Name`, `s`.`ReferenceId`, `s`.`ReferencedEntityId`, `s`.`Id0`, `s`.`Name0`, `r`.`Id` FROM `ReferencedEntities` AS `r` INNER JOIN ( SELECT `p`.`Id`, `p`.`Name`, `p`.`ReferenceId`, `p`.`ReferencedEntityId`, `r0`.`Id` AS `Id0`, `r0`.`Name` AS `Name0` FROM `PrincipalEntities` AS `p` LEFT JOIN `ReferencedEntities` AS `r0` ON `p`.`ReferenceId` = `r0`.`Id` -) AS `t` ON `r`.`Id` = `t`.`ReferencedEntityId` +) AS `s` ON `r`.`Id` = `s`.`ReferencedEntityId` ORDER BY `r`.`Id` """); } @@ -2610,34 +2610,34 @@ public override async Task Collection_projection_on_base_type_split(bool async) AssertSql( """ -SELECT `t`.`Id` +SELECT `u`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL SELECT `d`.`Id` FROM `DerivedEntities` AS `d` -) AS `t` -ORDER BY `t`.`Id` +) AS `u` +ORDER BY `u`.`Id` """, // """ -SELECT `t0`.`Id`, `t0`.`BaseParentId`, `t0`.`Name`, `t0`.`DerivedProperty`, `t0`.`Discriminator`, `t`.`Id` +SELECT `u0`.`Id`, `u0`.`BaseParentId`, `u0`.`Name`, `u0`.`DerivedProperty`, `u0`.`Discriminator`, `u`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL SELECT `d`.`Id` FROM `DerivedEntities` AS `d` -) AS `t` +) AS `u` INNER JOIN ( SELECT `b0`.`Id`, `b0`.`BaseParentId`, `b0`.`Name`, NULL AS `DerivedProperty`, 'BaseCollectionOnBase' AS `Discriminator` FROM `BaseCollectionsOnBase` AS `b0` UNION ALL SELECT `d0`.`Id`, `d0`.`BaseParentId`, `d0`.`Name`, `d0`.`DerivedProperty`, 'DerivedCollectionOnBase' AS `Discriminator` FROM `DerivedCollectionsOnBase` AS `d0` -) AS `t0` ON `t`.`Id` = `t0`.`BaseParentId` -ORDER BY `t`.`Id` +) AS `u0` ON `u`.`Id` = `u0`.`BaseParentId` +ORDER BY `u`.`Id` """); } @@ -2647,66 +2647,66 @@ public override async Task Include_on_derived_type_with_queryable_Cast_split(boo AssertSql( """ -SELECT `t`.`Id`, `t`.`Name`, `t`.`BaseId`, `t`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id`, `o`.`Id`, `o`.`Name`, `d`.`OwnedReferenceOnDerived_Id`, `d`.`OwnedReferenceOnDerived_Name` +SELECT `u`.`Id`, `u`.`Name`, `u`.`BaseId`, `u`.`Discriminator`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id`, `o`.`Id`, `o`.`Name`, `d0`.`OwnedReferenceOnDerived_Id`, `d0`.`OwnedReferenceOnDerived_Name` FROM ( SELECT `b`.`Id`, `b`.`Name`, NULL AS `BaseId`, 'BaseInheritanceRelationshipEntity' AS `Discriminator` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -WHERE `t`.`Id` >= 4 -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id`, `d`.`Name`, `d`.`BaseId`, 'DerivedInheritanceRelationshipEntity' AS `Discriminator` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o` ON `u`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d0` ON `u`.`Id` = `d0`.`Id` +WHERE `u`.`Id` >= 4 +ORDER BY `u`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d0`.`Id` """, // """ -SELECT `o0`.`BaseInheritanceRelationshipEntityId`, `o0`.`Id`, `o0`.`Name`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `o1`.`BaseInheritanceRelationshipEntityId`, `o1`.`Id`, `o1`.`Name`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d0`.`Id` - FROM `DerivedEntities` AS `d0` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `OwnedCollections` AS `o0` ON `t`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` -WHERE `t`.`Id` >= 4 -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `OwnedCollections` AS `o1` ON `u`.`Id` = `o1`.`BaseInheritanceRelationshipEntityId` +WHERE `u`.`Id` >= 4 +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `d0`.`DerivedInheritanceRelationshipEntityId`, `d0`.`Id`, `d0`.`Name`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d2`.`DerivedInheritanceRelationshipEntityId`, `d2`.`Id`, `d2`.`Name`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -WHERE `t`.`Id` >= 4 -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `DerivedEntities_OwnedCollectionOnDerived` AS `d2` ON `u`.`Id` = `d2`.`DerivedInheritanceRelationshipEntityId` +WHERE `u`.`Id` >= 4 +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """, // """ -SELECT `d0`.`Id`, `d0`.`Name`, `d0`.`ParentId`, `d0`.`DerivedInheritanceRelationshipEntityId`, `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` +SELECT `d3`.`Id`, `d3`.`Name`, `d3`.`ParentId`, `d3`.`DerivedInheritanceRelationshipEntityId`, `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` FROM ( SELECT `b`.`Id` FROM `BaseEntities` AS `b` UNION ALL - SELECT `d1`.`Id` - FROM `DerivedEntities` AS `d1` -) AS `t` -LEFT JOIN `OwnedReferences` AS `o` ON `t`.`Id` = `o`.`BaseInheritanceRelationshipEntityId` -LEFT JOIN `DerivedEntities` AS `d` ON `t`.`Id` = `d`.`Id` -INNER JOIN `DerivedCollectionsOnDerived` AS `d0` ON `t`.`Id` = `d0`.`DerivedInheritanceRelationshipEntityId` -WHERE `t`.`Id` >= 4 -ORDER BY `t`.`Id`, `o`.`BaseInheritanceRelationshipEntityId`, `d`.`Id` + SELECT `d`.`Id` + FROM `DerivedEntities` AS `d` +) AS `u` +LEFT JOIN `OwnedReferences` AS `o0` ON `u`.`Id` = `o0`.`BaseInheritanceRelationshipEntityId` +LEFT JOIN `DerivedEntities` AS `d1` ON `u`.`Id` = `d1`.`Id` +INNER JOIN `DerivedCollectionsOnDerived` AS `d3` ON `u`.`Id` = `d3`.`DerivedInheritanceRelationshipEntityId` +WHERE `u`.`Id` >= 4 +ORDER BY `u`.`Id`, `o0`.`BaseInheritanceRelationshipEntityId`, `d1`.`Id` """); } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/TPHInheritanceQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/TPHInheritanceQuerySingleStoreTest.cs index e89cc2ac5..88b6af530 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/TPHInheritanceQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/TPHInheritanceQuerySingleStoreTest.cs @@ -14,9 +14,9 @@ public TPHInheritanceQuerySingleStoreTest(TPHInheritanceQuerySingleStoreFixture } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Setting_foreign_key_to_a_different_type_throws() + public override Task Setting_foreign_key_to_a_different_type_throws() { - base.Setting_foreign_key_to_a_different_type_throws(); + return base.Setting_foreign_key_to_a_different_type_throws(); } [ConditionalTheory] @@ -34,15 +34,15 @@ public override Task Can_include_prey(bool async) } [ConditionalFact] - public override void Can_insert_update_delete() + public override Task Can_insert_update_delete() { // Skipping this test when running on Managed Service due to the specifics of // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) if (AppConfig.ManagedService) { - return; + return Task.CompletedTask; } - base.Can_insert_update_delete(); + return base.Can_insert_update_delete(); } } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/TPTGearsOfWarQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/TPTGearsOfWarQuerySingleStoreTest.cs index 1169f7e96..3c22378fe 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/TPTGearsOfWarQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/TPTGearsOfWarQuerySingleStoreTest.cs @@ -24,9 +24,6 @@ public TPTGearsOfWarQuerySingleStoreTest(TPTGearsOfWarQuerySingleStoreFixture fi //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - protected override bool CanExecuteQueryString - => true; - public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) { var dto = SingleStoreTestHelpers.GetExpectedValue(new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0))); @@ -517,7 +514,7 @@ await AssertQuery( AssertSql( """ - SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` + SELECT `m`.`Id`, `m`.`CodeName`, `m`.`Date`, `m`.`Difficulty`, `m`.`Duration`, `m`.`Rating`, `m`.`Time`, `m`.`Timeline` FROM `Missions` AS `m` WHERE EXTRACT(hour FROM `m`.`Timeline`) = 8 """); @@ -535,6 +532,13 @@ public override async Task Nav_expansion_with_member_pushdown_inside_Contains_ar await base.Nav_expansion_with_member_pushdown_inside_Contains_argument(async); } + // TODO: Implement once TimeSpan is translated as ticks instead of TIME. + public override async Task Non_string_concat_uses_appropriate_type_mapping(bool async) + { + var exception = await Assert.ThrowsAsync(() => base.Non_string_concat_uses_appropriate_type_mapping(async)); + Assert.Equal("Unable to cast object of type 'System.Byte[]' to type 'System.TimeSpan'.", exception.Message); + } + private string AssertSql(string expected) { Fixture.TestSqlLoggerFactory.AssertBaseline(new[] {expected}); diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/TPTInheritanceQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/TPTInheritanceQuerySingleStoreTest.cs index ce8b3bc30..5594d48d8 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/TPTInheritanceQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/TPTInheritanceQuerySingleStoreTest.cs @@ -21,9 +21,9 @@ public TPTInheritanceQuerySingleStoreTest( } [ConditionalFact(Skip = "Feature 'FOREIGN KEY' is not supported by SingleStore Distributed.")] - public override void Setting_foreign_key_to_a_different_type_throws() + public override Task Setting_foreign_key_to_a_different_type_throws() { - base.Setting_foreign_key_to_a_different_type_throws(); + return base.Setting_foreign_key_to_a_different_type_throws(); } [ConditionalTheory] @@ -196,16 +196,16 @@ public override Task Can_include_prey(bool async) } [ConditionalFact] - public override void Can_insert_update_delete() + public override Task Can_insert_update_delete() { // Skipping this test when running on Managed Service due to the specifics of // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) if (AppConfig.ManagedService) { - return; + return Task.CompletedTask; } - base.Can_insert_update_delete(); + return base.Can_insert_update_delete(); } [ConditionalTheory] @@ -378,16 +378,16 @@ public override Task Is_operator_on_result_of_FirstOrDefault(bool async) } [ConditionalFact] - public override void Member_access_on_intermediate_type_works() + public override Task Member_access_on_intermediate_type_works() { // Skipping this test when running on Managed Service due to the specifics of // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) if (AppConfig.ManagedService) { - return; + return Task.CompletedTask; } - base.Member_access_on_intermediate_type_works(); + return base.Member_access_on_intermediate_type_works(); } [ConditionalTheory] diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySingleStoreTest.cs index 38351680a..5356c211d 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/TPTManyToManyNoTrackingQuerySingleStoreTest.cs @@ -12,8 +12,5 @@ public TPTManyToManyNoTrackingQuerySingleStoreTest(TPTManyToManyQuerySingleStore Fixture.TestSqlLoggerFactory.Clear(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - - protected override bool CanExecuteQueryString - => true; } } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/TPTManyToManyQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/TPTManyToManyQuerySingleStoreTest.cs index 20e0958c2..d70a58419 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/TPTManyToManyQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/TPTManyToManyQuerySingleStoreTest.cs @@ -12,8 +12,5 @@ public TPTManyToManyQuerySingleStoreTest(TPTManyToManyQuerySingleStoreFixture fi Fixture.TestSqlLoggerFactory.Clear(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - - protected override bool CanExecuteQueryString - => true; } } diff --git a/test/EFCore.SingleStore.FunctionalTests/Query/ToSqlQuerySingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Query/ToSqlQuerySingleStoreTest.cs index 2142f1686..b9ac92f2a 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Query/ToSqlQuerySingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Query/ToSqlQuerySingleStoreTest.cs @@ -13,7 +13,7 @@ protected override ITestStoreFactory TestStoreFactory [ConditionalFact] public virtual void Check_all_tests_overridden() - => TestHelpers.AssertAllMethodsOverridden(GetType()); + => SingleStoreTestHelpers.AssertAllMethodsOverridden(GetType()); public override async Task Entity_type_with_navigation_mapped_to_SqlQuery(bool async) { diff --git a/test/EFCore.SingleStore.FunctionalTests/Scaffolding/CompiledModelSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Scaffolding/CompiledModelSingleStoreTest.cs new file mode 100644 index 000000000..a901d7fda --- /dev/null +++ b/test/EFCore.SingleStore.FunctionalTests/Scaffolding/CompiledModelSingleStoreTest.cs @@ -0,0 +1,396 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// ReSharper disable InconsistentNaming + +#nullable enable + +using System; +using System.Runtime.CompilerServices; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ChangeTracking; +using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using Microsoft.EntityFrameworkCore.Scaffolding; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Microsoft.Extensions.DependencyInjection; +using NetTopologySuite.Geometries; +using NetTopologySuite; +using EntityFrameworkCore.SingleStore.Design.Internal; +using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; +using EntityFrameworkCore.SingleStore.Infrastructure; +using EntityFrameworkCore.SingleStore.Internal; +using Xunit; + +namespace EntityFrameworkCore.SingleStore.FunctionalTests.Scaffolding; + +// TODO: Add more Pomelo specific cases. +public class CompiledModelSingleStoreTest : CompiledModelRelationalTestBase +{ + protected override void BuildBigModel(ModelBuilder modelBuilder, bool jsonColumns) + { + base.BuildBigModel(modelBuilder, jsonColumns); + + modelBuilder.HasCharSet("latin1"); + modelBuilder.UseCollation("latin1_general_ci"); + + modelBuilder.Entity( + eb => + { + eb.HasCharSet("cp1250"); + + eb.Property("Id"); + eb.HasKey("Id"); + + eb.Property("Point") + .HasSpatialReferenceSystem(4326); + + eb.Property("StringWithCharSet") + .HasColumnType("varchar(128)") + .HasDefaultValue("String having charset") + .HasCharSet("ascii") + .HasConversion, CustomValueComparer, CustomValueComparer>(); + + eb.Property("StringWithCollation") + .HasColumnType("varchar(128)") + .HasDefaultValue("String using collation") + .UseCollation("cp1250_general_ci") + .HasConversion, CustomValueComparer, CustomValueComparer>(); + }); + + modelBuilder.Entity( + eb => + { + eb.UseCollation("ascii_general_ci"); + + eb.Property("StringWithCharSet") + .HasColumnType("varchar(128)") + .HasDefaultValue("String having charset") + .HasCharSet("ascii") + .HasConversion, CustomValueComparer, CustomValueComparer>(); + + eb.Property("StringWithCollation") + .HasColumnType("varchar(128)") + .HasDefaultValue("String using collation") + .UseCollation("cp1250_general_ci") + .HasConversion, CustomValueComparer, CustomValueComparer>(); + + eb.Property("Point") + .HasColumnType("geometry") + .HasDefaultValue( + NtsGeometryServices.Instance.CreateGeometryFactory(srid: 0).CreatePoint(new CoordinateZM(0, 0, 0, 0))) + .HasConversion, CustomValueComparer, CustomValueComparer>(); + }); + } + + protected override void AssertBigModel(IModel model, bool jsonColumns) + { + base.AssertBigModel(model, jsonColumns); + + Assert.Equal( + CoreStrings.RuntimeModelMissingData, + Assert.Throws(model.GetCharSet).Message); + Assert.Equal( + CoreStrings.RuntimeModelMissingData, + Assert.Throws(() => model.GetCharSetDelegation()).Message); + Assert.Equal( + CoreStrings.RuntimeModelMissingData, + Assert.Throws(model.GetCollation).Message); + Assert.Equal( + CoreStrings.RuntimeModelMissingData, + Assert.Throws(() => model.GetCollationDelegation()).Message); + + // + // Data: + // + { + var dataEntity = model.FindEntityType(typeof(Data))!; + Assert.Equal(typeof(Data).FullName, dataEntity.Name); + Assert.False(dataEntity.HasSharedClrType); + Assert.False(dataEntity.IsPropertyBag); + Assert.False(dataEntity.IsOwned()); + Assert.IsType(dataEntity.ConstructorBinding); + Assert.Null(dataEntity.FindIndexerPropertyInfo()); + Assert.Equal(ChangeTrackingStrategy.Snapshot, dataEntity.GetChangeTrackingStrategy()); + Assert.Equal("Data", dataEntity.GetTableName()); + Assert.Null(dataEntity.GetSchema()); + Assert.Equal( + CoreStrings.RuntimeModelMissingData, + Assert.Throws(dataEntity.GetCharSet).Message); + Assert.Equal( + CoreStrings.RuntimeModelMissingData, + Assert.Throws(() => dataEntity.GetCharSetDelegation()).Message); + + var pointProperty = dataEntity.FindProperty("Point")!; + Assert.Equal(typeof(Point), pointProperty.ClrType); + Assert.True(pointProperty.IsNullable); + Assert.Equal(ValueGenerated.Never, pointProperty.ValueGenerated); + Assert.Equal("Point", pointProperty.GetColumnName()); + Assert.Equal("point", pointProperty.GetColumnType()); + Assert.Null(pointProperty.GetValueConverter()); + Assert.IsType>(pointProperty.GetValueComparer()); + Assert.IsType>(pointProperty.GetKeyValueComparer()); + Assert.Equal( + CoreStrings.RuntimeModelMissingData, + Assert.Throws(() => pointProperty.GetSpatialReferenceSystem()).Message); + + var stringWithCharSetProperty = dataEntity.FindProperty("StringWithCharSet")!; + Assert.Equal(typeof(string), stringWithCharSetProperty.ClrType); + Assert.True(stringWithCharSetProperty.IsNullable); + Assert.Equal(ValueGenerated.OnAdd, stringWithCharSetProperty.ValueGenerated); + Assert.Equal("StringWithCharSet", stringWithCharSetProperty.GetColumnName()); + Assert.Equal("varchar(128)", stringWithCharSetProperty.GetColumnType()); + Assert.Equal("String having charset", (string?)stringWithCharSetProperty.GetDefaultValue()); + Assert.IsType>(stringWithCharSetProperty.GetValueConverter()); + Assert.IsType>(stringWithCharSetProperty.GetValueComparer()); + Assert.IsType>(stringWithCharSetProperty.GetKeyValueComparer()); + Assert.IsType>(stringWithCharSetProperty.GetProviderValueComparer()); + Assert.Null(stringWithCharSetProperty[CoreAnnotationNames.PropertyAccessMode]); + Assert.Equal( + CoreStrings.RuntimeModelMissingData, + Assert.Throws(stringWithCharSetProperty.GetCharSet).Message); + + var stringWithCollationProperty = dataEntity.FindProperty("StringWithCollation")!; + Assert.Equal(typeof(string), stringWithCollationProperty.ClrType); + Assert.True(stringWithCollationProperty.IsNullable); + Assert.Equal(ValueGenerated.OnAdd, stringWithCollationProperty.ValueGenerated); + Assert.Equal("StringWithCollation", stringWithCollationProperty.GetColumnName()); + Assert.Equal("varchar(128)", stringWithCollationProperty.GetColumnType()); + Assert.Equal("String using collation", (string?)stringWithCollationProperty.GetDefaultValue()); + Assert.IsType>(stringWithCollationProperty.GetValueConverter()); + Assert.IsType>(stringWithCollationProperty.GetValueComparer()); + Assert.IsType>(stringWithCollationProperty.GetKeyValueComparer()); + Assert.IsType>(stringWithCollationProperty.GetProviderValueComparer()); + Assert.Null(stringWithCollationProperty[CoreAnnotationNames.PropertyAccessMode]); + Assert.Equal( + CoreStrings.RuntimeModelMissingData, + Assert.Throws(stringWithCollationProperty.GetCollation).Message); + } + + // + // PrincipalBase: + // + { + var principalBaseEntity = model.FindEntityType(typeof(PrincipalBase))!; + Assert.Equal( + CoreStrings.RuntimeModelMissingData, + Assert.Throws(principalBaseEntity.GetCollation).Message); + Assert.Equal( + CoreStrings.RuntimeModelMissingData, + Assert.Throws(() => principalBaseEntity.GetCollationDelegation()).Message); + + var pointProperty = principalBaseEntity.FindProperty("Point")!; + Assert.Equal(typeof(Point), pointProperty.ClrType); + Assert.True(pointProperty.IsNullable); + Assert.Equal(ValueGenerated.OnAdd, pointProperty.ValueGenerated); + Assert.Equal("Point", pointProperty.GetColumnName()); + Assert.Equal("geometry", pointProperty.GetColumnType()); + Assert.Equal(0, ((Point)pointProperty.GetDefaultValue()!).SRID); + Assert.IsType>(pointProperty.GetValueConverter()); + Assert.IsType>(pointProperty.GetValueComparer()); + Assert.IsType>(pointProperty.GetKeyValueComparer()); + Assert.IsType>(pointProperty.GetProviderValueComparer()); + Assert.Null(pointProperty[CoreAnnotationNames.PropertyAccessMode]); + + var stringWithCharSetProperty = principalBaseEntity.FindProperty("StringWithCharSet")!; + Assert.Equal(typeof(string), stringWithCharSetProperty.ClrType); + Assert.True(stringWithCharSetProperty.IsNullable); + Assert.Equal(ValueGenerated.OnAdd, stringWithCharSetProperty.ValueGenerated); + Assert.Equal("StringWithCharSet", stringWithCharSetProperty.GetColumnName()); + Assert.Equal("varchar(128)", stringWithCharSetProperty.GetColumnType()); + Assert.Equal("String having charset", (string?)stringWithCharSetProperty.GetDefaultValue()); + Assert.IsType>(stringWithCharSetProperty.GetValueConverter()); + Assert.IsType>(stringWithCharSetProperty.GetValueComparer()); + Assert.IsType>(stringWithCharSetProperty.GetKeyValueComparer()); + Assert.IsType>(stringWithCharSetProperty.GetProviderValueComparer()); + Assert.Null(stringWithCharSetProperty[CoreAnnotationNames.PropertyAccessMode]); + Assert.Equal( + CoreStrings.RuntimeModelMissingData, + Assert.Throws(stringWithCharSetProperty.GetCharSet).Message); + + var stringWithCollationProperty = principalBaseEntity.FindProperty("StringWithCollation")!; + Assert.Equal(typeof(string), stringWithCollationProperty.ClrType); + Assert.True(stringWithCollationProperty.IsNullable); + Assert.Equal(ValueGenerated.OnAdd, stringWithCollationProperty.ValueGenerated); + Assert.Equal("StringWithCollation", stringWithCollationProperty.GetColumnName()); + Assert.Equal("varchar(128)", stringWithCollationProperty.GetColumnType()); + Assert.Equal("String using collation", (string?)stringWithCollationProperty.GetDefaultValue()); + Assert.IsType>(stringWithCollationProperty.GetValueConverter()); + Assert.IsType>(stringWithCollationProperty.GetValueComparer()); + Assert.IsType>(stringWithCollationProperty.GetKeyValueComparer()); + Assert.IsType>(stringWithCollationProperty.GetProviderValueComparer()); + Assert.Null(stringWithCollationProperty[CoreAnnotationNames.PropertyAccessMode]); + Assert.Equal( + CoreStrings.RuntimeModelMissingData, + Assert.Throws(stringWithCollationProperty.GetCollation).Message); + } + } + + // TODO: 9.0 + // Check if we can use `UseSprocReturnValue` now. + public override Task Tpc_Sprocs() + { + // The CompiledModelRelationalTestBase implementation uses stored procedures with return values and result columns, which are not + // supported in MySQL. + // We either need to change the model by overriding `BuildTcpModel` (not an issue) and then fully override the very long `AssertTcp` + // method (possible maintenance issue, because the class is likely to have a higher volatility), or we need to skip the stored procedure + // validation to allow the unsupported stored procedure features. + // We do the latter here. + return Test( + BuildTpcSprocsModel, + AssertTpcSprocs, + options: new CompiledModelCodeGenerationOptions { UseNullableReferenceTypes = true, ForNativeAot = true }, + addServices: s => s.AddSingleton()); + } + + // protected override void BuildTpcModel(ModelBuilder modelBuilder) + // { + // base.BuildTpcModel(modelBuilder); + // + // modelBuilder.Entity( + // eb => + // { + // // The base implementation uses `HasRowsAffectedReturnValue` which is not supported by MySQL. + // // We use a parameter instead. + // new StoredProcedureBuilder(eb.Metadata.GetDeleteStoredProcedure()!, eb) + // .HasRowsAffectedReturnValue(false) + // .HasRowsAffectedParameter( + // p => p.HasName("RowsAffected")); + // }); + // + // modelBuilder.Entity>>( + // eb => + // { + // // The base implementation uses `HasResultColumn` which is not supported by MySQL. + // // We use an output parameter instead. + // var originalInsertStoredProcedure = eb.Metadata.RemoveInsertStoredProcedure()!; + // eb.InsertUsingStoredProcedure( + // "Derived_Insert", + // s => + // { + // foreach (var parameter in originalInsertStoredProcedure.Parameters) + // { + // s.HasParameter(parameter.PropertyName!); + // } + // + // s.HasParameter( + // p => p.Enum1, + // pb => pb + // .HasName("DerivedEnum") + // .HasAnnotation("foo", "bar3") + // .IsOutput()); + // }); + // }); + // } + + // public override void ComplexTypes() + // => Test( + // BuildComplexTypesModel, + // AssertComplexTypes, + // c => + // { + // c.Set>>().Add( + // new PrincipalDerived> + // { + // Id = 1, + // AlternateId = new Guid(), + // Dependent = new DependentBase(1), + // Owned = new OwnedType(c) { Principal = new PrincipalBase() } + // }); + // + // //c.SaveChanges(); + // }, + // options: new CompiledModelCodeGenerationOptions { UseNullableReferenceTypes = true }, + // addServices: s => s.AddSingleton()); + + protected override void BuildComplexTypesModel(ModelBuilder modelBuilder) + { + base.BuildComplexTypesModel(modelBuilder); + + // For some reason, the AssertComplexTypes base implementation expects the schema of the `PrincipalBaseTvf` db function to be `dbo`. + // We therefore just set the default schema here to `dbo`, which works. + modelBuilder.HasDefaultSchema("dbo"); + + modelBuilder.Entity( + eb => + { + // The base implementation uses `HasRowsAffectedReturnValue` which is not supported by MySQL. + // We use a parameter instead. + new StoredProcedureBuilder(eb.Metadata.GetDeleteStoredProcedure()!, eb) + .HasRowsAffectedReturnValue(false) + .HasRowsAffectedParameter( + p => p.HasName("RowsAffected")); + }); + } + + public override async Task BigModel_with_JSON_columns() + { + Assert.Equal( + SingleStoreStrings.Ef7CoreJsonMappingNotSupported, + (await Assert.ThrowsAsync(() => base.BigModel_with_JSON_columns())).Message); + } + + // TODO: 9.0 + // Check, if we can make this work. + public override async Task ComplexTypes() + { + var exception = await Assert.ThrowsAsync(() => base.ComplexTypes()); + Assert.Equal("The stored procedure 'dbo.PrincipalBase_Delete' cannot be configured to return the rows affected because a rows affected parameter or a rows affected result column for this stored procedure already exists.", exception.Message); + } + + protected override TestHelpers TestHelpers => SingleStoreTestHelpers.Instance; + protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; + + protected override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) + { + builder = base.AddOptions(builder); + + new SingleStoreDbContextOptionsBuilder(builder) + .UseNetTopologySuite() + .SchemaBehavior(SingleStoreSchemaBehavior.Ignore); + + return builder; + } + + protected override void AddDesignTimeServices(IServiceCollection services) + => new SingleStoreNetTopologySuiteDesignTimeServices().ConfigureDesignTimeServices(services); + + protected override BuildSource AddReferences(BuildSource build, [CallerFilePath] string filePath = "") + { + base.AddReferences(build); + build.References.Add(BuildReference.ByName("EntityFrameworkCore.SingleStore")); + build.References.Add(BuildReference.ByName("EntityFrameworkCore.SingleStore.NetTopologySuite")); + build.References.Add(BuildReference.ByName("NetTopologySuite")); + return build; + } + + // The CompiledModelRelationalTestBase implementation uses stored procedures with return values and result columns, which are not + // supported in MySQL. + // We either need to change the model by overriding `BuildTcpModel` (not an issue) and then fully override the very long `AssertTcp` + // method (possible maintenance issue, because the class is likely to have a higher volatility), or we need to skip the stored procedure + // validation to allow the unsupported stored procedure features. + // We do the latter here. + public class StoredProcedureValidationExceptionIgnoringSingleStoreModelValidator( + ModelValidatorDependencies dependencies, + RelationalModelValidatorDependencies relationalDependencies) + : SingleStoreModelValidator(dependencies, relationalDependencies) + { + protected override void ValidateStoredProcedures(IModel model, IDiagnosticsLogger logger) + { + try + { + base.ValidateStoredProcedures(model, logger); + } + catch (InvalidOperationException e) when (Regex.IsMatch(e.Message, Regex.Escape(SingleStoreStrings.StoredProcedureResultColumnsNotSupported("::::", "::::")).Replace("::::", ".*")) || + Regex.IsMatch(e.Message, Regex.Escape(SingleStoreStrings.StoredProcedureReturnValueNotSupported("::::", "::::")).Replace("::::", ".*"))) + { + } + } + } +} diff --git a/test/EFCore.SingleStore.FunctionalTests/Scaffolding/SingleStoreDatabaseModelFactoryTest.cs b/test/EFCore.SingleStore.FunctionalTests/Scaffolding/SingleStoreDatabaseModelFactoryTest.cs index ecfecc0c7..2f658f0a7 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Scaffolding/SingleStoreDatabaseModelFactoryTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Scaffolding/SingleStoreDatabaseModelFactoryTest.cs @@ -116,7 +116,7 @@ public void Filter_tables_is_case_insensitive() #region Table - [Fact] + [Fact(Skip = "Issue #582")] public void Create_tables() { Test( @@ -137,7 +137,7 @@ public void Create_tables() DROP TABLE IF EXISTS Denali;"); } - [Fact(Skip = "SingleStore supports COLLATE cause only for columns, not tables.")] + [Fact] public void Create_table_with_collation() { Test( @@ -165,7 +165,7 @@ public void Create_table_with_collation() DROP TABLE IF EXISTS `Mountains`;"); } - [Fact] + [Fact(Skip = "Issue #582")] public void Create_columns() { Test( @@ -190,7 +190,7 @@ Name text NOT NULL @"DROP TABLE IF EXISTS MountainsColumns;"); } - [Fact] + [Fact(Skip = "Issue #582")] public void Create_primary_key() { Test( @@ -232,7 +232,7 @@ Location int @"DROP TABLE IF EXISTS Place;"); } - [Fact] + [Fact(Skip = "Issue #582")] public void Create_indexes() { Test( @@ -308,7 +308,7 @@ FOREIGN KEY (Id) REFERENCES PrincipalTable(Id) ON DELETE NO ACTION DROP TABLE IF EXISTS PrincipalTable;"); } - [Fact(Skip = "Feature 'FOREIGN KEY on COLUMNAR table' is not supported by SingleStore.")] + [Fact] public void Create_dependent_table_with_missing_principal_table_creates_model_without_it() { Test( @@ -382,7 +382,7 @@ public void Create_json_column() DROP TABLE IF EXISTS `PlaceDetails`;"); } - [ConditionalFact(Skip = "BLOB/TEXT columns can't have a default value in SingleStore.")] + [ConditionalFact] [SupportedServerVersionCondition(nameof(ServerVersionSupport.DefaultExpression), nameof(ServerVersionSupport.AlternativeDefaultExpression))] public void Create_guid_columns() { @@ -459,7 +459,7 @@ public void Create_default_value_column_simple_function_expression() DROP TABLE IF EXISTS `DefaultValueSimpleExpressionTable`;"); } - [ConditionalFact(Skip = "BLOB/TEXT columns can't have a default value in SingleStore.")] + [ConditionalFact] [SupportedServerVersionCondition(nameof(ServerVersionSupport.DefaultExpression), nameof(ServerVersionSupport.AlternativeDefaultExpression))] public void Create_default_value_expression_column() { @@ -530,7 +530,7 @@ CREATE VIEW `item_data_view` AS #region ColumnFacets - [Fact(Skip = "TODO: PLAT-6286 (Add GEOGRAPHY types support)")] + [Fact] public void Column_storetype_is_set() { Test( @@ -561,7 +561,7 @@ RandomProperty randomType*/ @"DROP TABLE IF EXISTS StoreType;"); } - [Fact] + [Fact(Skip = "Issue #582")] public void Column_nullability_is_set() { Test( @@ -583,13 +583,14 @@ NonNullString text NOT NULL @"DROP TABLE IF EXISTS Nullable;"); } - [Fact] + [Fact(Skip = "Issue #582")] public void Column_default_value_is_set() { Test( @" CREATE TABLE DefaultValue ( Id int, + SomeText text DEFAULT 'Something', RealColumn real DEFAULT 3.14, Created datetime DEFAULT 'October 20, 2015 11am' );", @@ -599,18 +600,21 @@ CREATE TABLE DefaultValue ( { var columns = dbModel.Tables.Single().Columns; - Assert.Equal("'3.14'", columns.Single(c => c.Name == "RealColumn").DefaultValueSql); + Assert.Equal("'Something'", columns.Single(c => c.Name == "SomeText").DefaultValueSql); + Assert.Equal("3.14", columns.Single(c => c.Name == "RealColumn").DefaultValueSql); Assert.Equal("'October 20, 2015 11am'", columns.Single(c => c.Name == "Created").DefaultValueSql); }, @"DROP TABLE IF EXISTS DefaultValue;"); } - [Theory] + [Theory(Skip = "Issue #582")] [InlineData("DOUBLE NOT NULL DEFAULT 0")] [InlineData("FLOAT NOT NULL DEFAULT 0")] [InlineData("INT NOT NULL DEFAULT 0")] [InlineData("INTEGER NOT NULL DEFAULT 0")] [InlineData("REAL NOT NULL DEFAULT 0")] + [InlineData("NULL DEFAULT NULL")] + [InlineData("NOT NULL DEFAULT NULL")] public void Column_default_value_is_ignored_when_clr_default(string columnSql) { Test( @@ -625,7 +629,7 @@ public void Column_default_value_is_ignored_when_clr_default(string columnSql) "DROP TABLE IF EXISTS DefaultValueClr"); } - [ConditionalFact(Skip = "SingleStore allows users to create only persistent computed columns")] + [ConditionalFact] [SupportedServerVersionCondition(nameof(ServerVersionSupport.GeneratedColumns))] public void Computed_value_virtual() => Test(@" @@ -656,7 +660,7 @@ public void Computed_value_stored() `Id` int, `A` int NOT NULL, `B` int NOT NULL, - `SumOfAAndB` AS (`A` + `B`) PERSISTED int + `SumOfAAndB` int GENERATED ALWAYS AS (`A` + `B`) STORED );", Enumerable.Empty(), Enumerable.Empty(), @@ -667,10 +671,11 @@ public void Computed_value_stored() var column = columns.Single(c => c.Name == "SumOfAAndB"); Assert.Null(column.DefaultValueSql); Assert.Equal(@"`A` + `B`", column.ComputedColumnSql); + Assert.True(column.IsStored); }, @"DROP TABLE IF EXISTS `ComputedValues`"); - [ConditionalFact(Skip = "SingleStore allows users to create only persistent computed columns")] + [ConditionalFact] [SupportedServerVersionCondition(nameof(ServerVersionSupport.GeneratedColumns))] public void Computed_value_virtual_using_constant_string() => Test(@" @@ -722,7 +727,7 @@ public void Default_value_curdate_mariadb() #region PrimaryKeyFacets - [Fact] + [Fact(Skip = "Issue #582")] public void Create_composite_primary_key() { Test( @@ -744,7 +749,7 @@ PRIMARY KEY ( Id2, Id1 ) @"DROP TABLE IF EXISTS CompositePrimaryKey;"); } - [Fact] + [Fact(Skip = "Issue #582")] public void Create_primary_key_when_integer_primary_key_alised_to_rowid() { Test( @@ -786,7 +791,7 @@ CONSTRAINT PK PRIMARY KEY (Id) @"DROP TABLE IF EXISTS PrimaryKeyName;"); } - [Fact(Skip = "SingleStore doesn't support index prefixes.")] + [Fact] public void Prefix_lengths_for_primary_key() { Test( @@ -811,7 +816,7 @@ PRIMARY KEY (`Name`, `Brand`(20)) @"DROP TABLE IF EXISTS `IceCreams`;"); } - [Fact(Skip = "TODO: PLAT-6286 (Add GEOGRAPHY types support)")] + [Fact] public void Column_srid_value_is_set() { Test( @@ -899,7 +904,7 @@ CONSTRAINT UK UNIQUE (Id) #region IndexFacets - [Fact] + [Fact(Skip = "Issue #582")] public void Create_composite_index() { Test( @@ -950,7 +955,7 @@ Id2 text @"DROP TABLE IF EXISTS UniqueIndex;"); } - [Fact(Skip = "SingleStore doesn't support index prefixes.")] + [Fact] public void Prefix_lengths_for_index() { Test( @@ -980,7 +985,7 @@ PRIMARY KEY (`IceCreamId`) @"DROP TABLE IF EXISTS `IceCreams`;"); } - [Fact(Skip = "SingleStore doesn't support index prefixes.")] + [Fact] public void Prefix_lengths_for_multiple_indexes_same_colums() { Test( @@ -1012,7 +1017,7 @@ PRIMARY KEY (`IceCreamId`) @"DROP TABLE IF EXISTS `IceCreams`;"); } - [Fact(Skip = "SingleStore doesn't support index prefixes.")] + [Fact] public void Prefix_lengths_for_multiple_indexes_same_columns_without_prefix_lengths() { Test( @@ -1052,14 +1057,15 @@ public void Set_fulltext_for_fulltext_index() CREATE TABLE `IceCreams` ( `IceCreamId` int NOT NULL, `Name` varchar(255) NOT NULL, - PRIMARY KEY (`IceCreamId`), - FULLTEXT `IX_IceCreams_Name`(`Name`) -);", + PRIMARY KEY (`IceCreamId`) +); + +CREATE FULLTEXT INDEX `IX_IceCreams_Name` ON `IceCreams` (`Name`);", Enumerable.Empty(), Enumerable.Empty(), dbModel => { - var index = dbModel.Tables.Single().Indexes[1]; + var index = Assert.Single(dbModel.Tables.Single().Indexes); Assert.Equal("IceCreams", index.Table.Name, StringComparer.OrdinalIgnoreCase); Assert.Equal(1, index.Columns.Count); @@ -1069,7 +1075,7 @@ PRIMARY KEY (`IceCreamId`), @"DROP TABLE IF EXISTS `IceCreams`;"); } - [ConditionalFact(Skip = "SingleStore full text search doesn't support parsers.")] + [ConditionalFact] [SupportedServerVersionCondition(nameof(ServerVersionSupport.FullTextParser))] public void Set_fulltextparser_for_fulltext_index_with_parser() { @@ -1078,7 +1084,7 @@ public void Set_fulltextparser_for_fulltext_index_with_parser() CREATE TABLE `IceCreams` ( `IceCreamId` int NOT NULL, `Name` varchar(255) NOT NULL, - PRIMARY KEY (`IceCreamId`), + PRIMARY KEY (`IceCreamId`) ); CREATE FULLTEXT INDEX `IX_IceCreams_Name` ON `IceCreams` (`Name`) /*!50703 WITH PARSER `ngram` */;", @@ -1097,7 +1103,7 @@ PRIMARY KEY (`IceCreamId`), @"DROP TABLE IF EXISTS `IceCreams`;"); } - [ConditionalFact(Skip = "TODO: PLAT-6286 (Add GEOGRAPHY types support)")] + [ConditionalFact] [SupportedServerVersionCondition(nameof(ServerVersionSupport.SpatialIndexes))] public void Set_spatial_for_spatial_index() { @@ -1313,7 +1319,7 @@ FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(Id) ON DELETE SET NULL DROP TABLE IF EXISTS PrincipalTable;"); } - [Fact(Skip = "SingleStore doesn't support foreign keys and prepared statements.")] + [Fact] public void Ensure_constraints_scaffold_with_case_mismatch() { // The lower case table reference to a mixed cased table will only be accepted under certain conditions diff --git a/test/EFCore.SingleStore.FunctionalTests/ServiceProviderPerContextFixtureBase.cs b/test/EFCore.SingleStore.FunctionalTests/ServiceProviderPerContextFixtureBase.cs index 87f867008..9f964c9e7 100644 --- a/test/EFCore.SingleStore.FunctionalTests/ServiceProviderPerContextFixtureBase.cs +++ b/test/EFCore.SingleStore.FunctionalTests/ServiceProviderPerContextFixtureBase.cs @@ -1,26 +1,31 @@ using System; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; +using Xunit; namespace EntityFrameworkCore.SingleStore.FunctionalTests { - public abstract class ServiceProviderPerContextFixtureBase : ServiceProviderFixtureBase + public abstract class ServiceProviderPerContextFixtureBase : ServiceProviderFixtureBase, IAsyncLifetime where TContext : DbContext { protected abstract string StoreName { get; } - public TestStore TestStore { get; } + public TestStore TestStore { get; private set; } public TestSqlLoggerFactory TestSqlLoggerFactory => (TestSqlLoggerFactory)ListLoggerFactory; - public ServiceProviderPerContextFixtureBase() + public async Task InitializeAsync() { TestStore = TestStoreFactory.GetOrCreate(StoreName); // Setup database. var serviceProvider = SetupServices(); - TestStore.Initialize(serviceProvider, () => CreateContextFromServiceProvider(serviceProvider), c => Seed((TContext)c), Clean); + await TestStore.InitializeAsync(serviceProvider, () => CreateContextFromServiceProvider(serviceProvider), c => SeedAsync((TContext)c), CleanAsync); } + public Task DisposeAsync() + => Task.CompletedTask; + // We cannot use ServiceProviderFixtureBase.CreateOptions() here, because it does not accept an existing // DbContextOptionsBuilder or DbContextOptions object as a parameter, and we might already have one setup. protected virtual DbContextOptionsBuilder ConfigureOptions(IServiceProvider serviceProvider, DbContextOptionsBuilder optionsBuilder) @@ -64,12 +69,10 @@ protected virtual IServiceProvider SetupServices( public virtual TContext CreateContextFromServiceProvider(IServiceProvider serviceProvider) => (TContext)serviceProvider.GetRequiredService(typeof(TContext)); - protected virtual void Clean(DbContext context) - { - } + protected virtual Task CleanAsync(DbContext context) + => Task.CompletedTask; - protected virtual void Seed(TContext context) - { - } + protected virtual Task SeedAsync(TContext context) + => Task.CompletedTask; } } diff --git a/test/EFCore.SingleStore.FunctionalTests/SingleStoreComplianceTest.cs b/test/EFCore.SingleStore.FunctionalTests/SingleStoreComplianceTest.cs index fe85f2fe6..6cecf59b2 100644 --- a/test/EFCore.SingleStore.FunctionalTests/SingleStoreComplianceTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/SingleStoreComplianceTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Reflection; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ModelBuilding; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Update; @@ -12,6 +13,23 @@ public class SingleStoreComplianceTest : RelationalComplianceTestBase // TODO: Implement remaining 3.x tests. protected override ICollection IgnoredTestBases { get; } = new HashSet { + // There are two classes that can lead to a MySqlEndOfStreamException, if *both* test classes are included in the run: + // - RelationalModelBuilderTest.RelationalComplexTypeTestBase + // - RelationalModelBuilderTest.RelationalOwnedTypesTestBase + // + // The exception is thrown for MySQL most of the time, though in rare cases also for MariaDB. + // We disable `RelationalModelBuilderTest.RelationalOwnedTypesTestBase` for now. + + // typeof(RelationalModelBuilderTest.RelationalNonRelationshipTestBase), + // typeof(RelationalModelBuilderTest.RelationalComplexTypeTestBase), + // typeof(RelationalModelBuilderTest.RelationalInheritanceTestBase), + // typeof(RelationalModelBuilderTest.RelationalOneToManyTestBase), + // typeof(RelationalModelBuilderTest.RelationalManyToOneTestBase), + // typeof(RelationalModelBuilderTest.RelationalOneToOneTestBase), + // typeof(RelationalModelBuilderTest.RelationalManyToManyTestBase), + typeof(RelationalModelBuilderTest.RelationalOwnedTypesTestBase), + typeof(ModelBuilderTest.OwnedTypesTestBase), // base class of RelationalModelBuilderTest.RelationalOwnedTypesTestBase + typeof(UdfDbFunctionTestBase<>), typeof(TransactionInterceptionTestBase), typeof(CommandInterceptionTestBase), @@ -19,12 +37,19 @@ public class SingleStoreComplianceTest : RelationalComplianceTestBase typeof(NonSharedModelUpdatesTestBase), typeof(FindSingleStoreTest), + // TODO: 9.0 + typeof(AdHocComplexTypeQueryTestBase), + typeof(AdHocPrecompiledQueryRelationalTestBase), + typeof(PrecompiledQueryRelationalTestBase), + typeof(PrecompiledSqlPregenerationQueryRelationalTestBase), + // TODO: Reenable LoggingSingleStoreTest once its issue has been fixed in EF Core upstream. typeof(LoggingTestBase), typeof(LoggingRelationalTestBase<,>), // We have our own JSON support for now - typeof(JsonQueryAdHocTestBase), + typeof(AdHocJsonQueryTestBase), + typeof(JsonQueryRelationalTestBase<>), typeof(JsonQueryTestBase<>), typeof(JsonTypesRelationalTestBase), typeof(JsonTypesTestBase), diff --git a/test/EFCore.SingleStore.FunctionalTests/SingleStoreMigrationsSqlGeneratorTest.cs b/test/EFCore.SingleStore.FunctionalTests/SingleStoreMigrationsSqlGeneratorTest.cs index a6c9bf6b1..5544a6995 100644 --- a/test/EFCore.SingleStore.FunctionalTests/SingleStoreMigrationsSqlGeneratorTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/SingleStoreMigrationsSqlGeneratorTest.cs @@ -423,7 +423,7 @@ public override void DefaultValue_with_line_breaks(bool isUnicode) AssertSql( @"CREATE TABLE `TestLineBreaks` ( - `TestDefaultValue` longtext NOT NULL DEFAULT (CONCAT('', CHAR(13, 10), 'Various Line', CHAR(13), 'Breaks', CHAR(10), '')) + `TestDefaultValue` longtext NOT NULL DEFAULT CONCAT('', CHAR(13, 10), 'Various Line', CHAR(13), 'Breaks', CHAR(10), '') );"); } @@ -434,7 +434,7 @@ public override void DefaultValue_with_line_breaks_2(bool isUnicode) AssertSql( @"CREATE TABLE `TestLineBreaks` ( - `TestDefaultValue` longtext NOT NULL DEFAULT (CONCAT('0', CHAR(13, 10), '1', CHAR(13, 10), '2', CHAR(13, 10), '3', CHAR(13, 10), '4', CHAR(13, 10), '5', CHAR(13, 10), '6', CHAR(13, 10), '7', CHAR(13, 10), '8', CHAR(13, 10), '9', CHAR(13, 10), '10', CHAR(13, 10), '11', CHAR(13, 10), '12', CHAR(13, 10), '13', CHAR(13, 10), '14', CHAR(13, 10), '15', CHAR(13, 10), '16', CHAR(13, 10), '17', CHAR(13, 10), '18', CHAR(13, 10), '19', CHAR(13, 10), '20', CHAR(13, 10), '21', CHAR(13, 10), '22', CHAR(13, 10), '23', CHAR(13, 10), '24', CHAR(13, 10), '25', CHAR(13, 10), '26', CHAR(13, 10), '27', CHAR(13, 10), '28', CHAR(13, 10), '29', CHAR(13, 10), '30', CHAR(13, 10), '31', CHAR(13, 10), '32', CHAR(13, 10), '33', CHAR(13, 10), '34', CHAR(13, 10), '35', CHAR(13, 10), '36', CHAR(13, 10), '37', CHAR(13, 10), '38', CHAR(13, 10), '39', CHAR(13, 10), '40', CHAR(13, 10), '41', CHAR(13, 10), '42', CHAR(13, 10), '43', CHAR(13, 10), '44', CHAR(13, 10), '45', CHAR(13, 10), '46', CHAR(13, 10), '47', CHAR(13, 10), '48', CHAR(13, 10), '49', CHAR(13, 10), '50', CHAR(13, 10), '51', CHAR(13, 10), '52', CHAR(13, 10), '53', CHAR(13, 10), '54', CHAR(13, 10), '55', CHAR(13, 10), '56', CHAR(13, 10), '57', CHAR(13, 10), '58', CHAR(13, 10), '59', CHAR(13, 10), '60', CHAR(13, 10), '61', CHAR(13, 10), '62', CHAR(13, 10), '63', CHAR(13, 10), '64', CHAR(13, 10), '65', CHAR(13, 10), '66', CHAR(13, 10), '67', CHAR(13, 10), '68', CHAR(13, 10), '69', CHAR(13, 10), '70', CHAR(13, 10), '71', CHAR(13, 10), '72', CHAR(13, 10), '73', CHAR(13, 10), '74', CHAR(13, 10), '75', CHAR(13, 10), '76', CHAR(13, 10), '77', CHAR(13, 10), '78', CHAR(13, 10), '79', CHAR(13, 10), '80', CHAR(13, 10), '81', CHAR(13, 10), '82', CHAR(13, 10), '83', CHAR(13, 10), '84', CHAR(13, 10), '85', CHAR(13, 10), '86', CHAR(13, 10), '87', CHAR(13, 10), '88', CHAR(13, 10), '89', CHAR(13, 10), '90', CHAR(13, 10), '91', CHAR(13, 10), '92', CHAR(13, 10), '93', CHAR(13, 10), '94', CHAR(13, 10), '95', CHAR(13, 10), '96', CHAR(13, 10), '97', CHAR(13, 10), '98', CHAR(13, 10), '99', CHAR(13, 10), '100', CHAR(13, 10), '101', CHAR(13, 10), '102', CHAR(13, 10), '103', CHAR(13, 10), '104', CHAR(13, 10), '105', CHAR(13, 10), '106', CHAR(13, 10), '107', CHAR(13, 10), '108', CHAR(13, 10), '109', CHAR(13, 10), '110', CHAR(13, 10), '111', CHAR(13, 10), '112', CHAR(13, 10), '113', CHAR(13, 10), '114', CHAR(13, 10), '115', CHAR(13, 10), '116', CHAR(13, 10), '117', CHAR(13, 10), '118', CHAR(13, 10), '119', CHAR(13, 10), '120', CHAR(13, 10), '121', CHAR(13, 10), '122', CHAR(13, 10), '123', CHAR(13, 10), '124', CHAR(13, 10), '125', CHAR(13, 10), '126', CHAR(13, 10), '127', CHAR(13, 10), '128', CHAR(13, 10), '129', CHAR(13, 10), '130', CHAR(13, 10), '131', CHAR(13, 10), '132', CHAR(13, 10), '133', CHAR(13, 10), '134', CHAR(13, 10), '135', CHAR(13, 10), '136', CHAR(13, 10), '137', CHAR(13, 10), '138', CHAR(13, 10), '139', CHAR(13, 10), '140', CHAR(13, 10), '141', CHAR(13, 10), '142', CHAR(13, 10), '143', CHAR(13, 10), '144', CHAR(13, 10), '145', CHAR(13, 10), '146', CHAR(13, 10), '147', CHAR(13, 10), '148', CHAR(13, 10), '149', CHAR(13, 10), '150', CHAR(13, 10), '151', CHAR(13, 10), '152', CHAR(13, 10), '153', CHAR(13, 10), '154', CHAR(13, 10), '155', CHAR(13, 10), '156', CHAR(13, 10), '157', CHAR(13, 10), '158', CHAR(13, 10), '159', CHAR(13, 10), '160', CHAR(13, 10), '161', CHAR(13, 10), '162', CHAR(13, 10), '163', CHAR(13, 10), '164', CHAR(13, 10), '165', CHAR(13, 10), '166', CHAR(13, 10), '167', CHAR(13, 10), '168', CHAR(13, 10), '169', CHAR(13, 10), '170', CHAR(13, 10), '171', CHAR(13, 10), '172', CHAR(13, 10), '173', CHAR(13, 10), '174', CHAR(13, 10), '175', CHAR(13, 10), '176', CHAR(13, 10), '177', CHAR(13, 10), '178', CHAR(13, 10), '179', CHAR(13, 10), '180', CHAR(13, 10), '181', CHAR(13, 10), '182', CHAR(13, 10), '183', CHAR(13, 10), '184', CHAR(13, 10), '185', CHAR(13, 10), '186', CHAR(13, 10), '187', CHAR(13, 10), '188', CHAR(13, 10), '189', CHAR(13, 10), '190', CHAR(13, 10), '191', CHAR(13, 10), '192', CHAR(13, 10), '193', CHAR(13, 10), '194', CHAR(13, 10), '195', CHAR(13, 10), '196', CHAR(13, 10), '197', CHAR(13, 10), '198', CHAR(13, 10), '199', CHAR(13, 10), '200', CHAR(13, 10), '201', CHAR(13, 10), '202', CHAR(13, 10), '203', CHAR(13, 10), '204', CHAR(13, 10), '205', CHAR(13, 10), '206', CHAR(13, 10), '207', CHAR(13, 10), '208', CHAR(13, 10), '209', CHAR(13, 10), '210', CHAR(13, 10), '211', CHAR(13, 10), '212', CHAR(13, 10), '213', CHAR(13, 10), '214', CHAR(13, 10), '215', CHAR(13, 10), '216', CHAR(13, 10), '217', CHAR(13, 10), '218', CHAR(13, 10), '219', CHAR(13, 10), '220', CHAR(13, 10), '221', CHAR(13, 10), '222', CHAR(13, 10), '223', CHAR(13, 10), '224', CHAR(13, 10), '225', CHAR(13, 10), '226', CHAR(13, 10), '227', CHAR(13, 10), '228', CHAR(13, 10), '229', CHAR(13, 10), '230', CHAR(13, 10), '231', CHAR(13, 10), '232', CHAR(13, 10), '233', CHAR(13, 10), '234', CHAR(13, 10), '235', CHAR(13, 10), '236', CHAR(13, 10), '237', CHAR(13, 10), '238', CHAR(13, 10), '239', CHAR(13, 10), '240', CHAR(13, 10), '241', CHAR(13, 10), '242', CHAR(13, 10), '243', CHAR(13, 10), '244', CHAR(13, 10), '245', CHAR(13, 10), '246', CHAR(13, 10), '247', CHAR(13, 10), '248', CHAR(13, 10), '249', CHAR(13, 10), '250', CHAR(13, 10), '251', CHAR(13, 10), '252', CHAR(13, 10), '253', CHAR(13, 10), '254', CHAR(13, 10), '255', CHAR(13, 10), '256', CHAR(13, 10), '257', CHAR(13, 10), '258', CHAR(13, 10), '259', CHAR(13, 10), '260', CHAR(13, 10), '261', CHAR(13, 10), '262', CHAR(13, 10), '263', CHAR(13, 10), '264', CHAR(13, 10), '265', CHAR(13, 10), '266', CHAR(13, 10), '267', CHAR(13, 10), '268', CHAR(13, 10), '269', CHAR(13, 10), '270', CHAR(13, 10), '271', CHAR(13, 10), '272', CHAR(13, 10), '273', CHAR(13, 10), '274', CHAR(13, 10), '275', CHAR(13, 10), '276', CHAR(13, 10), '277', CHAR(13, 10), '278', CHAR(13, 10), '279', CHAR(13, 10), '280', CHAR(13, 10), '281', CHAR(13, 10), '282', CHAR(13, 10), '283', CHAR(13, 10), '284', CHAR(13, 10), '285', CHAR(13, 10), '286', CHAR(13, 10), '287', CHAR(13, 10), '288', CHAR(13, 10), '289', CHAR(13, 10), '290', CHAR(13, 10), '291', CHAR(13, 10), '292', CHAR(13, 10), '293', CHAR(13, 10), '294', CHAR(13, 10), '295', CHAR(13, 10), '296', CHAR(13, 10), '297', CHAR(13, 10), '298', CHAR(13, 10), '299', CHAR(13, 10), '')) + `TestDefaultValue` longtext NOT NULL DEFAULT CONCAT('0', CHAR(13, 10), '1', CHAR(13, 10), '2', CHAR(13, 10), '3', CHAR(13, 10), '4', CHAR(13, 10), '5', CHAR(13, 10), '6', CHAR(13, 10), '7', CHAR(13, 10), '8', CHAR(13, 10), '9', CHAR(13, 10), '10', CHAR(13, 10), '11', CHAR(13, 10), '12', CHAR(13, 10), '13', CHAR(13, 10), '14', CHAR(13, 10), '15', CHAR(13, 10), '16', CHAR(13, 10), '17', CHAR(13, 10), '18', CHAR(13, 10), '19', CHAR(13, 10), '20', CHAR(13, 10), '21', CHAR(13, 10), '22', CHAR(13, 10), '23', CHAR(13, 10), '24', CHAR(13, 10), '25', CHAR(13, 10), '26', CHAR(13, 10), '27', CHAR(13, 10), '28', CHAR(13, 10), '29', CHAR(13, 10), '30', CHAR(13, 10), '31', CHAR(13, 10), '32', CHAR(13, 10), '33', CHAR(13, 10), '34', CHAR(13, 10), '35', CHAR(13, 10), '36', CHAR(13, 10), '37', CHAR(13, 10), '38', CHAR(13, 10), '39', CHAR(13, 10), '40', CHAR(13, 10), '41', CHAR(13, 10), '42', CHAR(13, 10), '43', CHAR(13, 10), '44', CHAR(13, 10), '45', CHAR(13, 10), '46', CHAR(13, 10), '47', CHAR(13, 10), '48', CHAR(13, 10), '49', CHAR(13, 10), '50', CHAR(13, 10), '51', CHAR(13, 10), '52', CHAR(13, 10), '53', CHAR(13, 10), '54', CHAR(13, 10), '55', CHAR(13, 10), '56', CHAR(13, 10), '57', CHAR(13, 10), '58', CHAR(13, 10), '59', CHAR(13, 10), '60', CHAR(13, 10), '61', CHAR(13, 10), '62', CHAR(13, 10), '63', CHAR(13, 10), '64', CHAR(13, 10), '65', CHAR(13, 10), '66', CHAR(13, 10), '67', CHAR(13, 10), '68', CHAR(13, 10), '69', CHAR(13, 10), '70', CHAR(13, 10), '71', CHAR(13, 10), '72', CHAR(13, 10), '73', CHAR(13, 10), '74', CHAR(13, 10), '75', CHAR(13, 10), '76', CHAR(13, 10), '77', CHAR(13, 10), '78', CHAR(13, 10), '79', CHAR(13, 10), '80', CHAR(13, 10), '81', CHAR(13, 10), '82', CHAR(13, 10), '83', CHAR(13, 10), '84', CHAR(13, 10), '85', CHAR(13, 10), '86', CHAR(13, 10), '87', CHAR(13, 10), '88', CHAR(13, 10), '89', CHAR(13, 10), '90', CHAR(13, 10), '91', CHAR(13, 10), '92', CHAR(13, 10), '93', CHAR(13, 10), '94', CHAR(13, 10), '95', CHAR(13, 10), '96', CHAR(13, 10), '97', CHAR(13, 10), '98', CHAR(13, 10), '99', CHAR(13, 10), '100', CHAR(13, 10), '101', CHAR(13, 10), '102', CHAR(13, 10), '103', CHAR(13, 10), '104', CHAR(13, 10), '105', CHAR(13, 10), '106', CHAR(13, 10), '107', CHAR(13, 10), '108', CHAR(13, 10), '109', CHAR(13, 10), '110', CHAR(13, 10), '111', CHAR(13, 10), '112', CHAR(13, 10), '113', CHAR(13, 10), '114', CHAR(13, 10), '115', CHAR(13, 10), '116', CHAR(13, 10), '117', CHAR(13, 10), '118', CHAR(13, 10), '119', CHAR(13, 10), '120', CHAR(13, 10), '121', CHAR(13, 10), '122', CHAR(13, 10), '123', CHAR(13, 10), '124', CHAR(13, 10), '125', CHAR(13, 10), '126', CHAR(13, 10), '127', CHAR(13, 10), '128', CHAR(13, 10), '129', CHAR(13, 10), '130', CHAR(13, 10), '131', CHAR(13, 10), '132', CHAR(13, 10), '133', CHAR(13, 10), '134', CHAR(13, 10), '135', CHAR(13, 10), '136', CHAR(13, 10), '137', CHAR(13, 10), '138', CHAR(13, 10), '139', CHAR(13, 10), '140', CHAR(13, 10), '141', CHAR(13, 10), '142', CHAR(13, 10), '143', CHAR(13, 10), '144', CHAR(13, 10), '145', CHAR(13, 10), '146', CHAR(13, 10), '147', CHAR(13, 10), '148', CHAR(13, 10), '149', CHAR(13, 10), '150', CHAR(13, 10), '151', CHAR(13, 10), '152', CHAR(13, 10), '153', CHAR(13, 10), '154', CHAR(13, 10), '155', CHAR(13, 10), '156', CHAR(13, 10), '157', CHAR(13, 10), '158', CHAR(13, 10), '159', CHAR(13, 10), '160', CHAR(13, 10), '161', CHAR(13, 10), '162', CHAR(13, 10), '163', CHAR(13, 10), '164', CHAR(13, 10), '165', CHAR(13, 10), '166', CHAR(13, 10), '167', CHAR(13, 10), '168', CHAR(13, 10), '169', CHAR(13, 10), '170', CHAR(13, 10), '171', CHAR(13, 10), '172', CHAR(13, 10), '173', CHAR(13, 10), '174', CHAR(13, 10), '175', CHAR(13, 10), '176', CHAR(13, 10), '177', CHAR(13, 10), '178', CHAR(13, 10), '179', CHAR(13, 10), '180', CHAR(13, 10), '181', CHAR(13, 10), '182', CHAR(13, 10), '183', CHAR(13, 10), '184', CHAR(13, 10), '185', CHAR(13, 10), '186', CHAR(13, 10), '187', CHAR(13, 10), '188', CHAR(13, 10), '189', CHAR(13, 10), '190', CHAR(13, 10), '191', CHAR(13, 10), '192', CHAR(13, 10), '193', CHAR(13, 10), '194', CHAR(13, 10), '195', CHAR(13, 10), '196', CHAR(13, 10), '197', CHAR(13, 10), '198', CHAR(13, 10), '199', CHAR(13, 10), '200', CHAR(13, 10), '201', CHAR(13, 10), '202', CHAR(13, 10), '203', CHAR(13, 10), '204', CHAR(13, 10), '205', CHAR(13, 10), '206', CHAR(13, 10), '207', CHAR(13, 10), '208', CHAR(13, 10), '209', CHAR(13, 10), '210', CHAR(13, 10), '211', CHAR(13, 10), '212', CHAR(13, 10), '213', CHAR(13, 10), '214', CHAR(13, 10), '215', CHAR(13, 10), '216', CHAR(13, 10), '217', CHAR(13, 10), '218', CHAR(13, 10), '219', CHAR(13, 10), '220', CHAR(13, 10), '221', CHAR(13, 10), '222', CHAR(13, 10), '223', CHAR(13, 10), '224', CHAR(13, 10), '225', CHAR(13, 10), '226', CHAR(13, 10), '227', CHAR(13, 10), '228', CHAR(13, 10), '229', CHAR(13, 10), '230', CHAR(13, 10), '231', CHAR(13, 10), '232', CHAR(13, 10), '233', CHAR(13, 10), '234', CHAR(13, 10), '235', CHAR(13, 10), '236', CHAR(13, 10), '237', CHAR(13, 10), '238', CHAR(13, 10), '239', CHAR(13, 10), '240', CHAR(13, 10), '241', CHAR(13, 10), '242', CHAR(13, 10), '243', CHAR(13, 10), '244', CHAR(13, 10), '245', CHAR(13, 10), '246', CHAR(13, 10), '247', CHAR(13, 10), '248', CHAR(13, 10), '249', CHAR(13, 10), '250', CHAR(13, 10), '251', CHAR(13, 10), '252', CHAR(13, 10), '253', CHAR(13, 10), '254', CHAR(13, 10), '255', CHAR(13, 10), '256', CHAR(13, 10), '257', CHAR(13, 10), '258', CHAR(13, 10), '259', CHAR(13, 10), '260', CHAR(13, 10), '261', CHAR(13, 10), '262', CHAR(13, 10), '263', CHAR(13, 10), '264', CHAR(13, 10), '265', CHAR(13, 10), '266', CHAR(13, 10), '267', CHAR(13, 10), '268', CHAR(13, 10), '269', CHAR(13, 10), '270', CHAR(13, 10), '271', CHAR(13, 10), '272', CHAR(13, 10), '273', CHAR(13, 10), '274', CHAR(13, 10), '275', CHAR(13, 10), '276', CHAR(13, 10), '277', CHAR(13, 10), '278', CHAR(13, 10), '279', CHAR(13, 10), '280', CHAR(13, 10), '281', CHAR(13, 10), '282', CHAR(13, 10), '283', CHAR(13, 10), '284', CHAR(13, 10), '285', CHAR(13, 10), '286', CHAR(13, 10), '287', CHAR(13, 10), '288', CHAR(13, 10), '289', CHAR(13, 10), '290', CHAR(13, 10), '291', CHAR(13, 10), '292', CHAR(13, 10), '293', CHAR(13, 10), '294', CHAR(13, 10), '295', CHAR(13, 10), '296', CHAR(13, 10), '297', CHAR(13, 10), '298', CHAR(13, 10), '299', CHAR(13, 10), '') );"); } @@ -489,7 +489,7 @@ public virtual void DefaultValue_generated_for_unlimited_text_column() Assert.Equal( @"CREATE TABLE `History` ( - `Event` longtext NOT NULL DEFAULT ('The Battle of Waterloo') + `Event` longtext NOT NULL DEFAULT 'The Battle of Waterloo' ); ", Sql, @@ -978,7 +978,15 @@ public void AlterColumnOperation_ComputedColumnSql_with_index() }); Assert.Equal( - "ALTER TABLE `People` MODIFY COLUMN `Blob` AS ('TEST') PERSISTED varchar(95);" + EOL, + """ + ALTER TABLE `People` DROP INDEX `IX_People_Blob`; + + ALTER TABLE `People` DROP COLUMN `Blob`; + + ALTER TABLE `People` ADD `Blob` AS ('TEST') PERSISTED varchar(95); + + CREATE INDEX `IX_People_Blob` ON `People` (`Blob`); + """ + EOL, Sql); } @@ -1690,7 +1698,6 @@ public virtual void CreateSequenceOperation_with_minValue_and_maxValue() [SupportedServerVersionCondition(nameof(ServerVersionSupport.Sequences))] public virtual void CreateSequenceOperation_without_minValue_and_maxValue() { - Generate( new CreateSequenceOperation { @@ -1701,7 +1708,7 @@ public virtual void CreateSequenceOperation_without_minValue_and_maxValue() }); Assert.Equal( - @"CREATE SEQUENCE `MySequence` START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE NOCYCLE;" + EOL, + @"CREATE SEQUENCE `MySequence` START WITH 1 INCREMENT BY 1 NOCYCLE;" + EOL, Sql, ignoreLineEndingDifferences: true); } diff --git a/test/EFCore.SingleStore.FunctionalTests/StoreGeneratedSingleStoreTestBase.cs b/test/EFCore.SingleStore.FunctionalTests/StoreGeneratedSingleStoreTestBase.cs index a2b9a8ee7..a090359be 100644 --- a/test/EFCore.SingleStore.FunctionalTests/StoreGeneratedSingleStoreTestBase.cs +++ b/test/EFCore.SingleStore.FunctionalTests/StoreGeneratedSingleStoreTestBase.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; +using System.Threading.Tasks; using System.Linq; using System.Reflection; using EntityFrameworkCore.SingleStore.Tests; @@ -4535,9 +4536,12 @@ protected virtual void ExecuteWithStrategyInTransaction( Action? nestedTestOperation1 = null, Action? nestedTestOperation2 = null, Action? nestedTestOperation3 = null) - => TestHelpers.ExecuteWithStrategyInTransaction( + => TestHelpers.ExecuteWithStrategyInTransactionAsync( CreateContext, UseTransaction, - testOperation, nestedTestOperation1, nestedTestOperation2, nestedTestOperation3); + async context => { testOperation(context); await Task.CompletedTask; }, + nestedTestOperation1 == null ? null : async context => { nestedTestOperation1(context); await Task.CompletedTask; }, + nestedTestOperation2 == null ? null : async context => { nestedTestOperation2(context); await Task.CompletedTask; }, + nestedTestOperation3 == null ? null : async context => { nestedTestOperation3(context); await Task.CompletedTask; }).GetAwaiter().GetResult(); protected virtual void UseTransaction(DatabaseFacade facade, IDbContextTransaction transaction) { diff --git a/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestHelpers.cs b/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestHelpers.cs index d4241bd0a..d3246c246 100644 --- a/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestHelpers.cs +++ b/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestHelpers.cs @@ -1,14 +1,20 @@ using System; using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; using EntityFrameworkCore.SingleStore.Infrastructure; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; +using EntityFrameworkCore.SingleStore.Diagnostics.Internal; using EntityFrameworkCore.SingleStore.Infrastructure.Internal; using EntityFrameworkCore.SingleStore.Tests; +using Xunit; //ReSharper disable once CheckNamespace namespace EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities @@ -27,6 +33,8 @@ public override IServiceCollection AddProviderServices(IServiceCollection servic public override DbContextOptionsBuilder UseProviderOptions(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSingleStore("Database=DummyDatabase"); + public override LoggingDefinitions LoggingDefinitions { get; } = new SingleStoreLoggingDefinitions(); + public IServiceProvider CreateContextServices(ServerVersion serverVersion) => ((IInfrastructure)new DbContext(CreateOptions(serverVersion))).Instance; @@ -111,7 +119,7 @@ public static DateTimeOffset GetExpectedValue(DateTimeOffset value) public static string CastAsDouble(string innerSql) => AppConfig.ServerVersion.Supports.DoubleCast ? $@"CAST({innerSql} AS double)" - : $@"(CAST({innerSql} AS decimal(65,30)) + 0e0)"; + : $@"({innerSql} :> double)"; public static string SingleStoreBug96947Workaround(string innerSql, string type = "char") => AppConfig.ServerVersion.Supports.SingleStoreBug96947Workaround @@ -120,9 +128,61 @@ public static string SingleStoreBug96947Workaround(string innerSql, string type public static bool HasPrimitiveCollectionsSupport(SharedStoreFixtureBase fixture) where TContext : DbContext + => HasPrimitiveCollectionsSupport(fixture.CreateOptions()); + + public static bool HasPrimitiveCollectionsSupport(DbContextOptions options) + => AppConfig.ServerVersion.Supports.JsonTable && + options.GetExtension().PrimitiveCollectionsSupport; + + /// + /// Same implementation as EF Core base class, except that it can generate code for Task returning test without a `bool async` + /// parameter. + /// + public static void AssertAllMethodsOverridden(Type testClass, bool withAssertSqlCall = true) { - return AppConfig.ServerVersion.Supports.JsonTable && - fixture.CreateOptions().GetExtension().PrimitiveCollectionsSupport; + var methods = testClass + .GetRuntimeMethods() + .Where(m => m.DeclaringType != testClass + && (Attribute.IsDefined(m, typeof(ConditionalFactAttribute)) + || Attribute.IsDefined(m, typeof(ConditionalTheoryAttribute)))) + .ToList(); + + var methodCalls = new StringBuilder(); + + foreach (var method in methods) + { + if (method.ReturnType == typeof(Task)) + { + var parameters = method.GetParameters(); + var generateAsyncParameter = parameters.Length == 1 && + parameters[0].ParameterType == typeof(bool); + methodCalls.Append( + @$"public override async Task {method.Name}({(generateAsyncParameter ? "bool async" : null)}) +{{ + await base.{method.Name}({(generateAsyncParameter ? "async" : null)});{(withAssertSqlCall ? + """ + AssertSql(); + """ : null)} +}} +"); + } + else + { + methodCalls.Append( + @$"public override void {method.Name}() +{{ + base.{method.Name}();{(withAssertSqlCall ? + """ + AssertSql(); + """ : null)} +}} +"); + } + } + + Assert.False( + methods.Count > 0, + "\r\n-- Missing test overrides --\r\n\r\n" + methodCalls); } } } diff --git a/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestMigrator.cs b/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestMigrator.cs index dbfd70440..eb49cf867 100644 --- a/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestMigrator.cs +++ b/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestMigrator.cs @@ -2,10 +2,10 @@ using System; using System.Collections.Generic; -using JetBrains.Annotations; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage; using EntityFrameworkCore.SingleStore.Migrations.Internal; @@ -17,19 +17,23 @@ public class SingleStoreTestMigrator : SingleStoreMigrator public Func MigrationsSqlGenerationOptionsOverrider { get; set; } public SingleStoreTestMigrator( - [NotNull] IMigrationsAssembly migrationsAssembly, - [NotNull] IHistoryRepository historyRepository, - [NotNull] IDatabaseCreator databaseCreator, - [NotNull] IMigrationsSqlGenerator migrationsSqlGenerator, - [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder, - [NotNull] IMigrationCommandExecutor migrationCommandExecutor, - [NotNull] IRelationalConnection connection, - [NotNull] ISqlGenerationHelper sqlGenerationHelper, - [NotNull] ICurrentDbContext currentContext, - [NotNull] IModelRuntimeInitializer modelRuntimeInitializer, - [NotNull] IDiagnosticsLogger logger, - [NotNull] IRelationalCommandDiagnosticsLogger commandLogger, - [NotNull] IDatabaseProvider databaseProvider) + IMigrationsAssembly migrationsAssembly, + IHistoryRepository historyRepository, + IDatabaseCreator databaseCreator, + IMigrationsSqlGenerator migrationsSqlGenerator, + IRawSqlCommandBuilder rawSqlCommandBuilder, + IMigrationCommandExecutor migrationCommandExecutor, + IRelationalConnection connection, + ISqlGenerationHelper sqlGenerationHelper, + ICurrentDbContext currentContext, + IModelRuntimeInitializer modelRuntimeInitializer, + IDiagnosticsLogger logger, + IRelationalCommandDiagnosticsLogger commandLogger, + IDatabaseProvider databaseProvider, + IMigrationsModelDiffer migrationsModelDiffer, + IDesignTimeModel designTimeModel, + IDbContextOptions contextOptions, + IExecutionStrategy executionStrategy) : base( migrationsAssembly, historyRepository, @@ -43,7 +47,11 @@ public SingleStoreTestMigrator( modelRuntimeInitializer, logger, commandLogger, - databaseProvider) + databaseProvider, + migrationsModelDiffer, + designTimeModel, + contextOptions, + executionStrategy) { } diff --git a/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestStore.cs b/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestStore.cs index d942ff57b..534e8d9bb 100644 --- a/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestStore.cs +++ b/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestStore.cs @@ -22,6 +22,7 @@ public class SingleStoreTestStore : RelationalTestStore public const int DefaultCommandTimeout = 600; + private readonly string _connectionString; private readonly string _scriptPath; private readonly bool _useConnectionString; private readonly bool _noBackslashEscapes; @@ -35,20 +36,20 @@ public static SingleStoreTestStore GetOrCreate(string name, bool useConnectionSt public static SingleStoreTestStore GetOrCreate(string name, string scriptPath, bool noBackslashEscapes = false, string databaseCollation = null, SingleStoreGuidFormat guidFormat = SingleStoreGuidFormat.Default) => new SingleStoreTestStore(name, scriptPath: scriptPath, noBackslashEscapes: noBackslashEscapes, databaseCollation: databaseCollation, guidFormat: guidFormat); - public static SingleStoreTestStore GetOrCreateInitialized(string name) - => new SingleStoreTestStore(name, shared: true).InitializeSingleStore(null, (Func)null, null); + public static Task GetOrCreateInitializedAsync(string name) + => new SingleStoreTestStore(name, shared: true).InitializeSingleStoreAsync(null, (Func)null, null); public static SingleStoreTestStore Create(string name, bool useConnectionString = false, bool noBackslashEscapes = false, string databaseCollation = null, SingleStoreGuidFormat guidFormat = SingleStoreGuidFormat.Default) => new SingleStoreTestStore(name, useConnectionString: useConnectionString, shared: false, noBackslashEscapes: noBackslashEscapes, databaseCollation: databaseCollation, guidFormat: guidFormat); - public static SingleStoreTestStore CreateInitialized(string name) - => new SingleStoreTestStore(name, shared: false).InitializeSingleStore(null, null, null); + public static Task CreateInitializedAsync(string name) + => new SingleStoreTestStore(name, shared: false).InitializeSingleStoreAsync(null, null, null); - public static SingleStoreTestStore RecreateInitialized(string name) - => new SingleStoreTestStore(name, shared: false).InitializeSingleStore(null, null, null, c => + public static Task RecreateInitializedAsync(string name) + => new SingleStoreTestStore(name, shared: false).InitializeSingleStoreAsync(null, null, null, async c => { - c.Database.EnsureDeleted(); - c.Database.EnsureCreated(); + await c.Database.EnsureDeletedAsync(); + await c.Database.EnsureCreatedAsync(); }); public Lazy ServerVersion { get; } @@ -65,12 +66,16 @@ private SingleStoreTestStore( bool shared = true, bool noBackslashEscapes = false, SingleStoreGuidFormat guidFormat = SingleStoreGuidFormat.Default) - : base(name, shared) + : base(name, shared, new SingleStoreConnection(CreateConnectionString(name, noBackslashEscapes, guidFormat))) { _useConnectionString = useConnectionString; _noBackslashEscapes = noBackslashEscapes; - ConnectionString = CreateConnectionString(name, _noBackslashEscapes, guidFormat); - Connection = new SingleStoreConnection(ConnectionString); + + if (useConnectionString) + { + _connectionString = CreateConnectionString(name, _noBackslashEscapes, guidFormat); + } + ServerVersion = new Lazy(() => Microsoft.EntityFrameworkCore.ServerVersion.AutoDetect((SingleStoreConnection)Connection)); DatabaseCharSet = databaseCharSet ?? ServerVersion.Value.DefaultCharSet; DatabaseCollation = databaseCollation ?? ServerVersion.Value.DefaultUtf8CiCollation; @@ -99,12 +104,15 @@ public static string CreateConnectionString(string name, bool noBackslashEscapes public override DbContextOptionsBuilder AddProviderOptions(DbContextOptionsBuilder builder) => _useConnectionString - ? builder.UseSingleStore(ConnectionString, x => AddOptions(x, _noBackslashEscapes)) + ? builder.UseSingleStore(_connectionString, x => AddOptions(x, _noBackslashEscapes)) : builder.UseSingleStore(Connection, x => AddOptions(x, _noBackslashEscapes)); public static SingleStoreDbContextOptionsBuilder AddOptions(SingleStoreDbContextOptionsBuilder builder) { return builder + // Our UseSingleStore() methods explicitly set TranslateParameterizedCollectionsToConstants() as the default, which is not the + // default that the EF Core tests expect. + .TranslateParameterizedCollectionsToParameters() .UseQuerySplittingBehavior(QuerySplittingBehavior.SingleQuery) .CommandTimeout(GetCommandTimeout()) .ExecutionStrategy(d => new TestSingleStoreRetryingExecutionStrategy(d)); @@ -123,12 +131,15 @@ public static void AddOptions(SingleStoreDbContextOptionsBuilder builder, bool n } } - public SingleStoreTestStore InitializeSingleStore(IServiceProvider serviceProvider, Func createContext, Action seed, Action clean = null) - => (SingleStoreTestStore)Initialize(serviceProvider, createContext, seed, clean); + public async Task InitializeSingleStoreAsync(IServiceProvider serviceProvider, Func createContext, Func seed, Func clean = null) + => (SingleStoreTestStore)await InitializeAsync(serviceProvider, createContext, seed, clean); - protected override void Initialize(Func createContext, Action seed, Action clean) + protected override async Task InitializeAsync( + Func createContext, + Func seed, + Func clean) { - if (CreateDatabase(clean)) + if (await CreateDatabaseAsync(clean)) { if (_scriptPath != null) { @@ -136,41 +147,49 @@ protected override void Initialize(Func createContext, Action clean) + private async Task CreateDatabaseAsync(Func clean) { - using var master = new SingleStoreConnection(CreateAdminConnectionString()); - master.Open(); + await using var master = new SingleStoreConnection(CreateAdminConnectionString()); + await master.OpenAsync(); - if (DatabaseExists(Name)) + if (await DatabaseExistsAsync(Name)) { /*if (_scriptPath != null && !TestEnvironment.IsCI) { return false; }*/ - using (var context = new DbContext( + await using (var context = new DbContext( AddProviderOptions( new DbContextOptionsBuilder() .EnableServiceProviderCaching(false)) .Options)) { - clean?.Invoke(context); - Clean(context); + if (clean != null) + { + await clean(context); + } + + await CleanAsync(context); } - ExecuteNonQuery(master, $"DROP DATABASE IF EXISTS `{Name}`;"); + await ExecuteNonQueryAsync(master, $"DROP DATABASE IF EXISTS `{Name}`;"); } - ExecuteNonQuery( + await ExecuteNonQueryAsync( master, GetCreateDatabaseStatement(Name, DatabaseCharSet, DatabaseCollation)); return true; @@ -206,10 +225,10 @@ private void ChangeTableType() private static string GetCreateDatabaseStatement(string name, string charset = null, string collation = null) => $@"CREATE DATABASE `{name}`{(string.IsNullOrEmpty(charset) ? null : $" CHARACTER SET {charset}")}{(string.IsNullOrEmpty(collation) ? null : $" COLLATE {collation}")};"; - private static bool DatabaseExists(string name) + private static async Task DatabaseExistsAsync(string name) { - using (var master = new SingleStoreConnection(CreateAdminConnectionString())) - return ExecuteScalar(master, $@"SELECT COUNT(*) FROM `INFORMATION_SCHEMA`.`SCHEMATA` WHERE `SCHEMA_NAME` = '{name}';") > 0; + await using var master = new SingleStoreConnection(CreateAdminConnectionString()); + return await ExecuteScalarAsync(master, $@"SELECT COUNT(*) FROM `INFORMATION_SCHEMA`.`SCHEMATA` WHERE `SCHEMA_NAME` = '{name}';") > 0; } private static string CreateAdminConnectionString() @@ -234,17 +253,31 @@ public void ExecuteScript(string script) return 0; }, string.Empty); - public override void Clean(DbContext context) - => context.Database.EnsureClean(); + public override Task CleanAsync(DbContext context) + { + context.Database.EnsureClean(); + return Task.CompletedTask; + } private static T ExecuteScalar(DbConnection connection, string sql, params object[] parameters) => Execute(connection, command => (T)command.ExecuteScalar(), sql, false, parameters); + private static Task ExecuteScalarAsync(DbConnection connection, string sql, params object[] parameters) + => ExecuteAsync(connection, async command => (T)(await command.ExecuteScalarAsync()), sql, false, parameters); + private static T Execute( DbConnection connection, Func execute, string sql, bool useTransaction = false, object[] parameters = null) => ExecuteCommand(connection, execute, sql, useTransaction, parameters); + private static Task ExecuteAsync( + DbConnection connection, + Func> execute, + string sql, + bool useTransaction = false, + object[] parameters = null) + => ExecuteCommandAsync(connection, execute, sql, useTransaction, parameters); + private static T ExecuteCommand( DbConnection connection, Func execute, string sql, bool useTransaction, object[] parameters) { @@ -282,12 +315,62 @@ private static T ExecuteCommand( } } + private static async Task ExecuteCommandAsync( + DbConnection connection, + Func> execute, + string sql, + bool useTransaction, + object[] parameters) + { + if (connection.State != ConnectionState.Closed) + { + await connection.CloseAsync(); + } + + await connection.OpenAsync(); + + try + { + await using (var transaction = useTransaction + ? await connection.BeginTransactionAsync() + : null) + { + T result; + await using (var command = CreateCommand(connection, sql, parameters)) + { + command.Transaction = transaction; + result = await execute(command); + } + + if (transaction != null) + { + await transaction.CommitAsync(); + } + + return result; + } + } + finally + { + if (connection.State != ConnectionState.Closed) + { + await connection.CloseAsync(); + } + } + } + public int ExecuteNonQuery(string sql, params object[] parameters) => ExecuteNonQuery(Connection, sql, parameters); + public Task ExecuteNonQueryAsync(string sql, params object[] parameters) + => ExecuteNonQueryAsync(Connection, sql, parameters); + private static int ExecuteNonQuery(DbConnection connection, string sql, object[] parameters = null) => Execute(connection, command => command.ExecuteNonQuery(), sql, false, parameters); + private static Task ExecuteNonQueryAsync(DbConnection connection, string sql, object[] parameters = null) + => ExecuteAsync(connection, command => command.ExecuteNonQueryAsync(), sql, false, parameters); + public override void OpenConnection() { base.OpenConnection(); diff --git a/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestStoreFactory.cs b/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestStoreFactory.cs index f1a31e51d..b8716309d 100644 --- a/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestStoreFactory.cs +++ b/test/EFCore.SingleStore.FunctionalTests/TestUtilities/SingleStoreTestStoreFactory.cs @@ -35,7 +35,8 @@ public override TestStore GetOrCreate(string storeName) => SingleStoreTestStore.GetOrCreate(storeName, noBackslashEscapes: NoBackslashEscapes, databaseCollation: DatabaseCollation, guidFormat: GuidFormat); public override IServiceCollection AddProviderServices(IServiceCollection serviceCollection) - => serviceCollection.AddEntityFrameworkSingleStore(); - + => serviceCollection + .AddEntityFrameworkSingleStore() + .AddEntityFrameworkSingleStoreNetTopologySuite(); } } diff --git a/test/EFCore.SingleStore.FunctionalTests/TestUtilities/Xunit/SingleStoreXunitTestFrameworkDiscoverer.cs b/test/EFCore.SingleStore.FunctionalTests/TestUtilities/Xunit/SingleStoreXunitTestFrameworkDiscoverer.cs index 6f426e39b..dfe3debf2 100644 --- a/test/EFCore.SingleStore.FunctionalTests/TestUtilities/Xunit/SingleStoreXunitTestFrameworkDiscoverer.cs +++ b/test/EFCore.SingleStore.FunctionalTests/TestUtilities/Xunit/SingleStoreXunitTestFrameworkDiscoverer.cs @@ -25,6 +25,9 @@ public SingleStoreXunitTestFrameworkDiscoverer( // Prime the cache with our own discoverers, so they get used over the original ones from EF Core. DiscovererTypeCache.Add(typeof(ConditionalFactAttribute), typeof(SingleStoreConditionalFactDiscoverer)); DiscovererTypeCache.Add(typeof(ConditionalTheoryAttribute), typeof(SingleStoreConditionalTheoryDiscoverer)); + + DiscovererTypeCache.Add(typeof(SkippableFactAttribute), typeof(SkippableFactDiscoverer)); + DiscovererTypeCache.Add(typeof(SkippableTheoryAttribute), typeof(SkippableTheoryDiscoverer)); } protected override bool IsValidTestClass(ITypeInfo type) diff --git a/test/EFCore.SingleStore.FunctionalTests/TransactionSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/TransactionSingleStoreTest.cs index b432ee340..0896a0b6a 100644 --- a/test/EFCore.SingleStore.FunctionalTests/TransactionSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/TransactionSingleStoreTest.cs @@ -82,14 +82,14 @@ public class TransactionSingleStoreFixture : TransactionFixtureBase { protected override ITestStoreFactory TestStoreFactory => SingleStoreTestStoreFactory.Instance; - public override void Reseed() + public override async Task ReseedAsync() { - using var context = CreateContext(); + await using var context = CreateContext(); context.Set().RemoveRange(context.Set()); context.Set().RemoveRange(context.Set()); - context.SaveChanges(); + await context.SaveChangesAsync(); - base.Seed(context); + await base.SeedAsync(context); } public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) diff --git a/test/EFCore.SingleStore.FunctionalTests/Update/StoredProcedureUpdateSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/Update/StoredProcedureUpdateSingleStoreTest.cs index 4cddc358a..75cdbabc6 100644 --- a/test/EFCore.SingleStore.FunctionalTests/Update/StoredProcedureUpdateSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/Update/StoredProcedureUpdateSingleStoreTest.cs @@ -1192,13 +1192,13 @@ private async Task SaveChanges(DbContext context, bool async) } } - protected override void CreateStoredProcedures(DbContext context, string createSprocSql) + protected override async Task CreateStoredProcedures(DbContext context, string createSprocSql) { foreach (var batch in new Regex(@"[\r\n\s]*(?:\r|\n)GO;?[\r\n\s]*", RegexOptions.IgnoreCase | RegexOptions.Singleline, TimeSpan.FromMilliseconds(1000.0)) .Split(createSprocSql).Where(b => !string.IsNullOrEmpty(b))) { - context.Database.ExecuteSqlRaw(batch); + await context.Database.ExecuteSqlRawAsync(batch); } } diff --git a/test/EFCore.SingleStore.FunctionalTests/UpdatesSingleStoreTest.cs b/test/EFCore.SingleStore.FunctionalTests/UpdatesSingleStoreTest.cs index 45927ab82..19afdd1ca 100644 --- a/test/EFCore.SingleStore.FunctionalTests/UpdatesSingleStoreTest.cs +++ b/test/EFCore.SingleStore.FunctionalTests/UpdatesSingleStoreTest.cs @@ -5,15 +5,11 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.TestModels.UpdatesModel; using Microsoft.EntityFrameworkCore.TestUtilities; +using Microsoft.EntityFrameworkCore.Update; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; using EntityFrameworkCore.SingleStore.Infrastructure; using EntityFrameworkCore.SingleStore.Tests.TestUtilities.Attributes; -using EntityFrameworkCore.SingleStore.ValueGeneration.Internal; using Xunit; -using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage; - namespace EntityFrameworkCore.SingleStore.FunctionalTests { @@ -40,42 +36,42 @@ public override void Identifiers_are_generated_correctly() } [ConditionalFact] - public override void Can_add_and_remove_self_refs() + public override Task Can_add_and_remove_self_refs() { // We're skipping this test when we're running tests on Managed Service due to the specifics of // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) if (AppConfig.ManagedService) { - return; + return Task.CompletedTask; } - base.Can_add_and_remove_self_refs(); + return base.Can_add_and_remove_self_refs(); } [ConditionalFact] - public override void Can_use_shared_columns_with_conversion() + public override Task Can_use_shared_columns_with_conversion() { // We're skipping this test when we're running tests on Managed Service due to the specifics of // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) if (AppConfig.ManagedService) { - return; + return Task.CompletedTask; } - base.Can_use_shared_columns_with_conversion(); + return base.Can_use_shared_columns_with_conversion(); } [ConditionalFact] - public override void Can_change_enums_with_conversion() + public override Task Can_change_enums_with_conversion() { // We're skipping this test when we're running tests on Managed Service due to the specifics of // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) if (AppConfig.ManagedService) { - return; + return Task.CompletedTask; } - base.Can_change_enums_with_conversion(); + return base.Can_change_enums_with_conversion(); } [ConditionalTheory] @@ -105,16 +101,16 @@ public override async Task Can_change_type_of_pk_to_pk_dependent_by_replacing_wi } [ConditionalFact] - public override void Save_replaced_principal() + public override Task Save_replaced_principal() { // We're skipping this test when we're running tests on Managed Service due to the specifics of // how AUTO_INCREMENT works (https://docs.singlestore.com/cloud/reference/sql-reference/data-definition-language-ddl/create-table/#auto-increment-behavior) if (AppConfig.ManagedService) { - return; + return Task.CompletedTask; } - base.Save_replaced_principal(); + return base.Save_replaced_principal(); } [ConditionalTheory] @@ -147,9 +143,9 @@ public override void Save_replaced_principal() [SupportedServerVersionCondition(nameof(ServerVersionSupport.DefaultExpression), nameof(ServerVersionSupport.AlternativeDefaultExpression))] [SupportedServerVersionCondition(nameof(ServerVersionSupport.Returning))] - public override void Save_with_shared_foreign_key() + public override Task Save_with_shared_foreign_key() { - base.Save_with_shared_foreign_key(); + return base.Save_with_shared_foreign_key(); } public class UpdatesSingleStoreFixture : UpdatesRelationalFixture diff --git a/test/EFCore.SingleStore.FunctionalTests/WithConstructorsSingleStoreTestBase.cs b/test/EFCore.SingleStore.FunctionalTests/WithConstructorsSingleStoreTestBase.cs index 82ca8300c..ae3a77e7a 100644 --- a/test/EFCore.SingleStore.FunctionalTests/WithConstructorsSingleStoreTestBase.cs +++ b/test/EFCore.SingleStore.FunctionalTests/WithConstructorsSingleStoreTestBase.cs @@ -34,11 +34,11 @@ protected virtual void UseTransaction(DatabaseFacade facade, IDbContextTransacti } [ConditionalFact] - public virtual void Query_and_update_using_constructors_with_property_parameters() + public virtual async Task Query_and_update_using_constructors_with_property_parameters() { - TestHelpers.ExecuteWithStrategyInTransaction( + await TestHelpers.ExecuteWithStrategyInTransactionAsync( CreateContext, UseTransaction, - context => + async context => { var blog = context.Set().Include(e => e.Posts).Single(); @@ -61,9 +61,9 @@ public virtual void Query_and_update_using_constructors_with_property_parameters var newBlog = context.Add(new Blog("Cats", 100)).Entity; newBlog.AddPost(new Post("Baxter is a cat.", "With dog friends.")); - context.SaveChanges(); + await context.SaveChangesAsync(); }, - context => + async context => { var blogs = context.Set().Include(e => e.Posts).OrderBy(e => e.Title).ToList(); @@ -91,6 +91,8 @@ public virtual void Query_and_update_using_constructors_with_property_parameters Assert.StartsWith("Olive", posts[2].Title); Assert.StartsWith("Yes", posts[2].Content); + + await Task.CompletedTask; }); } @@ -1672,7 +1674,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con modelBuilder.Entity(); } - protected override void Seed(WithConstructorsContext context) + protected override Task SeedAsync(WithConstructorsContext context) { var blog = new Blog("Puppies"); @@ -1773,7 +1775,7 @@ protected override void Seed(WithConstructorsContext context) context.Add(lazyPcsBlog); - context.SaveChanges(); + return context.SaveChangesAsync(); } } } diff --git a/test/EFCore.SingleStore.FunctionalTests/config.json.example b/test/EFCore.SingleStore.FunctionalTests/config.json.example index c944e6fa7..edea7f396 100644 --- a/test/EFCore.SingleStore.FunctionalTests/config.json.example +++ b/test/EFCore.SingleStore.FunctionalTests/config.json.example @@ -1,6 +1,6 @@ { "Data": { - "ConnectionString": "server=127.0.0.1;user id=root;password=Password12!;port=3306;sslmode=none;", + "ConnectionString": "server=127.0.0.1;user id=root;password=Password12!;port=3306;sslmode=none;maxpoolsize=200;", "ServerVersion": "auto", "CommandTimeout": "600" } diff --git a/test/EFCore.SingleStore.IntegrationTests/AppDbScope.cs b/test/EFCore.SingleStore.IntegrationTests/AppDbScope.cs index 629a92958..c2b46952e 100644 --- a/test/EFCore.SingleStore.IntegrationTests/AppDbScope.cs +++ b/test/EFCore.SingleStore.IntegrationTests/AppDbScope.cs @@ -1,5 +1,6 @@ using System; using System.Data.Common; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using EntityFrameworkCore.SingleStore.Tests; @@ -8,23 +9,40 @@ namespace EntityFrameworkCore.SingleStore.IntegrationTests { public class AppDbScope : IDisposable { - private static ServiceProvider CreateServiceProvider(DbConnection connection = null) + private static ServiceProvider CreateServiceProvider(DbConnection connection = null, string sessionTimeZone = null) { var serviceCollection = new ServiceCollection(); - serviceCollection - .AddLogging(builder => - builder - .AddConfiguration(AppConfig.Config.GetSection("Logging")) - .AddConsole() - ); - Startup.ConfigureEntityFramework(serviceCollection); - - return serviceCollection.BuildServiceProvider(); + serviceCollection + .AddLogging(builder => + builder + .AddConfiguration(AppConfig.Config.GetSection("Logging")) + .AddConsole() + ); + + // Register baseline EF services/config (existing behavior) + Startup.ConfigureEntityFramework(serviceCollection); + + // If a session time zone is requested, re-register AppDb with the override. + // Last registration wins for GetService(). + if (!string.IsNullOrEmpty(sessionTimeZone)) + { + serviceCollection.AddDbContext(options => + { + if (connection != null) + { + options.UseSingleStore(connection, o => o.SessionTimeZone(sessionTimeZone)); + } + else + { + options.UseSingleStore(AppConfig.ConnectionString, o => o.SessionTimeZone(sessionTimeZone)); + } + }); + } + + return serviceCollection.BuildServiceProvider(); } - private static Lazy DefaultLazyServiceProvider = new Lazy(() => { - return CreateServiceProvider(); - }); + private static readonly Lazy DefaultLazyServiceProvider = new(() => CreateServiceProvider()); private IServiceScope _scope; @@ -40,6 +58,12 @@ public AppDbScope(DbConnection connection = null) _scope = serviceProvider.CreateScope(); } + public AppDbScope(string sessionTimeZone, DbConnection connection = null) + { + var serviceProvider = CreateServiceProvider(connection, sessionTimeZone); + _scope = serviceProvider.CreateScope(); + } + public AppDb AppDb => _scope.ServiceProvider.GetService(); public void Dispose() @@ -52,3 +76,4 @@ public void Dispose() } } } + diff --git a/test/EFCore.SingleStore.IntegrationTests/EFCore.SingleStore.IntegrationTests.csproj b/test/EFCore.SingleStore.IntegrationTests/EFCore.SingleStore.IntegrationTests.csproj index 5220d34c9..c152baf4e 100644 --- a/test/EFCore.SingleStore.IntegrationTests/EFCore.SingleStore.IntegrationTests.csproj +++ b/test/EFCore.SingleStore.IntegrationTests/EFCore.SingleStore.IntegrationTests.csproj @@ -22,9 +22,6 @@ - - - diff --git a/test/EFCore.SingleStore.IntegrationTests/Tests/Models/ExpressionTest.cs b/test/EFCore.SingleStore.IntegrationTests/Tests/Models/ExpressionTest.cs index f01af411b..41eee5d06 100644 --- a/test/EFCore.SingleStore.IntegrationTests/Tests/Models/ExpressionTest.cs +++ b/test/EFCore.SingleStore.IntegrationTests/Tests/Models/ExpressionTest.cs @@ -145,25 +145,28 @@ public async Task SingleStoreDatePartTranslator() [Fact] public async Task SingleStoreDateTimeNowTranslator() { - var utcOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now); - var utcOffsetStr = (utcOffset.TotalHours >= 0 ? "+" : "") + utcOffset.TotalHours.ToString("00") + ":" + utcOffset.Minutes.ToString("00"); + var offset = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow); + var sign = offset < TimeSpan.Zero ? "-" : "+"; + var hours = Math.Abs(offset.Hours); + var minutes = Math.Abs(offset.Minutes); + var utcOffsetStr = $"{sign}{hours:00}:{minutes:00}"; + + using var tzScope = new AppDbScope(sessionTimeZone: utcOffsetStr); + var db = tzScope.AppDb; + + var result = await db.DataTypesSimple + .Where(m => m.Id == _simple.Id) + .Select(m => new + { + UtcNow = DateTime.UtcNow, + LocalNow = DateTimeOffset.Now.LocalDateTime + }) + .FirstOrDefaultAsync(); - await _db.Database.OpenConnectionAsync(); -#pragma warning disable EF1002 - await _db.Database.ExecuteSqlRawAsync($"SET @@session.time_zone = '{utcOffsetStr}'"); -#pragma warning restore EF1002 - - var result = await _db.DataTypesSimple.Select(m => - new { - m.Id, - DateTime.Now, - DateTime.UtcNow - }).FirstOrDefaultAsync(m => m.Id == _simple.Id); - - _db.Database.CloseConnection(); + Assert.NotNull(result); - Assert.InRange(result.Now, DateTime.Now - TimeSpan.FromSeconds(5), DateTime.Now + TimeSpan.FromSeconds(5)); - Assert.InRange(result.UtcNow, DateTime.UtcNow - TimeSpan.FromSeconds(5), DateTime.UtcNow + TimeSpan.FromSeconds(5)); + // LocalNow should be UtcNow converted by the configured offset. + Assert.Equal(result.UtcNow.Add(offset), result.LocalNow, precision: TimeSpan.FromSeconds(10)); } [Fact] diff --git a/test/EFCore.SingleStore.IntegrationTests/scripts/stress.sh b/test/EFCore.SingleStore.IntegrationTests/scripts/stress.sh deleted file mode 100755 index da109d278..000000000 --- a/test/EFCore.SingleStore.IntegrationTests/scripts/stress.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -cd $(dirname $0) -cd vegeta - -RATE=${1:-50} -DURATION=${2:-5s} -TARGETS=${3:-async} -TARGETS=targets-$TARGETS.txt - -echo "Rate = $RATE RPS" -echo "Duration = $DURATION" -echo "Targets = $TARGETS" - -# warm up the JIT Compiler -vegeta attack -targets=$TARGETS -rate=10 -duration=1s > /dev/null 2>&1 -# run the actual test -vegeta attack -targets=$TARGETS -rate="$RATE" -duration="$DURATION" | vegeta report \ No newline at end of file diff --git a/test/EFCore.SingleStore.Tests/Behaviors/HavingBehavior.cs b/test/EFCore.SingleStore.Tests/Behaviors/HavingBehavior.cs new file mode 100644 index 000000000..98aa2db6f --- /dev/null +++ b/test/EFCore.SingleStore.Tests/Behaviors/HavingBehavior.cs @@ -0,0 +1,148 @@ +using System; +using Microsoft.EntityFrameworkCore; +using SingleStoreConnector; +using Xunit; +using Xunit.Abstractions; + +namespace EntityFrameworkCore.SingleStore.Behaviors; + +// See https://bugs.mysql.com/bug.php?id=103961. +public class HavingBehavior : RawSqlTestWithFixture +{ + public HavingBehavior(HavingBehaviorFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + } + + [Fact] + public void Having_without_aggregate_with_function_is_allowed_by_default() + { + using var command = Connection.CreateCommand(); + command.CommandText = """ +SELECT EXTRACT(year FROM `i`.`BestServedBefore`) AS `Year`, COUNT(*) AS `Count` +FROM `IceCreams` AS `i` +GROUP BY EXTRACT(year FROM `i`.`BestServedBefore`) +HAVING EXTRACT(year FROM `i`.`BestServedBefore`) < 2030 +ORDER BY COUNT(*) DESC +"""; + + using var reader = command.ExecuteReader(); + + Assert.True(reader.Read()); + Assert.Equal(2025, Convert.ToInt32(reader["Year"])); + Assert.Equal(2L, Convert.ToInt64(reader["Count"])); + Assert.False(reader.Read()); + } + + [Fact] + public void Having_without_aggregate_with_function_using_projection_reference() + { + using var command = Connection.CreateCommand(); + command.CommandText = """ +SELECT EXTRACT(year FROM `i`.`BestServedBefore`) AS `Year`, COUNT(*) AS `Count` +FROM `IceCreams` AS `i` +GROUP BY EXTRACT(year FROM `i`.`BestServedBefore`) +HAVING `Year` < 2030 +ORDER BY COUNT(*) DESC +"""; + + using var dataReader = command.ExecuteReader(); + + Assert.True(dataReader.Read()); + Assert.Equal(2025, Convert.ToInt32(dataReader["Year"])); + Assert.Equal(2L, Convert.ToInt64(dataReader["Count"])); + Assert.False(dataReader.Read()); + } + + [Fact] + public void Having_without_aggregate_with_column_is_allowed_by_default() + { + using var command = Connection.CreateCommand(); + command.CommandText = """ +SELECT EXTRACT(year FROM `i`.`BestServedBefore`) AS `Year`, COUNT(*) AS `Count` +FROM `IceCreams` AS `i` +GROUP BY EXTRACT(year FROM `i`.`BestServedBefore`) +HAVING `i`.`BestServedBefore` < '2030-01-01' +ORDER BY COUNT(*) DESC +"""; + + using var reader = command.ExecuteReader(); + + Assert.True(reader.Read()); + Assert.Equal(2025, Convert.ToInt32(reader["Year"])); + Assert.Equal(2L, Convert.ToInt64(reader["Count"])); + Assert.False(reader.Read()); + } + + [Fact] + public void Having_without_aggregate_with_column_using_projection_reference() + { + using var command = Connection.CreateCommand(); + command.CommandText = """ +SELECT EXTRACT(year FROM `i`.`BestServedBefore`) AS `Year`, COUNT(*) AS `Count`, `i`.`BestServedBefore` < '2030-01-01' AS `having` +FROM `IceCreams` AS `i` +GROUP BY EXTRACT(year FROM `i`.`BestServedBefore`), `i`.`BestServedBefore` < '2030-01-01' +HAVING `having` +ORDER BY COUNT(*) DESC +"""; + + using var dataReader = command.ExecuteReader(); + + Assert.True(dataReader.Read()); + Assert.Equal(2025, Convert.ToInt32(dataReader["Year"])); + Assert.Equal(2L, Convert.ToInt64(dataReader["Count"])); + Assert.False(dataReader.Read()); + } + + [Fact] + public void Having_without_aggregate_with_constant() + { + using var command = Connection.CreateCommand(); + command.CommandText = """ +SELECT EXTRACT(year FROM `i`.`BestServedBefore`) AS `Year`, COUNT(*) AS `Count` +FROM `IceCreams` AS `i` +GROUP BY EXTRACT(year FROM `i`.`BestServedBefore`) +HAVING TRUE +ORDER BY COUNT(*) DESC +"""; + + using var dataReader = command.ExecuteReader(); + + Assert.True(dataReader.Read()); + Assert.Equal(2025, Convert.ToInt32(dataReader["Year"])); + Assert.Equal(2L, Convert.ToInt64(dataReader["Count"])); + Assert.True(dataReader.Read()); + Assert.Equal(2036, Convert.ToInt32(dataReader["Year"])); + Assert.Equal(1L, Convert.ToInt64(dataReader["Count"])); + Assert.False(dataReader.Read()); + } + + public static class Model + { + public class IceCream + { + public int IceCreamId { get; set; } + public string Name { get; set; } + public DateTime BestServedBefore { get; set; } + } + + public class HavingBehaviorContext : ContextBase + { + public DbSet IceCreams { get; set; } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity( + entity => + { + entity.HasData( + new IceCream { IceCreamId = 1, Name = "Vanilla", BestServedBefore = new DateTime(2025, 6, 1)}, + new IceCream { IceCreamId = 2, Name = "Chocolate", BestServedBefore = new DateTime(2025, 6, 1)}, + new IceCream { IceCreamId = 3, Name = "Matcha", BestServedBefore = new DateTime(2036, 1, 1)}); + }); + } + } + } + + public class HavingBehaviorFixture : SingleStoreTestFixtureBase; +} diff --git a/test/EFCore.SingleStore.Tests/Bugs/SingleStoreBug96947.cs b/test/EFCore.SingleStore.Tests/Bugs/SingleStoreBug96947.cs index bb80e534e..a74108837 100644 --- a/test/EFCore.SingleStore.Tests/Bugs/SingleStoreBug96947.cs +++ b/test/EFCore.SingleStore.Tests/Bugs/SingleStoreBug96947.cs @@ -1,14 +1,11 @@ using System; using Microsoft.EntityFrameworkCore; -using EntityFrameworkCore.SingleStore.Infrastructure; -using EntityFrameworkCore.SingleStore.Tests.TestUtilities.Attributes; using Xunit; using Xunit.Abstractions; namespace EntityFrameworkCore.SingleStore.Bugs { // Made internal to skip all tests. - [SupportedServerVersionCondition(nameof(ServerVersionSupport.SingleStoreBug96947Workaround))] internal class SingleStoreBug96947 : RawSqlTestWithFixture { public SingleStoreBug96947(FixtureClass fixture, ITestOutputHelper testOutputHelper) diff --git a/test/EFCore.SingleStore.Tests/SingleStoreDbContextOptionsExtensionsTest.cs b/test/EFCore.SingleStore.Tests/SingleStoreDbContextOptionsExtensionsTest.cs index ca2905bc3..2fe75f98c 100644 --- a/test/EFCore.SingleStore.Tests/SingleStoreDbContextOptionsExtensionsTest.cs +++ b/test/EFCore.SingleStore.Tests/SingleStoreDbContextOptionsExtensionsTest.cs @@ -1,8 +1,10 @@ using System; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.TestModels.ConferencePlanner; using Microsoft.Extensions.DependencyInjection; +using SingleStoreConnector; using EntityFrameworkCore.SingleStore.Infrastructure; using EntityFrameworkCore.SingleStore.Infrastructure.Internal; using EntityFrameworkCore.SingleStore.Internal; @@ -216,28 +218,113 @@ public void UseSingleStore_with_ServerVersion_FromString() Assert.Equal("singlestore", mySqlOptions.ServerVersion.TypeIdentifier); } - [ConditionalFact(Skip="ServerVersion parameter isn't needed anymore to call UseSingleStore()")] - public void UseSingleStore_with_ServerVersion_AutoDetect() + [ConditionalTheory] + [InlineData(false)] + [InlineData(true)] + public async Task UseSingleStore_with_ServerVersion_AutoDetect_connection_string(bool async) { var builder = new DbContextOptionsBuilder(); - var serverVersion = ServerVersion.AutoDetect(AppConfig.ConnectionString); + var serverVersion = async + ? await ServerVersion.AutoDetectAsync(AppConfig.ConnectionString) + : ServerVersion.AutoDetect(AppConfig.ConnectionString); - builder.UseSingleStore( - "Server=foo"); + builder.UseSingleStore("Server=foo"); + + var mySqlOptions = new SingleStoreOptions(); + mySqlOptions.Initialize(builder.Options); + + // Use the autodetected value so the call is still validated + Assert.True(serverVersion.Version.Major > 0); + + Assert.Equal(SingleStoreServerVersion.LatestSupportedServerVersion.Version, mySqlOptions.ServerVersion.Version); + Assert.Equal(SingleStoreServerVersion.LatestSupportedServerVersion.Type, mySqlOptions.ServerVersion.Type); + Assert.Equal(SingleStoreServerVersion.LatestSupportedServerVersion.TypeIdentifier, mySqlOptions.ServerVersion.TypeIdentifier); + } + + [ConditionalTheory] + [InlineData(false)] + [InlineData(true)] + public async Task UseSingleStore_with_ServerVersion_AutoDetect_connection_closed(bool async) + { + var builder = new DbContextOptionsBuilder(); + await using var connection = new SingleStoreConnection(AppConfig.ConnectionString); + var serverVersion = async + ? await ServerVersion.AutoDetectAsync(connection) + : ServerVersion.AutoDetect(connection); + + builder.UseSingleStore("Server=foo"); + + var mySqlOptions = new SingleStoreOptions(); + mySqlOptions.Initialize(builder.Options); + + Assert.True(serverVersion.Version.Major > 0); + + Assert.Equal(SingleStoreServerVersion.LatestSupportedServerVersion.Version, mySqlOptions.ServerVersion.Version); + Assert.Equal(SingleStoreServerVersion.LatestSupportedServerVersion.Type, mySqlOptions.ServerVersion.Type); + Assert.Equal(SingleStoreServerVersion.LatestSupportedServerVersion.TypeIdentifier, mySqlOptions.ServerVersion.TypeIdentifier); + } + + [ConditionalTheory] + [InlineData(false)] + [InlineData(true)] + public async Task UseSingleStore_with_ServerVersion_AutoDetect_connection_opened(bool async) + { + var builder = new DbContextOptionsBuilder(); + + await using var connection = new SingleStoreConnection(AppConfig.ConnectionString); + if (async) + { + await connection.OpenAsync(); + } + else + { + connection.Open(); + } + + var serverVersion = async + ? await ServerVersion.AutoDetectAsync(connection) + : ServerVersion.AutoDetect(connection); + + builder.UseSingleStore("Server=foo"); + + var mySqlOptions = new SingleStoreOptions(); + mySqlOptions.Initialize(builder.Options); + + Assert.True(serverVersion.Version.Major > 0); + + Assert.Equal(SingleStoreServerVersion.LatestSupportedServerVersion.Version, mySqlOptions.ServerVersion.Version); + Assert.Equal(SingleStoreServerVersion.LatestSupportedServerVersion.Type, mySqlOptions.ServerVersion.Type); + Assert.Equal(SingleStoreServerVersion.LatestSupportedServerVersion.TypeIdentifier, mySqlOptions.ServerVersion.TypeIdentifier); + } + + [ConditionalTheory] + [InlineData(false)] + [InlineData(true)] + public async Task UseSingleStore_with_ServerVersion_AutoDetect_datasource(bool async) + { + var builder = new DbContextOptionsBuilder(); + await using var dataSource = new SingleStoreDataSource(AppConfig.ConnectionString); + var serverVersion = async + ? await ServerVersion.AutoDetectAsync(dataSource) + : ServerVersion.AutoDetect(dataSource); + + builder.UseSingleStore("Server=foo"); var mySqlOptions = new SingleStoreOptions(); mySqlOptions.Initialize(builder.Options); - Assert.Equal(serverVersion.Version, mySqlOptions.ServerVersion.Version); - Assert.Equal(serverVersion.Type, mySqlOptions.ServerVersion.Type); - Assert.Equal(serverVersion.TypeIdentifier, mySqlOptions.ServerVersion.TypeIdentifier); + Assert.True(serverVersion.Version.Major > 0); + + Assert.Equal(SingleStoreServerVersion.LatestSupportedServerVersion.Version, mySqlOptions.ServerVersion.Version); + Assert.Equal(SingleStoreServerVersion.LatestSupportedServerVersion.Type, mySqlOptions.ServerVersion.Type); + Assert.Equal(SingleStoreServerVersion.LatestSupportedServerVersion.TypeIdentifier, mySqlOptions.ServerVersion.TypeIdentifier); } [ConditionalFact(Skip="Connection string/connection is a mandatory parameter for UseSingleStore() call")] public void UseSingleStore_without_connection_string() { var builder = new DbContextOptionsBuilder(); - var serverVersion = ServerVersion.AutoDetect(AppConfig.ConnectionString); + var serverVersion = SingleStoreServerVersion.LatestSupportedServerVersion; builder.UseSingleStore(); diff --git a/test/EFCore.SingleStore.Tests/SingleStoreRelationalConnectionTest.cs b/test/EFCore.SingleStore.Tests/SingleStoreRelationalConnectionTest.cs index 8d14ab95b..da8bf44ab 100644 --- a/test/EFCore.SingleStore.Tests/SingleStoreRelationalConnectionTest.cs +++ b/test/EFCore.SingleStore.Tests/SingleStoreRelationalConnectionTest.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Data.Common; using System.Diagnostics; using System.Reflection; @@ -10,8 +11,10 @@ using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Primitives; using SingleStoreConnector; using EntityFrameworkCore.SingleStore.Diagnostics.Internal; using EntityFrameworkCore.SingleStore.Infrastructure.Internal; @@ -33,6 +36,19 @@ public void Creates_SingleStore_Server_connection_string() Assert.IsType(connection.DbConnection); } + [Fact] + public void Accepts_named_connection_string() + { + using var connection = CreateConnection( + new DbContextOptionsBuilder() + .UseSingleStore(@"name=NamedConnectionString") + .UseApplicationServiceProvider( + new ServiceCollection() + .AddSingleton() + .BuildServiceProvider()) + .Options); + } + /*[Fact] public void Uses_DbDataSource_from_DbContextOptions() { @@ -276,7 +292,7 @@ public void CurrentAmbientTransaction_returns_transaction_with_AutoEnlist_enable private static SingleStoreRelationalConnection CreateConnection(DbContextOptions options = null, DbDataSource dataSource = null) { options ??= new DbContextOptionsBuilder() - .UseSingleStore(@"Server=localhost;User ID=some_user;Password=some_password;Database=SingleStoreConnectionTest") + .UseSingleStore(ConnectionString) .Options; foreach (var extension in options.Extensions) @@ -320,20 +336,7 @@ private static SingleStoreRelationalConnection CreateConnection(DbContextOptions singletonOptions); } - private const string ConnectionString = "Fake Connection String"; - - private static IDbContextOptions CreateOptions( - RelationalOptionsExtension optionsExtension = null) - { - var optionsBuilder = new DbContextOptionsBuilder(); - - ((IDbContextOptionsBuilderInfrastructure)optionsBuilder) - .AddOrUpdateExtension( - optionsExtension - ?? new FakeRelationalOptionsExtension().WithConnectionString(ConnectionString)); - - return optionsBuilder.Options; - } + private const string ConnectionString = @"Server=localhost;User ID=some_user;Password=some_password;Database=SingleStoreConnectionTest"; private class FakeDbContext : DbContext { @@ -346,4 +349,22 @@ public FakeDbContext(DbContextOptions options) { } } + + private class FakeConfiguration : IConfiguration + { + public IConfigurationSection GetSection(string key) + => throw new NotImplementedException(); + + public IEnumerable GetChildren() + => throw new NotImplementedException(); + + public IChangeToken GetReloadToken() + => throw new NotImplementedException(); + + public string this[string key] + { + get => ConnectionString; + set => throw new NotImplementedException(); + } + } } diff --git a/test/EFCore.SingleStore.Tests/SingleStoreTestFixtureBase.cs b/test/EFCore.SingleStore.Tests/SingleStoreTestFixtureBase.cs index 52f286aab..941b2b895 100644 --- a/test/EFCore.SingleStore.Tests/SingleStoreTestFixtureBase.cs +++ b/test/EFCore.SingleStore.Tests/SingleStoreTestFixtureBase.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.Extensions.DependencyInjection; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; +using Xunit; namespace EntityFrameworkCore.SingleStore { @@ -24,33 +26,42 @@ public void Dispose() } public class SingleStoreTestFixtureBase - : SingleStoreTestFixtureBase + : SingleStoreTestFixtureBase, IAsyncLifetime where TContext : ContextBase, new() { + private readonly bool _initializeEmpty; private const string FixtureSuffix = "Fixture"; public SingleStoreTestFixtureBase(bool initializeEmpty = false) + { + _initializeEmpty = initializeEmpty; + } + + public async Task InitializeAsync() { // We branch here, because CreateDefaultDbContext depends on TestStore.Name by default, which would not be available yet in // the SingleStoreTestStore.RecreateInitialized(StoreName) call. - if (initializeEmpty) + if (_initializeEmpty) { - TestStore = SingleStoreTestStore.RecreateInitialized(StoreName); + TestStore = await SingleStoreTestStore.RecreateInitializedAsync(StoreName); } else { TestStore = SingleStoreTestStore.Create(StoreName); - TestStore.InitializeSingleStore(null, CreateDefaultDbContext, null, c => + await TestStore.InitializeSingleStoreAsync(null, CreateDefaultDbContext, null, async c => { - c.Database.EnsureDeleted(); - c.Database.EnsureCreated(); + await c.Database.EnsureDeletedAsync(); + await c.Database.EnsureCreatedAsync(); }); } SetupDatabase(); } + public Task DisposeAsync() + => Task.CompletedTask; + protected override void Dispose(bool disposing) { TestStore.Dispose(); @@ -68,7 +79,7 @@ protected virtual string StoreName } } - protected virtual SingleStoreTestStore TestStore { get; } + protected virtual SingleStoreTestStore TestStore { get; private set; } protected virtual string SetupDatabaseScript { get; } protected virtual List SqlCommands { get; } = new List(); protected virtual string Sql => string.Join("\n\n", SqlCommands); diff --git a/test/EFCore.SingleStore.Tests/TestBase.cs b/test/EFCore.SingleStore.Tests/TestBase.cs index 8f9a3a650..cb10510aa 100644 --- a/test/EFCore.SingleStore.Tests/TestBase.cs +++ b/test/EFCore.SingleStore.Tests/TestBase.cs @@ -1,27 +1,32 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using EntityFrameworkCore.SingleStore.FunctionalTests.TestUtilities; +using Xunit; namespace EntityFrameworkCore.SingleStore { - public class TestBase : IDisposable + public class TestBase : IDisposable, IAsyncLifetime where TContext : ContextBase, new() { - public TestBase() + public async Task InitializeAsync() { - TestStore = SingleStoreTestStore.CreateInitialized(StoreName); + TestStore = await SingleStoreTestStore.CreateInitializedAsync(StoreName); } + + public Task DisposeAsync() + => Task.CompletedTask; + public virtual void Dispose() => TestStore.Dispose(); public virtual string StoreName => GetType().Name; - public virtual SingleStoreTestStore TestStore { get; } + public virtual SingleStoreTestStore TestStore { get; private set; } public virtual List SqlCommands { get; } = new List(); public virtual string Sql => string.Join("\n\n", SqlCommands); - public virtual TContext CreateContext( - Action jetOptions = null, + public virtual async Task CreateContext(Action jetOptions = null, Action options = null, Action model = null) { @@ -34,7 +39,7 @@ public virtual TContext CreateContext( options: options, mySqlOptions: jetOptions); - TestStore.Clean(context); + await TestStore.CleanAsync(context); return context; } diff --git a/test/Shared/TestUtilities/Attributes/SupportedServerVersionBetweenConditionAttribute.cs b/test/Shared/TestUtilities/Attributes/SupportedServerVersionBetweenConditionAttribute.cs new file mode 100644 index 000000000..eab04578f --- /dev/null +++ b/test/Shared/TestUtilities/Attributes/SupportedServerVersionBetweenConditionAttribute.cs @@ -0,0 +1,48 @@ +using System; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.TestUtilities.Xunit; + +namespace EntityFrameworkCore.SingleStore.Tests.TestUtilities.Attributes +{ + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)] + public class SupportedServerVersionBetweenConditionAttribute : Attribute, ITestCondition + { + public ServerVersion MinVersionInclusive { get; } + public ServerVersion MaxVersionExclusive { get; } + + public SupportedServerVersionBetweenConditionAttribute(string minVersionInclusive, string maxVersionExclusive) + { + MinVersionInclusive = ServerVersion.Parse(minVersionInclusive); + MaxVersionExclusive = ServerVersion.Parse(maxVersionExclusive); + } + + public virtual ValueTask IsMetAsync() + { + var currentVersion = AppConfig.ServerVersion; + var isMet = currentVersion.Type == MinVersionInclusive.Type && + currentVersion.TypeIdentifier == MinVersionInclusive.TypeIdentifier && + currentVersion.Version >= MinVersionInclusive.Version && + currentVersion.Type == MaxVersionExclusive.Type && + currentVersion.TypeIdentifier == MaxVersionExclusive.TypeIdentifier && + currentVersion.Version < MaxVersionExclusive.Version; + + if (Invert) + { + isMet = !isMet; + } + + if (!isMet && string.IsNullOrEmpty(Skip)) + { + Skip = $"The test is not supported on server version {currentVersion}."; + } + + return new ValueTask(isMet); + } + + public virtual string SkipReason => Skip; + public virtual string Skip { get; set; } + public virtual bool Invert { get; set; } + } +} + diff --git a/tools/QueryBaselineUpdater/Program.cs b/tools/QueryBaselineUpdater/Program.cs index bf1e167cb..1ef9b7909 100644 --- a/tools/QueryBaselineUpdater/Program.cs +++ b/tools/QueryBaselineUpdater/Program.cs @@ -8,7 +8,7 @@ namespace QueryBaselineUpdater { internal static class Program { - private const string AssertSqlPattern = @"\s*Assert(?:ExecuteUpdate)?Sql\(\s*(?:(?:@?(""""""|"")).*?\1)?\);\r?\n"; + private const string AssertSqlPattern = @"(?\s*)Assert(?:ExecuteUpdate)?Sql\(\s*(?:(?:@?(""""""|"")).*?\1)?\);\r?\n"; private static int Main(string[] args) { @@ -85,7 +85,7 @@ private static int Main(string[] args) retryCustomized, f => f.Id, s => s, - (inner, _) => inner) + (outer, _) => outer) .OrderByDescending(t => t.Line) .Aggregate( File.ReadAllText(customizedFilePath), @@ -122,7 +122,7 @@ private static string ReplaceChunk(string result, AssertSqlChunk current, List