Class SQLServerDialect

java.lang.Object
org.huiche.dialect.BaseDialect
org.huiche.dialect.SQLServerDialect
All Implemented Interfaces:
Dialect

public class SQLServerDialect extends BaseDialect
Sql Server 方言实现

分页使用 OFFSET ... ROWS FETCH NEXT ... ROWS ONLY,且必须带 ORDER BY; 首页(只有 limit)时会补齐 OFFSET 0 ROWS。

  • Constructor Details

    • SQLServerDialect

      public SQLServerDialect()
      默认构造
    • SQLServerDialect

      public SQLServerDialect(String quoteString, Set<String> keywords)
      默认构造
      Parameters:
      quoteString - 标识符转义字符串
      keywords - 数据库关键字(会与内置关键字合并)
  • Method Details

    • requiresOrderByForPaging

      public boolean requiresOrderByForPaging()
      Description copied from interface: Dialect
      分页是否要求语句必须带ORDER BY

      SQL Server 的 OFFSET ... FETCH 必须配合 ORDER BY,否则语句无法执行。

      Returns:
      是否要求ORDER BY
    • supportsNullsOrdering

      public boolean supportsNullsOrdering()
      Description copied from interface: Dialect
      是否支持ORDER BY的NULLS FIRST/LAST语法

      MySQL、MariaDB、SQL Server不支持该语法,但它们都把NULL视为最小值, 因此可以改写为CASE WHEN ... IS NULL实现等价排序。

      Returns:
      是否支持
    • translatePaging

      public Translation translatePaging(Integer limit, Integer offset)
      Description copied from interface: Dialect
      转译分页
      Specified by:
      translatePaging in interface Dialect
      Overrides:
      translatePaging in class BaseDialect
      Parameters:
      limit - 限制条数
      offset - 跳过条数
      Returns:
      分页语法
    • quotePart

      protected String quotePart(String part)
      Description copied from class: BaseDialect
      转义单段标识符,不同数据库转义方式不同时可覆写此方法
      Overrides:
      quotePart in class BaseDialect
      Parameters:
      part - 标识符片段
      Returns:
      转义后标识符片段
    • template

      public String template(Template template)
      Description copied from interface: Dialect
      获取模板,可重写
      Parameters:
      template - 模板
      Returns:
      重写后模板