Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 88f2b00

Browse files
nio 2 convergence + test updates (vapor#107)
1 parent 85dff95 commit 88f2b00

File tree

4 files changed

+87
-17
lines changed

4 files changed

+87
-17
lines changed

‎Sources/FluentPostgresDriver/Postgres+Fluent.swift‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,38 @@ extension Databases {
2222
}
2323
}
2424

25-
extension ConnectionPool: Database where Source.Connection: SQLDatabase {
25+
extension ConnectionPool: Database where Source.Connection: Database {
2626
public var eventLoop: EventLoop {
2727
return self.source.eventLoop
2828
}
29+
30+
public func execute(_ schema: DatabaseSchema) -> EventLoopFuture<Void> {
31+
return self.withConnection { 0ドル.execute(schema) }
32+
}
33+
34+
public func execute(_ query: DatabaseQuery, _ onOutput: @escaping (DatabaseOutput) throws -> ()) -> EventLoopFuture<Void> {
35+
return self.withConnection { 0ドル.execute(query, onOutput) }
36+
}
37+
38+
public func close() -> EventLoopFuture<Void> {
39+
#warning("TODO: implement connectionPool.close()")
40+
fatalError("")
41+
}
42+
43+
public func transaction<T>(_ closure: @escaping (Database) -> EventLoopFuture<T>) -> EventLoopFuture<T> {
44+
return self.withConnection { conn in
45+
return closure(conn)
46+
}
47+
}
2948
}
30-
extension PostgresConnection: Database { }
3149

32-
extension Database where Self: SQLDatabase {
50+
extension PostgresError: DatabaseError { }
51+
52+
extension PostgresConnection: Database {
53+
public func transaction<T>(_ closure: @escaping (Database) -> EventLoopFuture<T>) -> EventLoopFuture<T> {
54+
return closure(self)
55+
}
56+
3357
public func execute(_ query: DatabaseQuery, _ onOutput: @escaping (DatabaseOutput) throws -> ()) -> EventLoopFuture<Void> {
3458
var sql = SQLQueryConverter().convert(query)
3559
switch query.action {

‎Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ final class FluentPostgresDriverTests: XCTestCase {
3838
}
3939

4040
func testEagerLoadSubqueryJSONEncode() throws {
41-
#warning("TODO: fix connection pool alg")
4241
try self.benchmarker.testEagerLoadSubqueryJSONEncode()
4342
}
4443

4544
func testEagerLoadJoinJSONEncode() throws {
46-
#warning("TODO: fix connection pool alg")
4745
try self.benchmarker.testEagerLoadJoinJSONEncode()
4846
}
4947

@@ -74,10 +72,22 @@ final class FluentPostgresDriverTests: XCTestCase {
7472
func testAggregates() throws {
7573
try self.benchmarker.testAggregates()
7674
}
77-
//
78-
// func testWorkUnit() throws {
79-
// try self.benchmarker.testWorkUnit()
80-
// }
75+
76+
func testIdentifierGeneration() throws {
77+
try self.benchmarker.testIdentifierGeneration()
78+
}
79+
80+
func testNullifyField() throws {
81+
try self.benchmarker.testNullifyField()
82+
}
83+
84+
func testChunkedFetch() throws {
85+
try self.benchmarker.testChunkedFetch()
86+
}
87+
88+
func testUniqueFields() throws {
89+
try self.benchmarker.testUniqueFields()
90+
}
8191

8292
override func setUp() {
8393
let eventLoop = MultiThreadedEventLoopGroup(numberOfThreads: 1).next()
@@ -99,8 +109,4 @@ final class FluentPostgresDriverTests: XCTestCase {
99109
let pool = ConnectionPool(config: .init(maxConnections: 1), source: db)
100110
self.benchmarker = FluentBenchmarker(database: pool)
101111
}
102-
103-
static let allTests = [
104-
("testAll", testAll),
105-
]
106112
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#if !canImport(ObjectiveC)
2+
import XCTest
3+
4+
extension FluentPostgresDriverTests {
5+
// DO NOT MODIFY: This is autogenerated, use:
6+
// `swift test --generate-linuxmain`
7+
// to regenerate.
8+
static let __allTests__FluentPostgresDriverTests = [
9+
("testAggregates", testAggregates),
10+
("testAll", testAll),
11+
("testBatchCreate", testBatchCreate),
12+
("testBatchUpdate", testBatchUpdate),
13+
("testChunkedFetch", testChunkedFetch),
14+
("testCreate", testCreate),
15+
("testDelete", testDelete),
16+
("testEagerLoadChildren", testEagerLoadChildren),
17+
("testEagerLoadJoinJSONEncode", testEagerLoadJoinJSONEncode),
18+
("testEagerLoadParent", testEagerLoadParent),
19+
("testEagerLoadParentJoin", testEagerLoadParentJoin),
20+
("testEagerLoadSubqueryJSONEncode", testEagerLoadSubqueryJSONEncode),
21+
("testIdentifierGeneration", testIdentifierGeneration),
22+
("testJoin", testJoin),
23+
("testMigrator", testMigrator),
24+
("testMigratorError", testMigratorError),
25+
("testNestedModel", testNestedModel),
26+
("testNullifyField", testNullifyField),
27+
("testRead", testRead),
28+
("testUniqueFields", testUniqueFields),
29+
("testUpdate", testUpdate),
30+
]
31+
}
32+
33+
public func __allTests() -> [XCTestCaseEntry] {
34+
return [
35+
testCase(FluentPostgresDriverTests.__allTests__FluentPostgresDriverTests),
36+
]
37+
}
38+
#endif

‎Tests/LinuxMain.swift‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import XCTest
2-
@testable import FluentPostgresDriverTests
32

4-
XCTMain([
5-
testCase(FluentPostgresDriverTests.allTests),
6-
])
3+
import FluentPostgresDriverTests
4+
5+
var tests = [XCTestCaseEntry]()
6+
tests += FluentPostgresDriverTests.__allTests()
7+
8+
XCTMain(tests)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /