stevearc / flywheel

Object mapper for Amazon's DynamoDB
MIT License
128 stars 25 forks source link

Query not returning result when using first() #59

Open shaloba opened 7 years ago

shaloba commented 7 years ago

Version: flywheel==0.4.4

I have encountered with an empty result issue when using "first" function on flywheel query object, but got result when using the "all" function (with the same query)

DB schema:


class User(Modal):
__metadata__ = {
        '_name': 'test_table',
        'global_indexes': [
            GlobalIndex('name-age-index', 'name', 'age_min').throughput(5, 3),
        ]
    }
name = Field(hash_key=True)
age_min = Field(data_type=int)      # OPTIONAL
age_max = Field(data_type=int)       # OPTIONAL

Query:

1. engine.query(User).filter(User.name == 'Erik', User.age_min <= age, User.age_max >= 18).first()
result: None

2.  engine.query(User).filter(User.name == 'Erik', User.age_min <= age, User.age_max >= 18).all()
result: [<object>]
stevearc commented 7 years ago

Yep, this is a known bug with that version. It's a dupe of #57 and was fixed in version 0.5.2. If you can't upgrade to the 0.5 branch because of backwards incompatibility I could backport it to 0.4