Description
When calling .contains("text") on an unwrapped optional String column inside .map, the generated SQL uses the IN operator instead of LIKE '%text%'. The same .contains() call on a non-optional String column correctly generates LIKE.
Checklist
Expected behavior
-- Expected for optional:
WHERE CASE "items"."subtitle" IS NULL WHEN 1 THEN NULL ELSE ("items"."subtitle" LIKE '%red%') END
Actual behavior
WHERE CASE "items"."subtitle" IS NULL WHEN 1 THEN NULL ELSE ('red') IN (("items"."subtitle")) END
Reproducing project
It appears that inside the .map closure, Swift's overload resolution picks a .contains that checks element membership (IN) rather than the string .contains that produces LIKE. Likely because String conforms to both StringProtocol and QueryExpression<String> (via QueryBindable), and the generic context of .map<T> tips the type checker toward the wrong overload.
Structured Queries version information
swift-structured-queries 0.31.1
Destination operating system
No response
Xcode version information
Version 26.4 (17E192
Swift Compiler version information
Description
When calling .contains("text") on an unwrapped optional String column inside .map, the generated SQL uses the IN operator instead of LIKE '%text%'. The same .contains() call on a non-optional String column correctly generates LIKE.
Checklist
mainbranch of this package.Expected behavior
-- Expected for optional:
WHERE CASE "items"."subtitle" IS NULL WHEN 1 THEN NULL ELSE ("items"."subtitle" LIKE '%red%') END
Actual behavior
WHERE CASE "items"."subtitle" IS NULL WHEN 1 THEN NULL ELSE ('red') IN (("items"."subtitle")) END
Reproducing project
It appears that inside the .map closure, Swift's overload resolution picks a .contains that checks element membership (IN) rather than the string .contains that produces LIKE. Likely because String conforms to both StringProtocol and QueryExpression<String> (via QueryBindable), and the generic context of .map<T> tips the type checker toward the wrong overload.
Structured Queries version information
swift-structured-queries 0.31.1
Destination operating system
No response
Xcode version information
Version 26.4 (17E192
Swift Compiler version information