From bf8268c7bd30474336cfdaed8580f3dca44c46c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Delaporte?= Date: Wed, 5 Apr 2017 14:40:32 +0200 Subject: [PATCH 1/2] NH-3975 - Synchronize some features dialect support properties (Informational metadata) --- .../Hql/Ast/BulkManipulation.cs | 9 ++--- .../SqlTest/Custom/MySQL/MySQLTest.cs | 2 +- src/NHibernate/Dialect/DB2Dialect.cs | 29 +++++++++++++++ src/NHibernate/Dialect/Dialect.cs | 8 ++--- src/NHibernate/Dialect/Ingres9Dialect.cs | 9 +++++ src/NHibernate/Dialect/IngresDialect.cs | 24 +++++++++++++ src/NHibernate/Dialect/MsSql2000Dialect.cs | 35 +++++++++++++++++++ src/NHibernate/Dialect/MsSql2005Dialect.cs | 22 ++++++++++++ src/NHibernate/Dialect/MySQLDialect.cs | 25 +++++++++++++ src/NHibernate/Dialect/PostgreSQLDialect.cs | 29 +++++++++++++++ 10 files changed, 181 insertions(+), 11 deletions(-) diff --git a/src/NHibernate.Test/Hql/Ast/BulkManipulation.cs b/src/NHibernate.Test/Hql/Ast/BulkManipulation.cs index fcdf0cbe2da..a59720c1d19 100644 --- a/src/NHibernate.Test/Hql/Ast/BulkManipulation.cs +++ b/src/NHibernate.Test/Hql/Ast/BulkManipulation.cs @@ -513,9 +513,8 @@ public void UpdateOnManyToOne() ITransaction t = s.BeginTransaction(); s.CreateQuery("update Animal a set a.mother = null where a.id = 2").ExecuteUpdate(); - if (! (Dialect is MySQLDialect)) + if (Dialect.SupportsSubqueryOnMutatingTable) { - // MySQL does not support (even un-correlated) subqueries against the update-mutating table s.CreateQuery("update Animal a set a.mother = (from Animal where id = 1) where a.id = 2").ExecuteUpdate(); } @@ -624,9 +623,8 @@ public void UpdateOnAnimal() .ExecuteUpdate(); Assert.That(count, Is.EqualTo(6), "incorrect count on 'complex' update assignment"); - if (! (Dialect is MySQLDialect)) + if (Dialect.SupportsSubqueryOnMutatingTable) { - // MySQL does not support (even un-correlated) subqueries against the update-mutating table s.CreateQuery("update Animal set bodyWeight = ( select max(bodyWeight) from Animal )").ExecuteUpdate(); } @@ -682,9 +680,8 @@ public void UpdateOnMammal() count = s.CreateQuery("update Mammal set bodyWeight = 25").ExecuteUpdate(); Assert.That(count, Is.EqualTo(2), "incorrect update count against 'middle' of joined-subclass hierarchy"); - if (! (Dialect is MySQLDialect)) + if (Dialect.SupportsSubqueryOnMutatingTable) { - // MySQL does not support (even un-correlated) subqueries against the update-mutating table count = s.CreateQuery("update Mammal set bodyWeight = ( select max(bodyWeight) from Animal )").ExecuteUpdate(); Assert.That(count, Is.EqualTo(2), "incorrect update count against 'middle' of joined-subclass hierarchy"); } diff --git a/src/NHibernate.Test/SqlTest/Custom/MySQL/MySQLTest.cs b/src/NHibernate.Test/SqlTest/Custom/MySQL/MySQLTest.cs index d3eee8a56a8..5e821b2d082 100644 --- a/src/NHibernate.Test/SqlTest/Custom/MySQL/MySQLTest.cs +++ b/src/NHibernate.Test/SqlTest/Custom/MySQL/MySQLTest.cs @@ -14,7 +14,7 @@ protected override IList Mappings protected override bool AppliesTo(Dialect.Dialect dialect) { - return dialect is MySQL5Dialect || dialect is MySQLDialect; + return dialect is MySQLDialect; } } } \ No newline at end of file diff --git a/src/NHibernate/Dialect/DB2Dialect.cs b/src/NHibernate/Dialect/DB2Dialect.cs index 5dd78d65360..74b4c34cd17 100644 --- a/src/NHibernate/Dialect/DB2Dialect.cs +++ b/src/NHibernate/Dialect/DB2Dialect.cs @@ -270,5 +270,34 @@ public override string ForUpdateString { get { return " for read only with rs"; } } + + #region Overridden informational metadata + + public override bool SupportsEmptyInList + { + get { return false; } + } + + public override bool SupportsResultSetPositionQueryMethodsOnForwardOnlyCursor + { + get { return false; } + } + + public override bool SupportsLobValueChangePropogation + { + get { return false; } + } + + public override bool SupportsExistsInSelect + { + get { return false; } + } + + public override bool DoesReadCommittedCauseWritersToBlockReaders + { + get { return true; } + } + + #endregion } } \ No newline at end of file diff --git a/src/NHibernate/Dialect/Dialect.cs b/src/NHibernate/Dialect/Dialect.cs index c9240005f95..402b30b1560 100644 --- a/src/NHibernate/Dialect/Dialect.cs +++ b/src/NHibernate/Dialect/Dialect.cs @@ -1879,7 +1879,7 @@ public virtual bool SupportsParametersInInsertSelect /// /// Does this dialect require that references to result variables - /// (i.e, select expresssion aliases) in an ORDER BY clause be + /// (i.e, select expression aliases) in an ORDER BY clause be /// replaced by column positions (1-origin) as defined by the select clause? /// /// @@ -2050,8 +2050,6 @@ public virtual bool SupportsBindAsCallableArgument get { return true; } } - #endregion - /// /// Does this dialect support subselects? /// @@ -2060,6 +2058,8 @@ public virtual bool SupportsSubSelects get { return true; } } + #endregion + /// /// Retrieve a set of default Hibernate properties for this database. /// @@ -2136,7 +2136,7 @@ public virtual string CreateTemporaryTablePostfix /// /// Should the value returned by /// be treated as callable. Typically this indicates that JDBC escape - /// sytnax is being used... + /// syntax is being used... /// public virtual bool IsCurrentTimestampSelectStringCallable { diff --git a/src/NHibernate/Dialect/Ingres9Dialect.cs b/src/NHibernate/Dialect/Ingres9Dialect.cs index b17ce9eb922..afaaf79d5ca 100644 --- a/src/NHibernate/Dialect/Ingres9Dialect.cs +++ b/src/NHibernate/Dialect/Ingres9Dialect.cs @@ -64,5 +64,14 @@ public override SqlString GetLimitString(SqlString queryString, SqlString offset return pagingBuilder.ToSqlString(); } + + #region Overridden informational metadata + + public override bool DoesRepeatableReadCauseReadersToBlockWriters + { + get { return true; } + } + + #endregion } } \ No newline at end of file diff --git a/src/NHibernate/Dialect/IngresDialect.cs b/src/NHibernate/Dialect/IngresDialect.cs index 78b783ec8e4..f0c91584b5a 100644 --- a/src/NHibernate/Dialect/IngresDialect.cs +++ b/src/NHibernate/Dialect/IngresDialect.cs @@ -51,5 +51,29 @@ public IngresDialect() DefaultProperties[Environment.ConnectionDriver] = "NHibernate.Driver.IngresDriver"; } + + #region Overridden informational metadata + + public override bool SupportsEmptyInList + { + get { return false; } + } + + public override bool SupportsSubselectAsInPredicateLHS + { + get { return false; } + } + + public override bool SupportsExpectedLobUsagePattern + { + get { return false; } + } + + public override bool DoesReadCommittedCauseWritersToBlockReaders + { + get { return true; } + } + + #endregion } } \ No newline at end of file diff --git a/src/NHibernate/Dialect/MsSql2000Dialect.cs b/src/NHibernate/Dialect/MsSql2000Dialect.cs index a2c41524352..4b42742676b 100644 --- a/src/NHibernate/Dialect/MsSql2000Dialect.cs +++ b/src/NHibernate/Dialect/MsSql2000Dialect.cs @@ -498,6 +498,41 @@ public override bool SupportsSqlBatches get { return true; } } + #region Overridden informational metadata + + public override bool SupportsEmptyInList + { + get { return false; } + } + + public override bool AreStringComparisonsCaseInsensitive + { + get { return true; } + } + + public override bool SupportsResultSetPositionQueryMethodsOnForwardOnlyCursor + { + get { return false; } + } + + public override bool SupportsLobValueChangePropogation + { + // note: at least my local SQL Server 2005 Express shows this not working... + get { return false; } + } + + public override bool DoesReadCommittedCauseWritersToBlockReaders + { + get { return true; } + } + + public override bool DoesRepeatableReadCauseReadersToBlockWriters + { + get { return true; } + } + + #endregion + public override bool IsKnownToken(string currentToken, string nextToken) { return currentToken == "n" && nextToken == "'"; // unicode character diff --git a/src/NHibernate/Dialect/MsSql2005Dialect.cs b/src/NHibernate/Dialect/MsSql2005Dialect.cs index 49dc47513f0..a876dd42e83 100644 --- a/src/NHibernate/Dialect/MsSql2005Dialect.cs +++ b/src/NHibernate/Dialect/MsSql2005Dialect.cs @@ -102,5 +102,27 @@ public override string AppendLockHint(LockMode lockMode, string tableName) return tableName; } + + #region Overridden informational metadata + + /// + /// We assume that applications using this dialect are using + /// SQL Server 2005 snapshot isolation modes. + /// + public override bool DoesReadCommittedCauseWritersToBlockReaders + { + get { return false; } + } + + /// + /// We assume that applications using this dialect are using + /// SQL Server 2005 snapshot isolation modes. + /// + public override bool DoesRepeatableReadCauseReadersToBlockWriters + { + get { return false; } + } + + #endregion } } diff --git a/src/NHibernate/Dialect/MySQLDialect.cs b/src/NHibernate/Dialect/MySQLDialect.cs index 5c8865985ee..42a9cbcd769 100644 --- a/src/NHibernate/Dialect/MySQLDialect.cs +++ b/src/NHibernate/Dialect/MySQLDialect.cs @@ -386,5 +386,30 @@ public override long TimestampResolutionInTicks return TimeSpan.TicksPerSecond; } } + + #region Overridden informational metadata + + public override bool SupportsEmptyInList + { + get { return false; } + } + + public override bool AreStringComparisonsCaseInsensitive + { + get { return true; } + } + + public override bool SupportsLobValueChangePropogation + { + // note: at least my local MySQL 5.1 install shows this not working... + get { return false; } + } + + public override bool SupportsSubqueryOnMutatingTable + { + get { return false; } + } + + #endregion } } \ No newline at end of file diff --git a/src/NHibernate/Dialect/PostgreSQLDialect.cs b/src/NHibernate/Dialect/PostgreSQLDialect.cs index 2bb45c861f3..4c33fa0a3af 100644 --- a/src/NHibernate/Dialect/PostgreSQLDialect.cs +++ b/src/NHibernate/Dialect/PostgreSQLDialect.cs @@ -249,5 +249,34 @@ public override string CurrentTimestampSelectString { get { return "SELECT CURRENT_TIMESTAMP"; } } + + #region Overridden informational metadata + + public override bool SupportsEmptyInList + { + get { return false; } + } + + /// + /// Should LOBs (both BLOB and CLOB) be bound using stream operations (i.e. + /// {@link java.sql.PreparedStatement#setBinaryStream}). + /// + /// True if BLOBs and CLOBs should be bound using stream operations. + public override bool UseInputStreamToInsertBlob + { + get { return false; } + } + + public override bool SupportsLobValueChangePropogation + { + get { return false; } + } + + public override bool SupportsUnboundedLobLocatorMaterialization + { + get { return false; } + } + + #endregion } } From 40833fddd9f3766a76b65ecb4998f74e2394fddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Delaporte?= Date: Thu, 6 Apr 2017 12:29:54 +0200 Subject: [PATCH 2/2] NH-3975 - syntax modernization --- src/NHibernate/Dialect/DB2Dialect.cs | 25 ++++------------ src/NHibernate/Dialect/Ingres9Dialect.cs | 5 +--- src/NHibernate/Dialect/IngresDialect.cs | 22 ++++---------- src/NHibernate/Dialect/MsSql2000Dialect.cs | 32 +++++---------------- src/NHibernate/Dialect/MsSql2005Dialect.cs | 10 ++----- src/NHibernate/Dialect/MySQLDialect.cs | 22 ++++---------- src/NHibernate/Dialect/PostgreSQLDialect.cs | 20 +++---------- 7 files changed, 29 insertions(+), 107 deletions(-) diff --git a/src/NHibernate/Dialect/DB2Dialect.cs b/src/NHibernate/Dialect/DB2Dialect.cs index 74b4c34cd17..f0b242ab89d 100644 --- a/src/NHibernate/Dialect/DB2Dialect.cs +++ b/src/NHibernate/Dialect/DB2Dialect.cs @@ -273,30 +273,15 @@ public override string ForUpdateString #region Overridden informational metadata - public override bool SupportsEmptyInList - { - get { return false; } - } + public override bool SupportsEmptyInList => false; - public override bool SupportsResultSetPositionQueryMethodsOnForwardOnlyCursor - { - get { return false; } - } + public override bool SupportsResultSetPositionQueryMethodsOnForwardOnlyCursor => false; - public override bool SupportsLobValueChangePropogation - { - get { return false; } - } + public override bool SupportsLobValueChangePropogation => false; - public override bool SupportsExistsInSelect - { - get { return false; } - } + public override bool SupportsExistsInSelect => false; - public override bool DoesReadCommittedCauseWritersToBlockReaders - { - get { return true; } - } + public override bool DoesReadCommittedCauseWritersToBlockReaders => true; #endregion } diff --git a/src/NHibernate/Dialect/Ingres9Dialect.cs b/src/NHibernate/Dialect/Ingres9Dialect.cs index afaaf79d5ca..9853388c625 100644 --- a/src/NHibernate/Dialect/Ingres9Dialect.cs +++ b/src/NHibernate/Dialect/Ingres9Dialect.cs @@ -67,10 +67,7 @@ public override SqlString GetLimitString(SqlString queryString, SqlString offset #region Overridden informational metadata - public override bool DoesRepeatableReadCauseReadersToBlockWriters - { - get { return true; } - } + public override bool DoesRepeatableReadCauseReadersToBlockWriters => true; #endregion } diff --git a/src/NHibernate/Dialect/IngresDialect.cs b/src/NHibernate/Dialect/IngresDialect.cs index f0c91584b5a..616d7cde29b 100644 --- a/src/NHibernate/Dialect/IngresDialect.cs +++ b/src/NHibernate/Dialect/IngresDialect.cs @@ -54,25 +54,13 @@ public IngresDialect() #region Overridden informational metadata - public override bool SupportsEmptyInList - { - get { return false; } - } - - public override bool SupportsSubselectAsInPredicateLHS - { - get { return false; } - } + public override bool SupportsEmptyInList => false; - public override bool SupportsExpectedLobUsagePattern - { - get { return false; } - } + public override bool SupportsSubselectAsInPredicateLHS => false; - public override bool DoesReadCommittedCauseWritersToBlockReaders - { - get { return true; } - } + public override bool SupportsExpectedLobUsagePattern => false; + + public override bool DoesReadCommittedCauseWritersToBlockReaders => true; #endregion } diff --git a/src/NHibernate/Dialect/MsSql2000Dialect.cs b/src/NHibernate/Dialect/MsSql2000Dialect.cs index 4b42742676b..c62c4e47259 100644 --- a/src/NHibernate/Dialect/MsSql2000Dialect.cs +++ b/src/NHibernate/Dialect/MsSql2000Dialect.cs @@ -500,36 +500,18 @@ public override bool SupportsSqlBatches #region Overridden informational metadata - public override bool SupportsEmptyInList - { - get { return false; } - } + public override bool SupportsEmptyInList => false; - public override bool AreStringComparisonsCaseInsensitive - { - get { return true; } - } + public override bool AreStringComparisonsCaseInsensitive => true; - public override bool SupportsResultSetPositionQueryMethodsOnForwardOnlyCursor - { - get { return false; } - } + public override bool SupportsResultSetPositionQueryMethodsOnForwardOnlyCursor => false; - public override bool SupportsLobValueChangePropogation - { - // note: at least my local SQL Server 2005 Express shows this not working... - get { return false; } - } + // note: at least SQL Server 2005 Express shows this not working... + public override bool SupportsLobValueChangePropogation => false; - public override bool DoesReadCommittedCauseWritersToBlockReaders - { - get { return true; } - } + public override bool DoesReadCommittedCauseWritersToBlockReaders => true; - public override bool DoesRepeatableReadCauseReadersToBlockWriters - { - get { return true; } - } + public override bool DoesRepeatableReadCauseReadersToBlockWriters => true; #endregion diff --git a/src/NHibernate/Dialect/MsSql2005Dialect.cs b/src/NHibernate/Dialect/MsSql2005Dialect.cs index a876dd42e83..4e3cd731dde 100644 --- a/src/NHibernate/Dialect/MsSql2005Dialect.cs +++ b/src/NHibernate/Dialect/MsSql2005Dialect.cs @@ -109,19 +109,13 @@ public override string AppendLockHint(LockMode lockMode, string tableName) /// We assume that applications using this dialect are using /// SQL Server 2005 snapshot isolation modes. /// - public override bool DoesReadCommittedCauseWritersToBlockReaders - { - get { return false; } - } + public override bool DoesReadCommittedCauseWritersToBlockReaders => false; /// /// We assume that applications using this dialect are using /// SQL Server 2005 snapshot isolation modes. /// - public override bool DoesRepeatableReadCauseReadersToBlockWriters - { - get { return false; } - } + public override bool DoesRepeatableReadCauseReadersToBlockWriters => false; #endregion } diff --git a/src/NHibernate/Dialect/MySQLDialect.cs b/src/NHibernate/Dialect/MySQLDialect.cs index 42a9cbcd769..9997784542d 100644 --- a/src/NHibernate/Dialect/MySQLDialect.cs +++ b/src/NHibernate/Dialect/MySQLDialect.cs @@ -389,26 +389,14 @@ public override long TimestampResolutionInTicks #region Overridden informational metadata - public override bool SupportsEmptyInList - { - get { return false; } - } + public override bool SupportsEmptyInList => false; - public override bool AreStringComparisonsCaseInsensitive - { - get { return true; } - } + public override bool AreStringComparisonsCaseInsensitive => true; - public override bool SupportsLobValueChangePropogation - { - // note: at least my local MySQL 5.1 install shows this not working... - get { return false; } - } + // note: at least MySQL 5.1 shows this not working... + public override bool SupportsLobValueChangePropogation => false; - public override bool SupportsSubqueryOnMutatingTable - { - get { return false; } - } + public override bool SupportsSubqueryOnMutatingTable => false; #endregion } diff --git a/src/NHibernate/Dialect/PostgreSQLDialect.cs b/src/NHibernate/Dialect/PostgreSQLDialect.cs index 4c33fa0a3af..c20ee556d13 100644 --- a/src/NHibernate/Dialect/PostgreSQLDialect.cs +++ b/src/NHibernate/Dialect/PostgreSQLDialect.cs @@ -252,30 +252,18 @@ public override string CurrentTimestampSelectString #region Overridden informational metadata - public override bool SupportsEmptyInList - { - get { return false; } - } + public override bool SupportsEmptyInList => false; /// /// Should LOBs (both BLOB and CLOB) be bound using stream operations (i.e. /// {@link java.sql.PreparedStatement#setBinaryStream}). /// /// True if BLOBs and CLOBs should be bound using stream operations. - public override bool UseInputStreamToInsertBlob - { - get { return false; } - } + public override bool UseInputStreamToInsertBlob => false; - public override bool SupportsLobValueChangePropogation - { - get { return false; } - } + public override bool SupportsLobValueChangePropogation => false; - public override bool SupportsUnboundedLobLocatorMaterialization - { - get { return false; } - } + public override bool SupportsUnboundedLobLocatorMaterialization => false; #endregion }