From a683596f1d20b5882599b1764766bf33e1c32e1a Mon Sep 17 00:00:00 2001 From: marcoarment Date: Mon, 26 Jun 2023 15:47:13 -0400 Subject: [PATCH] Fix Swift 6 type-name-shadowing warnings --- Sources/Blackbird/BlackbirdColumn.swift | 2 +- .../BlackbirdModelStructuredQuerying.swift | 24 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Sources/Blackbird/BlackbirdColumn.swift b/Sources/Blackbird/BlackbirdColumn.swift index 6a7d8cb..dfe5dbe 100644 --- a/Sources/Blackbird/BlackbirdColumn.swift +++ b/Sources/Blackbird/BlackbirdColumn.swift @@ -49,7 +49,7 @@ internal protocol ColumnWrapper: WrappedType { public static func == (lhs: Self, rhs: Self) -> Bool { type(of: lhs) == type(of: rhs) && lhs.value == rhs.value } private var _value: T - internal final class ColumnState: @unchecked Sendable /* unchecked due to external locking in all uses */ { + internal final class ColumnState: @unchecked Sendable /* unchecked due to external locking in all uses */ { var hasChanged: Bool weak var lastUsedDatabase: Blackbird.Database? diff --git a/Sources/Blackbird/BlackbirdModelStructuredQuerying.swift b/Sources/Blackbird/BlackbirdModelStructuredQuerying.swift index 00ef611..9a893bd 100644 --- a/Sources/Blackbird/BlackbirdModelStructuredQuerying.swift +++ b/Sources/Blackbird/BlackbirdModelStructuredQuerying.swift @@ -49,7 +49,7 @@ public extension String.StringInterpolation { /// Used as a `orderBy:` expression in ``BlackbirdModel`` functions such as: /// - ``BlackbirdModel/query(in:columns:matching:orderBy:limit:)`` /// - ``BlackbirdModel/read(from:matching:orderBy:limit:)`` -public struct BlackbirdModelOrderClause: Sendable { +public struct BlackbirdModelOrderClause: Sendable, CustomDebugStringConvertible { public enum Direction: Sendable { case ascending case descending @@ -70,6 +70,8 @@ public struct BlackbirdModelOrderClause: Sendable { let columnName = table.keyPathToColumnName(keyPath: column) return "`\(columnName)`\(direction == .descending ? " DESC" : "")" } + + public var debugDescription: String { orderByClause(table: T.table) } } fileprivate struct DecodedStructuredQuery: Sendable { @@ -566,12 +568,12 @@ public func || (lhs: BlackbirdModelColumnExpression, rhs: /// - ``BlackbirdModel/read(from:matching:orderBy:limit:)`` /// - ``BlackbirdModel/update(in:set:matching:)`` /// - ``BlackbirdModel/delete(from:matching:)`` -public struct BlackbirdModelColumnExpression: Sendable, BlackbirdQueryExpression { +public struct BlackbirdModelColumnExpression: Sendable, BlackbirdQueryExpression, CustomDebugStringConvertible { /// Use `.all` to operate on all rows in the table without a `WHERE` clause. public static var all: Self { get { - BlackbirdModelColumnExpression() + BlackbirdModelColumnExpression() } } @@ -595,29 +597,31 @@ public struct BlackbirdModelColumnExpression: Sendable, Black } private let expression: BlackbirdQueryExpression + + public var debugDescription: String { expression.compile(table: Model.table).whereClause ?? String(describing: self) } - init(column: T.BlackbirdColumnKeyPath, sqlOperator: UnaryOperator) { + init(column: Model.BlackbirdColumnKeyPath, sqlOperator: UnaryOperator) { expression = BlackbirdColumnUnaryExpression(column: column, sqlOperator: sqlOperator) } - init(column: T.BlackbirdColumnKeyPath, sqlOperator: BinaryOperator, value: Sendable) { + init(column: Model.BlackbirdColumnKeyPath, sqlOperator: BinaryOperator, value: Sendable) { expression = BlackbirdColumnBinaryExpression(column: column, sqlOperator: sqlOperator, value: value) } - init(column: T.BlackbirdColumnKeyPath, valueIn values: [Sendable]) { + init(column: Model.BlackbirdColumnKeyPath, valueIn values: [Sendable]) { expression = BlackbirdColumnInExpression(column: column, values: values) } - init(column: T.BlackbirdColumnKeyPath, valueLike pattern: String) { + init(column: Model.BlackbirdColumnKeyPath, valueLike pattern: String) { expression = BlackbirdColumnLikeExpression(column: column, pattern: pattern) } - init(lhs: BlackbirdModelColumnExpression, sqlOperator: CombiningOperator, rhs: BlackbirdModelColumnExpression) { + init(lhs: BlackbirdModelColumnExpression, sqlOperator: CombiningOperator, rhs: BlackbirdModelColumnExpression) { expression = BlackbirdCombiningExpression(lhs: lhs, rhs: rhs, sqlOperator: sqlOperator) } - init(not expression: BlackbirdModelColumnExpression) { - self.expression = BlackbirdColumnNotExpression(type: T.self, expression: expression) + init(not expression: BlackbirdModelColumnExpression) { + self.expression = BlackbirdColumnNotExpression(type: Model.self, expression: expression) } init(expressionLiteral: String, arguments: [Sendable]) {