Interface RDBMSFieldFunctionAdapterInterface

All Superinterfaces:
BackendFieldFunctionAdapterInterface, Serializable
All Known Implementing Classes:
PostgreSQLRDBMSWeekdayOfDateFunction, PostgreSQLRDBMSWeekdayOfDateTimeFunction, RDBMSStringLengthFunction, RDBMSSubStringFunction, RDBMSWeekdayOfDateFunction, RDBMSWeekdayOfDateTimeFunction

public interface RDBMSFieldFunctionAdapterInterface extends BackendFieldFunctionAdapterInterface
RDBMS-specific extension of BackendFieldFunctionAdapterInterface for adapting a FieldFunction into SQL expressions.

Implementations wrap a raw escaped column name in the appropriate SQL function call (e.g., CHAR_LENGTH(`col`)) for use in SELECT and WHERE clauses, and optionally supply bind-parameter values (e.g., for SUBSTR(`col`, ?, ?)

By default, the same expression is used for ORDER-BY, but, an alternative can be used instead if needed (e.g., to change weekday sorting)

  • Method Details

    • wrapColumnName

      String wrapColumnName(String escapedColumnName, FieldFunction fieldFunction, Function<String,String> fieldNameToColumnReference)
      Wraps the given escaped SQL column reference in the appropriate SQL function expression for use in SELECT, WHERE, ORDER-BY or GROUP-BY clauses.
      Parameters:
      escapedColumnName - a fully qualified and escaped SQL column name for the 'main' field that this function works with (e.g., FieldFunction#withFieldName(String). Looks like: `my_table`.`my_field`.
      fieldFunction - the function with arguments, being used.
      fieldNameToColumnReference - resolves a QQQ field name to its fully- qualified escaped SQL column reference (e.g., "timeZone"`t1`.`time_zone`). Useful when the function expression needs to reference additional columns on the same row.
    • getParams

      default List<Serializable> getParams(FieldFunction fieldFunction)
      Returns any SQL bind-parameter values needed by the wrapped expression (e.g., SUBSTRING start index). Returns an empty list by default.
    • wrapColumnNameForOrderBy

      default String wrapColumnNameForOrderBy(String escapedColumnName, FieldFunction fieldFunction, Function<String,String> fieldNameToColumnReference)
      Wraps the column reference for use specifically in an ORDER BY clause. Defaults to calling wrapColumnName(java.lang.String, com.kingsrook.qqq.backend.core.model.metadata.fields.functions.FieldFunction, java.util.function.Function<java.lang.String, java.lang.String>); may be overridden when the ORDER BY form differs (e.g., a modulo for Sunday-first sorting).