Skip to content

Draft: Removals for v2 #445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
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
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -8,10 +8,10 @@ let swiftSettings: [SwiftSetting] = [
let package = Package(
name: "postgres-nio",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.watchOS(.v6),
.tvOS(.v13),
.macOS(.v13),
.iOS(.v16),
.watchOS(.v9),
.tvOS(.v16),
],
products: [
.library(name: "PostgresNIO", targets: ["PostgresNIO"]),
Original file line number Diff line number Diff line change
@@ -246,7 +246,7 @@ extension PostgresConnection {
}

let connection: InternalConfiguration.Connection
let username: String?
let username: String
let password: String?
let database: String?
var tls: Configuration.TLS
290 changes: 11 additions & 279 deletions Sources/PostgresNIO/Connection/PostgresConnection.swift

Large diffs are not rendered by default.

This file was deleted.

135 changes: 0 additions & 135 deletions Sources/PostgresNIO/Data/PostgresData+Array.swift

This file was deleted.

66 changes: 0 additions & 66 deletions Sources/PostgresNIO/Data/PostgresData+Bool.swift

This file was deleted.

40 changes: 0 additions & 40 deletions Sources/PostgresNIO/Data/PostgresData+Bytes.swift

This file was deleted.

60 changes: 0 additions & 60 deletions Sources/PostgresNIO/Data/PostgresData+Date.swift

This file was deleted.

35 changes: 0 additions & 35 deletions Sources/PostgresNIO/Data/PostgresData+Decimal.swift

This file was deleted.

53 changes: 0 additions & 53 deletions Sources/PostgresNIO/Data/PostgresData+Double.swift

This file was deleted.

47 changes: 0 additions & 47 deletions Sources/PostgresNIO/Data/PostgresData+Float.swift

This file was deleted.

264 changes: 0 additions & 264 deletions Sources/PostgresNIO/Data/PostgresData+Int.swift

This file was deleted.

59 changes: 0 additions & 59 deletions Sources/PostgresNIO/Data/PostgresData+JSON.swift

This file was deleted.

70 changes: 0 additions & 70 deletions Sources/PostgresNIO/Data/PostgresData+JSONB.swift

This file was deleted.

19 changes: 0 additions & 19 deletions Sources/PostgresNIO/Data/PostgresData+Optional.swift

This file was deleted.

17 changes: 0 additions & 17 deletions Sources/PostgresNIO/Data/PostgresData+RawRepresentable.swift

This file was deleted.

17 changes: 0 additions & 17 deletions Sources/PostgresNIO/Data/PostgresData+Set.swift

This file was deleted.

113 changes: 0 additions & 113 deletions Sources/PostgresNIO/Data/PostgresData+String.swift

This file was deleted.

48 changes: 0 additions & 48 deletions Sources/PostgresNIO/Data/PostgresData+UUID.swift

This file was deleted.

121 changes: 0 additions & 121 deletions Sources/PostgresNIO/Data/PostgresData.swift

This file was deleted.

8 changes: 0 additions & 8 deletions Sources/PostgresNIO/Data/PostgresDataConvertible.swift

This file was deleted.

21 changes: 0 additions & 21 deletions Sources/PostgresNIO/Data/PostgresDataType.swift
Original file line number Diff line number Diff line change
@@ -17,13 +17,6 @@ extension PostgresFormat: CustomStringConvertible {
}
}

// TODO: The Codable conformance does not make any sense. Let's remove this with next major break.
extension PostgresFormat: Codable {}

// TODO: Renamed during 1.x. Remove this with next major break.
@available(*, deprecated, renamed: "PostgresFormat")
public typealias PostgresFormatCode = PostgresFormat

/// Data types and their raw OIDs.
///
/// Use `select * from pg_type where oid = <idhere>` to look up more information for a given type.
@@ -113,14 +106,10 @@ public struct PostgresDataType: RawRepresentable, Sendable, Hashable, CustomStri
/// `774`
public static let macaddr8 = PostgresDataType(774)
/// `775`
@available(*, deprecated, renamed: "macaddr8Array")
public static let macaddr8Aray = Self.macaddr8Array
public static let macaddr8Array = PostgresDataType(775)
/// `790`
public static let money = PostgresDataType(790)
/// `791`
@available(*, deprecated, renamed: "moneyArray")
public static let _money = Self.moneyArray
public static let moneyArray = PostgresDataType(791)
/// `829`
public static let macaddr = PostgresDataType(829)
@@ -784,13 +773,3 @@ public struct PostgresDataType: RawRepresentable, Sendable, Hashable, CustomStri
return self.knownSQLName ?? "UNKNOWN \(self.rawValue)"
}
}

