From b9333fab340f4eb922f06a3ec76b4ed6966b35fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 10 Apr 2018 13:45:31 +0200 Subject: [PATCH] Update a few tests that have been broken by 64899e5a399fdf4821221bbc5e6c5bfc1ff1b867. (Some expressions which were not safely wrapped inside parenthesis now are wrapped inside parenthesis) --- .../MutablePersistableRecordDeleteTests.swift | 2 +- .../GRDBTests/QueryInterfaceExtensibilityTests.swift | 2 +- Tests/GRDBTests/QueryInterfaceRequestTests.swift | 12 ++++++------ .../TableRecord+QueryInterfaceRequestTests.swift | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Tests/GRDBTests/MutablePersistableRecordDeleteTests.swift b/Tests/GRDBTests/MutablePersistableRecordDeleteTests.swift index 011927b1c..bee0a4c0d 100644 --- a/Tests/GRDBTests/MutablePersistableRecordDeleteTests.swift +++ b/Tests/GRDBTests/MutablePersistableRecordDeleteTests.swift @@ -151,7 +151,7 @@ class MutablePersistableRecordDeleteTests: GRDBTestCase { XCTAssertEqual(self.lastSQLQuery, "DELETE FROM \"persons\" WHERE (\"name\" = 'Arthur')") try Person.filter(sql: "id = 1").deleteAll(db) - XCTAssertEqual(self.lastSQLQuery, "DELETE FROM \"persons\" WHERE id = 1") + XCTAssertEqual(self.lastSQLQuery, "DELETE FROM \"persons\" WHERE (id = 1)") try Person.select(Column("name")).deleteAll(db) XCTAssertEqual(self.lastSQLQuery, "DELETE FROM \"persons\"") diff --git a/Tests/GRDBTests/QueryInterfaceExtensibilityTests.swift b/Tests/GRDBTests/QueryInterfaceExtensibilityTests.swift index 269d89fe0..b415dd871 100644 --- a/Tests/GRDBTests/QueryInterfaceExtensibilityTests.swift +++ b/Tests/GRDBTests/QueryInterfaceExtensibilityTests.swift @@ -112,7 +112,7 @@ class QueryInterfaceExtensibilityTests: GRDBTestCase { default: XCTFail("Expected data blob") } - XCTAssertEqual(self.lastSQLQuery, "SELECT CAST(\"text\" AS BLOB) FROM \"records\"") + XCTAssertEqual(self.lastSQLQuery, "SELECT (CAST(\"text\" AS BLOB)) FROM \"records\"") } } } diff --git a/Tests/GRDBTests/QueryInterfaceRequestTests.swift b/Tests/GRDBTests/QueryInterfaceRequestTests.swift index 00fdf0f94..f1d71d783 100644 --- a/Tests/GRDBTests/QueryInterfaceRequestTests.swift +++ b/Tests/GRDBTests/QueryInterfaceRequestTests.swift @@ -237,21 +237,21 @@ class QueryInterfaceRequestTests: GRDBTestCase { let dbQueue = try makeDatabaseQueue() XCTAssertEqual( sql(dbQueue, tableRequest.filter(sql: "id <> 1")), - "SELECT * FROM \"readers\" WHERE id <> 1") + "SELECT * FROM \"readers\" WHERE (id <> 1)") } func testFilterLiteralWithPositionalArguments() throws { let dbQueue = try makeDatabaseQueue() XCTAssertEqual( sql(dbQueue, tableRequest.filter(sql: "id <> ?", arguments: [1])), - "SELECT * FROM \"readers\" WHERE id <> 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])), - "SELECT * FROM \"readers\" WHERE id <> 1") + "SELECT * FROM \"readers\" WHERE (id <> 1)") } func testFilter() throws { @@ -316,21 +316,21 @@ class QueryInterfaceRequestTests: GRDBTestCase { let dbQueue = try makeDatabaseQueue() XCTAssertEqual( sql(dbQueue, tableRequest.group(Col.name).having(sql: "min(age) > 18")), - "SELECT * FROM \"readers\" GROUP BY \"name\" HAVING 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])), - "SELECT * FROM \"readers\" GROUP BY \"name\" HAVING min(age) > 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])), - "SELECT * FROM \"readers\" GROUP BY \"name\" HAVING min(age) > 18") + "SELECT * FROM \"readers\" GROUP BY \"name\" HAVING (min(age) > 18)") } func testHaving() throws { diff --git a/Tests/GRDBTests/TableRecord+QueryInterfaceRequestTests.swift b/Tests/GRDBTests/TableRecord+QueryInterfaceRequestTests.swift index 6448b5ad6..7e6845684 100644 --- a/Tests/GRDBTests/TableRecord+QueryInterfaceRequestTests.swift +++ b/Tests/GRDBTests/TableRecord+QueryInterfaceRequestTests.swift @@ -166,21 +166,21 @@ class TableRecordQueryInterfaceRequestTests: GRDBTestCase { let dbQueue = try makeDatabaseQueue() XCTAssertEqual( sql(dbQueue, Reader.filter(sql: "id <> 1")), - "SELECT * FROM \"readers\" WHERE id <> 1") + "SELECT * FROM \"readers\" WHERE (id <> 1)") } func testFilterLiteralWithPositionalArguments() throws { let dbQueue = try makeDatabaseQueue() XCTAssertEqual( sql(dbQueue, Reader.filter(sql: "id <> ?", arguments: [1])), - "SELECT * FROM \"readers\" WHERE id <> 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])), - "SELECT * FROM \"readers\" WHERE id <> 1") + "SELECT * FROM \"readers\" WHERE (id <> 1)") } func testFilter() throws {