Force KeyCondition when filtering by only partition key in a table with a composite key
thebatclaudio opened this issue · 1 comments
thebatclaudio commented
Describe the bug
I have a table with a partition key and a range key. I'm trying to use where
to filter records by partition key only, but when i run toDynamoDbQuery
I see that it is using FilterException instead of KeyConditionExpression.
I know that this behaviour is related to composite key definition, there is a way to force it to use KeyConditionExpression?
Thank you
Schema
Describe your table schema:
- entity (partition key)
- executed_at (range key)
Debug info
Running:
dd($activityLog->where('entity', 'App\UsersPeriods#44')->toDynamoDbQuery());
I get:
BaoPham\DynamoDb\RawDynamoDbQuery {#5844
+op: "Scan",
+query: [
"TableName" => "activity_logs_local",
"FilterExpression" => "#entity = :a1",
"ExpressionAttributeNames" => [
"#entity" => "entity",
],
"ExpressionAttributeValues" => [
":a1" => [
"S" => "App\UsersPeriods#44",
],
],
],
}
Version info
- Laravel: 8.83.4
- laravel-dynamodb: 6.1.3
thebatclaudio commented
I resolved it in PR #254