On Xcode 16 beta 1 and 2, .filter(\.$nullableField == nil) does not generate the proper query
Vapor version
4.102.0
Operating system and version
macOS 14.5 (23F79)
Swift version
Swift version 6.0 (swiftlang-6.0.0.4.52 clang-1600.0.21.1.3)
Steps to reproduce
Create a model with at least one NULL-able field;
Run a query filtering on NULL for the field.
Example:
private final class DbTestEntity : Model, @unchecked Sendable {
static let schema = "test_entities"
@ID
var id: UUID?
@Field(key: FieldKeys.nullableField)
var nullableField: String?
enum FieldKeys {
static let nullableField: FieldKey = "nullable_field"
}
}
func test() async throws {
let countNulls = try await DbTestEntity.query(on: app.db)
.filter(\.$nullableField == nil)
.count()
}
Outcome
The following SQL should be generated and run:
SELECT COUNT("test_entities"."id") AS "aggregate" FROM "test_entities" WHERE "test_entities"."nullable_field" IS NULL
On Xcode 16 beta 1 and 2, the following is generated:
SELECT COUNT("test_entities"."id") AS "aggregate" FROM "test_entities" WHERE "test_entities"."nullable_field" = $1
with the following bindings ["nil"].
Interestingly using Swift version 6.0-dev (LLVM 5b37bd4c1c578e9, Swift 54898ce105c7185) in a Linux VM yields the correct query.
Using the Swift 6.0 Development Snapshot 2024-06-22 (a) also yields the correct results.
Describe the issue
On Xcode 16 beta 1 and 2,
.filter(\.$nullableField == nil)
does not generate the proper queryVapor version
4.102.0
Operating system and version
macOS 14.5 (23F79)
Swift version
Swift version 6.0 (swiftlang-6.0.0.4.52 clang-1600.0.21.1.3)
Steps to reproduce
Example:
Outcome
The following SQL should be generated and run:
On Xcode 16 beta 1 and 2, the following is generated:
with the following bindings
["nil"]
.Interestingly using
Swift version 6.0-dev (LLVM 5b37bd4c1c578e9, Swift 54898ce105c7185)
in a Linux VM yields the correct query. Using theSwift 6.0 Development Snapshot 2024-06-22 (a)
also yields the correct results.Additional notes
No response