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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ test:
swift test --parallel

docker-test:
docker build -t feather-postgres-database-tests . -f ./docker/tests/Dockerfile && docker run --rm feather-postgres-database-tests
docker build -t feather-database-postgres-tests . -f ./docker/tests/Dockerfile && docker run --rm feather-database-postgres-tests
12 changes: 6 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var defaultSwiftSettings: [SwiftSetting] =
// https://forums.swift.org/t/experimental-support-for-lifetime-dependencies-in-swift-6-2-and-beyond/78638
.enableExperimentalFeature("Lifetimes"),
// https://github.com/swiftlang/swift/pull/65218
.enableExperimentalFeature("AvailabilityMacro=featherPostgresDatabase 1.0:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0"),
.enableExperimentalFeature("AvailabilityMacro=FeatherDatabasePostgres 1.0:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0"),
]

#if compiler(>=6.2)
Expand All @@ -23,7 +23,7 @@ defaultSwiftSettings.append(


let package = Package(
name: "feather-postgres-database",
name: "feather-database-postgres",
platforms: [
.macOS(.v15),
.iOS(.v18),
Expand All @@ -32,7 +32,7 @@ let package = Package(
.visionOS(.v2),
],
products: [
.library(name: "FeatherPostgresDatabase", targets: ["FeatherPostgresDatabase"]),
.library(name: "FeatherDatabasePostgres", targets: ["FeatherDatabasePostgres"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-log", from: "1.6.0"),
Expand All @@ -42,7 +42,7 @@ let package = Package(
],
targets: [
.target(
name: "FeatherPostgresDatabase",
name: "FeatherDatabasePostgres",
dependencies: [
.product(name: "Logging", package: "swift-log"),
.product(name: "PostgresNIO", package: "postgres-nio"),
Expand All @@ -51,9 +51,9 @@ let package = Package(
swiftSettings: defaultSwiftSettings
),
.testTarget(
name: "FeatherPostgresDatabaseTests",
name: "FeatherDatabasePostgresTests",
dependencies: [
.target(name: "FeatherPostgresDatabase"),
.target(name: "FeatherDatabasePostgres"),
],
swiftSettings: defaultSwiftSettings
),
Expand Down
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Feather Postgres Database
# Feather Database Postgres

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

[![Release: 1.0.0-beta.4](https://img.shields.io/badge/Release-1%2E0%2E0--beta%2E4-F05138)](https://github.com/feather-framework/feather-postgres-database/releases/tag/1.0.0-beta.4)
[
![Release: 1.0.0-beta.5](https://img.shields.io/badge/Release-1%2E0%2E0--beta%2E5-F05138)
](
https://github.com/feather-framework/feather-database-postgres/releases/tag/1.0.0-beta.5
)

## Features

Expand Down Expand Up @@ -33,20 +37,24 @@ 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-postgres-database", exact: "1.0.0-beta.4"),
.package(url: "https://github.com/feather-framework/feather-database-postgres", exact: "1.0.0-beta.5"),
```

Then add `FeatherPostgresDatabase` to your target dependencies:
Then add `FeatherDatabasePostgres` to your target dependencies:

```swift
.product(name: "FeatherPostgresDatabase", package: "feather-postgres-database"),
.product(name: "FeatherDatabasePostgres", package: "feather-database-postgres"),
```

## Usage

API documentation is available at the link below:

[![DocC API documentation](https://img.shields.io/badge/DocC-API_documentation-F05138)](https://feather-framework.github.io/feather-postgres-database/)
[
![DocC API documentation](https://img.shields.io/badge/DocC-API_documentation-F05138)
](
https://feather-framework.github.io/feather-database-postgres/
)

Here is a brief example:

Expand All @@ -55,7 +63,7 @@ import Logging
import NIOSSL
import PostgresNIO
import FeatherDatabase
import FeatherPostgresDatabase
import FeatherDatabasePostgres

var logger = Logger(label: "example")
logger.logLevel = .info
Expand Down Expand Up @@ -118,8 +126,8 @@ try await withThrowingTaskGroup(of: Void.self) { group in

The following database driver implementations are available for use:

- [SQLite](https://github.com/feather-framework/feather-sqlite-database)
- [MySQL](https://github.com/feather-framework/feather-mysql-database)
- [SQLite](https://github.com/feather-framework/feather-database-sqlite)
- [MySQL](https://github.com/feather-framework/feather-database-mysql)

## Development

Expand All @@ -132,4 +140,4 @@ The following database driver implementations are available for use:

## Contributing

[Pull requests](https://github.com/feather-framework/feather-postgres-database/pulls) are welcome. Please keep changes focused and include tests for new logic.
[Pull requests](https://github.com/feather-framework/feather-database-postgres/pulls) are welcome. Please keep changes focused and include tests for new logic.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// PostgresDatabaseClient.swift
// feather-postgres-database
// DatabaseClientPostgres.swift
// feather-database-postgres
//
// Created by Tibor Bödecs on 2026. 01. 10..
//
Expand All @@ -12,8 +12,8 @@ import PostgresNIO
/// A Postgres-backed database client.
///
/// Use this client to execute queries and manage transactions on Postgres.
public struct PostgresDatabaseClient: DatabaseClient {
public typealias Connection = PostgresDatabaseConnection
public struct DatabaseClientPostgres: DatabaseClient {
public typealias Connection = DatabaseConnectionPostgres

var client: PostgresNIO.PostgresClient
var logger: Logger
Expand Down Expand Up @@ -46,7 +46,7 @@ public struct PostgresDatabaseClient: DatabaseClient {
) async throws(DatabaseError) -> T {
do {
return try await client.withConnection { connection in
let databaseConnection = PostgresDatabaseConnection(
let databaseConnection = DatabaseConnectionPostgres(
connection: connection,
logger: logger
)
Expand Down Expand Up @@ -75,7 +75,7 @@ public struct PostgresDatabaseClient: DatabaseClient {
return try await client.withTransaction(
logger: logger
) { connection in
let databaseConnection = PostgresDatabaseConnection(
let databaseConnection = DatabaseConnectionPostgres(
connection: connection,
logger: logger
)
Expand All @@ -84,7 +84,7 @@ public struct PostgresDatabaseClient: DatabaseClient {
}
catch let error as PostgresTransactionError {
throw .transaction(
PostgresDatabaseTransactionError(
DatabaseTransactionErrorPostgres(
underlyingError: error
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// PostgresDatabaseConnection.swift
// feather-postgres-database
// DatabaseConnectionPostgres.swift
// feather-database-postgres
//
// Created by Tibor Bödecs on 2026. 01. 10.
//
Expand Down Expand Up @@ -40,9 +40,9 @@ extension DatabaseQuery {
}
}

public struct PostgresDatabaseConnection: DatabaseConnection {
public struct DatabaseConnectionPostgres: DatabaseConnection {

public typealias RowSequence = PostgresDatabaseRowSequence
public typealias RowSequence = DatabaseRowSequencePostgres

var connection: PostgresConnection
public var logger: Logger
Expand All @@ -67,7 +67,7 @@ public struct PostgresDatabaseConnection: DatabaseConnection {
)

return try await handler(
PostgresDatabaseRowSequence(
DatabaseRowSequencePostgres(
backingSequence: sequence
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//
// PostgresDatabaseRow.swift
// feather-postgres-database
// DatabaseRowPostgres.swift
// feather-database-postgres
//
// Created by Tibor Bödecs on 2026. 01. 10.
//

import FeatherDatabase
import PostgresNIO

public struct PostgresDatabaseRow: DatabaseRow {
public struct DatabaseRowPostgres: DatabaseRow {

var row: PostgresRow

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// PostgresDatabaseRowSequence.swift
// feather-postgres-database
// DatabaseRowSequencePostgres.swift
// feather-database-postgres
//
// Created by Tibor Bödecs on 2026. 01. 10.
//
Expand All @@ -11,7 +11,7 @@ import PostgresNIO
/// A query result backed by a Postgres row sequence.
///
/// Use this type to iterate or collect Postgres query results.
public struct PostgresDatabaseRowSequence: DatabaseRowSequence {
public struct DatabaseRowSequencePostgres: DatabaseRowSequence {

var backingSequence: PostgresRowSequence

Expand All @@ -28,7 +28,7 @@ public struct PostgresDatabaseRowSequence: DatabaseRowSequence {
/// - Returns: The next `PostgresRow`, or `nil` when finished.
#if compiler(>=6.2)
@concurrent
public mutating func next() async throws -> PostgresDatabaseRow? {
public mutating func next() async throws -> DatabaseRowPostgres? {
guard !Task.isCancelled else {
return nil
}
Expand Down Expand Up @@ -65,8 +65,8 @@ public struct PostgresDatabaseRowSequence: DatabaseRowSequence {
/// This consumes the sequence and returns all rows.
/// - Throws: An error if iteration fails.
/// - Returns: An array of `PostgresRow` values.
public func collect() async throws -> [PostgresDatabaseRow] {
var items: [PostgresDatabaseRow] = []
public func collect() async throws -> [DatabaseRowPostgres] {
var items: [DatabaseRowPostgres] = []
for try await item in self {
items.append(item)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//
// PostgresDatabaseTransactionError.swift
// feather-postgres-database
// DatabaseTransactionErrorPostgres.swift
// feather-database-postgres
//
// Created by Tibor Bödecs on 2026. 02. 02..
//

import FeatherDatabase
import PostgresNIO

public struct PostgresDatabaseTransactionError: DatabaseTransactionError {
public struct DatabaseTransactionErrorPostgres: DatabaseTransactionError {

var underlyingError: PostgresTransactionError

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// FeatherPostgresDatabaseTestSuite.swift
// feather-postgres-database
// FeatherDatabasePostgresTestSuite.swift
// feather-database-postgres
//
// Created by Tibor Bödecs on 2026. 01. 10..
//
Expand All @@ -11,7 +11,7 @@ import NIOSSL
import PostgresNIO
import Testing

@testable import FeatherPostgresDatabase
@testable import FeatherDatabasePostgres

#if canImport(FoundationEssentials)
import FoundationEssentials
Expand All @@ -20,7 +20,7 @@ import Foundation
#endif

@Suite
struct FeatherPostgresDatabaseTestSuite {
struct FeatherDatabasePostgresTestSuite {

private func randomTableSuffix() -> String {
let characters = Array("abcdefghijklmnopqrstuvwxyz0123456789")
Expand All @@ -34,7 +34,7 @@ struct FeatherPostgresDatabaseTestSuite {

private func runUsingTestDatabaseClient(
_ closure:
@escaping (@Sendable (PostgresDatabaseClient) async throws -> Void)
@escaping (@Sendable (DatabaseClientPostgres) async throws -> Void)
) async throws {
var logger = Logger(label: "test")
logger.logLevel = .info
Expand Down Expand Up @@ -66,7 +66,7 @@ struct FeatherPostgresDatabaseTestSuite {
backgroundLogger: logger
)

let database = PostgresDatabaseClient(
let database = DatabaseClientPostgres(
client: client,
logger: logger
)
Expand Down