From a7274d7dd80983d13b5129314ed389fc45fcbc52 Mon Sep 17 00:00:00 2001 From: Prince Ugwuh Date: Thu, 1 Sep 2016 13:51:43 -0500 Subject: [PATCH 01/16] Update to support 8-18 snapshot --- Sources/PostgreSQL/Database.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/PostgreSQL/Database.swift b/Sources/PostgreSQL/Database.swift index 8c4defc..748b0cf 100644 --- a/Sources/PostgreSQL/Database.swift +++ b/Sources/PostgreSQL/Database.swift @@ -81,7 +81,7 @@ public class Database { var ch = [UInt8](values[i].utf8) ch.append(0) v.append(ch) - paramsValues[i] = UnsafePointer(v.last!) + paramsValues[i] = UnsafePointer(OpaquePointer(v.last!)) } return paramsValues } From 4b1d4c124e0f6d2a3a1658dfb549e66003ba5070 Mon Sep 17 00:00:00 2001 From: Prince Ugwuh Date: Thu, 8 Sep 2016 09:30:00 -0500 Subject: [PATCH 02/16] updated swift-version added travis.yml file --- .swift-version | 2 +- travis.yml | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 travis.yml diff --git a/.swift-version b/.swift-version index fbe576f..c780b41 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -DEVELOPMENT-SNAPSHOT-2016-07-25-a +DEVELOPMENT-SNAPSHOT-2016-08-18-a diff --git a/travis.yml b/travis.yml new file mode 100644 index 0000000..ecc7d30 --- /dev/null +++ b/travis.yml @@ -0,0 +1,10 @@ +os: + - linux + - osx +language: generic +sudo: required +dist: trusty +osx_image: xcode8 +script: + - eval "$(curl -sL swift.vapor.sh/ci)" + - eval "$(curl -sL swift.vapor.sh/codecov)" \ No newline at end of file From de8d7c3d9bdc4da194b94ff4fdd6101e2539d15c Mon Sep 17 00:00:00 2001 From: Prince Ugwuh Date: Thu, 8 Sep 2016 09:47:19 -0500 Subject: [PATCH 03/16] fixed the test module, updated node 0.5.0 --- travis.yml => .travis.yml | 0 Package.swift | 2 +- Tests/{PostgreSQL => PostgreSQLTests}/PostgreSQLTests.swift | 0 Tests/{PostgreSQL => PostgreSQLTests}/Utilities.swift | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename travis.yml => .travis.yml (100%) rename Tests/{PostgreSQL => PostgreSQLTests}/PostgreSQLTests.swift (100%) rename Tests/{PostgreSQL => PostgreSQLTests}/Utilities.swift (100%) diff --git a/travis.yml b/.travis.yml similarity index 100% rename from travis.yml rename to .travis.yml diff --git a/Package.swift b/Package.swift index abd82a7..d17b031 100644 --- a/Package.swift +++ b/Package.swift @@ -4,6 +4,6 @@ let package = Package( name: "PostgreSQL", dependencies: [ .Package(url: "https://github.com/qutheory/cpostgresql.git", majorVersion: 0), - .Package(url: "https://github.com/vapor/node.git", majorVersion: 0, minor: 4) + .Package(url: "https://github.com/vapor/node.git", majorVersion: 0, minor: 5) ] ) diff --git a/Tests/PostgreSQL/PostgreSQLTests.swift b/Tests/PostgreSQLTests/PostgreSQLTests.swift similarity index 100% rename from Tests/PostgreSQL/PostgreSQLTests.swift rename to Tests/PostgreSQLTests/PostgreSQLTests.swift diff --git a/Tests/PostgreSQL/Utilities.swift b/Tests/PostgreSQLTests/Utilities.swift similarity index 100% rename from Tests/PostgreSQL/Utilities.swift rename to Tests/PostgreSQLTests/Utilities.swift From 0ce10249a7124958335e1e6c8ccf40f25c452336 Mon Sep 17 00:00:00 2001 From: Prince Ugwuh Date: Thu, 8 Sep 2016 10:14:15 -0500 Subject: [PATCH 04/16] import test name corrected --- Tests/LinuxMain.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift index 1c28c4d..c034117 100644 --- a/Tests/LinuxMain.swift +++ b/Tests/LinuxMain.swift @@ -1,7 +1,7 @@ #if os(Linux) import XCTest -@testable import PostgreSQLTestSuite +@testable import PostgreSQLTests XCTMain([ testCase(PostgreSQLTests.allTests) From a7169c80f981b07b301d1e528030c2edc7a76133 Mon Sep 17 00:00:00 2001 From: Prince Ugwuh Date: Thu, 8 Sep 2016 13:34:21 -0500 Subject: [PATCH 05/16] updated swift version .... updated travis yml --- .swift-version | 2 +- .travis.yml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index c780b41..37004a4 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -DEVELOPMENT-SNAPSHOT-2016-08-18-a +DEVELOPMENT-SNAPSHOT-2016-09-06-a diff --git a/.travis.yml b/.travis.yml index ecc7d30..2125b9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,12 @@ language: generic sudo: required dist: trusty osx_image: xcode8 +services: + - postgresql +addons: + postgresql: "9.4" +before_script: + - psql -c 'create database test;' -U postgres script: - eval "$(curl -sL swift.vapor.sh/ci)" - eval "$(curl -sL swift.vapor.sh/codecov)" \ No newline at end of file From d8e1bc9c72be184ad2d02ded2ac8908b94ccf578 Mon Sep 17 00:00:00 2001 From: Prince Ugwuh Date: Thu, 8 Sep 2016 17:36:12 -0500 Subject: [PATCH 06/16] remove the before_script attempt #8 to get travis to pass --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2125b9a..06ec8f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,8 @@ services: - postgresql addons: postgresql: "9.4" -before_script: - - psql -c 'create database test;' -U postgres +# before_script: + # - psql -c 'create database test;' -U postgres script: - eval "$(curl -sL swift.vapor.sh/ci)" - eval "$(curl -sL swift.vapor.sh/codecov)" \ No newline at end of file From 852a73f77debdd7d6bbae4db0684ab5718dbe506 Mon Sep 17 00:00:00 2001 From: Prince Ugwuh Date: Fri, 9 Sep 2016 15:59:21 -0500 Subject: [PATCH 07/16] fixed the test failure issue. removed the NodeRepresentable from execute and made it full [Node] --- Sources/PostgreSQL/Database.swift | 5 +++-- Sources/PostgreSQL/Node+UTF8.swift | 2 +- Sources/PostgreSQL/Result.swift | 2 +- Tests/PostgreSQLTests/Utilities.swift | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Sources/PostgreSQL/Database.swift b/Sources/PostgreSQL/Database.swift index 748b0cf..8eb1b8f 100644 --- a/Sources/PostgreSQL/Database.swift +++ b/Sources/PostgreSQL/Database.swift @@ -29,7 +29,7 @@ public class Database { } @discardableResult - public func execute(_ query: String, _ values: [NodeRepresentable]? = [], on connection: Connection? = nil) throws -> [[String: Node]] { + public func execute(_ query: String, _ values: [Node]? = [], on connection: Connection? = nil) throws -> [[String: Node]] { let internalConnection: Connection if let conn = connection { @@ -43,8 +43,9 @@ public class Database { } let res: Result.ResultPointer + if let values = values, values.count > 0 { - let paramsValues = bind(try values.map { try $0.makeNode() }) + let paramsValues = bind(values) res = PQexecParams(internalConnection.connection, query, Int32(values.count), nil, paramsValues, nil, nil, Int32(0)) defer { diff --git a/Sources/PostgreSQL/Node+UTF8.swift b/Sources/PostgreSQL/Node+UTF8.swift index e2b8d24..f9b1ea0 100644 --- a/Sources/PostgreSQL/Node+UTF8.swift +++ b/Sources/PostgreSQL/Node+UTF8.swift @@ -21,7 +21,7 @@ extension Node { case .number(.int(let int)): return String(int).utf8 default: - return "".utf8 + return String(UInt8(0)).utf8 } } } diff --git a/Sources/PostgreSQL/Result.swift b/Sources/PostgreSQL/Result.swift index 17bc9aa..6330b18 100644 --- a/Sources/PostgreSQL/Result.swift +++ b/Sources/PostgreSQL/Result.swift @@ -15,7 +15,7 @@ public class Result { self.resultPointer = resultPointer } - lazy var dictionary: [[String: Node]] = { [unowned self] in + lazy var dictionary: [[String: Node]] = { let rowCount = Int(PQntuples(self.resultPointer)) let columnCount = Int(PQnfields(self.resultPointer)) diff --git a/Tests/PostgreSQLTests/Utilities.swift b/Tests/PostgreSQLTests/Utilities.swift index 7c0b784..eb148d0 100644 --- a/Tests/PostgreSQLTests/Utilities.swift +++ b/Tests/PostgreSQLTests/Utilities.swift @@ -8,7 +8,7 @@ extension PostgreSQL.Database { host: "127.0.0.1", port: "5432", dbname: "test", - user: "user_testing", + user: "postgres", password: "" ) From 7ea1968e419506e2e34d2a5e0e4ff9512120d234 Mon Sep 17 00:00:00 2001 From: Prince Ugwuh Date: Fri, 9 Sep 2016 16:04:04 -0500 Subject: [PATCH 08/16] updated the error message to reflect the correct configuration --- Tests/PostgreSQLTests/Utilities.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/PostgreSQLTests/Utilities.swift b/Tests/PostgreSQLTests/Utilities.swift index eb148d0..c47837b 100644 --- a/Tests/PostgreSQLTests/Utilities.swift +++ b/Tests/PostgreSQLTests/Utilities.swift @@ -22,7 +22,7 @@ extension PostgreSQL.Database { print("Error: \(error)") print() print("You must configure PostgreSQL to run with the following configuration: ") - print(" user: 'user_testing'") + print(" user: 'postgres'") print(" password: '' // (empty)") print(" host: '127.0.0.1'") print(" database: 'test'") From 2804e9ef5b7f1ecc1b256dc4e6b62a56edf96e98 Mon Sep 17 00:00:00 2001 From: Prince Ugwuh Date: Fri, 9 Sep 2016 16:31:31 -0500 Subject: [PATCH 09/16] updated travis yaml file --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 06ec8f3..2125b9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,8 @@ services: - postgresql addons: postgresql: "9.4" -# before_script: - # - psql -c 'create database test;' -U postgres +before_script: + - psql -c 'create database test;' -U postgres script: - eval "$(curl -sL swift.vapor.sh/ci)" - eval "$(curl -sL swift.vapor.sh/codecov)" \ No newline at end of file From ddc748abf2833feb82faab1cce8fa1a20e6e4bef Mon Sep 17 00:00:00 2001 From: Prince Ugwuh Date: Fri, 9 Sep 2016 16:55:23 -0500 Subject: [PATCH 10/16] attempt again to get travis to build --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2125b9a..1f38404 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ os: - linux - osx +env: + global: + - PGPORT=5433 + - PGHOST=localhost language: generic sudo: required dist: trusty @@ -10,7 +14,7 @@ services: addons: postgresql: "9.4" before_script: - - psql -c 'create database test;' -U postgres + - psql -U postgres -c 'create database "test";' script: - eval "$(curl -sL swift.vapor.sh/ci)" - eval "$(curl -sL swift.vapor.sh/codecov)" \ No newline at end of file From de3bfb2075130cb2f762b5edcb97444d27d86938 Mon Sep 17 00:00:00 2001 From: Prince Ugwuh Date: Fri, 9 Sep 2016 18:27:54 -0500 Subject: [PATCH 11/16] :/ --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1f38404..2881646 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,7 @@ os: - osx env: global: - - PGPORT=5433 - - PGHOST=localhost + - PGPORT=5432 language: generic sudo: required dist: trusty @@ -12,7 +11,7 @@ osx_image: xcode8 services: - postgresql addons: - postgresql: "9.4" + postgresql: "9.5" before_script: - psql -U postgres -c 'create database "test";' script: From e6016f648c699be4423e38f1be16e4c34fa6c49b Mon Sep 17 00:00:00 2001 From: Logan Wright Date: Mon, 12 Sep 2016 11:47:53 -0400 Subject: [PATCH 12/16] Update .travis.yml --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2881646..52005d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,8 @@ services: addons: postgresql: "9.5" before_script: - - psql -U postgres -c 'create database "test";' + - sudo psql -U postgres -c 'create database "test";' + - createdb test script: - eval "$(curl -sL swift.vapor.sh/ci)" - - eval "$(curl -sL swift.vapor.sh/codecov)" \ No newline at end of file + - eval "$(curl -sL swift.vapor.sh/codecov)" From fe869eae3ebc2f17f4e7728b54681f99d2da1100 Mon Sep 17 00:00:00 2001 From: Logan Wright Date: Mon, 12 Sep 2016 12:04:19 -0400 Subject: [PATCH 13/16] Update .travis.yml --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 52005d7..d5f57b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,7 @@ services: addons: postgresql: "9.5" before_script: - - sudo psql -U postgres -c 'create database "test";' - - createdb test + - psql -c 'create database travis_ci_test;' -U postgres script: - eval "$(curl -sL swift.vapor.sh/ci)" - eval "$(curl -sL swift.vapor.sh/codecov)" From ca07a83667707bae545d3d8d26a6f5b6f4792810 Mon Sep 17 00:00:00 2001 From: Logan Wright Date: Mon, 12 Sep 2016 12:18:58 -0400 Subject: [PATCH 14/16] Update .travis.yml --- .travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index d5f57b8..3a9a2ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,14 @@ os: - linux - osx -env: - global: - - PGPORT=5432 language: generic sudo: required dist: trusty osx_image: xcode8 services: - postgresql -addons: - postgresql: "9.5" before_script: - - psql -c 'create database travis_ci_test;' -U postgres + - psql -c 'create database test;' -U postgres script: - eval "$(curl -sL swift.vapor.sh/ci)" - eval "$(curl -sL swift.vapor.sh/codecov)" From 479369b0c34ff52ccfb7fb79a13a60821ab94048 Mon Sep 17 00:00:00 2001 From: Logan Wright Date: Mon, 12 Sep 2016 12:24:02 -0400 Subject: [PATCH 15/16] Update .travis.yml --- .travis.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3a9a2ef..5e901f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,12 +3,27 @@ os: - osx language: generic sudo: required +env: + global: + - PGPORT=5433 + - PGHOST=localhost + - DATABASE_URL=postgres://localhost:5433/your_db dist: trusty osx_image: xcode8 services: - postgresql +addons: + apt: + sources: + - precise-pgdg-9.5 + packages: + - postgresql-9.5 + - postgresql-contrib-9.5 + postgresql: 9.5 before_script: - - psql -c 'create database test;' -U postgres + - sudo cp /etc/postgresql/9.4/main/pg_hba.conf /etc/postgresql/9.5/main/pg_hba.conf + - sudo /etc/init.d/postgresql restart + - psql -U postgres -c 'CREATE DATABASE test;' script: - eval "$(curl -sL swift.vapor.sh/ci)" - eval "$(curl -sL swift.vapor.sh/codecov)" From 7b5ac190f9a4432fd263bab9358b55d1fefba1b5 Mon Sep 17 00:00:00 2001 From: Logan Wright Date: Mon, 12 Sep 2016 12:30:23 -0400 Subject: [PATCH 16/16] Update .travis.yml --- .travis.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5e901f1..379b8ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,18 +12,8 @@ dist: trusty osx_image: xcode8 services: - postgresql -addons: - apt: - sources: - - precise-pgdg-9.5 - packages: - - postgresql-9.5 - - postgresql-contrib-9.5 - postgresql: 9.5 before_script: - - sudo cp /etc/postgresql/9.4/main/pg_hba.conf /etc/postgresql/9.5/main/pg_hba.conf - - sudo /etc/init.d/postgresql restart - - psql -U postgres -c 'CREATE DATABASE test;' + - sudo psql -U postgres -c 'CREATE DATABASE test;' script: - eval "$(curl -sL swift.vapor.sh/ci)" - eval "$(curl -sL swift.vapor.sh/codecov)"