// TODO: The Codable conformance does not make any sense. Let's remove this with next major break.
extension PostgresDataType: Codable {}

// TODO: The ExpressibleByIntegerLiteral conformance does not make any sense and is not used anywhere. Remove with next major break.
extension PostgresDataType: ExpressibleByIntegerLiteral {
public init(integerLiteral value: UInt32) {
self.init(value)
}
}
Original file line number Diff line number Diff line change
@@ -223,33 +223,6 @@ public struct PostgresNumeric: CustomStringConvertible, CustomDebugStringConvert
}
}

extension PostgresData {
public init(numeric: PostgresNumeric) {
var buffer = ByteBufferAllocator().buffer(capacity: 0)
buffer.writeInteger(numeric.ndigits, endianness: .big)
buffer.writeInteger(numeric.weight, endianness: .big)
buffer.writeInteger(numeric.sign, endianness: .big)
buffer.writeInteger(numeric.dscale, endianness: .big)
var value = numeric.value
buffer.writeBuffer(&value)
self.init(type: .numeric, value: buffer)
}

public var numeric: PostgresNumeric? {
/// create mutable value since we will be using `.extract` which advances the buffer's view
guard var value = self.value else {
return nil
}

/// grab the numeric metadata from the beginning of the array
guard let metadata = PostgresNumeric(buffer: &value) else {
return nil
}

return metadata
}
}

private extension Collection {
// splits the collection into chunks of the supplied size
// if the collection is not evenly divisible, the last chunk will be smaller
83 changes: 0 additions & 83 deletions Sources/PostgresNIO/Data/PostgresRow.swift
Original file line number Diff line number Diff line change
@@ -183,28 +183,6 @@ extension PostgresRandomAccessRow: Sendable, RandomAccessCollection {
}
}

extension PostgresRandomAccessRow {
public subscript(data index: Int) -> PostgresData {
guard index < self.endIndex else {
preconditionFailure("index out of bounds")
}
let column = self.columns[index]
return PostgresData(
type: column.dataType,
typeModifier: column.dataTypeModifier,
formatCode: .binary,
value: self.cells[index]
)
}

public subscript(data column: String) -> PostgresData {
guard let index = self.lookupTable[column] else {
fatalError(#"A column "\#(column)" does not exist."#)
}
return self[data: index]
}
}

extension PostgresRandomAccessRow {
/// Access the data in the provided column and decode it into the target type.
///
@@ -261,64 +239,3 @@ extension PostgresRandomAccessRow {
}
}
}

// MARK: Deprecated API

extension PostgresRow {
@available(*, deprecated, message: "Will be removed from public API.")
public var rowDescription: PostgresMessage.RowDescription {
let fields = self.columns.map { column in
PostgresMessage.RowDescription.Field(
name: column.name,
tableOID: UInt32(column.tableOID),
columnAttributeNumber: column.columnAttributeNumber,
dataType: PostgresDataType(UInt32(column.dataType.rawValue)),
dataTypeSize: column.dataTypeSize,
dataTypeModifier: column.dataTypeModifier,
formatCode: .init(psqlFormatCode: column.format)
)
}
return PostgresMessage.RowDescription(fields: fields)
}

@available(*, deprecated, message: "Iterate the cells on `PostgresRow` instead.")
public var dataRow: PostgresMessage.DataRow {
let columns = self.data.map {
PostgresMessage.DataRow.Column(value: $0)
}
return PostgresMessage.DataRow(columns: columns)
}

@available(*, deprecated, message: """
This call is O(n) where n is the number of cells in the row. For random access to cells
in a row create a PostgresRandomAccessRow from the row first and use its subscript
methods. (see `makeRandomAccess()`)
""")
public func column(_ column: String) -> PostgresData? {
guard let index = self.lookupTable[column] else {
return nil
}

return PostgresData(
type: self.columns[index].dataType,
typeModifier: self.columns[index].dataTypeModifier,
formatCode: .binary,
value: self.data[column: index]
)
}
}

extension PostgresRow: CustomStringConvertible {
public var description: String {
var row: [String: PostgresData] = [:]
for cell in self {
row[cell.columnName] = PostgresData(
type: cell.dataType,
typeModifier: 0,
formatCode: cell.format,
value: cell.bytes
)
}
return row.description
}
}

This file was deleted.

162 changes: 0 additions & 162 deletions Sources/PostgresNIO/Deprecated/PostgresData+UInt.swift

This file was deleted.

119 changes: 0 additions & 119 deletions Sources/PostgresNIO/Deprecated/PostgresMessage+Authentication.swift

