mirror of
https://github.com/predis/predis.git
synced 2026-08-31 04:35:05 +00:00
Fix support options array in ZINTERSTORE and ZUNIONSTORE (#1018)
* support old options array * fix zinterstore as well * single override
This commit is contained in:
@@ -50,6 +50,13 @@ class ZUNIONSTORE extends RedisCommand
|
||||
*/
|
||||
public function setArguments(array $arguments)
|
||||
{
|
||||
// support old `$options` array for backwards compatibility
|
||||
if (! isset($arguments[3]) && (isset($arguments[2]['weights']) || isset($arguments[2]['aggregate']))) {
|
||||
$options = array_pop($arguments);
|
||||
array_push($arguments, $options['weights'] ?? []);
|
||||
array_push($arguments, $options['aggregate'] ?? 'sum');
|
||||
}
|
||||
|
||||
$this->setAggregate($arguments);
|
||||
$arguments = $this->getArguments();
|
||||
|
||||
|
||||
@@ -153,7 +153,14 @@ class ZINTERSTORE_Test extends PredisCommandTestCase
|
||||
'with all arguments' => [
|
||||
['destination', ['key1', 'key2'], [1, 2], 'min'],
|
||||
['destination', 2, 'key1', 'key2', 'WEIGHTS', 1, 2, 'AGGREGATE', 'MIN'],
|
||||
]
|
||||
],
|
||||
'with options array' => [
|
||||
['destination', ['key1', 'key2'], [
|
||||
'weights' => [1, 2],
|
||||
'aggregate' => 'min',
|
||||
]],
|
||||
['destination', 2, 'key1', 'key2', 'WEIGHTS', 1, 2, 'AGGREGATE', 'MIN'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,14 @@ class ZUNIONSTORE_Test extends PredisCommandTestCase
|
||||
'with all arguments' => [
|
||||
['destination', ['key1', 'key2'], [1, 2], 'min'],
|
||||
['destination', 2, 'key1', 'key2', 'WEIGHTS', 1, 2, 'AGGREGATE', 'MIN'],
|
||||
]
|
||||
],
|
||||
'with options array' => [
|
||||
['destination', ['key1', 'key2'], [
|
||||
'weights' => [1, 2],
|
||||
'aggregate' => 'min',
|
||||
]],
|
||||
['destination', 2, 'key1', 'key2', 'WEIGHTS', 1, 2, 'AGGREGATE', 'MIN'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user