mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-26 04:07:50 +00:00
rawSQL migration complete
This commit is contained in:
1 parent
4bd5ace2ee
commit
a57aa2e346
24 files changed
+407
-309
No files matched your search
@@ -246,7 +246,7 @@ extension PlayersViewController {
|
||||
}
|
||||
// Delete a random player
|
||||
if Bool.random() {
|
||||
try Player.order(sql: "RANDOM()").limit(1).deleteAll(db)
|
||||
try Player.order(rawSQL: "RANDOM()").limit(1).deleteAll(db)
|
||||
}
|
||||
// Update some players
|
||||
for var player in try Player.fetchAll(db) where Bool.random() {
|
||||
|
||||
@@ -19,7 +19,7 @@ public struct SQLInterpolation: StringInterpolationProtocol {
|
||||
}
|
||||
|
||||
/// "SELECT * FROM \(sql: "player")"
|
||||
public mutating func appendInterpolation(sql: String, arguments: StatementArguments = StatementArguments()) {
|
||||
public mutating func appendInterpolation(rawSQL sql: String, arguments: StatementArguments = StatementArguments()) {
|
||||
self.sql += sql
|
||||
self.arguments += arguments
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ extension SQLLiteral {
|
||||
self += sqlLiteral
|
||||
}
|
||||
|
||||
public mutating func append(sql: String, arguments: StatementArguments = StatementArguments()) {
|
||||
public mutating func append(rawSQL sql: String, arguments: StatementArguments = StatementArguments()) {
|
||||
self += SQLLiteral(rawSQL: sql, arguments: arguments)
|
||||
}
|
||||
}
|
||||
|
||||
+95
-15
@@ -31,61 +31,141 @@ extension Database {
|
||||
|
||||
extension DatabaseValueConvertible {
|
||||
@available(*, unavailable, renamed: "fetchCursor(_:rawSQL:arguments:adapter:)")
|
||||
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> DatabaseValueCursor<Self> { preconditionFailure() }
|
||||
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> DatabaseValueCursor<Self> { preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, renamed: "fetchAll(_:rawSQL:arguments:adapter:)")
|
||||
public static func fetchAll(_ db: Database, _ sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> [Self] { preconditionFailure() }
|
||||
public static func fetchAll(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Self] { preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, renamed: "fetchOne(_:rawSQL:arguments:adapter:)")
|
||||
public static func fetchOne(_ db: Database, _ sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> Self? { preconditionFailure() }
|
||||
public static func fetchOne(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> Self? { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension Optional where Wrapped: DatabaseValueConvertible {
|
||||
@available(*, unavailable, renamed: "fetchCursor(_:rawSQL:arguments:adapter:)")
|
||||
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> NullableDatabaseValueCursor<Wrapped> { preconditionFailure() }
|
||||
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> NullableDatabaseValueCursor<Wrapped> { preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, renamed: "fetchAll(_:rawSQL:arguments:adapter:)")
|
||||
public static func fetchAll(_ db: Database, _ sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> [Wrapped?] { preconditionFailure() }
|
||||
public static func fetchAll(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Wrapped?] { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension Row {
|
||||
@available(*, unavailable, renamed: "fetchCursor(_:rawSQL:arguments:adapter:)")
|
||||
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> RowCursor { preconditionFailure() }
|
||||
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> RowCursor { preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, renamed: "fetchAll(_:rawSQL:arguments:adapter:)")
|
||||
public static func fetchAll(_ db: Database, _ sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> [Row] { preconditionFailure() }
|
||||
public static func fetchAll(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Row] { preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, renamed: "fetchOne(_:rawSQL:arguments:adapter:)")
|
||||
public static func fetchOne(_ db: Database, _ sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> Row? { preconditionFailure() }
|
||||
public static func fetchOne(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> Row? { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension DatabaseValueConvertible where Self: StatementColumnConvertible {
|
||||
@available(*, unavailable, renamed: "fetchCursor(_:rawSQL:arguments:adapter:)")
|
||||
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> FastDatabaseValueCursor<Self> { preconditionFailure() }
|
||||
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> FastDatabaseValueCursor<Self> { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension Optional where Wrapped: DatabaseValueConvertible & StatementColumnConvertible {
|
||||
@available(*, unavailable, renamed: "fetchCursor(_:rawSQL:arguments:adapter:)")
|
||||
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> FastNullableDatabaseValueCursor<Wrapped> { preconditionFailure() }
|
||||
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> FastNullableDatabaseValueCursor<Wrapped> { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension FetchableRecord {
|
||||
@available(*, unavailable, renamed: "fetchCursor(_:rawSQL:arguments:adapter:)")
|
||||
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> RecordCursor<Self> { preconditionFailure() }
|
||||
public static func fetchCursor(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> RecordCursor<Self> { preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, renamed: "fetchAll(_:rawSQL:arguments:adapter:)")
|
||||
public static func fetchAll(_ db: Database, _ sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> [Self] { preconditionFailure() }
|
||||
public static func fetchAll(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> [Self] { preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, renamed: "fetchOne(_:rawSQL:arguments:adapter:)")
|
||||
public static func fetchOne(_ db: Database, _ sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws -> Self? { preconditionFailure() }
|
||||
public static func fetchOne(_ db: Database, _ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws -> Self? { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension SQLRequest {
|
||||
@available(*, unavailable, renamed: "init(rawSQL:arguments:adapter:cached:)")
|
||||
public init(_ sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil, cached: Bool = false) { preconditionFailure() }
|
||||
public init(_ sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil, cached: Bool = false) { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension SQLExpressionLiteral {
|
||||
@available(*, unavailable, renamed: "init(rawSQL:arguments:)")
|
||||
public init(_ sql: String, arguments: StatementArguments = StatementArguments()) { preconditionFailure() }
|
||||
public init(_ sql: String, arguments: StatementArguments? = nil) { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension QueryInterfaceRequest {
|
||||
@available(*, unavailable, renamed: "select(rawSQL:arguments:as:)")
|
||||
public func select<RowDecoder>(sql: String, arguments: StatementArguments? = nil, as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension TableRecord {
|
||||
@available(*, unavailable, renamed: "select(rawSQL:arguments:)")
|
||||
public static func select(sql: String, arguments: StatementArguments? = nil) -> QueryInterfaceRequest<Self> { preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, renamed: "select(rawSQL:arguments:as:)")
|
||||
public static func select<RowDecoder>(sql: String, arguments: StatementArguments? = nil, as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> { preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, renamed: "filter(rawSQL:arguments:)")
|
||||
public static func filter(sql: String, arguments: StatementArguments? = nil) -> QueryInterfaceRequest<Self> { preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, renamed: "order(rawSQL:arguments:)")
|
||||
public static func order(sql: String, arguments: StatementArguments? = nil) -> QueryInterfaceRequest<Self> { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension SelectionRequest {
|
||||
@available(*, unavailable, renamed: "select(rawSQL:arguments:)")
|
||||
public func select(sql: String, arguments: StatementArguments? = nil) -> Self { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension FilteredRequest {
|
||||
@available(*, unavailable, renamed: "filter(rawSQL:arguments:)")
|
||||
public func filter(sql: String, arguments: StatementArguments? = nil) -> Self { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension AggregatingRequest {
|
||||
@available(*, unavailable, renamed: "group(rawSQL:arguments:)")
|
||||
public func group(sql: String, arguments: StatementArguments? = nil) -> Self { preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, renamed: "having(rawSQL:arguments:)")
|
||||
public func having(sql: String, arguments: StatementArguments? = nil) -> Self { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension OrderedRequest {
|
||||
@available(*, unavailable, renamed: "order(rawSQL:arguments:)")
|
||||
public func order(sql: String, arguments: StatementArguments? = nil) -> Self { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension TableDefinition {
|
||||
@available(*, unavailable, renamed: "check(rawSQL:)")
|
||||
public func check(sql: String) { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension ColumnDefinition {
|
||||
@available(*, unavailable, renamed: "check(rawSQL:)")
|
||||
public func check(sql: String) { preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, renamed: "defaults(rawSQL:)")
|
||||
public func defaults(sql: String) -> Self { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension FetchedRecordsController {
|
||||
@available(*, unavailable, renamed: "init(_:rawSQL:arguments:adapter:queue:isSameRecord:)")
|
||||
public convenience init(
|
||||
_ databaseWriter: DatabaseWriter,
|
||||
sql: String,
|
||||
arguments: StatementArguments? = nil,
|
||||
adapter: RowAdapter? = nil,
|
||||
queue: DispatchQueue = .main,
|
||||
isSameRecord: ((Record, Record) -> Bool)? = nil) throws { preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, renamed: "setRequest(rawSQL:arguments:adapter:)")
|
||||
public func setRequest(sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws { preconditionFailure() }
|
||||
}
|
||||
|
||||
extension FetchedRecordsController where Record: TableRecord {
|
||||
@available(*, unavailable, renamed: "init(_:rawSQL:arguments:adapter:queue:)")
|
||||
public convenience init(
|
||||
_ databaseWriter: DatabaseWriter,
|
||||
sql: String,
|
||||
arguments: StatementArguments? = nil,
|
||||
adapter: RowAdapter? = nil,
|
||||
queue: DispatchQueue = .main) throws { preconditionFailure() }
|
||||
}
|
||||
|
||||
@@ -103,10 +103,10 @@ extension QueryInterfaceRequest : DerivableRequest, AggregatingRequest {
|
||||
///
|
||||
/// try dbQueue.read { db in
|
||||
/// // SELECT max(score) FROM player
|
||||
/// let request = Player.all().select(sql: "max(score)", as: Int.self)
|
||||
/// let request = Player.all().select(rawSQL: "max(score)", as: Int.self)
|
||||
/// let maxScore: Int? = try request.fetchOne(db)
|
||||
/// }
|
||||
public func select<RowDecoder>(sql: String, arguments: StatementArguments = StatementArguments(), as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
|
||||
public func select<RowDecoder>(rawSQL sql: String, arguments: StatementArguments = StatementArguments(), as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
|
||||
return select(literal: SQLLiteral(rawSQL: sql, arguments: arguments), as: type)
|
||||
}
|
||||
|
||||
@@ -370,8 +370,8 @@ extension TableRecord {
|
||||
/// Creates a request which selects *sql*.
|
||||
///
|
||||
/// // SELECT id, email FROM player
|
||||
/// let request = Player.select(sql: "id, email")
|
||||
public static func select(sql: String, arguments: StatementArguments = StatementArguments()) -> QueryInterfaceRequest<Self> {
|
||||
/// let request = Player.select(rawSQL: "id, email")
|
||||
public static func select(rawSQL sql: String, arguments: StatementArguments = StatementArguments()) -> QueryInterfaceRequest<Self> {
|
||||
return select(literal: SQLLiteral(rawSQL: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
@@ -412,10 +412,10 @@ extension TableRecord {
|
||||
///
|
||||
/// try dbQueue.read { db in
|
||||
/// // SELECT max(score) FROM player
|
||||
/// let request = Player.select(sql: "max(score)", as: Int.self)
|
||||
/// let request = Player.select(rawSQL: "max(score)", as: Int.self)
|
||||
/// let maxScore: Int? = try request.fetchOne(db)
|
||||
/// }
|
||||
public static func select<RowDecoder>(sql: String, arguments: StatementArguments = StatementArguments(), as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
|
||||
public static func select<RowDecoder>(rawSQL sql: String, arguments: StatementArguments = StatementArguments(), as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
|
||||
return all().select(literal: SQLLiteral(rawSQL: sql, arguments: arguments), as: type)
|
||||
}
|
||||
|
||||
@@ -500,12 +500,12 @@ extension TableRecord {
|
||||
/// Creates a request with the provided *predicate*.
|
||||
///
|
||||
/// // SELECT * FROM player WHERE email = 'arthur@example.com'
|
||||
/// let request = Player.filter(sql: "email = ?", arguments: ["arthur@example.com"])
|
||||
/// let request = Player.filter(rawSQL: "email = ?", arguments: ["arthur@example.com"])
|
||||
///
|
||||
/// The selection defaults to all columns. This default can be changed for
|
||||
/// all requests by the `TableRecord.databaseSelection` property, or
|
||||
/// for individual requests with the `TableRecord.select` method.
|
||||
public static func filter(sql: String, arguments: StatementArguments = StatementArguments()) -> QueryInterfaceRequest<Self> {
|
||||
public static func filter(rawSQL sql: String, arguments: StatementArguments = StatementArguments()) -> QueryInterfaceRequest<Self> {
|
||||
return filter(literal: SQLLiteral(rawSQL: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
@@ -571,15 +571,33 @@ extension TableRecord {
|
||||
/// Creates a request sorted according to *sql*.
|
||||
///
|
||||
/// // SELECT * FROM player ORDER BY name
|
||||
/// let request = Player.order(sql: "name")
|
||||
/// let request = Player.order(rawSQL: "name")
|
||||
///
|
||||
/// The selection defaults to all columns. This default can be changed for
|
||||
/// all requests by the `TableRecord.databaseSelection` property, or
|
||||
/// for individual requests with the `TableRecord.select` method.
|
||||
public static func order(sql: String, arguments: StatementArguments = StatementArguments()) -> QueryInterfaceRequest<Self> {
|
||||
return all().order(sql: sql, arguments: arguments)
|
||||
public static func order(rawSQL sql: String, arguments: StatementArguments = StatementArguments()) -> QueryInterfaceRequest<Self> {
|
||||
return all().order(literal: SQLLiteral(rawSQL: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
/// Creates a request sorted according to *sql*.
|
||||
///
|
||||
/// // SELECT * FROM player ORDER BY name
|
||||
/// let request = Player.order(literal: SQLLiteral(rawSQL: "name"))
|
||||
///
|
||||
/// With Swift 5, you can safely embed raw values in your SQL queries,
|
||||
/// without any risk of syntax errors or SQL injection:
|
||||
///
|
||||
/// // SELECT * FROM player ORDER BY name
|
||||
/// let request = Player.order(literal: "name"))
|
||||
///
|
||||
/// The selection defaults to all columns. This default can be changed for
|
||||
/// all requests by the `TableRecord.databaseSelection` property, or
|
||||
/// for individual requests with the `TableRecord.select` method.
|
||||
public static func order(literal sqlLiteral: SQLLiteral) -> QueryInterfaceRequest<Self> {
|
||||
return all().order(literal: sqlLiteral)
|
||||
}
|
||||
|
||||
/// Creates a request which fetches *limit* rows, starting at
|
||||
/// *offset*.
|
||||
///
|
||||
|
||||
@@ -43,15 +43,15 @@ extension SelectionRequest {
|
||||
///
|
||||
/// // SELECT id, email FROM player
|
||||
/// var request = Player.all()
|
||||
/// request = request.select(sql: "id, email")
|
||||
/// request = request.select(rawSQL: "id, email")
|
||||
///
|
||||
/// Any previous selection is replaced:
|
||||
///
|
||||
/// // SELECT email FROM player
|
||||
/// request
|
||||
/// .select(sql: "id")
|
||||
/// .select(sql: "email")
|
||||
public func select(sql: String, arguments: StatementArguments = StatementArguments()) -> Self {
|
||||
/// .select(rawSQL: "id")
|
||||
/// .select(rawSQL: "email")
|
||||
public func select(rawSQL sql: String, arguments: StatementArguments = StatementArguments()) -> Self {
|
||||
return select(literal: SQLLiteral(rawSQL: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
@@ -120,8 +120,8 @@ extension FilteredRequest {
|
||||
///
|
||||
/// // SELECT * FROM player WHERE email = 'arthur@example.com'
|
||||
/// var request = Player.all()
|
||||
/// request = request.filter(sql: "email = ?", arguments: ["arthur@example.com"])
|
||||
public func filter(sql: String, arguments: StatementArguments = StatementArguments()) -> Self {
|
||||
/// request = request.filter(rawSQL: "email = ?", arguments: ["arthur@example.com"])
|
||||
public func filter(rawSQL sql: String, arguments: StatementArguments = StatementArguments()) -> Self {
|
||||
return filter(literal: SQLLiteral(rawSQL: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ extension AggregatingRequest {
|
||||
}
|
||||
|
||||
/// Creates a request with a new grouping.
|
||||
public func group(sql: String, arguments: StatementArguments = StatementArguments()) -> Self {
|
||||
public func group(rawSQL sql: String, arguments: StatementArguments = StatementArguments()) -> Self {
|
||||
return group(literal: SQLLiteral(rawSQL: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ extension AggregatingRequest {
|
||||
|
||||
/// Creates a request with the provided *sql* added to the
|
||||
/// eventual set of already applied predicates.
|
||||
public func having(sql: String, arguments: StatementArguments = StatementArguments()) -> Self {
|
||||
public func having(rawSQL sql: String, arguments: StatementArguments = StatementArguments()) -> Self {
|
||||
return having(literal: SQLLiteral(rawSQL: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
@@ -429,15 +429,15 @@ extension OrderedRequest {
|
||||
///
|
||||
/// // SELECT * FROM player ORDER BY name
|
||||
/// var request = Player.all()
|
||||
/// request = request.order(sql: "name")
|
||||
/// request = request.order(rawSQL: "name")
|
||||
///
|
||||
/// Any previous ordering is replaced:
|
||||
///
|
||||
/// // SELECT * FROM player ORDER BY name
|
||||
/// request
|
||||
/// .order(sql: "email")
|
||||
/// .order(sql: "name")
|
||||
public func order(sql: String, arguments: StatementArguments = StatementArguments()) -> Self {
|
||||
/// .order(rawSQL: "email")
|
||||
/// .order(rawSQL: "name")
|
||||
public func order(rawSQL sql: String, arguments: StatementArguments = StatementArguments()) -> Self {
|
||||
return order(literal: SQLLiteral(rawSQL: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
|
||||
@@ -409,13 +409,13 @@ public final class TableDefinition {
|
||||
/// try db.create(table: "player") { t in
|
||||
/// t.column("personalPhone", .text)
|
||||
/// t.column("workPhone", .text)
|
||||
/// t.check(sql: "personalPhone IS NOT NULL OR workPhone IS NOT NULL")
|
||||
/// t.check(rawSQL: "personalPhone IS NOT NULL OR workPhone IS NOT NULL")
|
||||
/// }
|
||||
///
|
||||
/// See https://www.sqlite.org/lang_createtable.html#ckconst
|
||||
///
|
||||
/// - parameter sql: An SQL snippet
|
||||
public func check(sql: String) {
|
||||
public func check(rawSQL sql: String) {
|
||||
// We do not want to wrap the SQL snippet inside parentheses around the
|
||||
// checked SQL. This is why we use the "unsafeLiteral" initializer.
|
||||
checkConstraints.append(SQLExpressionLiteral(unsafeLiteral: SQLLiteral(rawSQL: sql)))
|
||||
@@ -712,7 +712,7 @@ public final class ColumnDefinition {
|
||||
/// Adds a CHECK constraint on the column.
|
||||
///
|
||||
/// try db.create(table: "player") { t in
|
||||
/// t.column("name", .text).check(sql: "LENGTH(name) > 0")
|
||||
/// t.column("name", .text).check(rawSQL: "LENGTH(name) > 0")
|
||||
/// }
|
||||
///
|
||||
/// See https://www.sqlite.org/lang_createtable.html#ckconst
|
||||
@@ -720,7 +720,7 @@ public final class ColumnDefinition {
|
||||
/// - parameter sql: An SQL snippet.
|
||||
/// - returns: Self so that you can further refine the column definition.
|
||||
@discardableResult
|
||||
public func check(sql: String) -> Self {
|
||||
public func check(rawSQL sql: String) -> Self {
|
||||
// We do not want to wrap the SQL snippet inside parentheses around the
|
||||
// checked SQL. This is why we use the "unsafeLiteral" initializer.
|
||||
checkConstraints.append(SQLExpressionLiteral(unsafeLiteral: SQLLiteral(rawSQL: sql)))
|
||||
@@ -746,7 +746,7 @@ public final class ColumnDefinition {
|
||||
/// Defines the default column value.
|
||||
///
|
||||
/// try db.create(table: "player") { t in
|
||||
/// t.column("creationDate", .DateTime).defaults(sql: "CURRENT_TIMESTAMP")
|
||||
/// t.column("creationDate", .DateTime).defaults(rawSQL: "CURRENT_TIMESTAMP")
|
||||
/// }
|
||||
///
|
||||
/// See https://www.sqlite.org/lang_createtable.html#dfltval
|
||||
@@ -754,7 +754,7 @@ public final class ColumnDefinition {
|
||||
/// - parameter sql: An SQL snippet.
|
||||
/// - returns: Self so that you can further refine the column definition.
|
||||
@discardableResult
|
||||
public func defaults(sql: String) -> Self {
|
||||
public func defaults(rawSQL sql: String) -> Self {
|
||||
// We do not want to wrap the SQL snippet inside parentheses around the
|
||||
// checked SQL. This is why we use the "unsafeLiteral" initializer.
|
||||
defaultExpression = SQLExpressionLiteral(unsafeLiteral: SQLLiteral(rawSQL: sql))
|
||||
|
||||
@@ -18,7 +18,7 @@ public final class FetchedRecordsController<Record: FetchableRecord> {
|
||||
///
|
||||
/// let controller = FetchedRecordsController<Wine>(
|
||||
/// dbQueue,
|
||||
/// sql: "SELECT * FROM wine WHERE color = ? ORDER BY name",
|
||||
/// rawSQL: "SELECT * FROM wine WHERE color = ? ORDER BY name",
|
||||
/// arguments: [Color.red],
|
||||
/// isSameRecord: { (wine1, wine2) in wine1.id == wine2.id })
|
||||
///
|
||||
@@ -39,7 +39,7 @@ public final class FetchedRecordsController<Record: FetchableRecord> {
|
||||
/// same identity. For example, they have the same id.
|
||||
public convenience init(
|
||||
_ databaseWriter: DatabaseWriter,
|
||||
sql: String,
|
||||
rawSQL sql: String,
|
||||
arguments: StatementArguments = StatementArguments(),
|
||||
adapter: RowAdapter? = nil,
|
||||
queue: DispatchQueue = .main,
|
||||
@@ -197,7 +197,7 @@ public final class FetchedRecordsController<Record: FetchableRecord> {
|
||||
///
|
||||
/// This method must be used from the controller's dispatch queue (the
|
||||
/// main queue unless stated otherwise in the controller's initializer).
|
||||
public func setRequest(sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws {
|
||||
public func setRequest(rawSQL sql: String, arguments: StatementArguments = StatementArguments(), adapter: RowAdapter? = nil) throws {
|
||||
// TODO: rename sql parameter to rawSQL
|
||||
try setRequest(SQLRequest(rawSQL: sql, arguments: arguments, adapter: adapter))
|
||||
}
|
||||
@@ -404,7 +404,7 @@ extension FetchedRecordsController where Record: TableRecord {
|
||||
///
|
||||
/// let controller = FetchedRecordsController<Wine>(
|
||||
/// dbQueue,
|
||||
/// sql: "SELECT * FROM wine WHERE color = ? ORDER BY name",
|
||||
/// rawSQL: "SELECT * FROM wine WHERE color = ? ORDER BY name",
|
||||
/// arguments: [Color.red])
|
||||
///
|
||||
/// The records are compared by primary key (single-column primary key,
|
||||
@@ -414,7 +414,7 @@ extension FetchedRecordsController where Record: TableRecord {
|
||||
/// // Assuming the wine table has an `id` primary key:
|
||||
/// let controller = FetchedRecordsController<Wine>(
|
||||
/// dbQueue,
|
||||
/// sql: "SELECT * FROM wine WHERE color = ? ORDER BY name",
|
||||
/// rawSQL: "SELECT * FROM wine WHERE color = ? ORDER BY name",
|
||||
/// arguments: [Color.red],
|
||||
/// isSameRecord: { (wine1, wine2) in wine1.id == wine2.id })
|
||||
///
|
||||
@@ -430,7 +430,7 @@ extension FetchedRecordsController where Record: TableRecord {
|
||||
/// used from this queue.
|
||||
public convenience init(
|
||||
_ databaseWriter: DatabaseWriter,
|
||||
sql: String,
|
||||
rawSQL sql: String,
|
||||
arguments: StatementArguments = StatementArguments(),
|
||||
adapter: RowAdapter? = nil,
|
||||
queue: DispatchQueue = .main) throws
|
||||
|
||||
@@ -847,11 +847,11 @@ Arguments are optional arrays or dictionaries that fill the positional `?` and c
|
||||
|
||||
```swift
|
||||
let rows = try Row.fetchAll(db,
|
||||
"SELECT * FROM player WHERE name = ?",
|
||||
rawSQL: "SELECT * FROM player WHERE name = ?",
|
||||
arguments: ["Arthur"])
|
||||
|
||||
let rows = try Row.fetchAll(db,
|
||||
"SELECT * FROM player WHERE name = :name",
|
||||
rawSQL: "SELECT * FROM player WHERE name = :name",
|
||||
arguments: ["name": "Arthur"])
|
||||
```
|
||||
|
||||
@@ -2149,7 +2149,7 @@ To fetch records from the database, call a [fetching method](#fetching-methods):
|
||||
|
||||
```swift
|
||||
let arthur = try Player.fetchOne(db, // Player?
|
||||
"SELECT * FROM players WHERE name = ?",
|
||||
rawSQL: "SELECT * FROM players WHERE name = ?",
|
||||
arguments: ["Arthur"])
|
||||
|
||||
let bestPlayers = try Player // [Player]
|
||||
@@ -3558,7 +3558,7 @@ let count = try request.fetchCount(db) // Int
|
||||
<a name="list-of-record-methods-3">³</a> See [SQL queries](#fetch-queries):
|
||||
|
||||
```swift
|
||||
let player = try Player.fetchOne("SELECT * FROM player WHERE id = ?", arguments: [1]) // Player?
|
||||
let player = try Player.fetchOne(db, rawSQL: "SELECT * FROM player WHERE id = ?", arguments: [1]) // Player?
|
||||
```
|
||||
|
||||
<a name="list-of-record-methods-4">⁴</a> See [Prepared Statements](#prepared-statements):
|
||||
@@ -3601,12 +3601,12 @@ try dbQueue.write { db in
|
||||
|
||||
// Fetch records (with SQL)
|
||||
let wines = try Wine.fetchAll(db,
|
||||
"SELECT * FROM wine WHERE origin = ? ORDER BY price",
|
||||
rawSQL: "SELECT * FROM wine WHERE origin = ? ORDER BY price",
|
||||
arguments: ["Burgundy"])
|
||||
|
||||
// Count (with an SQL snippet)
|
||||
let count = try Wine
|
||||
.filter(sql: "color = ?", arguments: [Color.red])
|
||||
.filter(rawSQL: "color = ?", arguments: [Color.red])
|
||||
.fetchCount(db)
|
||||
|
||||
// Delete (with SQL)
|
||||
@@ -3740,7 +3740,7 @@ For extra index options, see [Create Indexes](#create-indexes) below.
|
||||
// name TEXT CHECK (LENGTH(name) > 0)
|
||||
// score INTEGER CHECK (score > 0)
|
||||
t.column("name", .text).check { length($0) > 0 }
|
||||
t.column("score", .integer).check(sql: "score > 0")
|
||||
t.column("score", .integer).check(rawSQL: "score > 0")
|
||||
```
|
||||
|
||||
Other **table constraints** can involve several columns:
|
||||
@@ -3759,7 +3759,7 @@ Other **table constraints** can involve several columns:
|
||||
t.check(Column("a") + Column("b") < 10)
|
||||
|
||||
// CHECK (a + b < 10)
|
||||
t.check(sql: "a + b < 10")
|
||||
t.check(rawSQL: "a + b < 10")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4028,9 +4028,9 @@ Raw SQL snippets are also accepted, with eventual [arguments](http://groue.githu
|
||||
```swift
|
||||
// SELECT DATE(creationDate), COUNT(*) FROM player WHERE name = 'Arthur' GROUP BY date(creationDate)
|
||||
Player
|
||||
.select(sql: "DATE(creationDate), COUNT(*)")
|
||||
.filter(sql: "name = ?", arguments: ["Arthur"])
|
||||
.group(sql: "DATE(creationDate)")
|
||||
.select(rawSQL: "DATE(creationDate), COUNT(*)")
|
||||
.filter(rawSQL: "name = ?", arguments: ["Arthur"])
|
||||
.group(rawSQL: "DATE(creationDate)")
|
||||
```
|
||||
|
||||
|
||||
@@ -4597,7 +4597,7 @@ let request = Player.all()
|
||||
extension Player {
|
||||
static func filter(color: Color) -> SQLRequest<Player> {
|
||||
return SQLRequest<Player>(
|
||||
"SELECT * FROM player WHERE color = ?"
|
||||
rawSQL: "SELECT * FROM player WHERE color = ?"
|
||||
arguments: [color])
|
||||
}
|
||||
}
|
||||
@@ -4646,7 +4646,7 @@ For example:
|
||||
|
||||
```swift
|
||||
let playerRequest = SQLRequest<Player>(
|
||||
"SELECT * FROM player WHERE color = ?"
|
||||
rawSQL: "SELECT * FROM player WHERE color = ?"
|
||||
arguments: [color])
|
||||
try request.fetchAll(db) // [Player]
|
||||
```
|
||||
@@ -4796,7 +4796,7 @@ let pattern = FTS3Pattern(matchingPhrase: "Moby-Dick")
|
||||
// Search with the query interface or SQL
|
||||
let books = try Book.matching(pattern).fetchAll(db)
|
||||
let books = try Book.fetchAll(db,
|
||||
"SELECT * FROM book WHERE book MATCH ?",
|
||||
rawSQL: "SELECT * FROM book WHERE book MATCH ?",
|
||||
arguments: [pattern])
|
||||
```
|
||||
|
||||
@@ -5058,7 +5058,7 @@ FTS3Pattern are regular [values](#values). You can use them as query [arguments]
|
||||
|
||||
```swift
|
||||
let documents = try Document.fetchAll(db,
|
||||
"SELECT * FROM document WHERE content MATCH ?",
|
||||
rawSQL: "SELECT * FROM document WHERE content MATCH ?",
|
||||
arguments: [pattern])
|
||||
```
|
||||
|
||||
@@ -5294,7 +5294,7 @@ FTS5Pattern are regular [values](#values). You can use them as query [arguments]
|
||||
|
||||
```swift
|
||||
let documents = try Document.fetchAll(db,
|
||||
"SELECT * FROM document WHERE document MATCH ?",
|
||||
rawSQL: "SELECT * FROM document WHERE document MATCH ?",
|
||||
arguments: [pattern])
|
||||
```
|
||||
|
||||
@@ -5312,7 +5312,7 @@ let documents = try Document.matching(pattern).fetchAll(db)
|
||||
```swift
|
||||
// SQL
|
||||
let documents = try Document.fetchAll(db,
|
||||
"SELECT * FROM document WHERE document MATCH ? ORDER BY rank",
|
||||
rawSQL: "SELECT * FROM document WHERE document MATCH ? ORDER BY rank",
|
||||
arguments: [pattern])
|
||||
|
||||
// Query Interface
|
||||
@@ -5742,7 +5742,7 @@ extension PlayerInfo {
|
||||
LEFT JOIN round ON ...
|
||||
GROUP BY ...
|
||||
"""
|
||||
return SQLRequest<PlayerInfo>(sql).adapted { db in
|
||||
return SQLRequest<PlayerInfo>(rawSQL: sql).adapted { db in
|
||||
let adapters = try splittingRowAdapters(columnCounts: [
|
||||
Player.numberOfSelectedColumns(db),
|
||||
Team.numberOfSelectedColumns(db)])
|
||||
@@ -5813,7 +5813,7 @@ extension PlayerInfo {
|
||||
LEFT JOIN round ON ...
|
||||
GROUP BY ...
|
||||
"""
|
||||
return SQLRequest<PlayerInfo>(sql).adapted { db in
|
||||
return SQLRequest<PlayerInfo>(rawSQL: sql).adapted { db in
|
||||
let adapters = try splittingRowAdapters(columnCounts: [
|
||||
Player.numberOfSelectedColumns(db),
|
||||
Team.numberOfSelectedColumns(db)])
|
||||
@@ -6074,7 +6074,7 @@ Those observations match the `fetchCount`, `fetchOne`, and `fetchAll` request me
|
||||
}
|
||||
|
||||
// Observe all player names
|
||||
let request = SQLRequest<String>("SELECT name FROM player")
|
||||
let request = SQLRequest<String>(rawSQL: "SELECT name FROM player")
|
||||
let observer = ValueObservation
|
||||
.trackingAll(request)
|
||||
.start(in: dbQueue) { names: [String] in
|
||||
@@ -6629,7 +6629,7 @@ let controller = FetchedRecordsController(
|
||||
// Using SQL, and eventual arguments:
|
||||
let controller = FetchedRecordsController<Player>(
|
||||
dbQueue,
|
||||
sql: "SELECT * FROM player ORDER BY name WHERE countryCode = ?",
|
||||
rawSQL: "SELECT * FROM player ORDER BY name WHERE countryCode = ?",
|
||||
arguments: ["FR"])
|
||||
```
|
||||
|
||||
@@ -6638,7 +6638,7 @@ The fetch request can involve several database tables. The fetched records contr
|
||||
```swift
|
||||
let controller = FetchedRecordsController<Author>(
|
||||
dbQueue,
|
||||
sql: """
|
||||
rawSQL: """
|
||||
SELECT author.name, COUNT(book.id) AS bookCount
|
||||
FROM author
|
||||
LEFT JOIN book ON book.authorId = author.id
|
||||
@@ -6766,7 +6766,7 @@ You can change a fetched records controller's fetch request or SQL query.
|
||||
|
||||
```swift
|
||||
controller.setRequest(Player.order(Column("name")))
|
||||
controller.setRequest(sql: "SELECT ...", arguments: ...)
|
||||
controller.setRequest(rawSQL: "SELECT ...", arguments: ...)
|
||||
```
|
||||
|
||||
The [notification callbacks](#the-changes-notifications) are notified of eventual changes if the new request fetches a different set of records.
|
||||
@@ -7664,7 +7664,7 @@ If you can't or don't want to define the comparison behavior of a column (see wa
|
||||
```swift
|
||||
let collation = DatabaseCollation.localizedCaseInsensitiveCompare
|
||||
let players = try Player.fetchAll(db,
|
||||
"SELECT * FROM player ORDER BY name COLLATE \(collation.name))")
|
||||
rawSQL: "SELECT * FROM player ORDER BY name COLLATE \(collation.name))")
|
||||
let players = try Player.order(nameColumn.collating(collation)).fetchAll(db)
|
||||
```
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ class AssociationAggregateTests: GRDBTestCase {
|
||||
let tableAlias = TableAlias(name: "custom")
|
||||
let request = Team
|
||||
.annotated(with: Team.players.count)
|
||||
.joining(required: Team.players.aliased(tableAlias).filter(sql: "custom.score < ?", arguments: [500]))
|
||||
.joining(required: Team.players.aliased(tableAlias).filter(rawSQL: "custom.score < ?", arguments: [500]))
|
||||
|
||||
try assertEqualSQL(db, request, """
|
||||
SELECT "team".*, COUNT(DISTINCT "custom"."rowid") AS "playerCount" \
|
||||
|
||||
@@ -154,7 +154,7 @@ class AssociationBelongsToSQLDerivationTests: GRDBTestCase {
|
||||
let bAlias = TableAlias(name: "customB")
|
||||
let request = A.including(required: A.b
|
||||
.aliased(bAlias)
|
||||
.filter(sql: "customB.name = ?", arguments: ["foo"]))
|
||||
.filter(rawSQL: "customB.name = ?", arguments: ["foo"]))
|
||||
try assertEqualSQL(db, request, """
|
||||
SELECT "a".*, "customB".* \
|
||||
FROM "a" \
|
||||
|
||||
@@ -77,7 +77,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
func testChainOfTwoIncludingIncluding() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
do {
|
||||
let request = A.including(required: A.defaultB.including(required: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
let request = A.including(required: A.defaultB.including(required: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
@@ -95,7 +95,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
XCTAssertEqual(rows[1].scopes["b"]!.scopes["c"]!, ["id":2, "bid":1, "did":nil, "name":"c2"])
|
||||
}
|
||||
do {
|
||||
let request = A.including(required: A.defaultB.including(optional: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
let request = A.including(required: A.defaultB.including(optional: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 3)
|
||||
@@ -120,11 +120,11 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
}
|
||||
do {
|
||||
// TODO: chainOptionalRequired
|
||||
// let request = A.including(optional: A.defaultB.including(required: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
// let request = A.including(optional: A.defaultB.including(required: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
// let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
}
|
||||
do {
|
||||
let request = A.including(optional: A.defaultB.including(optional: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
let request = A.including(optional: A.defaultB.including(optional: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 4)
|
||||
@@ -154,7 +154,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
XCTAssertEqual(rows[3].scopes["b"]!.scopes["c"]!, ["id":nil, "bid":nil, "did":nil, "name":nil])
|
||||
}
|
||||
do {
|
||||
let request = B.including(required: B.defaultC.including(required: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
let request = B.including(required: B.defaultC.including(required: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
@@ -166,7 +166,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
XCTAssertEqual(rows[0].scopes["c"]!.scopes["d"]!, ["id":1, "name":"d1"])
|
||||
}
|
||||
do {
|
||||
let request = B.including(required: B.defaultC.including(optional: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
let request = B.including(required: B.defaultC.including(optional: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
@@ -185,11 +185,11 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
}
|
||||
do {
|
||||
// TODO: chainOptionalRequired
|
||||
// let request = B.including(optional: B.defaultC.including(required: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
// let request = B.including(optional: B.defaultC.including(required: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
// let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
}
|
||||
do {
|
||||
let request = B.including(optional: B.defaultC.including(optional: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
let request = B.including(optional: B.defaultC.including(optional: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 3)
|
||||
@@ -217,7 +217,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
func testChainOfTwoIncludingJoining() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
do {
|
||||
let request = A.including(required: A.defaultB.joining(required: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
let request = A.including(required: A.defaultB.joining(required: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
@@ -233,7 +233,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
XCTAssertTrue(rows[1].scopes["b"]!.scopes.names.isEmpty)
|
||||
}
|
||||
do {
|
||||
let request = A.including(required: A.defaultB.joining(optional: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
let request = A.including(required: A.defaultB.joining(optional: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 3)
|
||||
@@ -255,11 +255,11 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
}
|
||||
do {
|
||||
// TODO: chainOptionalRequired
|
||||
// let request = A.including(optional: A.defaultB.joining(required: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
// let request = A.including(optional: A.defaultB.joining(required: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
// let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
}
|
||||
do {
|
||||
let request = A.including(optional: A.defaultB.joining(optional: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
let request = A.including(optional: A.defaultB.joining(optional: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 4)
|
||||
@@ -285,7 +285,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
XCTAssertTrue(rows[3].scopes["b"]!.scopes.names.isEmpty)
|
||||
}
|
||||
do {
|
||||
let request = B.including(required: B.defaultC.joining(required: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
let request = B.including(required: B.defaultC.joining(required: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
@@ -296,7 +296,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
XCTAssertTrue(rows[0].scopes["c"]!.scopes.names.isEmpty)
|
||||
}
|
||||
do {
|
||||
let request = B.including(required: B.defaultC.joining(optional: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
let request = B.including(required: B.defaultC.joining(optional: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
@@ -313,11 +313,11 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
}
|
||||
do {
|
||||
// TODO: chainOptionalRequired
|
||||
// let request = B.including(optional: B.defaultC.joining(required: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
// let request = B.including(optional: B.defaultC.joining(required: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
// let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
}
|
||||
do {
|
||||
let request = B.including(optional: B.defaultC.joining(optional: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
let request = B.including(optional: B.defaultC.joining(optional: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 3)
|
||||
@@ -342,7 +342,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
func testChainOfTwoJoiningIncluding() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
do {
|
||||
let request = A.joining(required: A.defaultB.including(required: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
let request = A.joining(required: A.defaultB.including(required: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
@@ -360,7 +360,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
XCTAssertEqual(rows[1].scopes["b"]!.scopes["c"]!, ["id":2, "bid":1, "did":nil, "name":"c2"])
|
||||
}
|
||||
do {
|
||||
let request = A.joining(required: A.defaultB.including(optional: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
let request = A.joining(required: A.defaultB.including(optional: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 3)
|
||||
@@ -385,11 +385,11 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
}
|
||||
do {
|
||||
// TODO: chainOptionalRequired
|
||||
// let request = A.joining(optional: A.defaultB.including(required: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
// let request = A.joining(optional: A.defaultB.including(required: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
// let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
}
|
||||
do {
|
||||
let request = A.joining(optional: A.defaultB.including(optional: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
let request = A.joining(optional: A.defaultB.including(optional: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 4)
|
||||
@@ -419,7 +419,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
XCTAssertEqual(rows[3].scopes["b"]!.scopes["c"]!, ["id":nil, "bid":nil, "did":nil, "name":nil])
|
||||
}
|
||||
do {
|
||||
let request = B.joining(required: B.defaultC.including(required: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
let request = B.joining(required: B.defaultC.including(required: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
@@ -431,7 +431,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
XCTAssertEqual(rows[0].scopes["c"]!.scopes["d"]!, ["id":1, "name":"d1"])
|
||||
}
|
||||
do {
|
||||
let request = B.joining(required: B.defaultC.including(optional: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
let request = B.joining(required: B.defaultC.including(optional: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
@@ -450,11 +450,11 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
}
|
||||
do {
|
||||
// TODO: chainOptionalRequired
|
||||
// let request = B.joining(optional: B.defaultC.including(required: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
// let request = B.joining(optional: B.defaultC.including(required: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
// let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
}
|
||||
do {
|
||||
let request = B.joining(optional: B.defaultC.including(optional: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
let request = B.joining(optional: B.defaultC.including(optional: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 3)
|
||||
@@ -482,7 +482,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
func testChainOfTwoJoiningJoining() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
do {
|
||||
let request = A.joining(required: A.defaultB.joining(required: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
let request = A.joining(required: A.defaultB.joining(required: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
@@ -494,7 +494,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
XCTAssertTrue(rows[1].scopes.names.isEmpty)
|
||||
}
|
||||
do {
|
||||
let request = A.joining(required: A.defaultB.joining(optional: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
let request = A.joining(required: A.defaultB.joining(optional: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 3)
|
||||
@@ -510,11 +510,11 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
}
|
||||
do {
|
||||
// TODO: chainOptionalRequired
|
||||
// let request = A.joining(optional: A.defaultB.joining(required: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
// let request = A.joining(optional: A.defaultB.joining(required: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
// let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
}
|
||||
do {
|
||||
let request = A.joining(optional: A.defaultB.joining(optional: B.defaultC)).order(sql: "a.id, b.id, c.id")
|
||||
let request = A.joining(optional: A.defaultB.joining(optional: B.defaultC)).order(rawSQL: "a.id, b.id, c.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 4)
|
||||
@@ -532,7 +532,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
XCTAssertTrue(rows[3].scopes.names.isEmpty)
|
||||
}
|
||||
do {
|
||||
let request = B.joining(required: B.defaultC.joining(required: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
let request = B.joining(required: B.defaultC.joining(required: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
@@ -541,7 +541,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
XCTAssertTrue(rows[0].scopes.names.isEmpty)
|
||||
}
|
||||
do {
|
||||
let request = B.joining(required: B.defaultC.joining(optional: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
let request = B.joining(required: B.defaultC.joining(optional: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
@@ -554,11 +554,11 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
}
|
||||
do {
|
||||
// TODO: chainOptionalRequired
|
||||
// let request = B.joining(optional: B.defaultC.joining(required: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
// let request = B.joining(optional: B.defaultC.joining(required: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
// let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
}
|
||||
do {
|
||||
let request = B.joining(optional: B.defaultC.joining(optional: C.defaultD)).order(sql: "b.id, c.id, d.id")
|
||||
let request = B.joining(optional: B.defaultC.joining(optional: C.defaultD)).order(rawSQL: "b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 3)
|
||||
@@ -576,7 +576,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
|
||||
func testChainOfThreeIncludingIncludingIncluding() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
let request = A.including(required: A.defaultB.including(required: B.defaultC.including(required: C.defaultD))).order(sql: "a.id, b.id, c.id, d.id")
|
||||
let request = A.including(required: A.defaultB.including(required: B.defaultC.including(required: C.defaultD))).order(rawSQL: "a.id, b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
@@ -592,7 +592,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
|
||||
func testChainOfThreeIncludingIncludingJoining() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
let request = A.including(required: A.defaultB.including(required: B.defaultC.joining(required: C.defaultD))).order(sql: "a.id, b.id, c.id, d.id")
|
||||
let request = A.including(required: A.defaultB.including(required: B.defaultC.joining(required: C.defaultD))).order(rawSQL: "a.id, b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
@@ -607,7 +607,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
|
||||
func testChainOfThreeIncludingJoiningIncluding() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
let request = A.including(required: A.defaultB.joining(required: B.defaultC.including(required: C.defaultD))).order(sql: "a.id, b.id, c.id, d.id")
|
||||
let request = A.including(required: A.defaultB.joining(required: B.defaultC.including(required: C.defaultD))).order(rawSQL: "a.id, b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
@@ -623,7 +623,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
|
||||
func testChainOfThreeIncludingJoiningJoining() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
let request = A.including(required: A.defaultB.joining(required: B.defaultC.joining(required: C.defaultD))).order(sql: "a.id, b.id, c.id, d.id")
|
||||
let request = A.including(required: A.defaultB.joining(required: B.defaultC.joining(required: C.defaultD))).order(rawSQL: "a.id, b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
@@ -636,7 +636,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
|
||||
func testChainOfThreeJoiningIncludingIncluding() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
let request = A.joining(required: A.defaultB.including(required: B.defaultC.including(required: C.defaultD))).order(sql: "a.id, b.id, c.id, d.id")
|
||||
let request = A.joining(required: A.defaultB.including(required: B.defaultC.including(required: C.defaultD))).order(rawSQL: "a.id, b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
@@ -652,7 +652,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
|
||||
func testChainOfThreeJoiningIncludingJoining() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
let request = A.joining(required: A.defaultB.including(required: B.defaultC.joining(required: C.defaultD))).order(sql: "a.id, b.id, c.id, d.id")
|
||||
let request = A.joining(required: A.defaultB.including(required: B.defaultC.joining(required: C.defaultD))).order(rawSQL: "a.id, b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
@@ -667,7 +667,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
|
||||
func testChainOfThreeJoiningJoiningIncluding() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
let request = A.joining(required: A.defaultB.joining(required: B.defaultC.including(required: C.defaultD))).order(sql: "a.id, b.id, c.id, d.id")
|
||||
let request = A.joining(required: A.defaultB.joining(required: B.defaultC.including(required: C.defaultD))).order(rawSQL: "a.id, b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
@@ -683,7 +683,7 @@ class AssociationChainRowScopesTests: GRDBTestCase {
|
||||
|
||||
func testChainOfThreeJoiningJoiningJoining() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
let request = A.joining(required: A.defaultB.joining(required: B.defaultC.joining(required: C.defaultD))).order(sql: "a.id, b.id, c.id, d.id")
|
||||
let request = A.joining(required: A.defaultB.joining(required: B.defaultC.joining(required: C.defaultD))).order(rawSQL: "a.id, b.id, c.id, d.id")
|
||||
let rows = try dbQueue.inDatabase { try request.asRequest(of: Row.self).fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(rows.count, 1)
|
||||
|
||||
@@ -154,7 +154,7 @@ class AssociationHasOneSQLDerivationTests: GRDBTestCase {
|
||||
let bAlias = TableAlias(name: "customB")
|
||||
let request = A.including(required: A.b
|
||||
.aliased(bAlias)
|
||||
.filter(sql: "customB.name = ?", arguments: ["foo"]))
|
||||
.filter(rawSQL: "customB.name = ?", arguments: ["foo"]))
|
||||
try assertEqualSQL(db, request, """
|
||||
SELECT "a".*, "customB".* \
|
||||
FROM "a" \
|
||||
|
||||
@@ -86,7 +86,7 @@ class AssociationParallelDecodableRecordTests: GRDBTestCase {
|
||||
let request = A
|
||||
.including(required: AWithRequiredBD.b)
|
||||
.including(required: AWithRequiredBD.d)
|
||||
.order(sql: "a.id, b.id, d.id")
|
||||
.order(rawSQL: "a.id, b.id, d.id")
|
||||
.asRequest(of: AWithRequiredBD.self)
|
||||
let records = try dbQueue.inDatabase { try request.fetchAll($0) }
|
||||
|
||||
@@ -116,7 +116,7 @@ class AssociationParallelDecodableRecordTests: GRDBTestCase {
|
||||
let request = A
|
||||
.including(optional: AWithOptionalBD.b)
|
||||
.including(optional: AWithOptionalBD.d)
|
||||
.order(sql: "a.id, b.id, d.id")
|
||||
.order(rawSQL: "a.id, b.id, d.id")
|
||||
.asRequest(of: AWithOptionalBD.self)
|
||||
let records = try dbQueue.inDatabase { try request.fetchAll($0) }
|
||||
|
||||
@@ -177,7 +177,7 @@ class AssociationParallelDecodableRecordTests: GRDBTestCase {
|
||||
let request = A
|
||||
.joining(required: A.b)
|
||||
.joining(required: A.d)
|
||||
.order(sql: "a.id, b.id, d.id")
|
||||
.order(rawSQL: "a.id, b.id, d.id")
|
||||
let records = try dbQueue.inDatabase { try request.fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(records.count, 2)
|
||||
@@ -198,7 +198,7 @@ class AssociationParallelDecodableRecordTests: GRDBTestCase {
|
||||
let request = A
|
||||
.joining(optional: A.b)
|
||||
.joining(optional: A.d)
|
||||
.order(sql: "a.id, b.id, d.id")
|
||||
.order(rawSQL: "a.id, b.id, d.id")
|
||||
let records = try dbQueue.inDatabase { try request.fetchAll($0) }
|
||||
|
||||
XCTAssertEqual(records.count, 6)
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -130,7 +130,7 @@ class FetchedRecordsControllerTests: GRDBTestCase {
|
||||
return cervantes.id!
|
||||
}
|
||||
|
||||
let controller = try FetchedRecordsController<Book>(dbQueue, sql: "SELECT * FROM books WHERE authorID = ?", arguments: [authorId])
|
||||
let controller = try FetchedRecordsController<Book>(dbQueue, rawSQL: "SELECT * FROM books WHERE authorID = ?", arguments: [authorId])
|
||||
try controller.performFetch()
|
||||
XCTAssertEqual(controller.fetchedRecords.count, 1)
|
||||
XCTAssertEqual(controller.fetchedRecords[0].title, "Don Quixote")
|
||||
@@ -149,7 +149,7 @@ class FetchedRecordsControllerTests: GRDBTestCase {
|
||||
}
|
||||
|
||||
let adapter = ColumnMapping(["id": "_id", "authorId": "_authorId", "title": "_title"])
|
||||
let controller = try FetchedRecordsController<Book>(dbQueue, sql: "SELECT id AS _id, authorId AS _authorId, title AS _title FROM books WHERE authorID = ?", arguments: [authorId], adapter: adapter)
|
||||
let controller = try FetchedRecordsController<Book>(dbQueue, rawSQL: "SELECT id AS _id, authorId AS _authorId, title AS _title FROM books WHERE authorID = ?", arguments: [authorId], adapter: adapter)
|
||||
try controller.performFetch()
|
||||
XCTAssertEqual(controller.fetchedRecords.count, 1)
|
||||
XCTAssertEqual(controller.fetchedRecords[0].title, "Don Quixote")
|
||||
@@ -457,7 +457,7 @@ class FetchedRecordsControllerTests: GRDBTestCase {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
let controller = try FetchedRecordsController<Person>(
|
||||
dbQueue,
|
||||
sql: """
|
||||
rawSQL: """
|
||||
SELECT persons.*, COUNT(books.id) AS bookCount
|
||||
FROM persons
|
||||
LEFT JOIN books ON books.authorId = persons.id
|
||||
@@ -681,7 +681,7 @@ class FetchedRecordsControllerTests: GRDBTestCase {
|
||||
|
||||
// Change request with SQL and arguments
|
||||
recorder.transactionExpectation = expectation(description: "expectation")
|
||||
try controller.setRequest(sql: "SELECT ? AS id, ? AS name", arguments: [1, "Craig"])
|
||||
try controller.setRequest(rawSQL: "SELECT ? AS id, ? AS name", arguments: [1, "Craig"])
|
||||
waitForExpectations(timeout: 1, handler: nil)
|
||||
|
||||
XCTAssertEqual(recorder.recordsBeforeChanges.count, 2)
|
||||
|
||||
@@ -230,7 +230,7 @@ class JoinSupportTests: GRDBTestCase {
|
||||
t.column("t3id", .integer).references("t3", onDelete: .cascade)
|
||||
t.column("t4id", .integer).references("t4", onDelete: .cascade)
|
||||
t.column("name", .text).notNull()
|
||||
t.check(sql: "(t3id IS NOT NULL) + (t4id IS NOT NULL) = 1")
|
||||
t.check(rawSQL: "(t3id IS NOT NULL) + (t4id IS NOT NULL) = 1")
|
||||
}
|
||||
|
||||
// Sample data
|
||||
|
||||
@@ -150,7 +150,7 @@ class MutablePersistableRecordDeleteTests: GRDBTestCase {
|
||||
try Person.filter(Column("name") == "Arthur").deleteAll(db)
|
||||
XCTAssertEqual(self.lastSQLQuery, "DELETE FROM \"persons\" WHERE (\"name\" = 'Arthur')")
|
||||
|
||||
try Person.filter(sql: "id = 1").deleteAll(db)
|
||||
try Person.filter(rawSQL: "id = 1").deleteAll(db)
|
||||
XCTAssertEqual(self.lastSQLQuery, "DELETE FROM \"persons\" WHERE (id = 1)")
|
||||
|
||||
try Person.select(Column("name")).deleteAll(db)
|
||||
|
||||
@@ -147,7 +147,7 @@ class QueryInterfaceRequestTests: GRDBTestCase {
|
||||
try db.execute(rawSQL: "INSERT INTO readers (name, age) VALUES (?, ?)", arguments: ["Arthur", 42])
|
||||
try db.execute(rawSQL: "INSERT INTO readers (name, age) VALUES (?, ?)", arguments: ["Barbara", 36])
|
||||
|
||||
let request = tableRequest.select(sql: "name, id - 1")
|
||||
let request = tableRequest.select(rawSQL: "name, id - 1")
|
||||
let rows = try Row.fetchAll(db, request)
|
||||
XCTAssertEqual(lastSQLQuery, "SELECT name, id - 1 FROM \"readers\"")
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
@@ -164,7 +164,7 @@ class QueryInterfaceRequestTests: GRDBTestCase {
|
||||
try db.execute(rawSQL: "INSERT INTO readers (name, age) VALUES (?, ?)", arguments: ["Arthur", 42])
|
||||
try db.execute(rawSQL: "INSERT INTO readers (name, age) VALUES (?, ?)", arguments: ["Barbara", 36])
|
||||
|
||||
let request = tableRequest.select(sql: "name, id - ?", arguments: [1])
|
||||
let request = tableRequest.select(rawSQL: "name, id - ?", arguments: [1])
|
||||
let rows = try Row.fetchAll(db, request)
|
||||
XCTAssertEqual(lastSQLQuery, "SELECT name, id - 1 FROM \"readers\"")
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
@@ -181,7 +181,7 @@ class QueryInterfaceRequestTests: GRDBTestCase {
|
||||
try db.execute(rawSQL: "INSERT INTO readers (name, age) VALUES (?, ?)", arguments: ["Arthur", 42])
|
||||
try db.execute(rawSQL: "INSERT INTO readers (name, age) VALUES (?, ?)", arguments: ["Barbara", 36])
|
||||
|
||||
let request = tableRequest.select(sql: "name, id - :n", arguments: ["n": 1])
|
||||
let request = tableRequest.select(rawSQL: "name, id - :n", arguments: ["n": 1])
|
||||
let rows = try Row.fetchAll(db, request)
|
||||
XCTAssertEqual(lastSQLQuery, "SELECT name, id - 1 FROM \"readers\"")
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
@@ -293,7 +293,7 @@ class QueryInterfaceRequestTests: GRDBTestCase {
|
||||
// raw sql without argument
|
||||
do {
|
||||
let value = try Reader
|
||||
.select(sql: "name", as: String.self)
|
||||
.select(rawSQL: "name", as: String.self)
|
||||
.fetchOne(db)!
|
||||
XCTAssertEqual(value, "Arthur")
|
||||
}
|
||||
@@ -338,7 +338,7 @@ class QueryInterfaceRequestTests: GRDBTestCase {
|
||||
do {
|
||||
let value = try Reader
|
||||
.all()
|
||||
.select(sql: "name", as: String.self)
|
||||
.select(rawSQL: "name", as: String.self)
|
||||
.fetchOne(db)!
|
||||
XCTAssertEqual(value, "Arthur")
|
||||
}
|
||||
@@ -382,7 +382,7 @@ class QueryInterfaceRequestTests: GRDBTestCase {
|
||||
// raw sql with named argument
|
||||
do {
|
||||
let value = try Reader
|
||||
.select(sql: "name, :age AS age", arguments: ["age": 22], as: Row.self)
|
||||
.select(rawSQL: "name, :age AS age", arguments: ["age": 22], as: Row.self)
|
||||
.fetchOne(db)!
|
||||
XCTAssertEqual(value, ["name": "Arthur", "age": 22])
|
||||
}
|
||||
@@ -427,7 +427,7 @@ class QueryInterfaceRequestTests: GRDBTestCase {
|
||||
do {
|
||||
let value = try Reader
|
||||
.all()
|
||||
.select(sql: "name, ? AS age", arguments: [22], as: Row.self)
|
||||
.select(rawSQL: "name, ? AS age", arguments: [22], as: Row.self)
|
||||
.fetchOne(db)!
|
||||
XCTAssertEqual(value, ["name": "Arthur", "age": 22])
|
||||
}
|
||||
@@ -452,21 +452,21 @@ class QueryInterfaceRequestTests: GRDBTestCase {
|
||||
func testFilterLiteral() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(sql: "id <> 1")),
|
||||
sql(dbQueue, tableRequest.filter(rawSQL: "id <> 1")),
|
||||
"SELECT * FROM \"readers\" WHERE (id <> 1)")
|
||||
}
|
||||
|
||||
func testFilterLiteralWithPositionalArguments() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(sql: "id <> ?", arguments: [1])),
|
||||
sql(dbQueue, tableRequest.filter(rawSQL: "id <> ?", arguments: [1])),
|
||||
"SELECT * FROM \"readers\" WHERE (id <> 1)")
|
||||
}
|
||||
|
||||
func testFilterLiteralWithNamedArguments() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.filter(sql: "id <> :id", arguments: ["id": 1])),
|
||||
sql(dbQueue, tableRequest.filter(rawSQL: "id <> :id", arguments: ["id": 1])),
|
||||
"SELECT * FROM \"readers\" WHERE (id <> 1)")
|
||||
}
|
||||
|
||||
@@ -474,13 +474,13 @@ class QueryInterfaceRequestTests: GRDBTestCase {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest
|
||||
.filter(sql: "age > :age", arguments: ["age": 20])
|
||||
.filter(sql: "name = ?", arguments: ["arthur"])),
|
||||
.filter(rawSQL: "age > :age", arguments: ["age": 20])
|
||||
.filter(rawSQL: "name = ?", arguments: ["arthur"])),
|
||||
"SELECT * FROM \"readers\" WHERE ((age > 20) AND (name = 'arthur'))")
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest
|
||||
.filter(sql: "age > ?", arguments: [20])
|
||||
.filter(sql: "name = :name", arguments: ["name": "arthur"])),
|
||||
.filter(rawSQL: "age > ?", arguments: [20])
|
||||
.filter(rawSQL: "name = :name", arguments: ["name": "arthur"])),
|
||||
"SELECT * FROM \"readers\" WHERE ((age > 20) AND (name = 'arthur'))")
|
||||
}
|
||||
|
||||
@@ -504,21 +504,21 @@ class QueryInterfaceRequestTests: GRDBTestCase {
|
||||
func testGroupLiteral() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.group(sql: "age, lower(name)")),
|
||||
sql(dbQueue, tableRequest.group(rawSQL: "age, lower(name)")),
|
||||
"SELECT * FROM \"readers\" GROUP BY age, lower(name)")
|
||||
}
|
||||
|
||||
func testGroupLiteralWithPositionalArguments() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.group(sql: "age + ?, lower(name)", arguments: [1])),
|
||||
sql(dbQueue, tableRequest.group(rawSQL: "age + ?, lower(name)", arguments: [1])),
|
||||
"SELECT * FROM \"readers\" GROUP BY age + 1, lower(name)")
|
||||
}
|
||||
|
||||
func testGroupLiteralWithNamedArguments() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.group(sql: "age + :n, lower(name)", arguments: ["n": 1])),
|
||||
sql(dbQueue, tableRequest.group(rawSQL: "age + :n, lower(name)", arguments: ["n": 1])),
|
||||
"SELECT * FROM \"readers\" GROUP BY age + 1, lower(name)")
|
||||
}
|
||||
|
||||
@@ -545,21 +545,21 @@ class QueryInterfaceRequestTests: GRDBTestCase {
|
||||
func testHavingLiteral() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.group(Col.name).having(sql: "min(age) > 18")),
|
||||
sql(dbQueue, tableRequest.group(Col.name).having(rawSQL: "min(age) > 18")),
|
||||
"SELECT * FROM \"readers\" GROUP BY \"name\" HAVING (min(age) > 18)")
|
||||
}
|
||||
|
||||
func testHavingLiteralWithPositionalArguments() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.group(Col.name).having(sql: "min(age) > ?", arguments: [18])),
|
||||
sql(dbQueue, tableRequest.group(Col.name).having(rawSQL: "min(age) > ?", arguments: [18])),
|
||||
"SELECT * FROM \"readers\" GROUP BY \"name\" HAVING (min(age) > 18)")
|
||||
}
|
||||
|
||||
func testHavingLiteralWithNamedArguments() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.group(Col.name).having(sql: "min(age) > :age", arguments: ["age": 18])),
|
||||
sql(dbQueue, tableRequest.group(Col.name).having(rawSQL: "min(age) > :age", arguments: ["age": 18])),
|
||||
"SELECT * FROM \"readers\" GROUP BY \"name\" HAVING (min(age) > 18)")
|
||||
}
|
||||
|
||||
@@ -583,21 +583,21 @@ class QueryInterfaceRequestTests: GRDBTestCase {
|
||||
func testSortLiteral() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.order(sql: "lower(name) desc")),
|
||||
sql(dbQueue, tableRequest.order(rawSQL: "lower(name) desc")),
|
||||
"SELECT * FROM \"readers\" ORDER BY lower(name) desc")
|
||||
}
|
||||
|
||||
func testSortLiteralWithPositionalArguments() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.order(sql: "age + ?", arguments: [1])),
|
||||
sql(dbQueue, tableRequest.order(rawSQL: "age + ?", arguments: [1])),
|
||||
"SELECT * FROM \"readers\" ORDER BY age + 1")
|
||||
}
|
||||
|
||||
func testSortLiteralWithNamedArguments() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, tableRequest.order(sql: "age + :age", arguments: ["age": 1])),
|
||||
sql(dbQueue, tableRequest.order(rawSQL: "age + :age", arguments: ["age": 1])),
|
||||
"SELECT * FROM \"readers\" ORDER BY age + 1")
|
||||
}
|
||||
|
||||
|
||||
@@ -681,9 +681,9 @@ class RecordPrimaryKeyHiddenRowIDTests : GRDBTestCase {
|
||||
XCTAssertTrue(try Person.fetchAll(db, keys: [["rowid": 1]]).first!.id != nil)
|
||||
XCTAssertTrue(try Person.all().fetchOne(db)!.id != nil)
|
||||
XCTAssertTrue(try Person.filter(Column.rowID == 1).fetchOne(db)!.id != nil)
|
||||
XCTAssertTrue(try Person.filter(sql: "rowid = 1").fetchOne(db)!.id != nil)
|
||||
XCTAssertTrue(try Person.filter(rawSQL: "rowid = 1").fetchOne(db)!.id != nil)
|
||||
XCTAssertTrue(try Person.order(Column.rowID).fetchOne(db)!.id != nil)
|
||||
XCTAssertTrue(try Person.order(sql: "rowid").fetchOne(db)!.id != nil)
|
||||
XCTAssertTrue(try Person.order(rawSQL: "rowid").fetchOne(db)!.id != nil)
|
||||
XCTAssertTrue(try Person.limit(1).fetchOne(db)!.id != nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ class SQLInterpolationTests: GRDBTestCase {
|
||||
func testSQLInterpolation() {
|
||||
var sql = SQLInterpolation(literalCapacity: 0, interpolationCount: 2)
|
||||
|
||||
sql.appendInterpolation(sql: "\(1)"); sql.appendLiteral("\n")
|
||||
sql.appendInterpolation(sql: ":name", arguments: ["name": "Arthur"])
|
||||
sql.appendInterpolation(rawSQL: "\(1)"); sql.appendLiteral("\n")
|
||||
sql.appendInterpolation(rawSQL: ":name", arguments: ["name": "Arthur"])
|
||||
|
||||
XCTAssertEqual(sql.sql, """
|
||||
1
|
||||
|
||||
@@ -53,11 +53,11 @@ class SQLLiteralTests: GRDBTestCase {
|
||||
XCTAssertEqual(sql.arguments, [1, "Arthur"])
|
||||
}
|
||||
|
||||
func testAppendSQL() {
|
||||
func testAppendRawSQL() {
|
||||
var sql = SQLLiteral(rawSQL: "SELECT * ")
|
||||
sql.append(sql: "FROM player ")
|
||||
sql.append(sql: "WHERE score > \(1000) ")
|
||||
sql.append(sql: "AND \("name") = :name", arguments: ["name": "Arthur"])
|
||||
sql.append(rawSQL: "FROM player ")
|
||||
sql.append(rawSQL: "WHERE score > \(1000) ")
|
||||
sql.append(rawSQL: "AND \("name") = :name", arguments: ["name": "Arthur"])
|
||||
XCTAssertEqual(sql.sql, """
|
||||
SELECT * FROM player WHERE score > 1000 AND name = :name
|
||||
""")
|
||||
@@ -67,12 +67,12 @@ class SQLLiteralTests: GRDBTestCase {
|
||||
|
||||
#if swift(>=5.0)
|
||||
extension SQLLiteralTests {
|
||||
func testSQLInterpolation() {
|
||||
func testRawSQLInterpolation() {
|
||||
let sql: SQLLiteral = """
|
||||
SELECT *
|
||||
\(sql: "FROM player")
|
||||
\(sql: "WHERE score > \(1000)")
|
||||
\(sql: "AND \("name") = :name", arguments: ["name": "Arthur"])
|
||||
\(rawSQL: "FROM player")
|
||||
\(rawSQL: "WHERE score > \(1000)")
|
||||
\(rawSQL: "AND \("name") = :name", arguments: ["name": "Arthur"])
|
||||
"""
|
||||
XCTAssertEqual(sql.sql, """
|
||||
SELECT *
|
||||
@@ -268,11 +268,11 @@ extension SQLLiteralTests {
|
||||
XCTAssertEqual(sql.arguments, [1])
|
||||
}
|
||||
|
||||
func testAppendSQLWithInterpolation() {
|
||||
func testAppendRawSQLWithInterpolation() {
|
||||
var sql: SQLLiteral = "SELECT \(AllColumns()) "
|
||||
sql.append(sql: "FROM player ")
|
||||
sql.append(sql: "WHERE score > \(1000) ")
|
||||
sql.append(sql: "AND \("name") = :name", arguments: ["name": "Arthur"])
|
||||
sql.append(rawSQL: "FROM player ")
|
||||
sql.append(rawSQL: "WHERE score > \(1000) ")
|
||||
sql.append(rawSQL: "AND \("name") = :name", arguments: ["name": "Arthur"])
|
||||
XCTAssertEqual(sql.sql, """
|
||||
SELECT * FROM player WHERE score > 1000 AND name = :name
|
||||
""")
|
||||
|
||||
@@ -184,7 +184,7 @@ class TableDefinitionTests: GRDBTestCase {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.create(table: "test") { t in
|
||||
t.column("a", .integer).check { $0 > 0 }
|
||||
t.column("b", .integer).check(sql: "b <> 2")
|
||||
t.column("b", .integer).check(rawSQL: "b <> 2")
|
||||
t.column("c", .integer).check { $0 > 0 }.check { $0 < 10 }
|
||||
}
|
||||
assertEqualSQL(
|
||||
@@ -213,7 +213,7 @@ class TableDefinitionTests: GRDBTestCase {
|
||||
t.column("b", .integer).defaults(to: 1.0)
|
||||
t.column("c", .integer).defaults(to: "'fooéı👨👨🏿🇫🇷🇨🇮'")
|
||||
t.column("d", .integer).defaults(to: "foo".data(using: .utf8)!)
|
||||
t.column("e", .integer).defaults(sql: "NULL")
|
||||
t.column("e", .integer).defaults(rawSQL: "NULL")
|
||||
}
|
||||
assertEqualSQL(
|
||||
lastSQLQuery,
|
||||
@@ -376,7 +376,7 @@ class TableDefinitionTests: GRDBTestCase {
|
||||
try dbQueue.inDatabase { db in
|
||||
try db.create(table: "test") { t in
|
||||
t.check(Column("a") + Column("b") < 10)
|
||||
t.check(sql: "a + b < 10")
|
||||
t.check(rawSQL: "a + b < 10")
|
||||
t.column("a", .integer)
|
||||
t.column("b", .integer)
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class TableRecordQueryInterfaceRequestTests: GRDBTestCase {
|
||||
try db.execute(rawSQL: "INSERT INTO readers (name, age) VALUES (?, ?)", arguments: ["Arthur", 42])
|
||||
try db.execute(rawSQL: "INSERT INTO readers (name, age) VALUES (?, ?)", arguments: ["Barbara", 36])
|
||||
|
||||
let request = Reader.select(sql: "name, id - 1")
|
||||
let request = Reader.select(rawSQL: "name, id - 1")
|
||||
let rows = try Row.fetchAll(db, request)
|
||||
XCTAssertEqual(lastSQLQuery, "SELECT name, id - 1 FROM \"readers\"")
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
@@ -107,7 +107,7 @@ class TableRecordQueryInterfaceRequestTests: GRDBTestCase {
|
||||
try db.execute(rawSQL: "INSERT INTO readers (name, age) VALUES (?, ?)", arguments: ["Arthur", 42])
|
||||
try db.execute(rawSQL: "INSERT INTO readers (name, age) VALUES (?, ?)", arguments: ["Barbara", 36])
|
||||
|
||||
let request = Reader.select(sql: "name, id - ?", arguments: [1])
|
||||
let request = Reader.select(rawSQL: "name, id - ?", arguments: [1])
|
||||
let rows = try Row.fetchAll(db, request)
|
||||
XCTAssertEqual(lastSQLQuery, "SELECT name, id - 1 FROM \"readers\"")
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
@@ -124,7 +124,7 @@ class TableRecordQueryInterfaceRequestTests: GRDBTestCase {
|
||||
try db.execute(rawSQL: "INSERT INTO readers (name, age) VALUES (?, ?)", arguments: ["Arthur", 42])
|
||||
try db.execute(rawSQL: "INSERT INTO readers (name, age) VALUES (?, ?)", arguments: ["Barbara", 36])
|
||||
|
||||
let request = Reader.select(sql: "name, id - :n", arguments: ["n": 1])
|
||||
let request = Reader.select(rawSQL: "name, id - :n", arguments: ["n": 1])
|
||||
let rows = try Row.fetchAll(db, request)
|
||||
XCTAssertEqual(lastSQLQuery, "SELECT name, id - 1 FROM \"readers\"")
|
||||
XCTAssertEqual(rows.count, 2)
|
||||
@@ -187,21 +187,21 @@ class TableRecordQueryInterfaceRequestTests: GRDBTestCase {
|
||||
func testFilterLiteral() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, Reader.filter(sql: "id <> 1")),
|
||||
sql(dbQueue, Reader.filter(rawSQL: "id <> 1")),
|
||||
"SELECT * FROM \"readers\" WHERE (id <> 1)")
|
||||
}
|
||||
|
||||
func testFilterLiteralWithPositionalArguments() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, Reader.filter(sql: "id <> ?", arguments: [1])),
|
||||
sql(dbQueue, Reader.filter(rawSQL: "id <> ?", arguments: [1])),
|
||||
"SELECT * FROM \"readers\" WHERE (id <> 1)")
|
||||
}
|
||||
|
||||
func testFilterLiteralWithNamedArguments() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, Reader.filter(sql: "id <> :id", arguments: ["id": 1])),
|
||||
sql(dbQueue, Reader.filter(rawSQL: "id <> :id", arguments: ["id": 1])),
|
||||
"SELECT * FROM \"readers\" WHERE (id <> 1)")
|
||||
}
|
||||
|
||||
@@ -225,21 +225,21 @@ class TableRecordQueryInterfaceRequestTests: GRDBTestCase {
|
||||
func testSortLiteral() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, Reader.order(sql: "lower(name) desc")),
|
||||
sql(dbQueue, Reader.order(rawSQL: "lower(name) desc")),
|
||||
"SELECT * FROM \"readers\" ORDER BY lower(name) desc")
|
||||
}
|
||||
|
||||
func testSortLiteralWithPositionalArguments() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, Reader.order(sql: "age + ?", arguments: [1])),
|
||||
sql(dbQueue, Reader.order(rawSQL: "age + ?", arguments: [1])),
|
||||
"SELECT * FROM \"readers\" ORDER BY age + 1")
|
||||
}
|
||||
|
||||
func testSortLiteralWithNamedArguments() throws {
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
XCTAssertEqual(
|
||||
sql(dbQueue, Reader.order(sql: "age + :age", arguments: ["age": 1])),
|
||||
sql(dbQueue, Reader.order(rawSQL: "age + :age", arguments: ["age": 1])),
|
||||
"SELECT * FROM \"readers\" ORDER BY age + 1")
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user