Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.build/
.git/
.swiftpm/
4 changes: 2 additions & 2 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:
jobs:

create-docc-and-deploy:
uses: BinaryBirds/github-workflows/.github/workflows/docc_deploy.yml@main
uses: BinaryBirds/github-workflows/.github/workflows/docc_deploy.yml@0.2.0
permissions:
contents: read
pages: write
id-token: write
id-token: write
24 changes: 9 additions & 15 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ on:

jobs:

api_breakage:
name: Check API breakage
uses: BinaryBirds/github-workflows/.github/workflows/api_breakage.yml@main

swiftlang_checks:
name: Swiftlang Checks
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@0.0.16
with:
license_header_check_project_name: "project"
format_check_enabled : true
Expand All @@ -26,16 +22,14 @@ jobs:
yamllint_check_enabled : false
python_lint_check_enabled : false

bb_checks:
name: BB Checks
uses: BinaryBirds/github-workflows/.github/workflows/extra_soundness.yml@main
with:
local_swift_dependencies_check_enabled : true
headers_check_enabled : false
docc_warnings_check_enabled : true

swiftlang_tests:
name: Swiftlang Tests
docker_tests:
name: Docker Tests
strategy:
fail-fast: false
matrix:
swift-version: ["6.3", "6.4"]
env:
SWIFT_VERSION: ${{ matrix.swift-version }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
22 changes: 11 additions & 11 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 25 additions & 25 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
// swift-tools-version:6.1
// swift-tools-version:6.3
import PackageDescription

// NOTE: https://github.com/swift-server/swift-http-server/blob/main/Package.swift
var defaultSwiftSettings: [SwiftSetting] =
[
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0441-formalize-language-mode-terminology.md
let swiftSettings: [SwiftSetting] = [
.swiftLanguageMode(.v6),
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
.strictMemorySafety(),
.treatAllWarnings(as: .error),
.enableUpcomingFeature("InternalImportsByDefault"),
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("MemberImportVisibility"),
// https://forums.swift.org/t/experimental-support-for-lifetime-dependencies-in-swift-6-2-and-beyond/78638
.enableUpcomingFeature("InferIsolatedConformances"),
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
.enableUpcomingFeature("ImmutableWeakCaptures"),
.enableUpcomingFeature("StrictConcurrency"),
.enableExperimentalFeature("SuppressedAssociatedTypes"),
.enableExperimentalFeature("LifetimeDependence"),
.enableExperimentalFeature("Lifetimes"),
// https://github.com/swiftlang/swift/pull/65218
.enableExperimentalFeature("AvailabilityMacro=FeatherDatabasePostgres 1.0:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0"),
]

#if compiler(>=6.2)
defaultSwiftSettings.append(
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0461-async-function-isolation.md
.enableUpcomingFeature("NonisolatedNonsendingByDefault")
)
#endif


let package = Package(
name: "feather-database-postgres",
platforms: [
Expand All @@ -32,13 +27,18 @@ let package = Package(
.visionOS(.v2),
],
products: [
.library(name: "FeatherDatabasePostgres", targets: ["FeatherDatabasePostgres"]),
.library(
name: "FeatherDatabasePostgres",
targets: ["FeatherDatabasePostgres"]
)
],
dependencies: [
.package(url: "https://github.com/apple/swift-log", from: "1.14.0"),
.package(url: "https://github.com/vapor/postgres-nio", from: "1.27.0"),
.package(url: "https://github.com/feather-framework/feather-database", exact: "1.0.0-rc.2"),
// [docc-plugin-placeholder]
.package(url: "https://github.com/apple/swift-log", from: "1.16.1"),
.package(url: "https://github.com/vapor/postgres-nio", from: "1.33.1"),
.package(
url: "https://github.com/feather-framework/feather-database",
exact: "1.0.0-rc.3"
),
],
targets: [
.target(
Expand All @@ -48,14 +48,14 @@ let package = Package(
.product(name: "PostgresNIO", package: "postgres-nio"),
.product(name: "FeatherDatabase", package: "feather-database"),
],
swiftSettings: defaultSwiftSettings
swiftSettings: swiftSettings
),
.testTarget(
name: "FeatherDatabasePostgresTests",
dependencies: [
.target(name: "FeatherDatabasePostgres"),
.target(name: "FeatherDatabasePostgres")
],
swiftSettings: defaultSwiftSettings
swiftSettings: swiftSettings
),
]
)
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Postgres driver implementation for the abstract [Feather Database](https://github.com/feather-framework/feather-database) Swift API package.

[![Release: 1.0.0-rc.2](https://img.shields.io/badge/Release-1%2E0%2E0--rc%2E2-F05138)](https://github.com/feather-framework/feather-database-postgres/releases/tag/1.0.0-rc.2)
[![Release: 1.0.0-rc.3](https://img.shields.io/badge/Release-1%2E0%2E0--rc%2E3-F05138)](https://github.com/feather-framework/feather-database-postgres/releases/tag/1.0.0-rc.3)

## Features

Expand All @@ -15,10 +15,10 @@ Postgres driver implementation for the abstract [Feather Database](https://githu

## Requirements

![Swift 6.1+](https://img.shields.io/badge/Swift-6%2E1%2B-F05138)
![Swift 6.3+](https://img.shields.io/badge/Swift-6%2E3%2B-F05138)
![Platforms: Linux, macOS, iOS, tvOS, watchOS, visionOS](https://img.shields.io/badge/Platforms-Linux_%7C_macOS_%7C_iOS_%7C_tvOS_%7C_watchOS_%7C_visionOS-F05138)

- Swift 6.1+
- Swift 6.3+

- Platforms:
- Linux
Expand All @@ -33,7 +33,7 @@ Postgres driver implementation for the abstract [Feather Database](https://githu
Add the dependency to your `Package.swift`:

```swift
.package(url: "https://github.com/feather-framework/feather-database-postgres", exact: "1.0.0-rc.2"),
.package(url: "https://github.com/feather-framework/feather-database-postgres", exact: "1.0.0-rc.3"),
```

Then add `FeatherDatabasePostgres` to your target dependencies:
Expand Down
4 changes: 2 additions & 2 deletions Sources/FeatherDatabasePostgres/DatabaseClientPostgres.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// Created by Tibor Bödecs on 2026. 01. 10..
//

import FeatherDatabase
public import FeatherDatabase
import Logging
import PostgresNIO
public import PostgresNIO

/// A Postgres-backed database client.
///
Expand Down
14 changes: 13 additions & 1 deletion Sources/FeatherDatabasePostgres/DatabaseConnectionPostgres.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Tibor Bödecs on 2026. 01. 10.
//

import FeatherDatabase
public import FeatherDatabase
import Logging
import PostgresNIO

Expand All @@ -27,10 +27,22 @@ extension DatabaseQuery {
postgresBindings.append(value)
case .int(let value):
postgresBindings.append(value)
case .int32(let value):
postgresBindings.append(value)
case .double(let value):
postgresBindings.append(value)
case .float(let value):
postgresBindings.append(value)
case .string(let value):
postgresBindings.append(value)
case .uuid(let value):
postgresBindings.append(value)
case .date(let value):
postgresBindings.append(value)
case .data(let value):
postgresBindings.append(PostgresData(bytes: value))
case .json(let value):
postgresBindings.append(PostgresData(jsonb: value))
}
}

Expand Down
38 changes: 36 additions & 2 deletions Sources/FeatherDatabasePostgres/DatabaseRowPostgres.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,39 @@
// Created by Tibor Bödecs on 2026. 01. 10.
//

import FeatherDatabase
public import FeatherDatabase
import PostgresNIO

public struct DatabaseRowPostgres: DatabaseRow {

var row: PostgresRow
private let randomAccessRow: PostgresRandomAccessRow

init(row: PostgresRow) {
self.row = row
self.randomAccessRow = row.makeRandomAccess()
}

public var columns: [String] {
randomAccessRow.map(\.columnName)
}

public func contains(column: String) -> Bool {
randomAccessRow.contains(column)
}

public func decodeNil(column: String) throws(DecodingError) -> Bool {
guard randomAccessRow.contains(column) else {
throw .keyNotFound(
PostgresColumnKey(stringValue: column),
.init(
codingPath: [],
debugDescription: "Missing data for column \(column)."
)
)
}
return randomAccessRow[column].bytes == nil
}

/// Decode a column value as the given type.
///
Expand All @@ -24,7 +51,7 @@ public struct DatabaseRowPostgres: DatabaseRow {
column: String,
as type: T.Type
) throws(DecodingError) -> T {
let row = row.makeRandomAccess()
let row = randomAccessRow
guard row.contains(column) else {
throw .dataCorrupted(
.init(
Expand Down Expand Up @@ -69,3 +96,10 @@ public struct DatabaseRowPostgres: DatabaseRow {
)
}
}

private struct PostgresColumnKey: CodingKey {
let stringValue: String
let intValue: Int? = nil
init(stringValue: String) { self.stringValue = stringValue }
init?(intValue: Int) { return nil }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Tibor Bödecs on 2026. 01. 10.
//

import FeatherDatabase
public import FeatherDatabase
import PostgresNIO

/// A query result backed by a Postgres row sequence.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Tibor Bödecs on 2026. 02. 02..
//

import FeatherDatabase
public import FeatherDatabase
import PostgresNIO

public struct DatabaseTransactionErrorPostgres: DatabaseTransactionError {
Expand Down
Loading
Loading