We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
NilAssertionError
1 parent 2b7db58 commit e1b899cCopy full SHA for e1b899c
1 file changed
src/onyx-sql/model/instance_query_shortcuts.cr
@@ -58,7 +58,11 @@ module Onyx::SQL::Model
58
{% unless (a = ivar.annotation(Reference)) && a[:foreign_key] %}
59
when {{ivar.name.stringify}}
60
{% if (a = ivar.annotation(Field) || ivar.annotation(Reference)) && a[:not_null] %}
61
- query.set({{ivar.name}}: value.as({{ivar.type}}).not_nil!)
+ if value.nil?
62
+ raise NilAssertionError.new("{{@type}}@{{ivar.name}} must not be nil on {{@type}}#update")
63
+ else
64
+ query.set({{ivar.name}}: value.as({{ivar.type}}).not_nil!)
65
+ end
66
{% else %}
67
query.set({{ivar.name}}: value.as({{ivar.type}}))
68
{% end %}
0 commit comments