Skip to content

Commit 6d3711c

Browse files
pimpinclaude
andcommitted
Handle nil values in nested Hash attribute updates
When a nil value is passed in a Hash update (e.g. update(field: { key: nil })), quote() returns nil which interpolates as an empty string, producing invalid N1QL syntax. Fall back to 'NULL' literal in that case. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fd9d945 commit 6d3711c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/couchbase-orm/relation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def build_update(**cond)
217217
end
218218
if value.is_a?(Hash)
219219
value.map do |k, v|
220-
"#{key}.#{k} = #{@model.quote(v)}"
220+
"#{key}.#{k} = #{@model.quote(v) || 'NULL'}"
221221
end.join(", ") + for_clause
222222
else
223223
"#{key} = #{@model.quote(value)}#{for_clause}"

0 commit comments

Comments
 (0)