Skip to content

Commit bc06e1f

Browse files
committed
refactor: add @_disfavoredOverload to QueryExpression methods conflicting with stdlib
- Add @_disfavoredOverload to QueryExpression.map() (Optional.swift:273) - Add @_disfavoredOverload to QueryExpression.flatMap() (Optional.swift:293) - Remove deprecated .count property that conflicted with Collection.count These changes resolve ambiguity when QueryExpression extensions are imported alongside Swift standard library types, ensuring the compiler prefers stdlib methods for regular Swift types while keeping SQL query building methods available for QueryExpression types. This helps packages importing StructuredQueriesPostgres avoid type inference conflicts when working with regular Swift collections and optionals. All 835 tests passing.
1 parent 9c433b9 commit bc06e1f

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

Sources/StructuredQueriesCore/Optional.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ extension QueryExpression where QueryValue: _OptionalProtocol {
270270
///
271271
/// - Parameter transform: A closure that takes an unwrapped version of this expression.
272272
/// - Returns: The result of the transform function, optionalized.
273+
@_disfavoredOverload
273274
public func map<T>(
274275
_ transform: (SQLQueryExpression<QueryValue.Wrapped>) -> some QueryExpression<T>
275276
) -> some QueryExpression<T?> {
@@ -289,6 +290,7 @@ extension QueryExpression where QueryValue: _OptionalProtocol {
289290
///
290291
/// - Parameter transform: A closure that takes an unwrapped version of this expression.
291292
/// - Returns: The result of the transform function.
293+
@_disfavoredOverload
292294
public func flatMap<T>(
293295
_ transform: (SQLQueryExpression<QueryValue.Wrapped>) -> some QueryExpression<T?>
294296
) -> some QueryExpression<T?> {

Sources/StructuredQueriesPostgres/Functions/String/BasicStringFunctions.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ extension QueryExpression where QueryValue: Collection {
3030
public func length() -> some QueryExpression<Int> {
3131
QueryFunction("length", self)
3232
}
33-
34-
@available(
35-
*,
36-
deprecated,
37-
message: "Use 'count()' for SQL's 'count' aggregate function, or 'length()'"
38-
)
39-
public var count: some QueryExpression<Int> {
40-
length()
41-
}
4233
}
4334

4435
extension QueryExpression where QueryValue == String {

0 commit comments

Comments
 (0)