Closed nastynate13 closed 9 months ago
Hm... That's a bug alright, and the practical upshot of it is that the uniformity check isn't really sensible unless the input mapping is smart enough to use an explicit default literal... looks like I need to tweak the logic for .create()
to explicitly request defaulted values for unset fields. I'll put up a fix for this shortly, thanks for reporting!
Thank you!
Describe the bug
Fatal error "Non-uniform query input" when creating models from a collection.
To Reproduce
The issue seems to be triggered when:
and
Steps to reproduce the behavior:
in
configure(_ app: Application)
to reproduce the crash:
debug crash log:
[ DEBUG ] query create foos input=[[id: E88693CF-100F-496B-9019-57F7DA4AA134, maybe_nil: "not nil"], [id: 1B224F66-F7CD-4A93-B7EA-8371FD1ED913]] [database-id: psql] (FluentKit/QueryBuilder.swift:293) FluentSQL/SQLQueryConverter.swift:107: Fatal error: Non-uniform query input: [[id: E88693CF-100F-496B-9019-57F7DA4AA134, maybe_nil: "not nil"], [id: 1B224F66-F7CD-4A93-B7EA-8371FD1ED913]]
to eliminate the crash:
explicit set the the
Foo.maybeNil
value to nil in the model's initializer (as opposed to leaving it unset)Expected behavior
No error - just as if the models were created one by one. The following code does not produce the error, even when the optional fields are left unset.
Environment
package details: