SQLSpecificExpressible
SQLSpecificExpressible is a protocol for all database-specific types that
can be turned into an SQL expression. Types whose existence is not purely
dedicated to the database should adopt the SQLExpressible
protocol instead.
For example, Column is a type that only exists to help you build requests,
and it adopts SQLSpecificExpressible.
On the other side, Int adopts SQLExpressible.
-
sqlSelectionExtension method -
sqlOrderingExtension method
-
ascExtension methodReturns a value that can be used as an argument to QueryInterfaceRequest.order()
See https://github.com/groue/GRDB.swift/#the-query-interface
-
descExtension methodReturns a value that can be used as an argument to QueryInterfaceRequest.order()
See https://github.com/groue/GRDB.swift/#the-query-interface
-
ascNullsLastExtension methodReturns a value that can be used as an argument to QueryInterfaceRequest.order()
See https://github.com/groue/GRDB.swift/#the-query-interface
-
descNullsFirstExtension methodReturns a value that can be used as an argument to QueryInterfaceRequest.order()
See https://github.com/groue/GRDB.swift/#the-query-interface
-
forKey(_:Extension method) Returns an aliased column.
For example:
// SELECT (width * height) AS area FROM shape let area = (Column("width") * Column("height")).forKey("area") let request = Shape.select(area) if let row = try Row.fetchOne(db, request) { let area: Int = row["area"] }If you need to refer to the aliased column in another part of a request, use
Column(...).detached. For example:// SELECT (width * height) AS area FROM shape ORDER BY area let area = (Column("width") * Column("height")).forKey("area") let request = Shape .select(area) .order(Column("area").detached) let rows = try Row.fetchCursor(db, request) while let row = try rows.next() { let area: Int = row["area"] }
-
collating(_:Extension method) Returns a collated expression.
For example:
Player.filter(Column("email").collating(.nocase) == "contact@example.com")
-
like(_:Extension methodescape: ) An SQL expression with the
LIKESQL operator.// email LIKE '%@example.com" Column("email").like("%@example.com") // title LIKE '%10\%%' ESCAPE '\' Column("title").like("%10\\%%", escape: "\\")
View on GitHub
Install in Dash
SQLSpecificExpressible Protocol Reference