Skip to content
This repository has been archived by the owner on Mar 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from vapor/gm_support
Browse files Browse the repository at this point in the history
Gm support (Circle CI passes) we can make another branch for getting travis to work
  • Loading branch information
Prince2k3 authored Sep 12, 2016
2 parents 57088a6 + 7b5ac19 commit b8ba859
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DEVELOPMENT-SNAPSHOT-2016-07-25-a
DEVELOPMENT-SNAPSHOT-2016-09-06-a
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
os:
- linux
- 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
before_script:
- sudo psql -U postgres -c 'CREATE DATABASE test;'
script:
- eval "$(curl -sL swift.vapor.sh/ci)"
- eval "$(curl -sL swift.vapor.sh/codecov)"
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]
)
7 changes: 4 additions & 3 deletions Sources/PostgreSQL/Database.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -81,7 +82,7 @@ public class Database {
var ch = [UInt8](values[i].utf8)
ch.append(0)
v.append(ch)
paramsValues[i] = UnsafePointer<Int8>(v.last!)
paramsValues[i] = UnsafePointer<Int8>(OpaquePointer(v.last!))
}
return paramsValues
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/PostgreSQL/Node+UTF8.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extension Node {
case .number(.int(let int)):
return String(int).utf8
default:
return "".utf8
return String(UInt8(0)).utf8
}
}
}
2 changes: 1 addition & 1 deletion Sources/PostgreSQL/Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#if os(Linux)

import XCTest
@testable import PostgreSQLTestSuite
@testable import PostgreSQLTests

XCTMain([
testCase(PostgreSQLTests.allTests)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extension PostgreSQL.Database {
host: "127.0.0.1",
port: "5432",
dbname: "test",
user: "user_testing",
user: "postgres",
password: ""

)
Expand All @@ -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'")
Expand Down

0 comments on commit b8ba859

Please sign in to comment.