Skip to content

Commit 24110a5

Browse files
committed
fix (Query#set): raise earlier if key is not found
1 parent 028c141 commit 24110a5

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/onyx-sql/query/set.cr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,12 @@ module Onyx::SQL
5353
{% for key, value in U %}
5454
{%
5555
ivar = T.instance_vars.find(&.name.== key)
56+
raise "Cannot find an instance variable named @#{key} in #{T}" unless ivar
5657

5758
not_null = (a = ivar.annotation(Field) || ivar.annotation(Reference)) && a[:not_null]
5859
raise "On Query(#{T})#set: #{key} is nilable in compilation time (`#{value}`), but #{T}@#{ivar.name} has `not_null` option set to `true`. Consider calling `.not_nil!` on the value" if not_null && value.nilable?
5960
%}
6061

61-
{% raise "Cannot find an instance variable named @#{key} in #{T}" unless ivar %}
62-
6362
when {{key.symbolize}}
6463
ensure_set << Set.new(
6564
clause: T.db_column({{ivar.name.symbolize}}),

0 commit comments

Comments
 (0)