Skip to content

Commit 20a479e

Browse files
vkvnhazzik
andauthored
Add SybaseASE16Dialect with LIMIT and OFFSET pagination support (#3624)
Co-authored-by: Alex Zaytsev <[email protected]>
1 parent bff26ec commit 20a479e

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

doc/reference/modules/configuration.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,11 @@ in the parameter binding.</programlisting>
16061606
<entry><literal>NHibernate.Dialect.SybaseASE15Dialect</literal></entry>
16071607
<entry></entry>
16081608
</row>
1609+
<row>
1610+
<entry>Sybase Adaptive Server Enterprise 16</entry>
1611+
<entry><literal>NHibernate.Dialect.SybaseASE16Dialect</literal></entry>
1612+
<entry></entry>
1613+
</row>
16091614
<row>
16101615
<entry>Sybase SQL Anywhere 10</entry>
16111616
<entry><literal>NHibernate.Dialect.SybaseSQLAnywhere10Dialect</literal></entry>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using NHibernate.SqlCommand;
2+
3+
namespace NHibernate.Dialect
4+
{
5+
/// <summary>
6+
/// An SQL dialect targeting Sybase Adaptive Server Enterprise (ASE) 16 and higher.
7+
/// </summary>
8+
/// <remarks>
9+
/// The dialect defaults the following configuration properties:
10+
/// <list type="table">
11+
/// <listheader>
12+
/// <term>Property</term>
13+
/// <description>Default Value</description>
14+
/// </listheader>
15+
/// <item>
16+
/// <term>connection.driver_class</term>
17+
/// <description><see cref="NHibernate.Driver.SybaseAseClientDriver" /></description>
18+
/// </item>
19+
/// </list>
20+
/// </remarks>
21+
public class SybaseASE16Dialect : SybaseASE15Dialect
22+
{
23+
/// <summary>
24+
/// ASE 16 supports limit statements, see https://help.sap.com/docs/SAP_ASE/e0d4539d39c34f52ae9ef822c2060077/26d84b4ddae94fed89d4e7c88bc8d1e6.html?locale=en-US
25+
/// </summary>
26+
/// <returns>true</returns>
27+
public override bool SupportsLimit => true;
28+
29+
/// <inheritdoc />
30+
/// <returns>true</returns>
31+
public override bool SupportsLimitOffset => true;
32+
33+
/// <inheritdoc />
34+
/// <returns>false</returns>
35+
public override bool SupportsVariableLimit => false;
36+
37+
/// <inheritdoc />
38+
public override SqlString GetLimitString(SqlString queryString, SqlString offset, SqlString limit)
39+
{
40+
if (offset == null && limit == null)
41+
return queryString;
42+
43+
var pagingBuilder = new SqlStringBuilder();
44+
pagingBuilder.Add(queryString);
45+
pagingBuilder.Add(" rows ");
46+
47+
if (limit != null)
48+
{
49+
pagingBuilder.Add(" limit ");
50+
pagingBuilder.Add(limit);
51+
}
52+
53+
if (offset != null)
54+
{
55+
pagingBuilder.Add(" offset ");
56+
pagingBuilder.Add(offset);
57+
}
58+
59+
return pagingBuilder.ToSqlString();
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)