Skip to content

Commit e1b899c

Browse files
committed
feat (Model#update): NilAssertionError with message
1 parent 2b7db58 commit e1b899c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/onyx-sql/model/instance_query_shortcuts.cr

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ module Onyx::SQL::Model
5858
{% unless (a = ivar.annotation(Reference)) && a[:foreign_key] %}
5959
when {{ivar.name.stringify}}
6060
{% if (a = ivar.annotation(Field) || ivar.annotation(Reference)) && a[:not_null] %}
61-
query.set({{ivar.name}}: value.as({{ivar.type}}).not_nil!)
61+
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
6266
{% else %}
6367
query.set({{ivar.name}}: value.as({{ivar.type}}))
6468
{% end %}

0 commit comments

Comments
 (0)