mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-29 04:24:21 +00:00
Reduce internal coupling
This commit is contained in:
1 parent
c8023adff1
commit
dae4ae1c6b
36 files changed
+1798
-1625
No files matched your search
@@ -0,0 +1,48 @@
|
||||
// MARK: - SQLStar
|
||||
|
||||
struct SQLStar : SQLSelectable {
|
||||
func resultColumnSQL(_ arguments: inout StatementArguments?) -> String {
|
||||
return "*"
|
||||
}
|
||||
|
||||
func countedSQL(_ arguments: inout StatementArguments?) -> String {
|
||||
return "*"
|
||||
}
|
||||
|
||||
public func count(distinct: Bool) -> SQLCount? {
|
||||
// SELECT DISTINCT * FROM tableName ...
|
||||
guard !distinct else {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SELECT * FROM tableName ...
|
||||
// ->
|
||||
// SELECT COUNT(*) FROM tableName ...
|
||||
return .star
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - SQLAliasedExpression
|
||||
|
||||
struct SQLAliasedExpression : SQLSelectable {
|
||||
let expression: SQLExpression
|
||||
let alias: String
|
||||
|
||||
init(_ expression: SQLExpression, alias: String) {
|
||||
self.expression = expression
|
||||
self.alias = alias
|
||||
}
|
||||
|
||||
func resultColumnSQL(_ arguments: inout StatementArguments?) -> String {
|
||||
return expression.resultColumnSQL(&arguments) + " AS " + alias.quotedDatabaseIdentifier
|
||||
}
|
||||
|
||||
func countedSQL(_ arguments: inout StatementArguments?) -> String {
|
||||
return expression.countedSQL(&arguments)
|
||||
}
|
||||
|
||||
public func count(distinct: Bool) -> SQLCount? {
|
||||
return expression.count(distinct: distinct)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user