From f7567eb3a200ba903825145ac8007a56626218a1 Mon Sep 17 00:00:00 2001
From: Vivek N <117155414+n-vivek@users.noreply.github.com>
Date: Sun, 17 Nov 2024 10:33:39 +0530
Subject: [PATCH 1/5] Add SybaseASE16Dialect with LIMIT and OFFSET pagination
support - Introduced SybaseASE16Dialect for Sybase ASE 16 compatibility. -
Implemented SQL generation for LIMIT and OFFSET to support pagination.
---
src/NHibernate/Dialect/SybaseASE16Dialect.cs | 86 ++++++++++++++++++++
1 file changed, 86 insertions(+)
create mode 100644 src/NHibernate/Dialect/SybaseASE16Dialect.cs
diff --git a/src/NHibernate/Dialect/SybaseASE16Dialect.cs b/src/NHibernate/Dialect/SybaseASE16Dialect.cs
new file mode 100644
index 0000000000..6818878476
--- /dev/null
+++ b/src/NHibernate/Dialect/SybaseASE16Dialect.cs
@@ -0,0 +1,86 @@
+using NHibernate.SqlCommand;
+
+namespace NHibernate.Dialect
+{
+ ///
+ /// An SQL dialect targeting Sybase Adaptive Server Enterprise (ASE) 16 and higher.
+ ///
+ ///
+ /// The dialect defaults the following configuration properties:
+ ///
+ ///
+ /// Property
+ /// Default Value
+ ///
+ /// -
+ /// connection.driver_class
+ ///
+ ///
+ ///
+ ///
+ public class SybaseASE16Dialect : SybaseASE15Dialect
+ {
+ #region Limit/offset support
+
+ ///
+ /// Does this Dialect have some kind of LIMIT syntax?
+ ///
+ /// False, unless overridden.
+ public override bool SupportsLimit
+ {
+ get { return true; }
+ }
+
+ ///
+ /// Does this Dialect support an offset?
+ ///
+ public override bool SupportsLimitOffset
+ {
+ get { return true; }
+ }
+
+ ///
+ /// Can parameters be used for a statement containing a LIMIT?
+ ///
+ public override bool SupportsVariableLimit
+ {
+ get { return false; }
+ }
+
+ ///
+ /// Attempts to add a LIMIT clause to the given SQL SELECT.
+ /// Expects any database-specific offset and limit adjustments to have already been performed (ex. UseMaxForLimit, OffsetStartsAtOne).
+ ///
+ /// The to base the limit query off.
+ /// Offset of the first row to be returned by the query. This may be represented as a parameter, a string literal, or a null value if no limit is requested. This should have already been adjusted to account for OffsetStartsAtOne.
+ /// Maximum number of rows to be returned by the query. This may be represented as a parameter, a string literal, or a null value if no offset is requested. This should have already been adjusted to account for UseMaxForLimit.
+ /// A new that contains the LIMIT clause. Returns null
+ /// if represents a SQL statement to which a limit clause cannot be added,
+ /// for example when the query string is custom SQL invoking a stored procedure.
+ public override SqlString GetLimitString(SqlString queryString, SqlString offset, SqlString limit)
+ {
+ if (offset == null && limit == null)
+ return queryString;
+
+ SqlStringBuilder pagingBuilder = new SqlStringBuilder();
+ pagingBuilder.Add(queryString);
+ pagingBuilder.Add(" rows ");
+
+ if(limit !=null)
+ {
+ pagingBuilder.Add(" limit ");
+ pagingBuilder.Add(limit);
+ }
+
+ if (offset != null)
+ {
+ pagingBuilder.Add(" offset ");
+ pagingBuilder.Add(offset);
+ }
+
+ return pagingBuilder.ToSqlString();
+ }
+
+ #endregion
+ }
+}
From af6c98b06d650981ccc16661b02a8b4215a37025 Mon Sep 17 00:00:00 2001
From: Alex Zaytsev
Date: Thu, 27 Mar 2025 09:53:46 +1000
Subject: [PATCH 2/5] Add documentation
---
doc/reference/modules/configuration.xml | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/doc/reference/modules/configuration.xml b/doc/reference/modules/configuration.xml
index 7e590d4c9d..94c24caf72 100644
--- a/doc/reference/modules/configuration.xml
+++ b/doc/reference/modules/configuration.xml
@@ -1602,9 +1602,14 @@ in the parameter binding.
- Sybase Adaptive Server Enterprise 15
- NHibernate.Dialect.SybaseASE15Dialect
-
+ Sybase Adaptive Server Enterprise 15
+ NHibernate.Dialect.SybaseASE15Dialect
+
+
+
+ Sybase Adaptive Server Enterprise 16
+ NHibernate.Dialect.SybaseASE16Dialect
+
Sybase SQL Anywhere 10
From 199a83f89189b893ae5bebf565704bddffb6fc4b Mon Sep 17 00:00:00 2001
From: Alex Zaytsev
Date: Thu, 27 Mar 2025 09:55:27 +1000
Subject: [PATCH 3/5] Modernize code and improve xml comments
---
src/NHibernate/Dialect/SybaseASE16Dialect.cs | 48 +++++---------------
1 file changed, 12 insertions(+), 36 deletions(-)
diff --git a/src/NHibernate/Dialect/SybaseASE16Dialect.cs b/src/NHibernate/Dialect/SybaseASE16Dialect.cs
index 6818878476..f1078855dc 100644
--- a/src/NHibernate/Dialect/SybaseASE16Dialect.cs
+++ b/src/NHibernate/Dialect/SybaseASE16Dialect.cs
@@ -20,53 +20,31 @@ namespace NHibernate.Dialect
///
public class SybaseASE16Dialect : SybaseASE15Dialect
{
- #region Limit/offset support
-
///
- /// Does this Dialect have some kind of LIMIT syntax?
+ /// ASE 16 supports limit statements, see: https://help.sap.com/docs/SAP_ASE/e0d4539d39c34f52ae9ef822c2060077/26d84b4ddae94fed89d4e7c88bc8d1e6.html?locale=en-US
///
- /// False, unless overridden.
- public override bool SupportsLimit
- {
- get { return true; }
- }
+ /// true
+ public override bool SupportsLimit => true;
- ///
- /// Does this Dialect support an offset?
- ///
- public override bool SupportsLimitOffset
- {
- get { return true; }
- }
+ ///
+ /// true
+ public override bool SupportsLimitOffset => true;
- ///
- /// Can parameters be used for a statement containing a LIMIT?
- ///
- public override bool SupportsVariableLimit
- {
- get { return false; }
- }
+ ///
+ /// false
+ public override bool SupportsVariableLimit => false;
- ///
- /// Attempts to add a LIMIT clause to the given SQL SELECT.
- /// Expects any database-specific offset and limit adjustments to have already been performed (ex. UseMaxForLimit, OffsetStartsAtOne).
- ///
- /// The to base the limit query off.
- /// Offset of the first row to be returned by the query. This may be represented as a parameter, a string literal, or a null value if no limit is requested. This should have already been adjusted to account for OffsetStartsAtOne.
- /// Maximum number of rows to be returned by the query. This may be represented as a parameter, a string literal, or a null value if no offset is requested. This should have already been adjusted to account for UseMaxForLimit.
- /// A new that contains the LIMIT clause. Returns null
- /// if represents a SQL statement to which a limit clause cannot be added,
- /// for example when the query string is custom SQL invoking a stored procedure.
+ ///
public override SqlString GetLimitString(SqlString queryString, SqlString offset, SqlString limit)
{
if (offset == null && limit == null)
return queryString;
- SqlStringBuilder pagingBuilder = new SqlStringBuilder();
+ var pagingBuilder = new SqlStringBuilder();
pagingBuilder.Add(queryString);
pagingBuilder.Add(" rows ");
- if(limit !=null)
+ if (limit != null)
{
pagingBuilder.Add(" limit ");
pagingBuilder.Add(limit);
@@ -80,7 +58,5 @@ public override SqlString GetLimitString(SqlString queryString, SqlString offset
return pagingBuilder.ToSqlString();
}
-
- #endregion
}
}
From f19513eb16581469702a0455077758ba49010cab Mon Sep 17 00:00:00 2001
From: Alex Zaytsev
Date: Thu, 27 Mar 2025 09:58:38 +1000
Subject: [PATCH 4/5] whitespaces
---
doc/reference/modules/configuration.xml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/doc/reference/modules/configuration.xml b/doc/reference/modules/configuration.xml
index 94c24caf72..e39690c2ae 100644
--- a/doc/reference/modules/configuration.xml
+++ b/doc/reference/modules/configuration.xml
@@ -1602,14 +1602,14 @@ in the parameter binding.
- Sybase Adaptive Server Enterprise 15
- NHibernate.Dialect.SybaseASE15Dialect
-
+ Sybase Adaptive Server Enterprise 15
+ NHibernate.Dialect.SybaseASE15Dialect
+
- Sybase Adaptive Server Enterprise 16
- NHibernate.Dialect.SybaseASE16Dialect
-
+ Sybase Adaptive Server Enterprise 16
+ NHibernate.Dialect.SybaseASE16Dialect
+
Sybase SQL Anywhere 10
From 4813d1a2d89cb9b2b060ca744491402cd7a46f21 Mon Sep 17 00:00:00 2001
From: Alex Zaytsev
Date: Thu, 27 Mar 2025 09:59:50 +1000
Subject: [PATCH 5/5] doc
---
src/NHibernate/Dialect/SybaseASE16Dialect.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/NHibernate/Dialect/SybaseASE16Dialect.cs b/src/NHibernate/Dialect/SybaseASE16Dialect.cs
index f1078855dc..41aab5fcd0 100644
--- a/src/NHibernate/Dialect/SybaseASE16Dialect.cs
+++ b/src/NHibernate/Dialect/SybaseASE16Dialect.cs
@@ -21,7 +21,7 @@ namespace NHibernate.Dialect
public class SybaseASE16Dialect : SybaseASE15Dialect
{
///
- /// ASE 16 supports limit statements, see: https://help.sap.com/docs/SAP_ASE/e0d4539d39c34f52ae9ef822c2060077/26d84b4ddae94fed89d4e7c88bc8d1e6.html?locale=en-US
+ /// ASE 16 supports limit statements, see https://help.sap.com/docs/SAP_ASE/e0d4539d39c34f52ae9ef822c2060077/26d84b4ddae94fed89d4e7c88bc8d1e6.html?locale=en-US
///
/// true
public override bool SupportsLimit => true;