Skip to content

Commit d6d4b1e

Browse files
committed
PHPC-734: Query "collation" option
1 parent f37f589 commit d6d4b1e

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/MongoDB/Query.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ static bool php_phongo_query_init(php_phongo_query_t *intern, zval *filter, zval
255255
PHONGO_QUERY_OPT_BOOL("allowPartialResults", options, "allowPartialResults");
256256
PHONGO_QUERY_OPT_BOOL("awaitData", options, "awaitData");
257257
PHONGO_QUERY_OPT_INT64("batchSize", options, "batchSize");
258+
PHONGO_QUERY_OPT_DOCUMENT("collation", options, "collation");
258259
PHONGO_QUERY_OPT_STRING("comment", options, "comment")
259260
else PHONGO_QUERY_OPT_STRING("comment", modifiers, "$comment");
260261
PHONGO_QUERY_OPT_BOOL("exhaust", options, "exhaust");

tests/query/query-ctor-002.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var_dump(new MongoDB\Driver\Query(
99
'allowPartialResults' => false,
1010
'awaitData' => false,
1111
'batchSize' => 10,
12+
'collation' => ['locale' => 'en_US'],
1213
'comment' => 'foo',
1314
'exhaust' => false,
1415
'limit' => 20,
@@ -62,6 +63,11 @@ object(MongoDB\Driver\Query)#%d (%d) {
6263
bool(false)
6364
["batchSize"]=>
6465
int(10)
66+
["collation"]=>
67+
object(stdClass)#3 (1) {
68+
["locale"]=>
69+
string(5) "en_US"
70+
}
6571
["comment"]=>
6672
string(3) "foo"
6773
["exhaust"]=>

tests/query/query-ctor_error-002.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require_once __DIR__ . '/../utils/tools.php';
77

88
$tests = [
99
['modifiers' => 0],
10+
['collation' => 0],
1011
['comment' => 0],
1112
['hint' => 0],
1213
['max' => 0],
@@ -33,6 +34,9 @@ foreach ($tests as $options) {
3334
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
3435
Expected "modifiers" option to be array, integer given
3536

37+
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
38+
Expected "collation" option to be array or object, integer given
39+
3640
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
3741
Expected "comment" option to be string, integer given
3842

0 commit comments

Comments
 (0)