Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vapor/postgres-kit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.0-rc.1.0.1
Choose a base ref
...
head repository: vapor/postgres-kit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref

Commits on Mar 2, 2018

  1. nio

    tanner0101 committed Mar 2, 2018
    Copy the full SHA
    027838d View commit details
  2. nio encoder/decoder

    tanner0101 committed Mar 2, 2018
    Copy the full SHA
    fa640ea View commit details
  3. add nio deps to circleci

    tanner0101 committed Mar 2, 2018
    Copy the full SHA
    d051b78 View commit details
  4. bump

    tanner0101 committed Mar 2, 2018
    Copy the full SHA
    d0a7c82 View commit details
  5. update linux main

    tanner0101 committed Mar 2, 2018
    Copy the full SHA
    52a43c7 View commit details

Commits on Mar 3, 2018

  1. Copy the full SHA
    31a0fb8 View commit details
  2. nio updates

    tanner0101 committed Mar 3, 2018
    Copy the full SHA
    f362d4c View commit details
  3. Copy the full SHA
    9f90100 View commit details

Commits on Mar 6, 2018

  1. Copy the full SHA
    7a50dfd View commit details

Commits on Mar 7, 2018

  1. Copy the full SHA
    1a0855e View commit details
  2. organization updates

    tanner0101 committed Mar 7, 2018
    Copy the full SHA
    6080505 View commit details
  3. add isnull to psql data

    tanner0101 committed Mar 7, 2018
    Copy the full SHA
    49f6676 View commit details
  4. fix tests

    tanner0101 committed Mar 7, 2018
    Copy the full SHA
    a81d233 View commit details
  5. Merge pull request #27 from vapor/mysql-nio

    nio cleanup
    tanner0101 authored Mar 7, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    83333e7 View commit details
  6. changed method signature, per @tanner0101

    Shaun Hubbard committed Mar 7, 2018
    Copy the full SHA
    bd3d280 View commit details

Commits on Mar 8, 2018

  1. bytebuffer updates

    tanner0101 committed Mar 8, 2018
    Copy the full SHA
    54ea05c View commit details
  2. publicize rawrep

    tanner0101 committed Mar 8, 2018
    Copy the full SHA
    efba3a4 View commit details

Commits on Mar 13, 2018

  1. Add support for persisting dates with microsecond precision.

    Note that I have not made parsing the textual format of the timestamp type more accurate - do we need that? If so, where is that format documented?
    MrMage committed Mar 13, 2018
    Copy the full SHA
    c36db27 View commit details
  2. Merge pull request #29 from MrMage/fix-date-format

    Add support for persisting dates with microsecond precision
    tanner0101 authored Mar 13, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    42fbe05 View commit details

Commits on Mar 14, 2018

  1. Fix a memory leak in PostgreSQLConnection

    `PostgreSQLTableNameCache` holds a `PostgreSQLConnection` future. Once that future is fulfilled, it strongly holds a reference to `PostgreSQLConnection`. That connection in turn holds the table name cache, so we have a reference cycle. This causes the table name cache and its connection to never get released. This is relevant when testing, if the tests are set up such that each test creates a new `Database`.
    MrMage authored Mar 14, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a3f4297 View commit details
  2. Merge pull request #31 from vapor/nio-connection-leak-1

    Fix a memory leak in `PostgreSQLConnection`
    tanner0101 authored Mar 14, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a4e81ae View commit details
  3. Merge pull request #25 from pedantix/swh-add-connection-string-to-config

    added connection string parsing for PostgreSQLDatabaseConfig
    tanner0101 authored Mar 14, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c2b4be0 View commit details
  4. Copy the full SHA
    265fba3 View commit details
  5. Copy the full SHA
    dfad288 View commit details
  6. update ci psql deps

    tanner0101 committed Mar 14, 2018
    Copy the full SHA
    9837294 View commit details
  7. Copy the full SHA
    d75533d View commit details
  8. embedded event loop

    tanner0101 committed Mar 14, 2018
    Copy the full SHA
    bbacbae View commit details

Commits on Mar 15, 2018

  1. Copy the full SHA
    31be47f View commit details
  2. trigger ci

    tanner0101 committed Mar 15, 2018
    Copy the full SHA
    65c3e12 View commit details
  3. add table name cache test

    tanner0101 committed Mar 15, 2018
    Copy the full SHA
    c9b7afa View commit details

Commits on Mar 18, 2018

  1. Copy the full SHA
    4f5c24b View commit details

Commits on Mar 20, 2018

  1. Close a PostgreSQLConnection's channel on deinit.

    Otherwise, the connection is never claused, and PostgreSQL might complain about too many open connections.
    MrMage committed Mar 20, 2018
    Copy the full SHA
    b70b73c View commit details

Commits on Mar 21, 2018

  1. remove table name cache

    tanner0101 committed Mar 21, 2018
    Copy the full SHA
    9c9bb11 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    93444ff View commit details
  3. Merge pull request #32 from vapor/query-pipeline-bug24

    combines parameterized query phases
    tanner0101 authored Mar 21, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    96abdce View commit details
  4. Merge pull request #36 from vapor/close-connection-on-deinit

    Close a `PostgreSQLConnection`'s channel on deinit.
    tanner0101 authored Mar 21, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e4d26fd View commit details
  5. Merge pull request #34 from vapor/default-port

    Default Postgres port to 5432 when not supplied
    tanner0101 authored Mar 21, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9c2079d View commit details
  6. Merge pull request #23 from vapor/nio

    nio
    tanner0101 authored Mar 21, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1823a1c View commit details
  7. Copy the full SHA
    dcfe5f0 View commit details
  8. rc.2 updates

    tanner0101 committed Mar 21, 2018
    Copy the full SHA
    afc9853 View commit details
  9. Merge pull request #38 from vapor/remove-on

    Remove an unused argument in PostgreSQLDatabase.init
    tanner0101 authored Mar 21, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f710161 View commit details
  10. trigger ci

    tanner0101 committed Mar 21, 2018
    Copy the full SHA
    19c7c89 View commit details

Commits on Mar 22, 2018

  1. fix core import

    tanner0101 committed Mar 22, 2018
    Copy the full SHA
    387cf9e View commit details

Commits on Mar 23, 2018

  1. update to crypto rc 3

    tanner0101 committed Mar 23, 2018
    Copy the full SHA
    64f9c20 View commit details

Commits on Mar 29, 2018

  1. add decimal support

    tanner0101 committed Mar 29, 2018
    Copy the full SHA
    390c22c View commit details

Commits on Mar 31, 2018

  1. Merge pull request #1 from vapor/master

    Sync
    pedantix authored Mar 31, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0267e10 View commit details
  2. Add Listen/Notify functionality to PostgreSQL

    Shaun Hubbard committed Mar 31, 2018
    Copy the full SHA
    97ccb06 View commit details
  3. D'OH

    Shaun Hubbard committed Mar 31, 2018
    Copy the full SHA
    439395d View commit details
  4. Double D'Oh

    Shaun Hubbard committed Mar 31, 2018
    Copy the full SHA
    b35c295 View commit details

Commits on Apr 1, 2018

  1. should not pop the message handler... my bad

    Shaun Hubbard committed Apr 1, 2018
    Copy the full SHA
    5541222 View commit details
Showing with 2,660 additions and 3,176 deletions.
  1. +8 −0 .github/CODEOWNERS
  2. +10 −0 .github/dependabot.yml
  3. +14 −0 .github/workflows/api-docs.yml
  4. +200 −0 .github/workflows/test.yml
  5. +3 −1 .gitignore
  6. +5 −0 .spi.yml
  7. +34 −22 Package.swift
  8. +47 −0 Package@swift-5.9.swift
  9. +136 −20 README.md
  10. +0 −77 Sources/PostgreSQL/Connection/PostgreSQLConnection+Query.swift
  11. +0 −35 Sources/PostgreSQL/Connection/PostgreSQLConnection+SimpleQuery.swift
  12. +0 −18 Sources/PostgreSQL/Connection/PostgreSQLConnection+TCP.swift
  13. +0 −130 Sources/PostgreSQL/Connection/PostgreSQLConnection.swift
  14. +0 −142 Sources/PostgreSQL/Data/PostgreSQLArrayCustomConvertible.swift
  15. +0 −86 Sources/PostgreSQL/Data/PostgreSQLData+BinaryFloatingPoint.swift
  16. +0 −42 Sources/PostgreSQL/Data/PostgreSQLData+Bool.swift
  17. +0 −49 Sources/PostgreSQL/Data/PostgreSQLData+Data.swift
  18. +0 −63 Sources/PostgreSQL/Data/PostgreSQLData+Date.swift
  19. +0 −104 Sources/PostgreSQL/Data/PostgreSQLData+FixedWidthInteger.swift
  20. +0 −32 Sources/PostgreSQL/Data/PostgreSQLData+Optional.swift
  21. +0 −68 Sources/PostgreSQL/Data/PostgreSQLData+Point.swift
  22. +0 −114 Sources/PostgreSQL/Data/PostgreSQLData+String.swift
  23. +0 −39 Sources/PostgreSQL/Data/PostgreSQLData+UUID.swift
  24. +0 −35 Sources/PostgreSQL/Data/PostgreSQLData.swift
  25. +0 −65 Sources/PostgreSQL/Data/PostgreSQLDataCustomConvertible.swift
  26. +0 −71 Sources/PostgreSQL/Data/PostgreSQLJSONCustomConvertible.swift
  27. +0 −120 Sources/PostgreSQL/DataType/PostgreSQLDataType.swift
  28. +0 −38 Sources/PostgreSQL/DataType/PostgreSQLFormatCode.swift
  29. +0 −42 Sources/PostgreSQL/Database/PostgreSQLDatabase.swift
  30. +0 −32 Sources/PostgreSQL/Database/PostgreSQLDatabaseConfig.swift
  31. +0 −5 Sources/PostgreSQL/Database/PostgreSQLLogger.swift
  32. +0 −1 Sources/PostgreSQL/Exports.swift
  33. +0 −285 Sources/PostgreSQL/Message+Parse/PostgreSQLMessageDecoder.swift
  34. +0 −48 Sources/PostgreSQL/Message+Parse/PostgreSQLMessageParser.swift
  35. +0 −259 Sources/PostgreSQL/Message+Serialize/PostgreSQLMessageEncoder.swift
  36. +0 −54 Sources/PostgreSQL/Message+Serialize/PostgreSQLMessageSerializer.swift
  37. +0 −45 Sources/PostgreSQL/Message/PostgreSQLAuthenticationRequest.swift
  38. +0 −17 Sources/PostgreSQL/Message/PostgreSQLBackendKeyData.swift
  39. +0 −31 Sources/PostgreSQL/Message/PostgreSQLBindRequest.swift
  40. +0 −35 Sources/PostgreSQL/Message/PostgreSQLClose.swift
  41. +0 −35 Sources/PostgreSQL/Message/PostgreSQLDataRow.swift
  42. +0 −32 Sources/PostgreSQL/Message/PostgreSQLDescribeRequest.swift
  43. +0 −121 Sources/PostgreSQL/Message/PostgreSQLErrorReponse.swift
  44. +0 −9 Sources/PostgreSQL/Message/PostgreSQLExecuteRequest.swift
  45. +0 −46 Sources/PostgreSQL/Message/PostgreSQLMessage.swift
  46. +0 −5 Sources/PostgreSQL/Message/PostgreSQLParameterDescription.swift
  47. +0 −14 Sources/PostgreSQL/Message/PostgreSQLParameterStatus.swift
  48. +0 −27 Sources/PostgreSQL/Message/PostgreSQLParameters.swift
  49. +0 −14 Sources/PostgreSQL/Message/PostgreSQLParseRequest.swift
  50. +0 −7 Sources/PostgreSQL/Message/PostgreSQLPasswordMessage.swift
  51. +0 −11 Sources/PostgreSQL/Message/PostgreSQLQuery.swift
  52. +0 −23 Sources/PostgreSQL/Message/PostgreSQLReadyForQuery.swift
  53. +0 −67 Sources/PostgreSQL/Message/PostgreSQLRowDescription.swift
  54. +0 −31 Sources/PostgreSQL/Message/PostgreSQLStartupMessage.swift
  55. +0 −29 Sources/PostgreSQL/PostgreSQLError.swift
  56. +0 −38 Sources/PostgreSQL/PostgreSQLProvider.swift
  57. +0 −79 Sources/PostgreSQL/Utilities.swift
  58. +50 −0 Sources/PostgresKit/ConnectionPool+Postgres.swift
  59. +307 −0 Sources/PostgresKit/Deprecations/PostgresColumnType.swift
  60. +91 −0 Sources/PostgresKit/Deprecations/PostgresConfiguration.swift
  61. +70 −0 Sources/PostgresKit/Deprecations/PostgresConnectionSource+PostgresConfiguration.swift
  62. +133 −0 Sources/PostgresKit/Deprecations/PostgresDataDecoder.swift
  63. +125 −0 Sources/PostgresKit/Deprecations/PostgresDataEncoder.swift
  64. +39 −0 Sources/PostgresKit/Deprecations/PostgresDatabase+SQL+Deprecated.swift
  65. +32 −0 Sources/PostgresKit/Docs.docc/PostgresKit.md
  66. +21 −0 Sources/PostgresKit/Docs.docc/Resources/vapor-postgreskit-logo.svg
  67. +21 −0 Sources/PostgresKit/Docs.docc/theme-settings.json
  68. +4 −0 Sources/PostgresKit/Exports.swift
  69. +42 −0 Sources/PostgresKit/PostgresConnectionSource.swift
  70. +444 −0 Sources/PostgresKit/PostgresDataTranslation.swift
  71. +109 −0 Sources/PostgresKit/PostgresDatabase+SQL.swift
  72. +118 −0 Sources/PostgresKit/PostgresDialect.swift
  73. +45 −0 Sources/PostgresKit/PostgresRow+SQL.swift
  74. +163 −0 Sources/PostgresKit/SQLPostgresConfiguration.swift
  75. +0 −7 Tests/LinuxMain.swift
  76. +0 −312 Tests/PostgreSQLTests/PostgreSQLConnectionTests.swift
  77. +0 −15 Tests/PostgreSQLTests/PostgreSQLMessageTests.swift
  78. +276 −0 Tests/PostgresKitTests/PostgresKitTests.swift
  79. +75 −0 Tests/PostgresKitTests/SQLPostgresConfigurationTests.swift
  80. +38 −0 Tests/PostgresKitTests/Utilities.swift
  81. +0 −29 circle.yml
