col = model_class.columns.select { |c| c.name == subproperty[0] }.first
if subproperty.length == 2
- if col.type != :jsonb
- raise ArgumentError.new("Invalid attribute '#{subproperty[0]}' for operator '#{operator}' in filter")
+ if col.nil? or col.type != :jsonb
+ raise ArgumentError.new("Invalid attribute '#{subproperty[0]}' for subproperty filter")
end
if subproperty[1][0] == "<" and subproperty[1][-1] == ">"
"for '#{operator}' operator in filters")
end
when 'exists'
- if operand
+ if operand == true
cond_out << "jsonb_exists(#{ar_table_name}.#{subproperty[0]}, ?)"
- else
+ elsif operand == false
cond_out << "(NOT jsonb_exists(#{ar_table_name}.#{subproperty[0]}, ?)) OR #{ar_table_name}.#{subproperty[0]} is NULL"
+ else
+ raise ArgumentError.new("Invalid operand '#{operand}' for '#{operator}' must be true or false")
end
param_out << subproperty[1]
else