From 61732b0467dba76d96e3724c728ccc8fba679c14 Mon Sep 17 00:00:00 2001 From: Alex Zaytsev Date: Fri, 14 Jul 2023 17:03:18 +1000 Subject: [PATCH 1/8] Run tests for MicrosoftDataSqlClientDriver --- .github/workflows/NetCoreTests.yml | 4 ++++ appveyor.yml | 4 ++++ psake.ps1 | 13 +++++++++++++ teamcity.build | 11 +++++++++++ 4 files changed, 32 insertions(+) diff --git a/.github/workflows/NetCoreTests.yml b/.github/workflows/NetCoreTests.yml index c88177b97e9..478eabf8f9a 100644 --- a/.github/workflows/NetCoreTests.yml +++ b/.github/workflows/NetCoreTests.yml @@ -12,6 +12,10 @@ jobs: CONNECTION_STRING: "Server=localhost;initial catalog=nhibernate;User Id=sa;Password=P@ssw0rd;packet size=4096;" DB_INIT: | docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=P@ssw0rd" -e "MSSQL_PID=Express" -p 1433:1433 -d --name sqlexpress mcr.microsoft.com/mssql/server:2019-latest; + - DB: SqlServer2008-MicrosoftDataSqlClientDriver + CONNECTION_STRING: "Server=localhost;initial catalog=nhibernate;User Id=sa;Password=P@ssw0rd;packet size=4096;" + DB_INIT: | + docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=P@ssw0rd" -e "MSSQL_PID=Express" -p 1433:1433 -d --name sqlexpress mcr.microsoft.com/mssql/server:2019-latest; - DB: PostgreSQL CONNECTION_STRING: "Host=localhost;Username=nhibernate;Password=nhibernate;Database=nhibernate;Enlist=true;" DB_INIT: | diff --git a/appveyor.yml b/appveyor.yml index a73e841f7e6..cf5da450722 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,8 @@ environment: matrix: - DB: SqlServer2008 CONNECTION_STRING: Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate; + - DB: SqlServer2008-MicrosoftDataSqlClientDriver + CONNECTION_STRING: Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate; - DB: PostgreSQL CONNECTION_STRING: Host=localhost;Port=5432;Username=postgres;Password=Password12!;Database=nhibernate;Enlist=true; - DB: Firebird @@ -73,7 +75,9 @@ before_test: Start-Service 'postgresql-x64-10' } 'SqlServer2008' { Start-Service 'MSSQL$SQL2017' } + 'SqlServer2008-MicrosoftDataSqlClientDriver' { Start-Service 'MSSQL$SQL2017' } 'SqlServer2012' { Start-Service 'MSSQL$SQL2017' } + 'SqlServer2012-MicrosoftDataSqlClientDriver' { Start-Service 'MSSQL$SQL2017' } 'SQLite' { } } test_script: diff --git a/psake.ps1 b/psake.ps1 index 34fa3e2ea37..7448605a9a9 100644 --- a/psake.ps1 +++ b/psake.ps1 @@ -63,9 +63,22 @@ Task Set-Configuration { }; 'SqlServer2008' = @{ 'connection.connection_string' = 'Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate;' + 'connection.driver_class' = 'NHibernate.Driver.SqlClientDriver'; + 'dialect' = 'NHibernate.Dialect.MsSql2008Dialect' }; 'SqlServer2012' = @{ 'connection.connection_string' = 'Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate;'; + 'connection.driver_class' = 'NHibernate.Driver.SqlClientDriver'; + 'dialect' = 'NHibernate.Dialect.MsSql2012Dialect' + }; + 'SqlServer2008-MicrosoftDataSqlClientDriver' = @{ + 'connection.connection_string' = 'Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate;' + 'connection.driver_class' = 'NHibernate.Driver.MicrosoftDataSqlClientDriver'; + 'dialect' = 'NHibernate.Dialect.MsSql2008Dialect' + }; + 'SqlServer2012-MicrosoftDataSqlClientDriver' = @{ + 'connection.connection_string' = 'Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate;'; + 'connection.driver_class' = 'NHibernate.Driver.MicrosoftDataSqlClientDriver'; 'dialect' = 'NHibernate.Dialect.MsSql2012Dialect' }; 'Oracle' = @{ diff --git a/teamcity.build b/teamcity.build index 7e90e13e430..b8125f5dfe5 100644 --- a/teamcity.build +++ b/teamcity.build @@ -67,11 +67,22 @@ + + + + + + + + + + + From 334875bf0c21ecaf5aa732e326abe8633a15ea9b Mon Sep 17 00:00:00 2001 From: Alex Zaytsev Date: Fri, 14 Jul 2023 19:36:29 +1000 Subject: [PATCH 2/8] Fix --- psake.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/psake.ps1 b/psake.ps1 index 7448605a9a9..16f7a267f14 100644 --- a/psake.ps1 +++ b/psake.ps1 @@ -63,12 +63,12 @@ Task Set-Configuration { }; 'SqlServer2008' = @{ 'connection.connection_string' = 'Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate;' - 'connection.driver_class' = 'NHibernate.Driver.SqlClientDriver'; + 'connection.driver_class' = 'NHibernate.Driver.Sql2008ClientDriver'; 'dialect' = 'NHibernate.Dialect.MsSql2008Dialect' }; 'SqlServer2012' = @{ 'connection.connection_string' = 'Server=(local)\SQL2017;User ID=sa;Password=Password12!;initial catalog=nhibernate;'; - 'connection.driver_class' = 'NHibernate.Driver.SqlClientDriver'; + 'connection.driver_class' = 'NHibernate.Driver.Sql2008ClientDriver'; 'dialect' = 'NHibernate.Dialect.MsSql2012Dialect' }; 'SqlServer2008-MicrosoftDataSqlClientDriver' = @{ From d8ec6b44eff80b1a0e9f537e78242a292da0c740 Mon Sep 17 00:00:00 2001 From: Alex Zaytsev Date: Fri, 14 Jul 2023 19:37:34 +1000 Subject: [PATCH 3/8] Add setup method --- src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs b/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs index deea09fb3a5..0856f339d02 100644 --- a/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs +++ b/src/NHibernate.TestDatabaseSetup/TestDatabaseSetup.cs @@ -23,6 +23,7 @@ public class DatabaseSetup { {"NHibernate.Driver.SqlClientDriver", SetupSqlServer}, {"NHibernate.Driver.Sql2008ClientDriver", SetupSqlServer}, + {"NHibernate.Driver.MicrosoftDataSqlClientDriver", SetupSqlServer}, {"NHibernate.Driver.FirebirdClientDriver", SetupFirebird}, {"NHibernate.Driver.NpgsqlDriver", SetupNpgsql}, {"NHibernate.Driver.OracleDataClientDriver", SetupOracle}, From 0f007804641ac2c73d6ac7ad4e900293ef714f07 Mon Sep 17 00:00:00 2001 From: Alex Zaytsev Date: Fri, 14 Jul 2023 21:35:23 +1000 Subject: [PATCH 4/8] Show SQL --- src/NHibernate.Test/Linq/FunctionTests.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NHibernate.Test/Linq/FunctionTests.cs b/src/NHibernate.Test/Linq/FunctionTests.cs index 877040e35ba..79523a5c1b8 100644 --- a/src/NHibernate.Test/Linq/FunctionTests.cs +++ b/src/NHibernate.Test/Linq/FunctionTests.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Text.RegularExpressions; +using NHibernate.Cfg; using NHibernate.DomainModel; using NHibernate.DomainModel.Northwind.Entities; using NUnit.Framework; @@ -10,6 +11,11 @@ namespace NHibernate.Test.Linq [TestFixture] public class FunctionTests : LinqTestCase { + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Cfg.Environment.ShowSql, "true"); + } + [Test] public void LikeFunction() { From 8770e9350bb21275bf8833b4bca838641027a200 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 14 Jul 2023 11:38:20 +0000 Subject: [PATCH 5/8] Generate async files --- src/NHibernate.Test/Async/Linq/FunctionTests.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NHibernate.Test/Async/Linq/FunctionTests.cs b/src/NHibernate.Test/Async/Linq/FunctionTests.cs index c39ff901df4..794416439a5 100644 --- a/src/NHibernate.Test/Async/Linq/FunctionTests.cs +++ b/src/NHibernate.Test/Async/Linq/FunctionTests.cs @@ -11,6 +11,7 @@ using System; using System.Linq; using System.Text.RegularExpressions; +using NHibernate.Cfg; using NHibernate.DomainModel; using NHibernate.DomainModel.Northwind.Entities; using NUnit.Framework; @@ -22,6 +23,11 @@ namespace NHibernate.Test.Linq [TestFixture] public class FunctionTestsAsync : LinqTestCase { + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Cfg.Environment.ShowSql, "true"); + } + [Test] public async Task LikeFunctionAsync() { From 68287c3098a76ffc5a0b755d15fa950ce92c4acf Mon Sep 17 00:00:00 2001 From: Alex Zaytsev Date: Fri, 14 Jul 2023 22:23:59 +1000 Subject: [PATCH 6/8] Fix character parameter lengths --- src/NHibernate.Test/Linq/FunctionTests.cs | 5 ----- .../Driver/MicrosoftDataSqlClientDriver.cs | 16 ++++++++++++++-- src/NHibernate/Driver/SqlClientDriver.cs | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/NHibernate.Test/Linq/FunctionTests.cs b/src/NHibernate.Test/Linq/FunctionTests.cs index 79523a5c1b8..0b4ffa0f553 100644 --- a/src/NHibernate.Test/Linq/FunctionTests.cs +++ b/src/NHibernate.Test/Linq/FunctionTests.cs @@ -11,11 +11,6 @@ namespace NHibernate.Test.Linq [TestFixture] public class FunctionTests : LinqTestCase { - protected override void Configure(Configuration configuration) - { - configuration.SetProperty(Cfg.Environment.ShowSql, "true"); - } - [Test] public void LikeFunction() { diff --git a/src/NHibernate/Driver/MicrosoftDataSqlClientDriver.cs b/src/NHibernate/Driver/MicrosoftDataSqlClientDriver.cs index 1c4ad3d9fc0..e2e12674e3d 100644 --- a/src/NHibernate/Driver/MicrosoftDataSqlClientDriver.cs +++ b/src/NHibernate/Driver/MicrosoftDataSqlClientDriver.cs @@ -112,7 +112,7 @@ protected override void InitializeParameter(DbParameter dbParam, string name, Sq case DbType.AnsiStringFixedLength: dbParam.Size = IsAnsiText(dbParam, sqlType) ? MsSql2000Dialect.MaxSizeForAnsiClob - : MsSql2000Dialect.MaxSizeForLengthLimitedAnsiString; + : IsChar(dbParam, sqlType) ? sqlType.Length : MsSql2000Dialect.MaxSizeForLengthLimitedAnsiString; break; case DbType.Binary: dbParam.Size = IsBlob(dbParam, sqlType) @@ -130,7 +130,7 @@ protected override void InitializeParameter(DbParameter dbParam, string name, Sq case DbType.StringFixedLength: dbParam.Size = IsText(dbParam, sqlType) ? MsSql2000Dialect.MaxSizeForClob - : MsSql2000Dialect.MaxSizeForLengthLimitedString; + : IsChar(dbParam, sqlType) ? sqlType.Length : MsSql2000Dialect.MaxSizeForLengthLimitedString; break; case DbType.DateTime2: dbParam.Size = MsSql2000Dialect.MaxDateTime2; @@ -199,6 +199,18 @@ protected static bool IsBlob(DbParameter dbParam, SqlType sqlType) return sqlType is BinaryBlobSqlType || DbType.Binary == dbParam.DbType && sqlType.LengthDefined && sqlType.Length > MsSql2000Dialect.MaxSizeForLengthLimitedBinary; } + + /// + /// Interprets if a parameter is a character (for the purposes of setting its default size) + /// + /// The parameter + /// The of the parameter + /// True, if the parameter should be interpreted as a character, otherwise False + protected static bool IsChar(DbParameter dbParam, SqlType sqlType) + { + return sqlType.LengthDefined && sqlType.Length == 1 && + (dbParam.DbType == DbType.StringFixedLength || dbParam.DbType == DbType.AnsiStringFixedLength); + } /// public override IResultSetsCommand GetResultSetsCommand(ISessionImplementor session) diff --git a/src/NHibernate/Driver/SqlClientDriver.cs b/src/NHibernate/Driver/SqlClientDriver.cs index 1002005395d..a3da3a4db73 100644 --- a/src/NHibernate/Driver/SqlClientDriver.cs +++ b/src/NHibernate/Driver/SqlClientDriver.cs @@ -295,8 +295,8 @@ protected static bool IsBlob(DbParameter dbParam, SqlType sqlType) /// True, if the parameter should be interpreted as a character, otherwise False protected static bool IsChar(DbParameter dbParam, SqlType sqlType) { - return (DbType.StringFixedLength == dbParam.DbType || DbType.AnsiStringFixedLength == dbParam.DbType) && - sqlType.LengthDefined && sqlType.Length == 1; + return sqlType.LengthDefined && sqlType.Length == 1 && + (dbParam.DbType == DbType.StringFixedLength || dbParam.DbType == DbType.AnsiStringFixedLength); } public override IResultSetsCommand GetResultSetsCommand(ISessionImplementor session) From eab2eaf544fe7e4ce84249942016579a1abf2721 Mon Sep 17 00:00:00 2001 From: Alex Zaytsev Date: Fri, 14 Jul 2023 22:27:29 +1000 Subject: [PATCH 7/8] Code cleanup --- src/NHibernate.Test/Linq/FunctionTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NHibernate.Test/Linq/FunctionTests.cs b/src/NHibernate.Test/Linq/FunctionTests.cs index 0b4ffa0f553..877040e35ba 100644 --- a/src/NHibernate.Test/Linq/FunctionTests.cs +++ b/src/NHibernate.Test/Linq/FunctionTests.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using System.Text.RegularExpressions; -using NHibernate.Cfg; using NHibernate.DomainModel; using NHibernate.DomainModel.Northwind.Entities; using NUnit.Framework; From 0d705b4cde6feed1c9f3b3d23d73de54162473a8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 14 Jul 2023 12:30:36 +0000 Subject: [PATCH 8/8] Generate async files --- src/NHibernate.Test/Async/Linq/FunctionTests.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/NHibernate.Test/Async/Linq/FunctionTests.cs b/src/NHibernate.Test/Async/Linq/FunctionTests.cs index 794416439a5..c39ff901df4 100644 --- a/src/NHibernate.Test/Async/Linq/FunctionTests.cs +++ b/src/NHibernate.Test/Async/Linq/FunctionTests.cs @@ -11,7 +11,6 @@ using System; using System.Linq; using System.Text.RegularExpressions; -using NHibernate.Cfg; using NHibernate.DomainModel; using NHibernate.DomainModel.Northwind.Entities; using NUnit.Framework; @@ -23,11 +22,6 @@ namespace NHibernate.Test.Linq [TestFixture] public class FunctionTestsAsync : LinqTestCase { - protected override void Configure(Configuration configuration) - { - configuration.SetProperty(Cfg.Environment.ShowSql, "true"); - } - [Test] public async Task LikeFunctionAsync() {