Skip to content

Commit 5230817

Browse files
authored
Explicitly handle a custom ID key set to the empty string (#197)
* Add the composite ID benchmark tests. * CI update * Drop support for Swift 5.2 and 5.3 * Require current version of Fluent
1 parent b06c5bf commit 5230817

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

.github/workflows/test.yml

+9-14
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@ jobs:
1515
- md5
1616
- scram-sha-256
1717
swiftver:
18-
- swift:5.2
18+
- swift:5.4
1919
- swift:5.5
2020
- swift:5.6
2121
- swiftlang/swift:nightly-main
2222
swiftos:
2323
- focal
24-
include:
25-
- swiftver: swift:5.2
26-
test_flag: --enable-test-discovery
2724
container: ${{ format('{0}-{1}', matrix.swiftver, matrix.swiftos) }}
2825
runs-on: ubuntu-latest
2926
env:
@@ -57,8 +54,8 @@ jobs:
5754
steps:
5855
- name: Check out package
5956
uses: actions/checkout@v3
60-
- name: Run all tests with Thread Sanitizer
61-
run: swift test ${{ matrix.test_flag }} --sanitize=thread
57+
- name: Run all tests
58+
run: swift test
6259

6360
macos-all:
6461
strategy:
@@ -69,10 +66,10 @@ jobs:
6966
- postgresql@14
7067
dbauth:
7168
- scram-sha-256
72-
xcode:
73-
- latest-stable
74-
#- latest
75-
runs-on: macos-11
69+
macos: ['macos-11', 'macos-12']
70+
xcode: ['latest-stable', 'latest']
71+
exclude: [{ macos: 'macos-11', xcode: 'latest' }]
72+
runs-on: ${{ matrix.macos }}
7673
env:
7774
LOG_LEVEL: debug
7875
POSTGRES_HOSTNAME_A: 127.0.0.1
@@ -103,7 +100,5 @@ jobs:
103100
timeout-minutes: 2
104101
- name: Checkout code
105102
uses: actions/checkout@v3
106-
- name: Run all tests with Thread Sanitizer
107-
run: |
108-
swift test --sanitize=thread -Xlinker -rpath \
109-
-Xlinker $(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx
103+
- name: Run all tests
104+
run: swift test

Package.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.2
1+
// swift-tools-version:5.4
22
import PackageDescription
33

44
let package = Package(
@@ -11,7 +11,7 @@ let package = Package(
1111
],
1212
dependencies: [
1313
.package(url: "https://github.com/vapor/async-kit.git", from: "1.2.0"),
14-
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.0.0"),
14+
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.27.0"),
1515
.package(url: "https://github.com/vapor/postgres-kit.git", from: "2.5.1"),
1616
],
1717
targets: [

Sources/FluentPostgresDriver/FluentPostgresDatabase.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extension _FluentPostgresDatabase: Database {
1818
var expression = SQLQueryConverter(delegate: PostgresConverterDelegate())
1919
.convert(query)
2020
switch query.action {
21-
case .create:
21+
case .create where query.customIDKey != .string(""):
2222
expression = PostgresReturningID(
2323
base: expression,
2424
idKey: query.customIDKey ?? .id

Tests/FluentPostgresDriverTests/FluentPostgresDriverTests.swift

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ final class FluentPostgresDriverTests: XCTestCase {
1313
func testChildren() throws { try self.benchmarker.testChildren() }
1414
func testChunk() throws { try self.benchmarker.testChunk() }
1515
func testCodable() throws { try self.benchmarker.testCodable() }
16+
func testCompositeID() throws { try self.benchmarker.testCompositeID() }
1617
func testCRUD() throws { try self.benchmarker.testCRUD() }
1718
func testEagerLoad() throws { try self.benchmarker.testEagerLoad() }
1819
func testEnum() throws { try self.benchmarker.testEnum() }

0 commit comments

Comments
 (0)