Skip to content

Finder query comparisons gt, gte, lt, lte are reversed #130

@cognitiveflux

Description

@cognitiveflux

The greater or less than comparisons are reversed.

Example -- the gt() method as currently implemented:

def gt ...
... do |comparator, item|
comparator > item

which is receives yield query_string, comparator from do_comparison, substituting from above:

def gt ...
... do |query_string, comparator|
query_string > comparator

If you send SomeModel.where(:attribute).gt(1), that currently gets evaluated as:

def gt ...
... do |1, attribute_value|
1 > attribute_value

If you're looking for all model instances with the attribute value greater than 1, it should be:

def gt ...
... do |1, attribute_value|
1 < attribute_value

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions