mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-28 04:24:20 +00:00
Replace TableMapping.selectsRowID with TableMapping.databaseSelection
This commit is contained in:
1 parent
0030ad1804
commit
376d295853
20 files changed
+314
-112
No files matched your search
@@ -1,15 +1,37 @@
|
||||
// MARK: - SQLStar
|
||||
// MARK: - AllColumns
|
||||
|
||||
struct SQLStar : SQLSelectable {
|
||||
func resultColumnSQL(_ arguments: inout StatementArguments?) -> String {
|
||||
/// AllColumns is the `*` in `SELECT *`.
|
||||
///
|
||||
/// You use AllColumns in your custom implementation of
|
||||
/// TableMapping.databaseSelection.
|
||||
///
|
||||
/// For example:
|
||||
///
|
||||
/// struct Person : TableMapping {
|
||||
/// static var databaseTableName = "persons"
|
||||
/// static let databaseSelection: [SQLSelectable] = [AllColumns(), Column.rowID]
|
||||
/// }
|
||||
///
|
||||
/// // SELECT *, rowid FROM persons
|
||||
/// let request = Person.all()
|
||||
public struct AllColumns {
|
||||
///
|
||||
public init() { }
|
||||
}
|
||||
|
||||
extension AllColumns : SQLSelectable {
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
public func resultColumnSQL(_ arguments: inout StatementArguments?) -> String {
|
||||
return "*"
|
||||
}
|
||||
|
||||
func countedSQL(_ arguments: inout StatementArguments?) -> String {
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
public func countedSQL(_ arguments: inout StatementArguments?) -> String {
|
||||
return "*"
|
||||
}
|
||||
|
||||
func count(distinct: Bool) -> SQLCount? {
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
public func count(distinct: Bool) -> SQLCount? {
|
||||
// SELECT DISTINCT * FROM tableName ...
|
||||
guard !distinct else {
|
||||
return nil
|
||||
@@ -18,7 +40,7 @@ struct SQLStar : SQLSelectable {
|
||||
// SELECT * FROM tableName ...
|
||||
// ->
|
||||
// SELECT COUNT(*) FROM tableName ...
|
||||
return .star
|
||||
return .all
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user