Skip to content

Commit 4b25340

Browse files
authored
alpha (#138)
* alpha * updates * updates
1 parent 3d81762 commit 4b25340

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+320
-1755
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
/*.xcodeproj
55
Package.resolved
66
DerivedData
7+
.swiftpm
78

Package.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ let package = Package(
55
name: "postgres-kit",
66
products: [
77
.library(name: "PostgresKit", targets: ["PostgresKit"]),
8-
.executable(name: "PostgresKitPerformance", targets: ["PostgresKitPerformance"]),
98
],
109
dependencies: [
11-
.package(url: "https://github.com/vapor/nio-postgres.git", .branch("master")),
12-
.package(url: "https://github.com/vapor/sql.git", .branch("master")),
13-
.package(url: "https://github.com/vapor/nio-kit.git", .branch("master")),
10+
.package(url: "https://github.com/vapor/postgres-nio.git", from: "1.0.0-alpha"),
11+
.package(url: "https://github.com/vapor/sql-kit.git", from: "3.0.0-alpha"),
12+
.package(url: "https://github.com/vapor/async-kit.git", from: "1.0.0-alpha"),
1413
],
1514
targets: [
16-
.target(name: "PostgresKit", dependencies: ["NIOKit", "NIOPostgres", "SQLKit"]),
15+
.target(name: "PostgresKit", dependencies: ["AsyncKit", "PostgresNIO", "SQLKit"]),
1716
.testTarget(name: "PostgresKitTests", dependencies: ["PostgresKit", "SQLKitBenchmark"]),
18-
.target(name: "PostgresKitPerformance", dependencies: ["PostgresKit"]),
1917
]
2018
)

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<p align="center">
2-
<img src="https://user-images.githubusercontent.com/1342803/43222823-387a185a-901f-11e8-9582-84ba7af7bf5f.png" height="64" alt="PostgreSQL">
2+
<img src="https://user-images.githubusercontent.com/1342803/59063319-d190f500-8875-11e9-8fe6-16197dd56d0f.png" alt="PostgresKit">
33
<br>
44
<br>
5-
<a href="http://docs.vapor.codes/3.0/">
6-
<img src="http://img.shields.io/badge/read_the-docs-2196f3.svg" alt="Documentation">
5+
<a href="https://api.vapor.codes/postgres-kit/master/PostgresKit/index.html">
6+
<img src="http://img.shields.io/badge/api-docs-2196f3.svg" alt="Documentation">
77
</a>
88
<a href="https://discord.gg/vapor">
99
<img src="https://img.shields.io/discord/431917998102675485.svg" alt="Team Chat">
1010
</a>
1111
<a href="LICENSE">
1212
<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License">
1313
</a>
14-
<a href="https://circleci.com/gh/vapor/postgresql">
15-
<img src="https://circleci.com/gh/vapor/postgresql.svg?style=shield" alt="Continuous Integration">
14+
<a href="https://circleci.com/gh/vapor/postgres-kit">
15+
<img src="https://circleci.com/gh/vapor/postgres-kit.svg?style=shield" alt="Continuous Integration">
1616
</a>
1717
<a href="https://swift.org">
1818
<img src="http://img.shields.io/badge/swift-5-brightgreen.svg" alt="Swift 5">

Sources/PostgresKit/Exports.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
@_exported import NIOPostgres
2-
@_exported import NIOKit
1+
@_exported import AsyncKit
2+
@_exported import PostgresNIO
33
@_exported import SQLKit
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
extension PostgresConnection: SQLDatabase { }
2+
3+
extension SQLDatabase where Self: PostgresClient {
4+
public func execute(sql query: SQLExpression, _ onRow: @escaping (SQLRow) throws -> ()) -> EventLoopFuture<Void> {
5+
var serializer = SQLSerializer(dialect: PostgresDialect())
6+
query.serialize(to: &serializer)
7+
do {
8+
return try self.query(serializer.sql, serializer.binds.map { encodable in
9+
return try PostgresDataEncoder().encode(encodable)
10+
}) { row in
11+
try onRow(row)
12+
}
13+
} catch {
14+
return self.eventLoop.makeFailedFuture(error)
15+
}
16+
}
17+
}
18+
19+
extension ConnectionPool: SQLDatabase where Source.Connection: SQLDatabase {
20+
public func execute(sql query: SQLExpression, _ onRow: @escaping (SQLRow) throws -> ()) -> EventLoopFuture<Void> {
21+
return self.withConnection { $0.execute(sql: query, onRow) }
22+
}
23+
}
24+
25+
extension ConnectionPool: PostgresClient where Source.Connection: PostgresClient {
26+
public var eventLoop: EventLoop {
27+
return self.source.eventLoop
28+
}
29+
30+
public func send(_ request: PostgresRequest) -> EventLoopFuture<Void> {
31+
return self.withConnection { $0.send(request) }
32+
}
33+
}

0 commit comments

Comments
 (0)