- when 'exists', 'not exists'
- if operand
- raise ArgumentError.new("Invalid operand for subproperty existence filter, should be empty or null")
- end
- if operator.downcase[0..2] == "not" then
- cond_out << "(NOT jsonb_exists(#{ar_table_name}.#{subproperty[0]}, ?)) OR #{ar_table_name}.#{subproperty[0]} is NULL"
- else
- cond_out << "jsonb_exists(#{ar_table_name}.#{subproperty[0]}, ?)"
- end
- param_out << subproperty[1]
+ when 'exists'
+ if operand == true
+ cond_out << "jsonb_exists(#{ar_table_name}.#{subproperty[0]}, ?)"
+ 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]