Open grvhi opened 5 years ago
Were you ever able to figure this out @grvhi? I'm running into the same issue :/
@bhayani - not that I remember I’m afraid. IIRC, I ended up not using a secondary index anyway, but the issue remained.
When you don't provide a filter_condition
, there's code that gracefully assumes you provided a filter condition in place of a range key condition, and treats your range key condition as a filter condition.
However, if you provide both, then your range key condition must be a proper range key condition.
In the code above:
return SomeModel.some_index.query(
'some-hash-id',
range_key_condition=cls.range_key == 'some-value',
filter_condition=cls.status == 0
)
it's hard to tell just from this code what's wrong, but for starters:
1) Why cls.range_key
and not SomeModel.range_key
? We're not told what cls
is, and I cannot infer if there was a mistake (maybe cls != SomeModel
?)
2) I'd need to see the model definition.
What it does tell me is that we need a better error message.
When querying a global secondary index, I cannot apply both a
range_key_condition
andfilter_expression
to the query:This code works exactly as expected:
But this code fails with a
ValueError
:Note that the
status
attribute is aNumberAttribute
and is not a hash key or range key. Andcls.range_key
is the attribute name of the model's range key and is aUnicodeAttribute
.The exception is: