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 36ab616

Browse files
Release Candidate 1 (#140)
* rc 1 * update ci
1 parent 4265268 commit 36ab616

File tree

8 files changed

+97
-108
lines changed

8 files changed

+97
-108
lines changed

‎.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: test
22
on:
33
- pull_request
44
jobs:
5-
xenial:
5+
fluent-postgres-driver_xenial:
66
container:
77
image: vapor/swift:5.2-xenial
88
services:
@@ -20,7 +20,7 @@ jobs:
2020
- run: swift test --enable-test-discovery --sanitize=thread
2121
env:
2222
POSTGRES_HOSTNAME: psql
23-
bionic:
23+
fluent-postgres-driver_bionic:
2424
container:
2525
image: vapor/swift:5.2-bionic
2626
services:

‎Package.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
// swift-tools-version:5.1
1+
// swift-tools-version:5.2
22
import PackageDescription
33

44
let package = Package(
55
name: "fluent-postgres-driver",
66
platforms: [
7-
.macOS(.v10_14)
7+
.macOS(.v10_15)
88
],
99
products: [
1010
.library(name: "FluentPostgresDriver", targets: ["FluentPostgresDriver"]),
1111
],
1212
dependencies: [
13-
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.0.0-beta.5"),
14-
.package(url: "https://github.com/vapor/postgres-kit.git", from: "2.0.0-beta.2"),
13+
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.0.0-rc.1"),
14+
.package(url: "https://github.com/vapor/postgres-kit.git", from: "2.0.0-rc.1"),
1515
],
1616
targets: [
1717
.target(name: "FluentPostgresDriver", dependencies: [
18-
"FluentKit",
19-
"FluentSQL",
20-
"PostgresKit",
18+
.product(name:"FluentKit",package:"fluent-kit"),
19+
.product(name:"FluentSQL",package:"fluent-kit"),
20+
.product(name:"PostgresKit",package:"postgres-kit"),
2121
]),
2222
.testTarget(name: "FluentPostgresDriverTests", dependencies: [
23-
"FluentBenchmark",
24-
"FluentPostgresDriver",
23+
.product(name:"FluentBenchmark",package:"fluent-kit"),
24+
.target(name:"FluentPostgresDriver"),
2525
]),
2626
]
2727
)

‎README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
<p align="center">
2-
<img src="https://user-images.githubusercontent.com/1342803/59065097-ec656880-8879-11e9-9e80-2e393dc313c1.png" alt="FluentPostgresDriver">
2+
<img
3+
src="https://user-images.githubusercontent.com/1342803/59065097-ec656880-8879-11e9-9e80-2e393dc313c1.png"
4+
height="64"
5+
alt="FluentPostgresDriver"
6+
>
37
<br>
48
<br>
5-
<a href="https://api.vapor.codes/fluent-postgres-driver/master/FluentPostgresDriver/index.html">
6-
<img src="http://img.shields.io/badge/api-docs-2196f3.svg" alt="Documentation">
9+
<a href="https://docs.vapor.codes/4.0/">
10+
<img src="http://img.shields.io/badge/read_the-docs-2196f3.svg" alt="Documentation">
711
</a>
812
<a href="https://discord.gg/vapor">
913
<img src="https://img.shields.io/discord/431917998102675485.svg" alt="Team Chat">
1014
</a>
1115
<a href="LICENSE">
1216
<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License">
1317
</a>
14-
<a href="https://circleci.com/gh/vapor/fluent-postgres-driver">
15-
<img src="https://circleci.com/gh/vapor/fluent-postgres-driver.svg?style=shield" alt="Continuous Integration">
18+
<a href="https://github.com/vapor/fluent-postgres-driver/actions">
19+
<img src="https://github.com/vapor/fluent-postgres-driver/workflows/test/badge.svg" alt="Continuous Integration">
1620
</a>
1721
<a href="https://swift.org">
18-
<img src="http://img.shields.io/badge/swift-5.1-brightgreen.svg" alt="Swift 5.1">
22+
<img src="http://img.shields.io/badge/swift-5.2-brightgreen.svg" alt="Swift 5.2">
1923
</a>
2024
</p>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
extension DatabaseConfigurationFactory {
2+
public static func postgres(
3+
url: URL,
4+
maxConnectionsPerEventLoop: Int = 1
5+
) throws -> DatabaseConfigurationFactory {
6+
guard let configuration = PostgresConfiguration(url: url) else {
7+
throw FluentPostgresError.invalidURL(url)
8+
}
9+
return .postgres(
10+
configuration: configuration,
11+
maxConnectionsPerEventLoop: maxConnectionsPerEventLoop
12+
)
13+
}
14+
15+
public static func postgres(
16+
hostname: String,
17+
port: Int = 5432,
18+
username: String,
19+
password: String,
20+
database: String? = nil,
21+
tlsConfiguration: TLSConfiguration? = nil,
22+
maxConnectionsPerEventLoop: Int = 1
23+
) -> DatabaseConfigurationFactory {
24+
return .postgres(
25+
configuration: .init(
26+
hostname: hostname,
27+
port: port,
28+
username: username,
29+
password: password,
30+
database: database,
31+
tlsConfiguration: tlsConfiguration
32+
),
33+
maxConnectionsPerEventLoop: maxConnectionsPerEventLoop
34+
)
35+
}
36+
37+
public static func postgres(
38+
configuration: PostgresConfiguration,
39+
maxConnectionsPerEventLoop: Int = 1
40+
) -> DatabaseConfigurationFactory {
41+
return DatabaseConfigurationFactory {
42+
FluentPostgresConfiguration(
43+
middleware: [],
44+
configuration: configuration,
45+
maxConnectionsPerEventLoop: maxConnectionsPerEventLoop
46+
)
47+
}
48+
}
49+
}
50+
51+
struct FluentPostgresConfiguration: DatabaseConfiguration {
52+
var middleware: [AnyModelMiddleware]
53+
let configuration: PostgresConfiguration
54+
let maxConnectionsPerEventLoop: Int
55+
56+
func makeDriver(for databases: Databases) -> DatabaseDriver {
57+
let db = PostgresConnectionSource(
58+
configuration: configuration
59+
)
60+
let pool = EventLoopGroupConnectionPool(
61+
source: db,
62+
maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
63+
on: databases.eventLoopGroup
64+
)
65+
return _FluentPostgresDriver(pool: pool)
66+
}
67+
}

‎Sources/FluentPostgresDriver/FluentPostgresDriver.swift

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,3 @@
1-
extension DatabaseConfigurationFactory {
2-
public static func postgres(
3-
url: URL,
4-
maxConnectionsPerEventLoop: Int = 1
5-
) throws -> DatabaseConfigurationFactory {
6-
guard let configuration = PostgresConfiguration(url: url) else {
7-
throw FluentPostgresError.invalidURL(url)
8-
}
9-
return .postgres(
10-
configuration: configuration,
11-
maxConnectionsPerEventLoop: maxConnectionsPerEventLoop
12-
)
13-
}
14-
15-
public static func postgres(
16-
hostname: String,
17-
port: Int = 5432,
18-
username: String,
19-
password: String,
20-
database: String? = nil,
21-
tlsConfiguration: TLSConfiguration? = nil,
22-
maxConnectionsPerEventLoop: Int = 1
23-
) -> DatabaseConfigurationFactory {
24-
return .postgres(
25-
configuration: .init(
26-
hostname: hostname,
27-
port: port,
28-
username: username,
29-
password: password,
30-
database: database,
31-
tlsConfiguration: tlsConfiguration
32-
),
33-
maxConnectionsPerEventLoop: maxConnectionsPerEventLoop
34-
)
35-
}
36-
37-
public static func postgres(
38-
configuration: PostgresConfiguration,
39-
maxConnectionsPerEventLoop: Int = 1
40-
) -> DatabaseConfigurationFactory {
41-
return DatabaseConfigurationFactory {
42-
FluentPostgresConfiguration(
43-
middleware: [],
44-
configuration: configuration,
45-
maxConnectionsPerEventLoop: maxConnectionsPerEventLoop
46-
)
47-
}
48-
}
49-
}
50-
51-
struct FluentPostgresConfiguration: DatabaseConfiguration {
52-
var middleware: [AnyModelMiddleware]
53-
let configuration: PostgresConfiguration
54-
let maxConnectionsPerEventLoop: Int
55-
56-
func makeDriver(for databases: Databases) -> DatabaseDriver {
57-
let db = PostgresConnectionSource(
58-
configuration: configuration
59-
)
60-
let pool = EventLoopGroupConnectionPool(
61-
source: db,
62-
maxConnectionsPerEventLoop: maxConnectionsPerEventLoop,
63-
on: databases.eventLoopGroup
64-
)
65-
return _FluentPostgresDriver(pool: pool)
66-
}
67-
68-
69-
}
70-
711
enum FluentPostgresError: Error {
722
case invalidURL(URL)
733
}

‎Sources/FluentPostgresDriver/PostgresConverterDelegate.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,4 @@ struct PostgresConverterDelegate: SQLConverterDelegate {
2323
return nil
2424
}
2525
}
26-
27-
func nestedFieldExpression(_ column: String, _ path: [String]) -> SQLExpression {
28-
switch path.count {
29-
case 1:
30-
return SQLRaw("\(column)->>'\(path[0])'")
31-
case 2...:
32-
let inner = path[0..<path.count - 1].map { "'\(0ドル)'" }.joined(separator: "->")
33-
return SQLRaw("\(column)->\(inner)->>'\(path.last!)'")
34-
default:
35-
fatalError()
36-
}
37-
}
3826
}

‎Sources/FluentPostgresDriver/PostgresRow+Database.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ private struct _PostgresDatabaseOutput: DatabaseOutput {
1919
self.row.description
2020
}
2121

22-
func contains(_ field:FieldKey) -> Bool {
23-
return self.row.column(self.column(field)) != nil
22+
func contains(_ path:[FieldKey]) -> Bool {
23+
return self.row.column(self.columnName(path)) != nil
2424
}
2525

2626
func schema(_ schema: String) -> DatabaseOutput {
@@ -32,18 +32,20 @@ private struct _PostgresDatabaseOutput: DatabaseOutput {
3232
}
3333

3434
func decode<T>(
35-
_ field:FieldKey,
35+
_ path:[FieldKey],
3636
as type: T.Type
3737
) throws -> T where T : Decodable {
3838
try self.row.sql(decoder: self.decoder)
39-
.decode(column: self.column(field), as: T.self)
39+
.decode(column: self.columnName(path), as: T.self)
4040
}
4141

42-
private func column(_ field: FieldKey) -> String {
42+
private func columnName(_ path: [FieldKey]) -> String {
43+
let field = path.map { 0ドル.description }.joined(separator: "_")
4344
if let schema = self.schema {
44-
return schema +"_"+field.description
45+
return "\(schema)_\(field)"
4546
} else {
46-
return field.description
47+
return field
4748
}
49+
4850
}
4951
}

‎Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ final class FluentPostgresDriverTests: XCTestCase {
1010
func testBatch() throws { try self.benchmarker.testBatch() }
1111
func testChildren() throws { try self.benchmarker.testChildren() }
1212
func testChunk() throws { try self.benchmarker.testChunk() }
13-
func testCompoundField() throws { try self.benchmarker.testCompoundField() }
1413
func testCRUD() throws { try self.benchmarker.testCRUD() }
1514
func testEagerLoad() throws { try self.benchmarker.testEagerLoad() }
1615
func testEnum() throws { try self.benchmarker.testEnum() }
@@ -21,7 +20,6 @@ final class FluentPostgresDriverTests: XCTestCase {
2120
func testMiddleware() throws { try self.benchmarker.testMiddleware() }
2221
func testMigrator() throws { try self.benchmarker.testMigrator() }
2322
func testModel() throws { try self.benchmarker.testModel() }
24-
func testNestedField() throws { try self.benchmarker.testNestedField() }
2523
func testOptionalParent() throws { try self.benchmarker.testOptionalParent() }
2624
func testPagination() throws { try self.benchmarker.testPagination() }
2725
func testParent() throws { try self.benchmarker.testParent() }

0 commit comments

Comments
(0)

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