mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-23 04:04:22 +00:00
57 lines
1.7 KiB
Swift
57 lines
1.7 KiB
Swift
// MARK: - SQL Ordering Support
|
|
|
|
extension SQLSpecificExpressible {
|
|
|
|
/// Returns a value that can be used as an argument to QueryInterfaceRequest.order()
|
|
///
|
|
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
|
public var asc: SQLOrderingTerm {
|
|
return SQLOrdering.asc(sqlExpression)
|
|
}
|
|
|
|
/// Returns a value that can be used as an argument to QueryInterfaceRequest.order()
|
|
///
|
|
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
|
public var desc: SQLOrderingTerm {
|
|
return SQLOrdering.desc(sqlExpression)
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: - SQL Selection Support
|
|
|
|
extension SQLSpecificExpressible {
|
|
|
|
/// Returns a value that can be used as an argument to QueryInterfaceRequest.select()
|
|
///
|
|
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
|
public func aliased(_ alias: String) -> SQLSelectable {
|
|
return SQLAliasedExpression(sqlExpression, alias: alias)
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: - SQL Collations Support
|
|
|
|
extension SQLSpecificExpressible {
|
|
|
|
/// Returns a collated expression.
|
|
///
|
|
/// For example:
|
|
///
|
|
/// Person.filter(Column("email").collating(.nocase) == "contact@example.com")
|
|
public func collating(_ collation: Database.CollationName) -> SQLCollatedExpression {
|
|
return SQLCollatedExpression(sqlExpression, collationName: collation)
|
|
}
|
|
|
|
/// Returns a collated expression.
|
|
///
|
|
/// For example:
|
|
///
|
|
/// Person.filter(Column("name").collating(.localizedStandardCompare) == "Hervé")
|
|
public func collating(_ collation: DatabaseCollation) -> SQLCollatedExpression {
|
|
return SQLCollatedExpression(sqlExpression, collationName: Database.CollationName(collation.name))
|
|
}
|
|
}
|
|
|