Method: Parse::Constraint::NullabilityConstraint#build

Defined in:
lib/parse/query/constraints.rb

#buildHash

Returns the compiled constraint.

Returns:

  • (Hash)

    the compiled constraint.



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/parse/query/constraints.rb', line 245

def build
  # if nullability is equal true, then $exists should be set to false

  value = formatted_value
  unless value == true || value == false
    raise ArgumentError, "#{self.class}: Non-Boolean value passed, it must be either `true` or `false`"
  end

  if value == true
    return { @operation.operand => { key => false } }
  else
    #current bug in parse where if you want exists => true with geo queries
    # we should map it to a "not equal to null" constraint
    return { @operation.operand => { Parse::Constraint::NotEqualConstraint.key => nil } }
  end
end