-
The table to select rows from.
Declaration
Swift
public let tables: [Table]
-
The SQL WHERE clause containing the filter for rows to retrieve. Could be represented with a
Filter
clause or aString
containing raw SQL.Declaration
Swift
public private(set) var whereClause: QueryFilterProtocol? { get }
-
A boolean indicating whether the selected values have to be distinct. If true, corresponds to the SQL SELECT DISTINCT statement.
Declaration
Swift
public private(set) var distinct: Bool { get }
-
The number of rows to select. If specified, corresponds to the SQL SELECT TOP/LIMIT clause.
Declaration
Swift
public private(set) var rowsToReturn: Int? { get }
-
The number of rows to skip. If specified, corresponds to the SQL SELECT OFFSET clause.
Declaration
Swift
public private(set) var offset: Int? { get }
-
The SQL HAVING clause containing the filter for the rows to select when aggregate functions are used. Could be represented with a
Having
clause or aString
containing raw SQL.Declaration
Swift
public private(set) var havingClause: QueryHavingProtocol? { get }
-
The SQL UNION clauses.
Declaration
Swift
public private(set) var unions: [Union]? { get }
-
The SQL JOIN, ON and USING clauses. ON clause can be represented as
Filter
or aString
containing raw SQL. USING clause: an array ofColumn
elements that have to match in a JOIN query.Declaration
Swift
public private(set) var joins: [(join: Join, on: QueryFilterProtocol?, using: [Column]?)] { get }
-
An array of
AuxiliaryTable
which will be used in a query with a WITH clause.Declaration
Swift
public private(set) var with: [AuxiliaryTable]? { get }
-
Build the query using
QueryBuilder
.Throws
QueryError.syntaxError if query build fails.Declaration
Swift
public func build(queryBuilder: QueryBuilder) throws -> String
Parameters
queryBuilder
The QueryBuilder to use.
Return Value
A String representation of the query.
-
Add the HAVING clause to the query.
Declaration
Swift
public func having(_ clause: QueryHavingProtocol) -> Select
Parameters
clause
The
Having
clause or aString
containing SQL HAVING clause to apply.Return Value
A new instance of Select with the
Having
clause. -
Add the LIMIT/TOP clause to the query.
Declaration
Swift
public func limit(to newLimit: Int) -> Select
Parameters
to
The limit of the number of rows to select.
Return Value
A new instance of Select with the LIMIT clause.
-
Add the OFFSET clause to the query.
Declaration
Swift
public func offset(_ offset: Int) -> Select
Parameters
to
The number of rows to skip.
Return Value
A new instance of Select with the OFFSET clause.
-
Add an SQL WHERE clause to the select statement.
Declaration
Swift
public func `where`(_ conditions: QueryFilterProtocol) -> Select
Parameters
conditions
The
Filter
clause or aString
containing SQL WHERE clause to apply.Return Value
A new instance of Select with the WHERE clause.
-
Add an SQL ON clause to the JOIN statement.
Declaration
Swift
public func on(_ conditions: QueryFilterProtocol) -> Select
Parameters
conditions
The
Filter
clause or aString
containing SQL ON clause to apply.Return Value
A new instance of Select with the ON clause.
-
Create an SQL SELECT UNION statement.
Declaration
Swift
public func union(_ query: Select) -> Select
Parameters
table
The second Select query used in performing the union.
Return Value
A new instance of Select corresponding to the SELECT UNION.
-
Create an SQL SELECT UNION ALL statement.
Declaration
Swift
public func unionAll(_ query: Select) -> Select
Parameters
table
The second Select query used in performing the union.
Return Value
A new instance of Select corresponding to the SELECT UNION ALL.
-
Create an SQL SELECT INNER JOIN statement.
Declaration
Swift
public func join(_ table: Table) -> Select
Parameters
table
The right table used in performing the join. The left table is the table field of this
Select
instance.Return Value
A new instance of Select corresponding to the SELECT INNER JOIN.
-
Create an SQL SELECT LEFT JOIN statement.
Declaration
Swift
public func leftJoin(_ table: Table) -> Select
Parameters
table
The right table used in performing the join. The left table is the table field of this
Select
instance.Return Value
A new instance of Select corresponding to the SELECT LEFT JOIN.
-
Create an SQL SELECT CROSS JOIN statement.
Declaration
Swift
public func crossJoin(_ table: Table) -> Select
Parameters
table
The right table used in performing the join. The left table is the table field of this
Select
instance.Return Value
A new instance of Select corresponding to the SELECT CROSS JOIN.
-
Create an SQL SELECT NATURAL JOIN statement.
Declaration
Swift
public func naturalJoin(_ table: Table) -> Select
Parameters
table
The right table used in performing the join. The left table is the table field of this
Select
instance.Return Value
A new instance of Select corresponding to the SELECT NATURAL JOIN.
-
Create a join statement with the type of join specified in the String.
Declaration
Swift
public func rawJoin(_ raw: String, _ table: Table) -> Select
Parameters
raw
A String containg a join to apply.
table
The right table used in performing the join. The left table is the table field of this
Select
instance.Return Value
A new instance of Select corresponding to the join.