We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ed4323b commit 2b7db58Copy full SHA for 2b7db58
1 file changed
src/onyx-sql/model/instance_query_shortcuts.cr
@@ -55,11 +55,13 @@ module Onyx::SQL::Model
55
changeset.changes!.each do |key, value|
56
case key
57
{% for ivar in @type.instance_vars %}
58
- when {{ivar.name.stringify}}
59
- {% if (a = ivar.annotation(Field) || ivar.annotation(Reference)) && a[:not_null] %}
60
- query.set({{ivar.name}}: value.as({{ivar.type}}).not_nil!)
61
- {% else %}
62
- query.set({{ivar.name}}: value.as({{ivar.type}}))
+ {% unless (a = ivar.annotation(Reference)) && a[:foreign_key] %}
+ when {{ivar.name.stringify}}
+ {% if (a = ivar.annotation(Field) || ivar.annotation(Reference)) && a[:not_null] %}
+ query.set({{ivar.name}}: value.as({{ivar.type}}).not_nil!)
+ {% else %}
63
+ query.set({{ivar.name}}: value.as({{ivar.type}}))
64
+ {% end %}
65
{% end %}
66
67
else
0 commit comments