Skip to content

Commit 3344030

Browse files
Merge pull request #22 from GBeushausen/master
Allow QueryOperation to filter custom expressions
2 parents 8ba21b2 + 3cf2049 commit 3344030

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

src/DynamoDb/Operation/QueryOperation.php

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,27 @@ public function __construct(
4949
) {
5050
parent::__construct($client, $marshaler, $tableName);
5151
if (!empty($keyConditions)) {
52-
$this->setPartitionKeyConditionExpression(
53-
$keyConditions['partition']['name'],
54-
$keyConditions['partition']['value']
55-
);
56-
if (isset($keyConditions['sort'])) {
57-
$this->setSortKeyConditionExpression(
58-
$keyConditions['sort']['name'],
59-
$keyConditions['sort']['operator'],
60-
$keyConditions['sort']['value']
61-
);
52+
foreach ($keyConditions as $key => $condition) {
53+
switch ($key) {
54+
case 'partition':
55+
$this->setPartitionKeyConditionExpression(
56+
$condition['name'],
57+
$condition['value']
58+
);
59+
break;
60+
case 'sort':
61+
$this->setSortKeyConditionExpression(
62+
$condition['name'],
63+
$condition['operator'],
64+
$condition['value']
65+
);
66+
break;
67+
default:
68+
$this->setExpression([
69+
$key => $condition,
70+
]);
71+
break;
72+
}
6273
}
6374
}
6475
}

0 commit comments

Comments
 (0)