8 changes: 8 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* @gwynne
/.github/CONTRIBUTING.md @gwynne @0xTim
/.github/workflows/*.yml @gwynne @0xTim
/.github/workflows/test.yml @gwynne
/.spi.yml @gwynne @0xTim
/.gitignore @gwynne @0xTim
/LICENSE @gwynne @0xTim
/README.md @gwynne @0xTim
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
groups:
dependencies:
patterns:
- "*"
14 changes: 14 additions & 0 deletions .github/workflows/api-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: deploy-api-docs
on:
push:
branches:
- main

jobs:
build-and-deploy:
uses: vapor/api-docs/.github/workflows/build-and-deploy-docs-workflow.yml@main
secrets: inherit
with:
package_name: postgres-kit
modules: PostgresKit
pathsToInvalidate: /postgreskit/*
200 changes: 200 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
name: test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request: { types: [opened, reopened, synchronize, ready_for_review] }
push: { branches: [ main ] }

env:
LOG_LEVEL: info
SWIFT_DETERMINISTIC_HASHING: 1
POSTGRES_HOSTNAME: 'psql-a'
POSTGRES_HOSTNAME_A: 'psql-a'
POSTGRES_HOSTNAME_B: 'psql-b'
POSTGRES_DB: 'test_database'
POSTGRES_DB_A: 'test_database'
POSTGRES_DB_B: 'test_database'
POSTGRES_USER: 'test_username'
POSTGRES_USER_A: 'test_username'
POSTGRES_USER_B: 'test_username'
POSTGRES_PASSWORD: 'test_password'
POSTGRES_PASSWORD_A: 'test_password'
POSTGRES_PASSWORD_B: 'test_password'

jobs:
api-breakage:
if: ${{ github.event_name == 'pull_request' && !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:jammy
steps:
- name: Checkout
uses: actions/checkout@v4
with: { 'fetch-depth': 0 }
- name: API breaking changes
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
swift package diagnose-api-breaking-changes origin/main
dependency-graph:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
container: swift:jammy
permissions:
contents: write
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Fix Git configuration
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
apt-get update && apt-get install -y curl
- name: Submit dependency graph
uses: vapor-community/swift-dependency-submission@v0.1

code-coverage:
if: ${{ !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:jammy
services:
psql-a:
image: postgres:16
env:
POSTGRES_USER: test_username
POSTGRES_DB: test_database
POSTGRES_PASSWORD: test_password
POSTGRES_HOST_AUTH_METHOD: scram-sha-256
POSTGRES_INITDB_ARGS: --auth-host=scram-sha-256
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Run unit tests for coverage data
run: swift test --enable-code-coverage
- name: Upload coverage data
uses: vapor/swift-codecov-action@v0.3
with:
codecov_token: ${{ secrets.CODECOV_TOKEN }}

# gh-codeql:
# if: ${{ !(github.event.pull_request.draft || false) }}
# runs-on: ubuntu-latest
# container:
# image: swift:5.10-jammy
# permissions: { actions: write, contents: read, security-events: write }
# timeout-minutes: 60
# steps:
# - name: Check out code
# uses: actions/checkout@v4
# - name: Mark repo safe in non-fake global config
# run: |
# git config --global --add safe.directory "${GITHUB_WORKSPACE}"
# - name: Initialize CodeQL
# uses: github/codeql-action/init@v3
# with: { languages: swift }
# - name: Perform build
# run: swift build
# - name: Run CodeQL analyze
# uses: github/codeql-action/analyze@v3

linux-unit:
if: ${{ !(github.event.pull_request.draft || false) }}
strategy:
fail-fast: false
matrix:
postgres-image:
- postgres:16
- postgres:14
- postgres:12
swift-image:
- swift:5.8-jammy
- swift:5.9-jammy
- swift:5.10-jammy
- swiftlang/swift:nightly-main-jammy
include:
- postgres-image: postgres:16
postgres-auth: scram-sha-256
- postgres-image: postgres:14
postgres-auth: md5
- postgres-image: postgres:12
postgres-auth: trust
runs-on: ubuntu-latest
container: ${{ matrix.swift-image }}
services:
psql-a:
image: ${{ matrix.postgres-image }}
env:
POSTGRES_USER: test_username
POSTGRES_DB: test_database
POSTGRES_PASSWORD: test_password
POSTGRES_HOST_AUTH_METHOD: ${{ matrix.postgres-auth }}
POSTGRES_INITDB_ARGS: --auth-host=${{ matrix.postgres-auth }}
steps:
- name: Check out package
uses: actions/checkout@v4
- name: Run local tests
run: swift test --sanitize=thread

linux-integration:
if: ${{ !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:5.10-jammy
services:
psql-a:
image: postgres:16
env:
POSTGRES_USER: test_username
POSTGRES_DB: test_database
POSTGRES_PASSWORD: test_password
POSTGRES_HOST_AUTH_METHOD: scram-sha-256
POSTGRES_INITDB_ARGS: --auth-host=scram-sha-256
psql-b:
image: postgres:15
env:
POSTGRES_USER: test_username
POSTGRES_DB: test_database
POSTGRES_PASSWORD: test_password
POSTGRES_HOST_AUTH_METHOD: scram-sha-256
POSTGRES_INITDB_ARGS: --auth-host=scram-sha-256
steps:
- name: Check out package
uses: actions/checkout@v4
with: { path: 'postgres-kit' }
- name: Check out fluent-postgres-driver dependent
uses: actions/checkout@v4
with: { repository: 'vapor/fluent-postgres-driver', path: 'fluent-postgres-driver' }
- name: Use local package
run: swift package --package-path fluent-postgres-driver edit postgres-kit --path postgres-kit
- name: Run fluent-postgres-kit tests
run: swift test --package-path fluent-postgres-driver --sanitize=thread

macos-unit:
if: ${{ !(github.event.pull_request.draft || false) }}
strategy:
fail-fast: false
matrix:
include:
- macos-version: macos-13
xcode-version: '~14.3'
- macos-version: macos-14
xcode-version: latest
runs-on: ${{ matrix.macos-version }}
env:
POSTGRES_HOSTNAME: 127.0.0.1
POSTGRES_DB: postgres
steps:
- name: Select latest available Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.xcode-version }}
- name: Install Postgres, setup DB and auth, and wait for server start
run: |
brew upgrade || true
export PATH="$(brew --prefix)/opt/postgresql@13/bin:$PATH" PGDATA=/tmp/vapor-postgres-test
(brew unlink postgresql@14 || true) && brew install "postgresql@13" && brew link --force "postgresql@13"
initdb --locale=C --auth-host "scram-sha-256" -U "${POSTGRES_USER}" --pwfile=<(echo "${POSTGRES_PASSWORD}")
pg_ctl start --wait
timeout-minutes: 15
- name: Checkout code
uses: actions/checkout@v4
- name: Run local tests
run: swift test --sanitize=thread
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -3,4 +3,6 @@
/Packages
/*.xcodeproj
Package.resolved

DerivedData
.swiftpm
Tests/LinuxMain.swift
5 changes: 5 additions & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: 1
metadata:
authors: "Maintained by the Vapor Core Team with hundreds of contributions from the Vapor Community."
external_links:
documentation: "https://api.vapor.codes/postgreskit/documentation/postgreskit/"
56 changes: 34 additions & 22 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
// swift-tools-version:4.0
// swift-tools-version:5.8
import PackageDescription

let package = Package(
name: "PostgreSQL",
name: "postgres-kit",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.watchOS(.v6),
.tvOS(.v13),
],
products: [
.library(name: "PostgreSQL", targets: ["PostgreSQL"]),
.library(name: "PostgresKit", targets: ["PostgresKit"]),
],
dependencies: [
// ⏱ Promises and reactive-streams in Swift built for high-performance and scalability.
.package(url: "https://github.com/vapor/async.git", from: "1.0.0-rc"),

// 🌎 Utility package containing tools for byte manipulation, Codable, OS APIs, and debugging.
.package(url: "https://github.com/vapor/core.git", from: "3.0.0-rc"),

// 🔑 Hashing (BCrypt, SHA, HMAC, etc), encryption, and randomness.
.package(url: "https://github.com/vapor/crypto.git", from: "3.0.0-rc"),

// 🗄 Core services for creating database integrations.
.package(url: "https://github.com/vapor/database-kit.git", from: "1.0.0-rc"),

// 📦 Dependency injection / inversion of control framework.
.package(url: "https://github.com/vapor/service.git", from: "1.0.0-rc"),

// 🔌 Non-blocking TCP socket layer, with event-driven server and client.
.package(url: "https://github.com/vapor/sockets.git", from: "3.0.0-rc"),
.package(url: "https://github.com/vapor/postgres-nio.git", from: "1.21.1"),
.package(url: "https://github.com/vapor/sql-kit.git", from: "3.29.3"),
.package(url: "https://github.com/vapor/async-kit.git", from: "1.19.0"),
],
targets: [
.target(name: "PostgreSQL", dependencies: ["Async", "Bits", "Crypto", "DatabaseKit", "Service", "TCP"]),
.testTarget(name: "PostgreSQLTests", dependencies: ["PostgreSQL"]),
.target(
name: "PostgresKit",
dependencies: [
.product(name: "AsyncKit", package: "async-kit"),
.product(name: "PostgresNIO", package: "postgres-nio"),
.product(name: "SQLKit", package: "sql-kit"),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "PostgresKitTests",
dependencies: [
.target(name: "PostgresKit"),
.product(name: "SQLKitBenchmark", package: "sql-kit"),
],
swiftSettings: swiftSettings
),
]
)

var swiftSettings: [SwiftSetting] { [
.enableUpcomingFeature("ConciseMagicFile"),
.enableUpcomingFeature("ForwardTrailingClosures"),
] }
47 changes: 47 additions & 0 deletions Package@swift-5.9.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// swift-tools-version:5.9
import PackageDescription

let package = Package(
name: "postgres-kit",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.watchOS(.v6),
.tvOS(.v13),
],
products: [
.library(name: "PostgresKit", targets: ["PostgresKit"]),
],
dependencies: [
.package(url: "https://github.com/vapor/postgres-nio.git", from: "1.20.2"),
.package(url: "https://github.com/vapor/sql-kit.git", from: "3.28.0"),
.package(url: "https://github.com/vapor/async-kit.git", from: "1.19.0"),
],
targets: [
.target(
name: "PostgresKit",
dependencies: [
.product(name: "AsyncKit", package: "async-kit"),
.product(name: "PostgresNIO", package: "postgres-nio"),
.product(name: "SQLKit", package: "sql-kit"),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "PostgresKitTests",
dependencies: [
.target(name: "PostgresKit"),
.product(name: "SQLKitBenchmark", package: "sql-kit"),
],
swiftSettings: swiftSettings
),
]
)

var swiftSettings: [SwiftSetting] { [
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("ConciseMagicFile"),
.enableUpcomingFeature("ForwardTrailingClosures"),
.enableUpcomingFeature("DisableOutwardActorInference"),
.enableExperimentalFeature("StrictConcurrency=complete"),
] }
156 changes: 136 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,140 @@
<p align="center">
<img src="https://user-images.githubusercontent.com/1342803/36623751-7f1f2884-18d5-11e8-9fd8-5a94c23ec7ce.png" height="64" alt="PostgreSQL">
<br>
<br>
<a href="http://docs.vapor.codes/3.0/">
<img src="http://img.shields.io/badge/read_the-docs-2196f3.svg" alt="Documentation">
</a>
<a href="http://vapor.team">
<img src="http://vapor.team/badge.svg" alt="Slack Team">
</a>
<a href="LICENSE">
<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License">
</a>
<a href="https://circleci.com/gh/vapor/postgresql">
<img src="https://circleci.com/gh/vapor/postgresql.svg?style=shield" alt="Continuous Integration">
</a>
<a href="https://swift.org">
<img src="http://img.shields.io/badge/swift-4.1-brightgreen.svg" alt="Swift 4.1">
</a>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/vapor/postgres-kit/assets/1130717/02ca33b1-d788-4846-8280-7cd89f09c397">
<source media="(prefers-color-scheme: light)" srcset="https://github.com/vapor/postgres-kit/assets/1130717/91de055b-0e4f-42f3-8257-946ac40d731c">
<img src="https://github.com/vapor/postgres-kit/assets/1130717/91de055b-0e4f-42f3-8257-946ac40d731c" height="96" alt="PostgresKit">
</picture>
<br>
<br>
<a href="https://docs.vapor.codes/4.0/"><img src="https://design.vapor.codes/images/readthedocs.svg" alt="Documentation"></a>
<a href="https://discord.gg/vapor"><img src="https://design.vapor.codes/images/discordchat.svg" alt="Team Chat"></a>
<a href="LICENSE"><img src="https://design.vapor.codes/images/mitlicense.svg" alt="MIT License"></a>
<a href="https://github.com/vapor/postgres-kit/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/vapor/postgres-kit/test.yml?event=push&style=plastic&logo=github&label=tests&logoColor=%23ccc" alt="Continuous Integration"></a>
<a href="https://codecov.io/github/vapor/postgres-kit"><img src="https://img.shields.io/codecov/c/github/vapor/postgres-kit?style=plastic&logo=codecov&label=codecov"></a>
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift58up.svg" alt="Swift 5.8+"></a>
</p>

<hr>
<br>

See [vapor-community/postgresql](https://github.com/vapor-community/postgresql/) for `libpq` based version.
🐘 Non-blocking, event-driven Swift client for PostgreSQL.

### Usage

Use the SPM string to easily include the dependendency in your `Package.swift` file.

```swift
.package(url: "https://github.com/vapor/postgres-kit.git", from: "2.0.0")
```

### Supported Platforms

PostgresKit supports the following platforms:

- Ubuntu 20.04+
- macOS 10.15+

## Overview

PostgresKit is an [SQLKit] driver for PostgreSQL clients. It supports building and serializing Postgres-dialect SQL queries. PostgresKit uses [PostgresNIO] to connect and communicate with the database server asynchronously. [AsyncKit](https://github.com/vapor/async-kit) is used to provide connection pooling.

> [!IMPORTANT]
> It is strongly recommended that users who leverage PostgresKit directly (e.g. absent the Fluent ORM layer) take advantage of PostgresNIO's [PostgresClient] API for connection management rather than relying upon the legacy AsyncKit API.
[SQLKit]: https://github.com/vapor/sql-kit
[PostgresNIO]: https://github.com/vapor/postgres-nio
[AsyncKit]: https://github.com/vapor/async-kit
[PostgresClient]: https://api.vapor.codes/postgresnio/documentation/postgresnio/postgresclient

### Configuration

Database connection options and credentials are specified using a `PostgresConfiguration` struct.

```swift
import PostgresKit

let configuration = PostgresConfiguration(
hostname: "localhost",
username: "vapor_username",
password: "vapor_password",
database: "vapor_database"
)
```

URL string based configuration is also supported.

```swift
guard let configuration = PostgresConfiguration(url: "postgres://...") else {
...
}
```

To connect via unix-domain sockets, use `unixDomainSocketPath` instead of `hostname` and `port`.

```swift
let configuration = PostgresConfiguration(
unixDomainSocketPath: "/path/to/socket",
username: "vapor_username",
password: "vapor_password",
database: "vapor_database"
)
```

### Connection Pool

Once you have a `PostgresConfiguration`, you can use it to create a connection source and pool.

```swift
let eventLoopGroup: EventLoopGroup = ...
defer { try! eventLoopGroup.syncShutdown() }

let pools = EventLoopGroupConnectionPool(
source: PostgresConnectionSource(configuration: configuration),
on: eventLoopGroup
)
defer { pools.shutdown() }
```

First create a `PostgresConnectionSource` using the configuration struct. This type is responsible for creating new connections to your database server as needed.

Next, use the connection source to create an `EventLoopGroupConnectionPool`. You will also need to pass an `EventLoopGroup`. For more information on creating an `EventLoopGroup`, visit SwiftNIO's [documentation](https://apple.github.io/swift-nio/docs/current/NIO/index.html). Make sure to shutdown the connection pool before it deinitializes.

`EventLoopGroupConnectionPool` is a collection of pools for each event loop. When using `EventLoopGroupConnectionPool` directly, random event loops will be chosen as needed.

```swift
pools.withConnection { conn
print(conn) // PostgresConnection on randomly chosen event loop
}
```

To get a pool for a specific event loop, use `pool(for:)`. This returns an `EventLoopConnectionPool`.

```swift
let eventLoop: EventLoop = ...
let pool = pools.pool(for: eventLoop)

pool.withConnection { conn
print(conn) // PostgresConnection on eventLoop
}
```

### PostgresDatabase

Both `EventLoopGroupConnectionPool` and `EventLoopConnectionPool` can be used to create instances of `PostgresDatabase`.

```swift
let postgres = pool.database(logger: ...) // PostgresDatabase
let rows = try postgres.simpleQuery("SELECT version();").wait()
```

Visit [PostgresNIO's docs](https://github.com/vapor/postgres-nio) for more information on using `PostgresDatabase`.

### SQLDatabase

A `PostgresDatabase` can be used to create an instance of `SQLDatabase`.

```swift
let sql = postgres.sql() // SQLDatabase
let planets = try sql.select().column("*").from("planets").all().wait()
```

Visit [SQLKit's docs](https://github.com/vapor/sql-kit) for more information on using `SQLDatabase`.
77 changes: 0 additions & 77 deletions Sources/PostgreSQL/Connection/PostgreSQLConnection+Query.swift

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions Sources/PostgreSQL/Connection/PostgreSQLConnection+TCP.swift

This file was deleted.

130 changes: 0 additions & 130 deletions Sources/PostgreSQL/Connection/PostgreSQLConnection.swift

This file was deleted.

142 changes: 0 additions & 142 deletions Sources/PostgreSQL/Data/PostgreSQLArrayCustomConvertible.swift

This file was deleted.

86 changes: 0 additions & 86 deletions Sources/PostgreSQL/Data/PostgreSQLData+BinaryFloatingPoint.swift

This file was deleted.

42 changes: 0 additions & 42 deletions Sources/PostgreSQL/Data/PostgreSQLData+Bool.swift

This file was deleted.

49 changes: 0 additions & 49 deletions Sources/PostgreSQL/Data/PostgreSQLData+Data.swift

This file was deleted.

63 changes: 0 additions & 63 deletions Sources/PostgreSQL/Data/PostgreSQLData+Date.swift

This file was deleted.

104 changes: 0 additions & 104 deletions Sources/PostgreSQL/Data/PostgreSQLData+FixedWidthInteger.swift

This file was deleted.

32 changes: 0 additions & 32 deletions Sources/PostgreSQL/Data/PostgreSQLData+Optional.swift

This file was deleted.

68 changes: 0 additions & 68 deletions Sources/PostgreSQL/Data/PostgreSQLData+Point.swift

This file was deleted.

114 changes: 0 additions & 114 deletions Sources/PostgreSQL/Data/PostgreSQLData+String.swift

This file was deleted.

39 changes: 0 additions & 39 deletions Sources/PostgreSQL/Data/PostgreSQLData+UUID.swift

This file was deleted.

35 changes: 0 additions & 35 deletions Sources/PostgreSQL/Data/PostgreSQLData.swift

This file was deleted.

65 changes: 0 additions & 65 deletions Sources/PostgreSQL/Data/PostgreSQLDataCustomConvertible.swift

This file was deleted.

71 changes: 0 additions & 71 deletions Sources/PostgreSQL/Data/PostgreSQLJSONCustomConvertible.swift

This file was deleted.

120 changes: 0 additions & 120 deletions Sources/PostgreSQL/DataType/PostgreSQLDataType.swift

This file was deleted.

38 changes: 0 additions & 38 deletions Sources/PostgreSQL/DataType/PostgreSQLFormatCode.swift

This file was deleted.

42 changes: 0 additions & 42 deletions Sources/PostgreSQL/Database/PostgreSQLDatabase.swift

This file was deleted.

32 changes: 0 additions & 32 deletions Sources/PostgreSQL/Database/PostgreSQLDatabaseConfig.swift

This file was deleted.

5 changes: 0 additions & 5 deletions Sources/PostgreSQL/Database/PostgreSQLLogger.swift

This file was deleted.

1 change: 0 additions & 1 deletion Sources/PostgreSQL/Exports.swift

This file was deleted.

285 changes: 0 additions & 285 deletions Sources/PostgreSQL/Message+Parse/PostgreSQLMessageDecoder.swift

This file was deleted.

48 changes: 0 additions & 48 deletions Sources/PostgreSQL/Message+Parse/PostgreSQLMessageParser.swift

This file was deleted.

259 changes: 0 additions & 259 deletions Sources/PostgreSQL/Message+Serialize/PostgreSQLMessageEncoder.swift

This file was deleted.

This file was deleted.

45 changes: 0 additions & 45 deletions Sources/PostgreSQL/Message/PostgreSQLAuthenticationRequest.swift

This file was deleted.

17 changes: 0 additions & 17 deletions Sources/PostgreSQL/Message/PostgreSQLBackendKeyData.swift

This file was deleted.

31 changes: 0 additions & 31 deletions Sources/PostgreSQL/Message/PostgreSQLBindRequest.swift

This file was deleted.

35 changes: 0 additions & 35 deletions Sources/PostgreSQL/Message/PostgreSQLClose.swift

This file was deleted.

35 changes: 0 additions & 35 deletions Sources/PostgreSQL/Message/PostgreSQLDataRow.swift

This file was deleted.

32 changes: 0 additions & 32 deletions Sources/PostgreSQL/Message/PostgreSQLDescribeRequest.swift

This file was deleted.

Loading