try dbQueue.read { db in
let request = Wine
.filter(Column("origin") == "Burgundy")
.order(Column("price")
let sqlRequest = try SQLRequest(db, request: request)
print(sqlRequest.sql)
// Prints SELECT * FROM wine WHERE origin = ? ORDER BY price
print(sqlRequest.arguments)
// Prints ["Burgundy"]
}
try dbQueue.read { db in
let request = Player.filter(Column("email") == "arthur@example.com")
let statement = try request.makePreparedRequest(db).statement
print(statement) // SELECT * FROM player WHERE email = ?
print(statement.arguments) // ["arthur@example.com"]
}
3条答案
按热度按时间6tdlim6h1#
最新的GRDB中有一个
trace
函数:h43kikqp2#
如何将请求打印为SQL?常见问题解答指出:
您可以将请求转换为SQLRequest示例:
5ktev3wc3#
对于较新版本的GRDB,答案是不同的。
摘自如何将请求打印为SQL?: