diff --git a/test/EFCore.Jet.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesJetTest.cs b/test/EFCore.Jet.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesJetTest.cs index 598ddc4..9198716 100644 --- a/test/EFCore.Jet.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesJetTest.cs +++ b/test/EFCore.Jet.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesJetTest.cs @@ -271,29 +271,26 @@ WHERE EXISTS ( await base.Delete_Where_Skip_Take_Skip_Take_causing_subquery(async); AssertSql( -""" -@__p_0='100' -@__p_1='20' -@__p_2='5' - -DELETE FROM [o] -FROM [Order Details] AS [o] -WHERE EXISTS ( - SELECT 1 - FROM ( - SELECT [t].[OrderID], [t].[ProductID], [t].[Discount], [t].[Quantity], [t].[UnitPrice] + """ + DELETE FROM `Order Details` AS `o` + WHERE EXISTS ( + SELECT 1 FROM ( - SELECT [o0].[OrderID], [o0].[ProductID], [o0].[Discount], [o0].[Quantity], [o0].[UnitPrice] - FROM [Order Details] AS [o0] - WHERE [o0].[OrderID] < 10300 - ORDER BY (SELECT 1) - OFFSET @__p_0 ROWS FETCH NEXT @__p_0 ROWS ONLY - ) AS [t] - ORDER BY (SELECT 1) - OFFSET @__p_1 ROWS FETCH NEXT @__p_2 ROWS ONLY - ) AS [t0] - WHERE [t0].[OrderID] = [o].[OrderID] AND [t0].[ProductID] = [o].[ProductID]) -"""); + SELECT TOP 5 `t1`.`OrderID`, `t1`.`ProductID`, `t1`.`Discount`, `t1`.`Quantity`, `t1`.`UnitPrice` + FROM ( + SELECT TOP 25 `t0`.`OrderID`, `t0`.`ProductID`, `t0`.`Discount`, `t0`.`Quantity`, `t0`.`UnitPrice` + FROM ( + SELECT TOP 100 `t`.`OrderID`, `t`.`ProductID`, `t`.`Discount`, `t`.`Quantity`, `t`.`UnitPrice` + FROM ( + SELECT TOP 200 `o0`.`OrderID`, `o0`.`ProductID`, `o0`.`Discount`, `o0`.`Quantity`, `o0`.`UnitPrice` + FROM `Order Details` AS `o0` + WHERE `o0`.`OrderID` < 10300 + ) AS `t` + ) AS `t0` + ) AS `t1` + ) AS `t2` + WHERE `t2`.`OrderID` = `o`.`OrderID` AND `t2`.`ProductID` = `o`.`ProductID`) + """); } public override async Task Delete_Where_Distinct(bool async) diff --git a/test/EFCore.Jet.FunctionalTests/Query/FromSqlQueryJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/FromSqlQueryJetTest.cs index 6d90c13..e6ff1c9 100644 --- a/test/EFCore.Jet.FunctionalTests/Query/FromSqlQueryJetTest.cs +++ b/test/EFCore.Jet.FunctionalTests/Query/FromSqlQueryJetTest.cs @@ -10,6 +10,8 @@ using System.Data.OleDb; using Microsoft.EntityFrameworkCore.Query; using Xunit; using Xunit.Abstractions; +using EntityFrameworkCore.Jet.FunctionalTests.TestUtilities; +using System.Data.Odbc; namespace EntityFrameworkCore.Jet.FunctionalTests.Query; @@ -991,7 +993,13 @@ FROM ( } protected override DbParameter CreateDbParameter(string name, object value) - => new OleDbParameter { ParameterName = name, Value = value }; + { + if (((JetTestStore)Fixture.TestStore).IsOleDb()) + { + return new OleDbParameter { ParameterName = name, Value = value }; + } + return new OdbcParameter { ParameterName = name, Value = value }; + } private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.Jet.FunctionalTests/Query/GearsOfWarQueryJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/GearsOfWarQueryJetTest.cs index 32a264e..cafdf32 100644 --- a/test/EFCore.Jet.FunctionalTests/Query/GearsOfWarQueryJetTest.cs +++ b/test/EFCore.Jet.FunctionalTests/Query/GearsOfWarQueryJetTest.cs @@ -7233,7 +7233,7 @@ WHERE `s`.`Banner5` = @__byteArrayParam_0 """ SELECT `l`.`Name`, `l`.`Discriminator`, `l`.`LocustHordeId`, `l`.`ThreatLevel`, `l`.`ThreatLevelByte`, `l`.`ThreatLevelNullableByte`, `l`.`DefeatedByNickname`, `l`.`DefeatedBySquadId`, `l`.`HighCommandId` FROM `LocustLeaders` AS `l` -WHERE CBYTE(`l`.`ThreatLevel`) >= 5 +WHERE CBYTE(`l`.`ThreatLevel`) >= CBYTE(5) """); } diff --git a/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs b/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs index 81fff1b..6d5acfd 100644 --- a/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs +++ b/test/EFCore.Jet.FunctionalTests/Query/NorthwindFunctionsQueryJetTest.Functions.cs @@ -1903,10 +1903,10 @@ FROM `Customers` AS `c` await base.Indexof_with_one_constant_arg(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 (InStr(`c`.`ContactName`, 'a') - 1) = 1 +WHERE (INSTR(1, `c`.`ContactName`, 'a', 1) - 1) = 1 """); } @@ -1915,13 +1915,13 @@ WHERE (InStr(`c`.`ContactName`, 'a') - 1) = 1 await base.Indexof_with_one_parameter_arg(async); AssertSql( - """ -@__pattern_0='a' (Size = 255) -@__pattern_0='a' (Size = 255) + """ +@__pattern_0='a' (Size = 30) +@__pattern_0='a' (Size = 30) 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 IIF(? = '', 0, InStr(`c`.`ContactName`, ?) - 1) = 1 +WHERE IIF(@__pattern_0 = '', 0, INSTR(1, `c`.`ContactName`, @__pattern_0, 1) - 1) = 1 """); } @@ -1933,7 +1933,7 @@ WHERE IIF(? = '', 0, InStr(`c`.`ContactName`, ?) - 1) = 1 """ 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 (InStr(3, `c`.`ContactName`, 'a', 1) - 1) = 4 +WHERE (INSTR(3, `c`.`ContactName`, 'a', 1) - 1) = 4 """); } @@ -1947,7 +1947,7 @@ WHERE (InStr(3, `c`.`ContactName`, 'a', 1) - 1) = 4 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 (InStr({AssertSqlHelper.Parameter("@__start_0")} + 1, `c`.`ContactName`, 'a', 1) - 1) = 4 +WHERE (INSTR({AssertSqlHelper.Parameter("@__start_0")} + 1, `c`.`ContactName`, 'a', 1) - 1) = 4 """); } @@ -2050,12 +2050,11 @@ WHERE `c`.`CustomerID` = 'ALFKI'"); await base.Substring_with_two_args_with_Index_of(async); AssertSql( - @"SELECT SUBSTRING(`c`.`ContactName`, CASE - WHEN 'a' = '' THEN 0 - ELSE CAST(CHARINDEX('a', `c`.`ContactName`) AS int) - 1 -END + 1, 3) -FROM `Customers` AS `c` -WHERE `c`.`CustomerID` = 'ALFKI'"); + """ + SELECT MID(`c`.`ContactName`, (INSTR(1, `c`.`ContactName`, 'a', 1) - 1) + 1, 3) + FROM `Customers` AS `c` + WHERE `c`.`CustomerID` = 'ALFKI' + """); } public override async Task IsNullOrEmpty_in_predicate(bool isAsync) diff --git a/test/EFCore.Jet.FunctionalTests/Query/NorthwindSelectQueryJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/NorthwindSelectQueryJetTest.cs index 57607dc..0876252 100644 --- a/test/EFCore.Jet.FunctionalTests/Query/NorthwindSelectQueryJetTest.cs +++ b/test/EFCore.Jet.FunctionalTests/Query/NorthwindSelectQueryJetTest.cs @@ -17,7 +17,7 @@ namespace EntityFrameworkCore.Jet.FunctionalTests.Query : base(fixture) { ClearLog(); - //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } protected override bool CanExecuteQueryString @@ -922,8 +922,10 @@ FROM `Orders` AS `o` await base.Select_byte_constant(isAsync); AssertSql( - $@"SELECT IIF(`c`.`CustomerID` = 'ALFKI', 0x01, 0x02) -FROM `Customers` AS `c`"); + """ +SELECT IIF(`c`.`CustomerID` = 'ALFKI', CBYTE(1), CBYTE(2)) +FROM `Customers` AS `c` +"""); } public override async Task Select_short_constant(bool isAsync) diff --git a/test/EFCore.Jet.FunctionalTests/Query/NorthwindWhereQueryJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/NorthwindWhereQueryJetTest.cs index 2d5ed8a..40afddd 100644 --- a/test/EFCore.Jet.FunctionalTests/Query/NorthwindWhereQueryJetTest.cs +++ b/test/EFCore.Jet.FunctionalTests/Query/NorthwindWhereQueryJetTest.cs @@ -743,9 +743,11 @@ WHERE `e`.`ReportsTo` IS NULL"); await base.Where_string_indexof(isAsync); 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 (INSTR(`c`.`City`, 'Sea') - 1) <> -1 OR (`c`.`City` IS NULL)"); +WHERE (INSTR(1, `c`.`City`, 'Sea', 1) - 1) <> -1 OR `c`.`City` IS NULL +"""); } public override async Task Where_string_replace(bool isAsync) diff --git a/test/EFCore.Jet.FunctionalTests/Query/SimpleQueryJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/SimpleQueryJetTest.cs index c22afb9..a467e59 100644 --- a/test/EFCore.Jet.FunctionalTests/Query/SimpleQueryJetTest.cs +++ b/test/EFCore.Jet.FunctionalTests/Query/SimpleQueryJetTest.cs @@ -78,7 +78,7 @@ WHERE `i`.`Taste` = 1 """ SELECT `f`.`Id`, `f`.`Taste` FROM `Food` AS `f` -WHERE `f`.`Taste` = 0x01 +WHERE `f`.`Taste` = CBYTE(1) """); } diff --git a/test/EFCore.Jet.FunctionalTests/Query/SqlExecutorJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/SqlExecutorJetTest.cs index 143fa64..119a8a2 100644 --- a/test/EFCore.Jet.FunctionalTests/Query/SqlExecutorJetTest.cs +++ b/test/EFCore.Jet.FunctionalTests/Query/SqlExecutorJetTest.cs @@ -118,7 +118,13 @@ SELECT COUNT(*) FROM ""Customers"" WHERE ""City"" = {AssertSqlHelper.Parameter(" } protected override DbParameter CreateDbParameter(string name, object value) - => new OdbcParameter { ParameterName = name, Value = value }; + { + if (((JetTestStore)Fixture.TestStore).IsOleDb()) + { + return new OleDbParameter { ParameterName = name, Value = value }; + } + return new OdbcParameter { ParameterName = name, Value = value }; + } protected override string TenMostExpensiveProductsSproc => "`Ten Most Expensive Products`"; protected override string CustomerOrderHistorySproc => "`CustOrderHist` @CustomerID"; diff --git a/test/EFCore.Jet.FunctionalTests/Query/TPTInheritanceQueryJetTest.cs b/test/EFCore.Jet.FunctionalTests/Query/TPTInheritanceQueryJetTest.cs index 8ad8fd0..8093183 100644 --- a/test/EFCore.Jet.FunctionalTests/Query/TPTInheritanceQueryJetTest.cs +++ b/test/EFCore.Jet.FunctionalTests/Query/TPTInheritanceQueryJetTest.cs @@ -27,8 +27,8 @@ public class TPTInheritanceQueryJetTest : TPTInheritanceQueryTestBase sql.Replace("[", "`").Replace("]", "`"); + + public bool IsOleDb() + { + return ((EntityFrameworkCore.Jet.Data.JetConnection)Connection).DataAccessProviderFactory is OleDbFactory; + } } } \ No newline at end of file