Skip to content

Structure

SQLFunction

A call to a function available in SQL, expressed as a name and a (possibly empty) list of arguments.
struct SQLFunction

Overview

Example usage:

try await sqlDatabase.select()
    .column(SQLFunction("coalesce", args: SQlColumn("col1"), SQlColumn("col2"), SQLBind(defaultValue)))
    .from("table")
    .all()

Note

SQLFunction is permitted to substitute function names during serialization based on the current dialect if a known, unambiguous replacement for an unavailable name is available. At the time of this writing, no such substitutions take place in practice, but it would be of obvious utility in certain common cases, such as SQLite’s lack of support for the NOW() function.

Topics

Initializers

  • init(_:args:)
    Create a function from a name and list of arguments.

Instance Properties

  • args
    The list of function arguments. May be empty.
  • name
    The function’s name.

Instance Methods

  • serialize(to:)
    Invoked when a request is made to serialize the expression to raw SQL.

Type Methods

  • coalesce(_:)
    A factory method to simplify use of the standard COALESCE() function.

Relationships

Conforms To

See Also

Syntactic Expressions

  • SQLBinaryExpression
    A fundamental syntactical expression - a left and right operand joined by an infix operator.
  • SQLBinaryOperator
    SQL binary expression operators.
  • SQLBind
    A parameterizied value bound to the SQL query.
  • SQLGroupExpression
    A fundamental syntactical expression - an arbitrary expression or list of expressions, surroudned by parenthesis.
  • SQLIdentifier
    A fundamental syntactical expression - a quoted identifier (also often referred to as a “name” or “object name”).
  • SQLList
    A fundamental syntactical expression - a list of subexpresions with a specified “separator” subexpression.
  • SQLLiteral
    A fundamental syntactical expression - one of several various kinds of literal SQL expressions.
  • SQLRaw
    A fundamental syntactical expression - an arbitrary string of raw SQL with no escaping or formating of any kind.