Functions
The following functions are available globally.
-
Returns an expression that evaluates the
ABSSQL function.// ABS(amount) abs(Column("amount"))Declaration
Swift
public func abs(_ value: SQLSpecificExpressible) -> SQLExpression
-
Returns an expression that evaluates the
AVGSQL function.// AVG(length) average(Column("length"))Declaration
Swift
public func average(_ value: SQLSpecificExpressible) -> SQLExpression
-
Returns an expression that evaluates the
COUNTSQL function.// COUNT(email) count(Column("email"))Declaration
Swift
public func count(_ counted: SQLSelectable) -> SQLExpression
-
Returns an expression that evaluates the
COUNT(DISTINCT)SQL function.// COUNT(DISTINCT email) count(distinct: Column("email"))Declaration
Swift
public func count(distinct value: SQLSpecificExpressible) -> SQLExpression
-
Returns an expression that evaluates the
IFNULLSQL function.// IFNULL(name, 'Anonymous') Column("name") ?? "Anonymous"Declaration
Swift
public func ?? (lhs: SQLSpecificExpressible, rhs: SQLExpressible) -> SQLExpression
-
Returns an expression that evaluates the
LENGTHSQL function.// LENGTH(name) length(Column("name"))Declaration
Swift
public func length(_ value: SQLSpecificExpressible) -> SQLExpression
-
Returns an expression that evaluates the
MAXSQL function.// MAX(score) max(Column("score"))Declaration
Swift
public func max(_ value: SQLSpecificExpressible) -> SQLExpression
-
Returns an expression that evaluates the
MINSQL function.// MIN(score) min(Column("score"))Declaration
Swift
public func min(_ value: SQLSpecificExpressible) -> SQLExpression
-
Returns an expression that evaluates the
SUMSQL function.// SUM(amount) sum(Column("amount"))Declaration
Swift
public func sum(_ value: SQLSpecificExpressible) -> SQLExpression
-
An SQL expression that compares two expressions with the
=SQL operator.// name = 'Arthur' Column("name") == "Arthur"When the right operand is nil,
IS NULLis used instead.// name IS NULL Column("name") == nilDeclaration
Swift
public func == (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpression -
An SQL expression that compares two expressions with the
=SQL operator.// name = 'Arthur' COLLATE NOCASE Column("name").collating(.nocase) == "Arthur"When the right operand is nil,
IS NULLis used instead.// name IS NULL Column("name").collating(.nocase) == nilDeclaration
Swift
public func == (lhs: SQLCollatedExpression, rhs: SQLExpressible?) -> SQLExpression -
An SQL expression that checks the boolean value of an expression.
The comparison is done with the built-in boolean evaluation of SQLite:
// validated Column("validated") == true // NOT validated Column("validated") == falseDeclaration
Swift
public func == (lhs: SQLSpecificExpressible, rhs: Bool) -> SQLExpression -
An SQL expression that compares two expressions with the
=SQL operator.// 'Arthur' = name "Arthur" == Column("name")When the left operand is nil,
IS NULLis used instead.// name IS NULL nil == Column("name")Declaration
Swift
public func == (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
=SQL operator.// 'Arthur' = name COLLATE NOCASE "Arthur" == Column("name").collating(.nocase)When the left operand is nil,
IS NULLis used instead.// name IS NULL nil == Column("name").collating(.nocase)Declaration
Swift
public func == (lhs: SQLExpressible?, rhs: SQLCollatedExpression) -> SQLExpression -
An SQL expression that checks the boolean value of an expression.
The comparison is done with the built-in boolean evaluation of SQLite:
// validated true == Column("validated") // NOT validated false == Column("validated")Declaration
Swift
public func == (lhs: Bool, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
=SQL operator.// email = login Column("email") == Column("login")Declaration
Swift
public func == (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
<>SQL operator.// name <> 'Arthur' Column("name") != "Arthur"When the right operand is nil,
IS NOT NULLis used instead.// name IS NOT NULL Column("name") != nilDeclaration
Swift
public func != (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpression -
An SQL expression that compares two expressions with the
<>SQL operator.// name <> 'Arthur' COLLATE NOCASE Column("name").collating(.nocase) != "Arthur"When the right operand is nil,
IS NOT NULLis used instead.// name IS NOT NULL Column("name").collating(.nocase) != nilDeclaration
Swift
public func != (lhs: SQLCollatedExpression, rhs: SQLExpressible?) -> SQLExpression -
An SQL expression that checks the boolean value of an expression.
The comparison is done with the built-in boolean evaluation of SQLite:
// NOT validated Column("validated") != true // validated Column("validated") != falseDeclaration
Swift
public func != (lhs: SQLSpecificExpressible, rhs: Bool) -> SQLExpression -
An SQL expression that compares two expressions with the
<>SQL operator.// 'Arthur' <> name "Arthur" != Column("name")When the left operand is nil,
IS NOT NULLis used instead.// name IS NOT NULL nil != Column("name")Declaration
Swift
public func != (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
<>SQL operator.// 'Arthur' <> name COLLATE NOCASE "Arthur" != Column("name").collating(.nocase)When the left operand is nil,
IS NOT NULLis used instead.// name IS NOT NULL nil != Column("name").collating(.nocase)Declaration
Swift
public func != (lhs: SQLExpressible?, rhs: SQLCollatedExpression) -> SQLExpression -
An SQL expression that checks the boolean value of an expression.
The comparison is done with the built-in boolean evaluation of SQLite:
// NOT validated true != Column("validated") // validated false != Column("validated")Declaration
Swift
public func != (lhs: Bool, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
<>SQL operator.// email <> login Column("email") != Column("login")Declaration
Swift
public func != (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
ISSQL operator.// name IS 'Arthur' Column("name") === "Arthur"Declaration
Swift
public func === (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpression -
An SQL expression that compares two expressions with the
ISSQL operator.// name IS 'Arthur' COLLATE NOCASE Column("name").collating(.nocase) === "Arthur"Declaration
Swift
public func === (lhs: SQLCollatedExpression, rhs: SQLExpressible?) -> SQLExpression -
An SQL expression that compares two expressions with the
ISSQL operator.// name IS 'Arthur' "Arthur" === Column("name")Declaration
Swift
public func === (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
ISSQL operator.// name IS 'Arthur' COLLATE NOCASE "Arthur" === Column("name").collating(.nocase)Declaration
Swift
public func === (lhs: SQLExpressible?, rhs: SQLCollatedExpression) -> SQLExpression -
An SQL expression that compares two expressions with the
ISSQL operator.// email IS login Column("email") === Column("login")Declaration
Swift
public func === (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
IS NOTSQL operator.// name IS NOT 'Arthur' Column("name") !== "Arthur"Declaration
Swift
public func !== (lhs: SQLSpecificExpressible, rhs: SQLExpressible?) -> SQLExpression -
An SQL expression that compares two expressions with the
IS NOTSQL operator.// name IS NOT 'Arthur' COLLATE NOCASE Column("name").collating(.nocase) !== "Arthur"Declaration
Swift
public func !== (lhs: SQLCollatedExpression, rhs: SQLExpressible?) -> SQLExpression -
An SQL expression that compares two expressions with the
IS NOTSQL operator.// name IS NOT 'Arthur' "Arthur" !== Column("name")Declaration
Swift
public func !== (lhs: SQLExpressible?, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
IS NOTSQL operator.// name IS NOT 'Arthur' COLLATE NOCASE "Arthur" !== Column("name").collating(.nocase)Declaration
Swift
public func !== (lhs: SQLExpressible?, rhs: SQLCollatedExpression) -> SQLExpression -
An SQL expression that compares two expressions with the
IS NOTSQL operator.// email IS NOT login Column("email") !== Column("login")Declaration
Swift
public func !== (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression
-
An SQL expression that compares two expressions with the
<SQL operator.// score < 18 Column("score") < 18Declaration
Swift
public func < (lhs: SQLSpecificExpressible, rhs: SQLExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
<SQL operator.// name < 'Arthur' COLLATE NOCASE Column("name").collating(.nocase) < "Arthur"Declaration
Swift
public func < (lhs: SQLCollatedExpression, rhs: SQLExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
<SQL operator.// 18 < score 18 < Column("score")Declaration
Swift
public func < (lhs: SQLExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
<SQL operator.// 'Arthur' < name COLLATE NOCASE "Arthur" < Column("name").collating(.nocase)Declaration
Swift
public func < (lhs: SQLExpressible, rhs: SQLCollatedExpression) -> SQLExpression -
An SQL expression that compares two expressions with the
<SQL operator.// width < height Column("width") < Column("height")Declaration
Swift
public func < (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
<=SQL operator.// score <= 18 Column("score") <= 18Declaration
Swift
public func <= (lhs: SQLSpecificExpressible, rhs: SQLExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
<=SQL operator.// name <= 'Arthur' COLLATE NOCASE Column("name").collating(.nocase) <= "Arthur"Declaration
Swift
public func <= (lhs: SQLCollatedExpression, rhs: SQLExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
<=SQL operator.// 18 <= score 18 <= Column("score")Declaration
Swift
public func <= (lhs: SQLExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
<=SQL operator.// 'Arthur' <= name COLLATE NOCASE "Arthur" <= Column("name").collating(.nocase)Declaration
Swift
public func <= (lhs: SQLExpressible, rhs: SQLCollatedExpression) -> SQLExpression -
An SQL expression that compares two expressions with the
<=SQL operator.// width <= height Column("width") <= Column("height")Declaration
Swift
public func <= (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
>SQL operator.// score > 18 Column("score") > 18Declaration
Swift
public func > (lhs: SQLSpecificExpressible, rhs: SQLExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
>SQL operator.// name > 'Arthur' COLLATE NOCASE Column("name").collating(.nocase) > "Arthur"Declaration
Swift
public func > (lhs: SQLCollatedExpression, rhs: SQLExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
>SQL operator.// 18 > score 18 > Column("score")Declaration
Swift
public func > (lhs: SQLExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
>SQL operator.// 'Arthur' > name COLLATE NOCASE "Arthur" > Column("name").collating(.nocase)Declaration
Swift
public func > (lhs: SQLExpressible, rhs: SQLCollatedExpression) -> SQLExpression -
An SQL expression that compares two expressions with the
>SQL operator.// width > height Column("width") > Column("height")Declaration
Swift
public func > (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
>=SQL operator.// score >= 18 Column("score") >= 18Declaration
Swift
public func >= (lhs: SQLSpecificExpressible, rhs: SQLExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
>=SQL operator.// name >= 'Arthur' COLLATE NOCASE Column("name").collating(.nocase) >= "Arthur"Declaration
Swift
public func >= (lhs: SQLCollatedExpression, rhs: SQLExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
>=SQL operator.// 18 >= score 18 >= Column("score")Declaration
Swift
public func >= (lhs: SQLExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL expression that compares two expressions with the
>=SQL operator.// 'Arthur' >= name COLLATE NOCASE "Arthur" >= Column("name").collating(.nocase)Declaration
Swift
public func >= (lhs: SQLExpressible, rhs: SQLCollatedExpression) -> SQLExpression -
An SQL expression that compares two expressions with the
>=SQL operator.// width >= height Column("width") >= Column("height")Declaration
Swift
public func >= (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression
-
An SQL arithmetic multiplication.
// width * 2 Column("width") * 2Declaration
Swift
public func * (lhs: SQLSpecificExpressible, rhs: SQLExpressible) -> SQLExpression -
An SQL arithmetic multiplication.
// 2 * width 2 * Column("width")Declaration
Swift
public func * (lhs: SQLExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL arithmetic multiplication.
// width * height Column("width") * Column("height")Declaration
Swift
public func * (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL arithmetic division.
// width / 2 Column("width") / 2Declaration
Swift
public func / (lhs: SQLSpecificExpressible, rhs: SQLExpressible) -> SQLExpression -
An SQL arithmetic division.
// 2 / width 2 / Column("width")Declaration
Swift
public func / (lhs: SQLExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL arithmetic division.
// width / height Column("width") / Column("height")Declaration
Swift
public func / (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL arithmetic addition.
// width + 2 Column("width") + 2Declaration
Swift
public func + (lhs: SQLSpecificExpressible, rhs: SQLExpressible) -> SQLExpression -
An SQL arithmetic addition.
// 2 + width 2 + Column("width")Declaration
Swift
public func + (lhs: SQLExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL arithmetic addition.
// width + height Column("width") + Column("height")Declaration
Swift
public func + (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
A negated SQL arithmetic expression.
// -width -Column("width")Declaration
Swift
public prefix func - (value: SQLSpecificExpressible) -> SQLExpression -
An SQL arithmetic substraction.
// width - 2 Column("width") - 2Declaration
Swift
public func - (lhs: SQLSpecificExpressible, rhs: SQLExpressible) -> SQLExpression -
An SQL arithmetic substraction.
// 2 - width 2 - Column("width")Declaration
Swift
public func - (lhs: SQLExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
An SQL arithmetic substraction.
// width - height Column("width") - Column("height")Declaration
Swift
public func - (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression
-
A logical SQL expression with the
ANDSQL operator.// favorite AND 0 Column("favorite") && falseDeclaration
Swift
public func && (lhs: SQLSpecificExpressible, rhs: SQLExpressible) -> SQLExpression -
A logical SQL expression with the
ANDSQL operator.// 0 AND favorite false && Column("favorite")Declaration
Swift
public func && (lhs: SQLExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
A logical SQL expression with the
ANDSQL operator.// email IS NOT NULL AND favorite Column("email") != nil && Column("favorite")Declaration
Swift
public func && (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
A logical SQL expression with the
ORSQL operator.// favorite OR 1 Column("favorite") || trueDeclaration
Swift
public func || (lhs: SQLSpecificExpressible, rhs: SQLExpressible) -> SQLExpression -
A logical SQL expression with the
ORSQL operator.// 0 OR favorite true || Column("favorite")Declaration
Swift
public func || (lhs: SQLExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
A logical SQL expression with the
ORSQL operator.// email IS NULL OR hidden Column("email") == nil || Column("hidden")Declaration
Swift
public func || (lhs: SQLSpecificExpressible, rhs: SQLSpecificExpressible) -> SQLExpression -
A negated logical SQL expression with the
NOTSQL operator.// NOT hidden !Column("hidden")Some expressions may be negated with specific SQL operators:
// id NOT BETWEEN 1 AND 10 !((1...10).contains(Column("id")))Declaration
Swift
public prefix func ! (value: SQLSpecificExpressible) -> SQLExpression
-
Return as many question marks separated with commas as the count argument.
databaseQuestionMarks(count: 3) // "?,?,?"Declaration
Swift
public func databaseQuestionMarks(count: Int) -> String
View on GitHub
Install in Dash
Functions Reference