This file was deleted.

61 changes: 0 additions & 61 deletions Sources/PostgresNIO/Deprecated/PostgresMessage+Bind.swift

This file was deleted.

40 changes: 0 additions & 40 deletions Sources/PostgresNIO/Deprecated/PostgresMessage+Close.swift

This file was deleted.

This file was deleted.

38 changes: 0 additions & 38 deletions Sources/PostgresNIO/Deprecated/PostgresMessage+Describe.swift

This file was deleted.

28 changes: 0 additions & 28 deletions Sources/PostgresNIO/Deprecated/PostgresMessage+Execute.swift

This file was deleted.

This file was deleted.

This file was deleted.

31 changes: 0 additions & 31 deletions Sources/PostgresNIO/Deprecated/PostgresMessage+Parse.swift

This file was deleted.

29 changes: 0 additions & 29 deletions Sources/PostgresNIO/Deprecated/PostgresMessage+Password.swift

This file was deleted.

This file was deleted.

This file was deleted.

27 changes: 0 additions & 27 deletions Sources/PostgresNIO/Deprecated/PostgresMessage+SSLRequest.swift

This file was deleted.

This file was deleted.

48 changes: 0 additions & 48 deletions Sources/PostgresNIO/Deprecated/PostgresMessage+Startup.swift

This file was deleted.

19 changes: 0 additions & 19 deletions Sources/PostgresNIO/Deprecated/PostgresMessage+Sync.swift

This file was deleted.

12 changes: 0 additions & 12 deletions Sources/PostgresNIO/Deprecated/PostgresMessage+Terminate.swift

This file was deleted.

66 changes: 0 additions & 66 deletions Sources/PostgresNIO/Deprecated/PostgresMessageDecoder.swift

This file was deleted.

42 changes: 0 additions & 42 deletions Sources/PostgresNIO/Deprecated/PostgresMessageEncoder.swift

This file was deleted.

4 changes: 0 additions & 4 deletions Sources/PostgresNIO/Docs.docc/index.md
Original file line number Diff line number Diff line change
@@ -50,9 +50,5 @@ configure ``PostgresConnection`` to use `Network.framework` as the underlying tr
- ``PostgresDecodingError``
- ``PSQLError``

### Deprecations

- <doc:deprecated>

[SwiftNIO]: https://github.com/apple/swift-nio
[SwiftLog]: https://github.com/apple/swift-log
23 changes: 0 additions & 23 deletions Sources/PostgresNIO/Message/PostgresMessage+0.swift

This file was deleted.

This file was deleted.

54 changes: 0 additions & 54 deletions Sources/PostgresNIO/Message/PostgresMessage+DataRow.swift

This file was deleted.

113 changes: 0 additions & 113 deletions Sources/PostgresNIO/Message/PostgresMessage+Error.swift

This file was deleted.

151 changes: 0 additions & 151 deletions Sources/PostgresNIO/Message/PostgresMessage+Identifier.swift

This file was deleted.

This file was deleted.

This file was deleted.

36 changes: 0 additions & 36 deletions Sources/PostgresNIO/Message/PostgresMessageType.swift

This file was deleted.

Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ struct AuthenticationStateMachine {
case saslChallengeResponseSent(SASLAuthenticationManager<SASLMechanism.SCRAM.SHA256>)
case saslFinalReceived

case error(PSQLError)
case error(PostgresError)
case authenticated
}

@@ -23,7 +23,7 @@ struct AuthenticationStateMachine {
case wait
case authenticated

case reportAuthenticationError(PSQLError)
case reportAuthenticationError(PostgresError)
}

let authContext: AuthContext
@@ -51,7 +51,7 @@ struct AuthenticationStateMachine {
return .authenticated
case .md5(let salt):
guard self.authContext.password != nil else {
return self.setAndFireError(PSQLError(code: .authMechanismRequiresPassword))
return self.setAndFireError(PostgresError(code: .authMechanismRequiresPassword))
}
self.state = .passwordAuthenticationSent
return .sendPassword(.md5(salt: salt), self.authContext)
@@ -160,11 +160,11 @@ struct AuthenticationStateMachine {
return self.setAndFireError(.server(message))
}

mutating func errorHappened(_ error: PSQLError) -> Action {
mutating func errorHappened(_ error: PostgresError) -> Action {
return self.setAndFireError(error)
}

private mutating func setAndFireError(_ error: PSQLError) -> Action {
private mutating func setAndFireError(_ error: PostgresError) -> Action {
switch self.state {
case .initialized:
preconditionFailure("""
Loading