mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-25 04:07:47 +00:00
Swift 3 Grand Renaming: SQLColumn -> Column
This commit is contained in:
1 parent
b6587da081
commit
00a1eebf60
24 files changed
+108
-108
No files matched your search
@@ -39,7 +39,7 @@ extension QueryInterfaceRequest where T: RowConvertible {
|
||||
|
||||
/// Returns a sequence of values.
|
||||
///
|
||||
/// let nameColumn = SQLColumn("name")
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Person.order(nameColumn)
|
||||
/// let persons = request.fetch(db) // DatabaseSequence<Person>
|
||||
///
|
||||
@@ -60,7 +60,7 @@ extension QueryInterfaceRequest where T: RowConvertible {
|
||||
|
||||
/// Returns an array of values fetched from a fetch request.
|
||||
///
|
||||
/// let nameColumn = SQLColumn("name")
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Person.order(nameColumn)
|
||||
/// let persons = request.fetchAll(db) // [Person]
|
||||
///
|
||||
@@ -71,7 +71,7 @@ extension QueryInterfaceRequest where T: RowConvertible {
|
||||
|
||||
/// Returns a single value fetched from a fetch request.
|
||||
///
|
||||
/// let nameColumn = SQLColumn("name")
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Person.order(nameColumn)
|
||||
/// let person = request.fetchOne(db) // Person?
|
||||
///
|
||||
@@ -165,13 +165,13 @@ extension QueryInterfaceRequest {
|
||||
|
||||
/// Returns a new QueryInterfaceRequest with the provided *orderings* added to
|
||||
/// the eventual set of already applied orderings.
|
||||
public func order(_ orderings: _SQLOrdering...) -> QueryInterfaceRequest<T> {
|
||||
public func order(_ orderings: _SQLOrderable...) -> QueryInterfaceRequest<T> {
|
||||
return order(orderings)
|
||||
}
|
||||
|
||||
/// Returns a new QueryInterfaceRequest with the provided *orderings* added to
|
||||
/// the eventual set of already applied orderings.
|
||||
public func order(_ orderings: [_SQLOrdering]) -> QueryInterfaceRequest<T> {
|
||||
public func order(_ orderings: [_SQLOrderable]) -> QueryInterfaceRequest<T> {
|
||||
var query = self.query
|
||||
query.orderings = orderings
|
||||
return QueryInterfaceRequest(query: query)
|
||||
@@ -267,13 +267,13 @@ extension TableMapping {
|
||||
|
||||
/// Returns a QueryInterfaceRequest sorted according to the
|
||||
/// provided *orderings*.
|
||||
public static func order(_ orderings: _SQLOrdering...) -> QueryInterfaceRequest<Self> {
|
||||
public static func order(_ orderings: _SQLOrderable...) -> QueryInterfaceRequest<Self> {
|
||||
return all().order(orderings)
|
||||
}
|
||||
|
||||
/// Returns a QueryInterfaceRequest sorted according to the
|
||||
/// provided *orderings*.
|
||||
public static func order(_ orderings: [_SQLOrdering]) -> QueryInterfaceRequest<Self> {
|
||||
public static func order(_ orderings: [_SQLOrderable]) -> QueryInterfaceRequest<Self> {
|
||||
return all().order(orderings)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ extension _SQLCollatedExpression : _SQLExpressible {
|
||||
}
|
||||
}
|
||||
|
||||
extension _SQLCollatedExpression : _SQLOrdering {
|
||||
extension _SQLCollatedExpression : _SQLOrderable {
|
||||
|
||||
/// This property is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
|
||||
@@ -117,7 +117,7 @@ extension _SpecificSQLExpressible {
|
||||
/// Returns an SQL expression that applies the Swift's built-in
|
||||
/// capitalized String property. It is NULL for non-String arguments.
|
||||
///
|
||||
/// let nameColumn = SQLColumn("name")
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Person.select(nameColumn.capitalized)
|
||||
/// let names = String.fetchAll(dbQueue, request) // [String]
|
||||
public var capitalized: _SQLExpression {
|
||||
@@ -127,7 +127,7 @@ extension _SpecificSQLExpressible {
|
||||
/// Returns an SQL expression that applies the Swift's built-in
|
||||
/// lowercased String property. It is NULL for non-String arguments.
|
||||
///
|
||||
/// let nameColumn = SQLColumn("name")
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Person.select(nameColumn.lowercased())
|
||||
/// let names = String.fetchAll(dbQueue, request) // [String]
|
||||
public var lowercased: _SQLExpression {
|
||||
@@ -137,7 +137,7 @@ extension _SpecificSQLExpressible {
|
||||
/// Returns an SQL expression that applies the Swift's built-in
|
||||
/// uppercased String property. It is NULL for non-String arguments.
|
||||
///
|
||||
/// let nameColumn = SQLColumn("name")
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Person.select(nameColumn.uppercased())
|
||||
/// let names = String.fetchAll(dbQueue, request) // [String]
|
||||
public var uppercased: _SQLExpression {
|
||||
@@ -150,7 +150,7 @@ extension _SpecificSQLExpressible {
|
||||
/// Returns an SQL expression that applies the Swift's built-in
|
||||
/// localizedCapitalized String property. It is NULL for non-String arguments.
|
||||
///
|
||||
/// let nameColumn = SQLColumn("name")
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Person.select(nameColumn.localizedCapitalized)
|
||||
/// let names = String.fetchAll(dbQueue, request) // [String]
|
||||
public var localizedCapitalized: _SQLExpression {
|
||||
@@ -160,7 +160,7 @@ extension _SpecificSQLExpressible {
|
||||
/// Returns an SQL expression that applies the Swift's built-in
|
||||
/// localizedLowercased String property. It is NULL for non-String arguments.
|
||||
///
|
||||
/// let nameColumn = SQLColumn("name")
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Person.select(nameColumn.localizedLowercased)
|
||||
/// let names = String.fetchAll(dbQueue, request) // [String]
|
||||
public var localizedLowercased: _SQLExpression {
|
||||
@@ -170,7 +170,7 @@ extension _SpecificSQLExpressible {
|
||||
/// Returns an SQL expression that applies the Swift's built-in
|
||||
/// localizedUppercased String property. It is NULL for non-String arguments.
|
||||
///
|
||||
/// let nameColumn = SQLColumn("name")
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Person.select(nameColumn.localizedUppercased)
|
||||
/// let names = String.fetchAll(dbQueue, request) // [String]
|
||||
public var localizedUppercased: _SQLExpression {
|
||||
|
||||
@@ -23,7 +23,7 @@ public struct _SQLSelectQuery {
|
||||
var source: _SQLSource?
|
||||
var whereExpression: _SQLExpression?
|
||||
var groupByExpressions: [_SQLExpression]
|
||||
var orderings: [_SQLOrdering]
|
||||
var orderings: [_SQLOrderable]
|
||||
var isReversed: Bool
|
||||
var havingExpression: _SQLExpression?
|
||||
var limit: _SQLLimit?
|
||||
@@ -34,7 +34,7 @@ public struct _SQLSelectQuery {
|
||||
from source: _SQLSource? = nil,
|
||||
filter whereExpression: _SQLExpression? = nil,
|
||||
groupBy groupByExpressions: [_SQLExpression] = [],
|
||||
orderBy orderings: [_SQLOrdering] = [],
|
||||
orderBy orderings: [_SQLOrderable] = [],
|
||||
isReversed: Bool = false,
|
||||
having havingExpression: _SQLExpression? = nil,
|
||||
limit: _SQLLimit? = nil)
|
||||
@@ -91,7 +91,7 @@ public struct _SQLSelectQuery {
|
||||
// Here we assume that _rowid_ is not a custom column.
|
||||
// TODO: support for user-defined _rowid_ column.
|
||||
// TODO: support for WITHOUT ROWID tables.
|
||||
orderings = [SQLColumn("_rowid_").desc]
|
||||
orderings = [Column("_rowid_").desc]
|
||||
} else {
|
||||
orderings = orderings.map { $0.reversedOrdering }
|
||||
}
|
||||
@@ -219,13 +219,13 @@ indirect enum _SQLSource {
|
||||
}
|
||||
|
||||
|
||||
// MARK: - _SQLOrdering
|
||||
// MARK: - _SQLOrderable
|
||||
|
||||
/// This protocol is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift/#the-query-interface
|
||||
public protocol _SQLOrdering {
|
||||
public protocol _SQLOrderable {
|
||||
var reversedOrdering: _SQLOrderingExpression { get }
|
||||
func orderingSQL(_ arguments: inout StatementArguments?) -> String
|
||||
}
|
||||
@@ -239,7 +239,7 @@ public enum _SQLOrderingExpression {
|
||||
case desc(_SQLExpression)
|
||||
}
|
||||
|
||||
extension _SQLOrderingExpression : _SQLOrdering {
|
||||
extension _SQLOrderingExpression : _SQLOrderable {
|
||||
|
||||
/// This property is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
@@ -322,7 +322,7 @@ public protocol _SpecificSQLExpressible : _SQLExpressible {
|
||||
//
|
||||
// _SpecificSQLExpressible, on the other side, is not adopted by any
|
||||
// Swift standard type or any user type. It is only adopted by GRDB types,
|
||||
// such as SQLColumn and _SQLExpression.
|
||||
// such as Column and _SQLExpression.
|
||||
//
|
||||
// This separation lets us define functions and operators that do not
|
||||
// spill out. The three declarations below have no chance overloading a
|
||||
@@ -333,7 +333,7 @@ public protocol _SpecificSQLExpressible : _SQLExpressible {
|
||||
// - ==(_SpecificSQLExpressible, _SpecificSQLExpressible)
|
||||
}
|
||||
|
||||
extension _SpecificSQLExpressible where Self: _SQLOrdering {
|
||||
extension _SpecificSQLExpressible where Self: _SQLOrderable {
|
||||
|
||||
/// This property is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
@@ -633,7 +633,7 @@ extension _SQLExpression : _SpecificSQLExpressible {
|
||||
}
|
||||
|
||||
extension _SQLExpression : _SQLSelectable {}
|
||||
extension _SQLExpression : _SQLOrdering {}
|
||||
extension _SQLExpression : _SQLOrderable {}
|
||||
|
||||
|
||||
// MARK: - _SQLSelectable
|
||||
@@ -697,12 +697,12 @@ extension _SQLResultColumn : _SQLSelectable {
|
||||
}
|
||||
|
||||
|
||||
// MARK: - SQLColumn
|
||||
// MARK: - Column
|
||||
|
||||
/// A column in the database
|
||||
///
|
||||
/// See https://github.com/groue/GRDB.swift#the-query-interface
|
||||
public struct SQLColumn {
|
||||
public struct Column {
|
||||
let sourceName: String?
|
||||
|
||||
/// The name of the column
|
||||
@@ -720,7 +720,7 @@ public struct SQLColumn {
|
||||
}
|
||||
}
|
||||
|
||||
extension SQLColumn : _SpecificSQLExpressible {
|
||||
extension Column : _SpecificSQLExpressible {
|
||||
|
||||
/// This property is an implementation detail of the query interface.
|
||||
/// Do not use it directly.
|
||||
@@ -731,5 +731,5 @@ extension SQLColumn : _SpecificSQLExpressible {
|
||||
}
|
||||
}
|
||||
|
||||
extension SQLColumn : _SQLSelectable {}
|
||||
extension SQLColumn : _SQLOrdering {}
|
||||
extension Column : _SQLSelectable {}
|
||||
extension Column : _SQLOrderable {}
|
||||
@@ -246,8 +246,8 @@ public final class TableDefinition {
|
||||
/// try db.create(table: "persons") { t in
|
||||
/// t.column("personalPhone", .Text)
|
||||
/// t.column("workPhone", .Text)
|
||||
/// let personalPhone = SQLColumn("personalPhone")
|
||||
/// let workPhone = SQLColumn("workPhone")
|
||||
/// let personalPhone = Column("personalPhone")
|
||||
/// let workPhone = Column("workPhone")
|
||||
/// t.check(personalPhone != nil || workPhone != nil)
|
||||
/// }
|
||||
///
|
||||
@@ -497,11 +497,11 @@ public final class ColumnDefinition {
|
||||
///
|
||||
/// See https://www.sqlite.org/lang_createtable.html#ckconst
|
||||
///
|
||||
/// - parameter condition: A closure whose argument is an SQLColumn that
|
||||
/// - parameter condition: A closure whose argument is an Column that
|
||||
/// represents the defined column, and returns the expression to check.
|
||||
/// - returns: Self so that you can further refine the column definition.
|
||||
@discardableResult public func check(_ condition: @noescape (SQLColumn) -> _SQLExpressible) -> Self {
|
||||
checkExpression = condition(SQLColumn(name)).sqlExpression
|
||||
@discardableResult public func check(_ condition: @noescape (Column) -> _SQLExpressible) -> Self {
|
||||
checkExpression = condition(Column(name)).sqlExpression
|
||||
return self
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user