Skip to content

Commit

Permalink
Fix overhaul breakage, part 2 (#176)
Browse files Browse the repository at this point in the history
* Fix source code breakage caused by APIs too aggressively adopting `some`.

* Restore 100% test coverage
  • Loading branch information
gwynne committed Apr 16, 2024
1 parent cd0c5b7 commit b971688
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ extension SQLColumnUpdateBuilder {
/// - bind: The value to assign to the named column.
@inlinable
@discardableResult
public func set(_ column: String, to bind: some Encodable & Sendable) -> Self {
public func set(_ column: String, to bind: any Encodable & Sendable) -> Self {
self.set(SQLColumn(column), to: SQLBind(bind))
}

Expand All @@ -102,7 +102,7 @@ extension SQLColumnUpdateBuilder {
/// - bind: The value to assign to the given column.
@inlinable
@discardableResult
public func set(_ column: any SQLExpression, to bind: some Encodable & Sendable) -> Self {
public func set(_ column: any SQLExpression, to bind: any Encodable & Sendable) -> Self {
self.set(column, to: SQLBind(bind))
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/SQLKit/Expressions/Basics/SQLQueryString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ extension SQLQueryString {
///
/// This overload is provided as shorthand - `\(bind: "a")` is identical to `\(SQLBind("a"))`.
@inlinable
public mutating func appendInterpolation(bind value: some Encodable & Sendable) {
public mutating func appendInterpolation(bind value: any Encodable & Sendable) {
self.fragments.append(SQLBind(value))
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/SQLKit/Expressions/Clauses/SQLColumnAssignment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public struct SQLColumnAssignment: SQLExpression {

/// Create a column assignment from a column identifier and value binding.
@inlinable
public init(setting columnName: any SQLExpression, to value: some Encodable & Sendable) {
public init(setting columnName: any SQLExpression, to value: any Encodable & Sendable) {
self.init(setting: columnName, to: SQLBind(value))
}

/// Create a column assignment from a column name and value binding.
@inlinable
public init(setting columnName: String, to value: some Encodable & Sendable) {
public init(setting columnName: String, to value: any Encodable & Sendable) {
self.init(setting: columnName, to: SQLBind(value))
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/SQLKit/Expressions/SQLSerializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public struct SQLSerializer: Sendable {
///
/// - Parameter encodable: The value to bind.
@inlinable
public mutating func write(bind encodable: some Encodable & Sendable) {
public mutating func write(bind encodable: any Encodable & Sendable) {
self.binds.append(encodable)
self.dialect.bindPlaceholder(at: self.binds.count)
.serialize(to: &self)
Expand Down
4 changes: 2 additions & 2 deletions Sources/SQLKit/Expressions/Syntax/SQLBind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ public struct SQLBind: SQLExpression {

/// Create a binding to a value.
@inlinable
public init(_ encodable: some Encodable & Sendable) {
public init(_ encodable: any Encodable & Sendable) {
self.encodable = encodable
}

/// Create a list of bindings to an array of values, with the placeholders wrapped in an ``SQLGroupExpression``.
@inlinable
public static func group(_ items: some Collection<some Encodable & Sendable>) -> any SQLExpression {
public static func group(_ items: [any Encodable & Sendable]) -> any SQLExpression {
SQLGroupExpression(items.map(SQLBind.init))
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/SQLKitTests/TestMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension SQLQueryBuilder {
/// A very minimal mock `SQLDatabase` which implements `execut(sql:_:)` by saving the serialized SQL and bindings to
/// its internal arrays of accumulated "results". Most things about its dialect are mutable.
final class TestDatabase: SQLDatabase, @unchecked Sendable {
let logger: Logger = .init(label: "codes.vapor.sql.test")
let logger: Logger = { var l = Logger(label: "codes.vapor.sql.test"); l.logLevel = .debug; return l }()
let eventLoop: any EventLoop = FakeEventLoop()
var results: [String] = []
var bindResults: [[any Encodable & Sendable]] = []
Expand Down

0 comments on commit b971688

Please sign in to comment.