Skip to content
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

Fix dependency and a compile failure. #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/Kitura/Swift-Kuery.git", from: "3.0.200"),
.package(url: "https://github.com/Kitura/Swift-Kuery.git", from: "4.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftKueryPostgreSQL/PostgreSQLParameterSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal struct PostgreSQLParameterSet {
/// - Throws: QueryError.unsupported if parameter cannot be converted to data
internal func withUnsafeBufferPointers(_ body: @escaping (UnsafePointers) -> Void) throws {
let (values, lengths, formats) = try parameterData()
defer { values.forEach({ free($0) }) }
defer { values.compactMap({ $0 }).forEach({ free($0) }) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there a problem that the compactMap is solving?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. values is an array of optionals, and the free function expects a non-optional (at least in the latest compiler/library versions). This code would not compile with my Swift 5.5 toolchain without replacing forEach with compactMap, to remove the optionality.


values.map({ UnsafePointer($0) }).withUnsafeBufferPointer { valuesBuffer in
lengths.withUnsafeBufferPointer { lengthsBuffer in
Expand Down