diff --git a/Package@swift-5.2.swift b/Package@swift-5.2.swift new file mode 100644 index 0000000..59f7fb9 --- /dev/null +++ b/Package@swift-5.2.swift @@ -0,0 +1,23 @@ +// swift-tools-version:5.2 +import PackageDescription + +let package = Package( + name: "PostgreSQL", + products: [ + .library(name: "PostgreSQL", targets: ["PostgreSQL"]), + ], + dependencies: [ + // Module map for `libpq` + .package(name: "CPostgreSQL", url: "https://github.com/vapor-community/cpostgresql.git", from: "2.1.0"), + + // Data structure for converting between multiple representations + .package(name: "Node", url: "https://github.com/vapor/node.git", from: "2.1.0"), + + // Core extensions, type-aliases, and functions that facilitate common tasks + .package(name: "Core", url: "https://github.com/vapor/core.git", from: "2.1.2"), + ], + targets: [ + .target(name: "PostgreSQL", dependencies: ["CPostgreSQL", "Node", "Core"]), + .testTarget(name: "PostgreSQLTests", dependencies: ["PostgreSQL"]), + ] +) diff --git a/Sources/PostgreSQL/Bind/BinaryUtils.swift b/Sources/PostgreSQL/Bind/BinaryUtils.swift index 40b9c7d..e513b66 100644 --- a/Sources/PostgreSQL/Bind/BinaryUtils.swift +++ b/Sources/PostgreSQL/Bind/BinaryUtils.swift @@ -4,12 +4,20 @@ import Core extension UInt8 { var lowercaseHexPair: String { let hexString = String(self, radix: 16, uppercase: false) + #if swift(>=5.0) + return String(repeating: "0", count: 2 - hexString.count) + hexString + #else return String(repeating: "0", count: 2 - hexString.characters.count) + hexString + #endif } var lowercaseBinaryString: String { let bitString = String(self, radix: 2, uppercase: false) + #if swift(>=5.0) + return String(repeating: "0", count: 8 - bitString.count) + bitString + #else return String(repeating: "0", count: 8 - bitString.characters.count) + bitString + #endif } } @@ -190,7 +198,11 @@ struct BinaryUtils { // The number of digits should be 4 (DEC_DIGITS), // so pad if necessary. + #if swift(>=5.0) + return String(repeating: "0", count: Numeric.decDigits - stringDigits.count) + stringDigits + #else return String(repeating: "0", count: Numeric.decDigits - stringDigits.characters.count) + stringDigits + #endif } /// Function for rounding numeric values. diff --git a/Sources/PostgreSQL/Bind/Bind.swift b/Sources/PostgreSQL/Bind/Bind.swift index 623ee1d..9051da1 100644 --- a/Sources/PostgreSQL/Bind/Bind.swift +++ b/Sources/PostgreSQL/Bind/Bind.swift @@ -14,7 +14,11 @@ public final class Bind { deinit { if ownsMemory { + #if swift(>=5.0) + bytes.deallocate() + #else bytes.deallocate(capacity: length) + #endif } } }