Interface Expression

All Superinterfaces:
ArithmeticOperable, ComparisonOperable, OrderOperable, PatternMatchingOperable, Segment, Serializable
All Known Subinterfaces:
CaseExpression, Column, Condition, Literal, SubQueryExpression, TemplateExpression
All Known Implementing Classes:
CaseExpression.Default, Column.Default, Condition.BooleanExpressionCondition, Condition.StaticCondition, Condition.TemplateCondition, Expression.Default, Expression.StaticExpression, Literal.Default, SubQueryExpression.Default, TemplateExpression.Default

表达式接口, 代表sql中所有表达式。

通过 of(String)、of(String, Object...) 创建的静态表达式/模板表达式 属于可信 SQL 片段,不做方言转换和注入校验;模板参数在 WHERE/ON 等条件中会绑定为 ?,在 SELECT 列表中会被当作字面量直接拼入 SQL。 禁止将终端用户输入拼入原始 SQL 或模板。

Author:
Maning
  • Method Details

    • of

      static Expression of(Template template, Object... params)
      模板表达式
      Parameters:
      template - 模板
      params - 参数
      Returns:
      模板表达式
    • of

      static Expression of(String template, Object... params)
      模板表达式。

      模板本身是可信 SQL 片段,不做方言转换和注入校验。params 在 WHERE/ON 等 条件中会绑定为 ?,但在 SELECT 列表中会被当作字面量直接拼入 SQL。 严禁将终端用户输入作为模板或 SELECT 列表参数传入。

      Parameters:
      template - 模板
      params - 参数
      Returns:
      模板表达式
    • of

      static Expression of(Template template, Collection<?> params)
      模板表达式
      Parameters:
      template - 模板
      params - 参数
      Returns:
      模板表达式
    • of

      static Expression of(String template, Collection<?> params)
      模板表达式
      Parameters:
      template - 模板
      params - 参数
      Returns:
      模板表达式
    • of

      static Expression of(String expression)
      静态表达式 不转译。

      原样拼入 SQL,不做任何转义或校验;仅用于可信 SQL 片段, 禁止拼接终端用户输入。

      Parameters:
      expression - 表达式
      Returns:
      表达式
    • as

      AliasSegment as(String alias)
      别名
      Parameters:
      alias - 别名不能为空
      Returns:
      实际对象
    • asCondition

      default Condition asCondition()
      作为条件,需要确保当前表达式为布尔类型
      Returns:
      条件