Class: Parse::Constraint::NullabilityConstraint
- Inherits:
- Parse::Constraint
- Object
- Parse::Constraint
- Parse::Constraint::NullabilityConstraint
- Defined in:
- lib/parse/query/constraints.rb
Overview
Parse currently has a bug that if you select items near a location and want to make sure a different column has a value, you need to search where the column does not contanin a null/undefined value. Therefore we override the build method to change the operation to a NotEqualConstraint.
Provides a mechanism using the equality operator to check for `(undefined)` values. Nullabiliity constraint maps the `$exists` Parse clause to enable checking for existance in a column when performing geoqueries due to a Parse limitation.
q.where :field.null => false
Instance Attribute Summary
Attributes inherited from Parse::Constraint
#operand, #operation, #operator, #value
Instance Method Summary collapse
- #build ⇒ Hash
The compiled constraint.
- #null ⇒ NullabilityConstraint
A registered method on a symbol to create the constraint.
Methods inherited from Parse::Constraint
#as_json, contraint_keyword, create, #formatted_value, formatted_value, #initialize, #key, #precedence, register, #to_s
Constructor Details
This class inherits a constructor from Parse::Constraint
Instance Method Details
#build ⇒ Hash
Returns 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 |
#null ⇒ NullabilityConstraint
A registered method on a symbol to create the constraint.
241 | # File 'lib/parse/query/constraints.rb', line 241 contraint_keyword :$exists |