SQLRequest+SQLLiteral: added literal initialization tests

This commit is contained in:
Gwendal Roué committed 2019-09-17 08:54:34 +02:00
1 parent 725e16390b
commit 27a05028db
2 files changed
+26

No files matched your search

+12
View File
@@ -112,6 +112,18 @@ class SQLLiteralTests: GRDBTestCase {
#if swift(>=5.0)
extension SQLLiteralTests {
func testLiteralInitializer() {
let query = SQLLiteral("""
SELECT * FROM player
WHERE id = \(1)
""")
XCTAssertEqual(query.sql, """
SELECT * FROM player
WHERE id = ?
""")
XCTAssertEqual(query.arguments, [1])
}
func testRawSQLInterpolation() {
let query: SQLLiteral = """
SELECT *
+14
View File
@@ -100,6 +100,20 @@ class SQLRequestTests: GRDBTestCase {
}
#if swift(>=5.0)
func testLiteralInitializer() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in
let request = SQLRequest<String>("""
SELECT \("O'Brien")
""")
XCTAssertEqual(request.sql, """
SELECT ?
""")
let string = try request.fetchOne(db)!
XCTAssertEqual(string, "O'Brien")
}
}
func testSQLLiteralInitializerWithInterpolation() throws {
let dbQueue = try makeDatabaseQueue()
try dbQueue.inDatabase { db in