Skip to content

Commit

Permalink
Declare UPSERT support for PostgreSQL (#212)
Browse files Browse the repository at this point in the history
* Declare UPSERT support for PostgreSQL.

* Quickie CI update

* Prevent slow-start with SCRAM-SHA-256 auth from failing performance tests
  • Loading branch information
gwynne authored Nov 4, 2021
1 parent a050d33 commit 8e5fc0e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
fail-fast: false
matrix:
dbimage:
- postgres:14
- postgres:13
- postgres:12
- postgres:11
Expand All @@ -22,7 +23,6 @@ jobs:
- 'swiftlang/swift:nightly-main'
swiftos:
- focal
- amazonlinux2
dependent:
- fluent-postgres-driver
container: ${{ format('{0}-{1}', matrix.swiftver, matrix.swiftos) }}
Expand Down Expand Up @@ -50,12 +50,6 @@ jobs:
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.dbauth }}
POSTGRES_INITDB_ARGS: --auth-host=${{ matrix.dbauth }}
steps:
- name: Workaround SPM incompatibility with old Git on CentOS 7
if: ${{ contains(matrix.swiftos, 'centos7') }}
run: |
yum install -y make libcurl-devel
git clone https://github.com/git/git -bv2.28.0 --depth 1 && cd git
make prefix=/usr -j all install NO_OPENSSL=1 NO_EXPAT=1 NO_TCLTK=1 NO_GETTEXT=1 NO_PERL=1
- name: Check out package
uses: actions/checkout@v2
with:
Expand All @@ -81,7 +75,7 @@ jobs:
matrix:
xcode:
- latest-stable
- latest
#- latest
dbauth:
- trust
- md5
Expand All @@ -90,9 +84,10 @@ jobs:
- postgresql@11
- postgresql@12
- postgresql@13
- postgresql@14
dependent:
- fluent-postgres-driver
runs-on: macos-latest
runs-on: macos-11
env:
LOG_LEVEL: debug
POSTGRES_HOSTNAME: 127.0.0.1
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/vapor/postgres-nio.git", from: "1.4.0"),
.package(url: "https://github.com/vapor/sql-kit.git", from: "3.5.0"),
.package(url: "https://github.com/vapor/sql-kit.git", from: "3.12.0"),
.package(url: "https://github.com/vapor/async-kit.git", from: "1.0.0"),
],
targets: [
Expand Down
4 changes: 4 additions & 0 deletions Sources/PostgresKit/PostgresDialect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ public struct PostgresDialect: SQLDialect {
alterColumnDefinitionTypeKeyword: SQLRaw("SET DATA TYPE")
)
}

public var upsertSyntax: SQLUpsertSyntax {
.standard
}
}
8 changes: 8 additions & 0 deletions Tests/PostgresKitTests/PostgresKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ class PostgresKitTests: XCTestCase {
on: self.eventLoopGroup
)
defer { pool.shutdown() }
// Postgres seems to take much longer on initial connections when using SCRAM-SHA-256 auth,
// which causes XCTest to bail due to the first measurement having a very high deviation.
// Spin the pool a bit before running the measurement to warm it up.
for _ in 1...25 {
_ = try! pool.withConnection { conn in
return conn.query("SELECT 1;")
}.wait()
}
self.measure {
for _ in 1...100 {
_ = try! pool.withConnection { conn in
Expand Down

0 comments on commit 8e5fc0e

Please sign in to comment.