From 3892fee6c51827298c7df3805a92e3120125e68d Mon Sep 17 00:00:00 2001 From: kilnerm <38245247+kilnerm@users.noreply.github.com> Date: Mon, 4 Jun 2018 16:10:55 +0100 Subject: [PATCH] Add AUTO INCREMENT support for SQLite (#51) --- .gitignore | 3 ++- Package.swift | 2 +- .../SwiftKueryPostgreSQL/PostgreSQLConnection.swift | 2 +- Tests/SwiftKueryPostgreSQLTests/CommonUtils.swift | 3 ++- Tests/SwiftKueryPostgreSQLTests/TestAlias.swift | 2 +- Tests/SwiftKueryPostgreSQLTests/TestInsert.swift | 6 +++--- Tests/SwiftKueryPostgreSQLTests/TestJoin.swift | 12 ++++++------ Tests/SwiftKueryPostgreSQLTests/TestParameters.swift | 8 ++++---- Tests/SwiftKueryPostgreSQLTests/TestSelect.swift | 12 ++++++------ Tests/SwiftKueryPostgreSQLTests/TestSubquery.swift | 2 +- .../SwiftKueryPostgreSQLTests/TestTransaction.swift | 12 ++++++------ Tests/SwiftKueryPostgreSQLTests/TestTypes.swift | 12 ++++++------ Tests/SwiftKueryPostgreSQLTests/TestUpdate.swift | 2 +- Tests/SwiftKueryPostgreSQLTests/TestWith.swift | 6 +++--- 14 files changed, 43 insertions(+), 41 deletions(-) diff --git a/.gitignore b/.gitignore index 913363a..82c27a2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .build build Package.resolved -.DS_Store \ No newline at end of file +.DS_Store +Packages diff --git a/Package.swift b/Package.swift index 0fc9027..ec96204 100644 --- a/Package.swift +++ b/Package.swift @@ -29,7 +29,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/IBM-Swift/CLibpq.git", .upToNextMinor(from: "0.1.0")), - .package(url: "https://github.com/IBM-Swift/Swift-Kuery.git", from: "1.3.0"), + .package(url: "https://github.com/IBM-Swift/Swift-Kuery.git", from: "2.0.0"), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. diff --git a/Sources/SwiftKueryPostgreSQL/PostgreSQLConnection.swift b/Sources/SwiftKueryPostgreSQL/PostgreSQLConnection.swift index ddf6f34..5c7ff81 100644 --- a/Sources/SwiftKueryPostgreSQL/PostgreSQLConnection.swift +++ b/Sources/SwiftKueryPostgreSQL/PostgreSQLConnection.swift @@ -108,7 +108,7 @@ public class PostgreSQLConnection: Connection { } - static func createAutoIncrement(_ type: String) -> String { + static func createAutoIncrement(_ type: String, _: Bool) -> String { switch type { case "smallint": return "smallserial" diff --git a/Tests/SwiftKueryPostgreSQLTests/CommonUtils.swift b/Tests/SwiftKueryPostgreSQLTests/CommonUtils.swift index a870c54..ba77902 100644 --- a/Tests/SwiftKueryPostgreSQLTests/CommonUtils.swift +++ b/Tests/SwiftKueryPostgreSQLTests/CommonUtils.swift @@ -102,7 +102,7 @@ func executeRawQuery(_ raw: String, connection: Connection, callback: @escaping } func cleanUp(table: String, connection: Connection, callback: @escaping (QueryResult)->()) { - connection.execute("DROP TABLE " + table) { result in + connection.execute("DROP TABLE \"" + table + "\"") { result in callback(result) } } @@ -151,6 +151,7 @@ func rowsAsArray(_ result: ResultSet) -> [[Any?]] { } func createConnection() -> PostgreSQLConnection { + // We do not specify a database name for our tests so postgreSQL defaults to using the username as the database name. let host = read(fileName: "host.txt") let port = Int32(read(fileName: "port.txt"))! let username = read(fileName: "username.txt") diff --git a/Tests/SwiftKueryPostgreSQLTests/TestAlias.swift b/Tests/SwiftKueryPostgreSQLTests/TestAlias.swift index 0fc6ae5..67d9e7f 100644 --- a/Tests/SwiftKueryPostgreSQLTests/TestAlias.swift +++ b/Tests/SwiftKueryPostgreSQLTests/TestAlias.swift @@ -52,7 +52,7 @@ class TestAlias: XCTestCase { } cleanUp(table: t.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") diff --git a/Tests/SwiftKueryPostgreSQLTests/TestInsert.swift b/Tests/SwiftKueryPostgreSQLTests/TestInsert.swift index c7c5e15..bdc0d33 100644 --- a/Tests/SwiftKueryPostgreSQLTests/TestInsert.swift +++ b/Tests/SwiftKueryPostgreSQLTests/TestInsert.swift @@ -73,11 +73,11 @@ class TestInsert: XCTestCase { cleanUp(table: t.tableName, connection: connection) { result in cleanUp(table: t2.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") - executeRawQuery("CREATE TABLE " + t2.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t2.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -181,7 +181,7 @@ class TestInsert: XCTestCase { } cleanUp(table: t3.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t3.tableName + " (a SERIAL PRIMARY KEY, b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t3.tableName + "\" (a SERIAL PRIMARY KEY, b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") let i7 = Insert(into: t3, valueTuples: [(t3.b, 5)], returnID: true) diff --git a/Tests/SwiftKueryPostgreSQLTests/TestJoin.swift b/Tests/SwiftKueryPostgreSQLTests/TestJoin.swift index e71bb26..07701e6 100644 --- a/Tests/SwiftKueryPostgreSQLTests/TestJoin.swift +++ b/Tests/SwiftKueryPostgreSQLTests/TestJoin.swift @@ -78,16 +78,16 @@ class TestJoin: XCTestCase { cleanUp(table: myTable3.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + myTable1.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + myTable1.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") - executeRawQuery("CREATE TABLE " + myTable2.tableName + " (c varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + myTable2.tableName + "\" (c varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") - executeRawQuery("CREATE TABLE " + myTable3.tableName + " (d varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + myTable3.tableName + "\" (d varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -203,16 +203,16 @@ class TestJoin: XCTestCase { cleanUp(table: myTable3.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + myTable1.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + myTable1.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") - executeRawQuery("CREATE TABLE " + myTable2.tableName + " (c varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + myTable2.tableName + "\" (c varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") - executeRawQuery("CREATE TABLE " + myTable3.tableName + " (d varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + myTable3.tableName + "\" (d varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") diff --git a/Tests/SwiftKueryPostgreSQLTests/TestParameters.swift b/Tests/SwiftKueryPostgreSQLTests/TestParameters.swift index 7370d5e..2d08c84 100644 --- a/Tests/SwiftKueryPostgreSQLTests/TestParameters.swift +++ b/Tests/SwiftKueryPostgreSQLTests/TestParameters.swift @@ -59,7 +59,7 @@ class TestParameters: XCTestCase { cleanUp(table: t.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -94,7 +94,7 @@ class TestParameters: XCTestCase { XCTAssertEqual(rows![2][0]! as! String, "peach", "Wrong value in row 2 column 0") XCTAssertEqual(rows![2][1]! as! Int32, 2, "Wrong value in row 2 column 1") - let raw = "UPDATE " + t.tableName + " SET a = 'banana', b = $1 WHERE a = $2" + let raw = "UPDATE \"" + t.tableName + "\" SET a = 'banana', b = $1 WHERE a = $2" executeRawQueryWithParameters(raw, connection: connection, parameters: 4, "peach") { result, rows in XCTAssertEqual(result.success, true, "UPDATE failed") XCTAssertNil(result.asError, "Error in UPDATE: \(result.asError!)") @@ -143,7 +143,7 @@ class TestParameters: XCTestCase { cleanUp(table: t.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -243,7 +243,7 @@ class TestParameters: XCTestCase { let s1 = Select(from: t).where(t.a == Parameter()) let preparedSelect = try connection.prepareStatement(s1) - let s2 = "SELECT * FROM " + t.tableName + let s2 = "SELECT * FROM \"" + t.tableName + "\"" let preparedSelect2 = try connection.prepareStatement(s2) connection.execute(preparedStatement: preparedInsert, parameters: ["apple", 3, "banana", -8]) { result in diff --git a/Tests/SwiftKueryPostgreSQLTests/TestSelect.swift b/Tests/SwiftKueryPostgreSQLTests/TestSelect.swift index 66cab7a..69dd719 100644 --- a/Tests/SwiftKueryPostgreSQLTests/TestSelect.swift +++ b/Tests/SwiftKueryPostgreSQLTests/TestSelect.swift @@ -78,7 +78,7 @@ class TestSelect: XCTestCase { cleanUp(table: t.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -194,7 +194,7 @@ class TestSelect: XCTestCase { XCTAssertEqual(rows!.count, 2, "SELECT returned wrong number of rows: \(rows!.count) instead of 2") XCTAssertEqual(rows![0][0]! as! String, "apple", "Wrong value in row 0 column 0") - let s9 = "Select * from \(t.tableName) where a IN ('apple', 'lalala')" + let s9 = "Select * from \"\(t.tableName)\" where a IN ('apple', 'lalala')" executeRawQuery(s9, connection: connection) { result, rows in XCTAssertEqual(result.success, true, "SELECT failed") XCTAssertNotNil(result.asResultSet, "SELECT returned no rows") @@ -242,15 +242,15 @@ class TestSelect: XCTestCase { cleanUp(table: t2.tableName, connection: connection) { result in cleanUp(table: t3.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t1.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t1.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") - executeRawQuery("CREATE TABLE " + t2.tableName + " (c varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t2.tableName + "\" (c varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") - executeRawQuery("CREATE TABLE " + t3.tableName + " (d varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t3.tableName + "\" (d varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -321,7 +321,7 @@ class TestSelect: XCTestCase { cleanUp(table: t.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), date date, timestamp timestamp with time zone, time time with time zone)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), date date, timestamp timestamp with time zone, time time with time zone)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") diff --git a/Tests/SwiftKueryPostgreSQLTests/TestSubquery.swift b/Tests/SwiftKueryPostgreSQLTests/TestSubquery.swift index 0742316..ad20ef9 100644 --- a/Tests/SwiftKueryPostgreSQLTests/TestSubquery.swift +++ b/Tests/SwiftKueryPostgreSQLTests/TestSubquery.swift @@ -51,7 +51,7 @@ class TestSubquery: XCTestCase { cleanUp(table: t.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") diff --git a/Tests/SwiftKueryPostgreSQLTests/TestTransaction.swift b/Tests/SwiftKueryPostgreSQLTests/TestTransaction.swift index 196ffb7..2084f52 100644 --- a/Tests/SwiftKueryPostgreSQLTests/TestTransaction.swift +++ b/Tests/SwiftKueryPostgreSQLTests/TestTransaction.swift @@ -58,7 +58,7 @@ class TestTransaction: XCTestCase { cleanUp(table: t.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -109,7 +109,7 @@ class TestTransaction: XCTestCase { cleanUp(table: t.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -163,7 +163,7 @@ class TestTransaction: XCTestCase { XCTAssertEqual(result.success, true, "Failed to start transaction") XCTAssertNil(result.asError, "Error in start transaction: \(result.asError!)") - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -264,7 +264,7 @@ class TestTransaction: XCTestCase { connection.startTransaction() { result in XCTAssertEqual(result.success, false, "Started second transaction") - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -320,7 +320,7 @@ class TestTransaction: XCTestCase { XCTAssertEqual(result.success, true, "Failed to start transaction") XCTAssertNil(result.asError, "Error in start transaction: \(result.asError!)") - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -375,7 +375,7 @@ class TestTransaction: XCTestCase { XCTAssertEqual(result.success, true, "Failed to start transaction") XCTAssertNil(result.asError, "Error in start transaction: \(result.asError!)") - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") diff --git a/Tests/SwiftKueryPostgreSQLTests/TestTypes.swift b/Tests/SwiftKueryPostgreSQLTests/TestTypes.swift index 35eb8fe..d440a25 100644 --- a/Tests/SwiftKueryPostgreSQLTests/TestTypes.swift +++ b/Tests/SwiftKueryPostgreSQLTests/TestTypes.swift @@ -79,7 +79,7 @@ class TestTypes: XCTestCase { cleanUp(table: t.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b smallint, c integer, d bigint, e decimal(7,2), f numeric, g real, h double precision, i smallserial, j serial, k bigserial)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b smallint, c integer, d bigint, e decimal(7,2), f numeric, g real, h double precision, i smallserial, j serial, k bigserial)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -170,7 +170,7 @@ class TestTypes: XCTestCase { cleanUp(table: t.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b decimal(7,2), c numeric, d decimal, e numeric(12,4))", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b decimal(7,2), c numeric, d decimal, e numeric(12,4))", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -330,7 +330,7 @@ class TestTypes: XCTestCase { cleanUp(table: t.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b boolean, c boolean)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b boolean, c boolean)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -388,7 +388,7 @@ class TestTypes: XCTestCase { cleanUp(table: t.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b date, c time, d time with time zone, e timestamp, f timestamp with time zone)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b date, c time, d time with time zone, e timestamp, f timestamp with time zone)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -498,7 +498,7 @@ class TestTypes: XCTestCase { cleanUp(table: t.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(4), b character varying(4), c character(5), d char(5), e text, f \"char\", g name, h json, i xml)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(4), b character varying(4), c character(5), d char(5), e text, f \"char\", g name, h json, i xml)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -561,7 +561,7 @@ class TestTypes: XCTestCase { cleanUp(table: t.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b uuid)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b uuid)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") diff --git a/Tests/SwiftKueryPostgreSQLTests/TestUpdate.swift b/Tests/SwiftKueryPostgreSQLTests/TestUpdate.swift index 8340198..1a6811e 100644 --- a/Tests/SwiftKueryPostgreSQLTests/TestUpdate.swift +++ b/Tests/SwiftKueryPostgreSQLTests/TestUpdate.swift @@ -53,7 +53,7 @@ class TestUpdate: XCTestCase { cleanUp(table: t.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") diff --git a/Tests/SwiftKueryPostgreSQLTests/TestWith.swift b/Tests/SwiftKueryPostgreSQLTests/TestWith.swift index 0b257a1..c527d01 100644 --- a/Tests/SwiftKueryPostgreSQLTests/TestWith.swift +++ b/Tests/SwiftKueryPostgreSQLTests/TestWith.swift @@ -93,12 +93,12 @@ class TestWith: XCTestCase { cleanUp(table: t2.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t1.tableName + " (a varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t1.tableName + "\" (a varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") - executeRawQuery("CREATE TABLE " + t2.tableName + " (c varchar(40), b integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t2.tableName + "\" (c varchar(40), b integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)") @@ -132,7 +132,7 @@ class TestWith: XCTestCase { cleanUp(table: t3.tableName, connection: connection) { result in - executeRawQuery("CREATE TABLE " + t3.tableName + " (x varchar(40), y integer)", connection: connection) { result, rows in + executeRawQuery("CREATE TABLE \"" + t3.tableName + "\" (x varchar(40), y integer)", connection: connection) { result, rows in XCTAssertEqual(result.success, true, "CREATE TABLE failed") XCTAssertNil(result.asError, "Error in CREATE TABLE: \(result.asError!)")