Skip to content

Commit c63a1a8

Browse files
committed
Merge pull request #218
2 parents c27c466 + 20e601a commit c63a1a8

File tree

4 files changed

+87
-1
lines changed

4 files changed

+87
-1
lines changed

src/MongoDB/Query.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,23 @@ HashTable *php_phongo_query_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
228228
ADD_ASSOC_LONG_EX(&retval, "limit", intern->limit);
229229
ADD_ASSOC_LONG_EX(&retval, "batch_size", intern->batch_size);
230230

231+
if (intern->read_concern) {
232+
#if PHP_VERSION_ID >= 70000
233+
zval read_concern;
234+
235+
php_phongo_read_concern_to_zval(&read_concern, intern->read_concern);
236+
ADD_ASSOC_ZVAL_EX(&retval, "readConcern", &read_concern);
237+
#else
238+
zval *read_concern = NULL;
239+
MAKE_STD_ZVAL(read_concern);
240+
241+
php_phongo_read_concern_to_zval(read_concern, intern->read_concern);
242+
ADD_ASSOC_ZVAL_EX(&retval, "readConcern", read_concern);
243+
#endif
244+
} else {
245+
ADD_ASSOC_NULL_EX(&retval, "readConcern");
246+
}
247+
231248
return Z_ARRVAL(retval);
232249

233250
} /* }}} */

tests/functional/query-sort-003.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ object(MongoDB\Driver\Query)#%d (%d) {
5555
int(0)
5656
["batch_size"]=>
5757
int(0)
58+
["readConcern"]=>
59+
NULL
5860
}
5961
string(21) "MongoDB\Driver\Cursor"
6062
aaliyah.kertzmann

tests/functional/query-sort-004.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ foreach ($cursor as $document) {
4040
<?php exit(0); ?>
4141
--EXPECTF--
4242
Inserted: 5
43-
object(MongoDB\Driver\Query)#%d (6) {
43+
object(MongoDB\Driver\Query)#%d (%d) {
4444
["query"]=>
4545
object(stdClass)#%d (2) {
4646
["$orderby"]=>
@@ -62,6 +62,8 @@ object(MongoDB\Driver\Query)#%d (6) {
6262
int(0)
6363
["batch_size"]=>
6464
int(0)
65+
["readConcern"]=>
66+
NULL
6567
}
6668
0
6769
1

tests/query/query-debug-001.phpt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
--TEST--
2+
MongoDB\Driver\Query debug output
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
5+
--FILE--
6+
<?php
7+
require_once __DIR__ . "/../utils/basic.inc";
8+
9+
var_dump(new MongoDB\Driver\Query(
10+
['a' => 123],
11+
[
12+
'limit' => 5,
13+
'modifiers' => [
14+
'$comment' => 'foo',
15+
'$maxTimeMS' => 500,
16+
],
17+
'projection' => ['c' => 1],
18+
'readConcern' => new MongoDB\Driver\ReadConcern(MongoDB\Driver\ReadConcern::LOCAL),
19+
'skip' => 10,
20+
'sort' => ['b' => -1],
21+
]
22+
));
23+
24+
?>
25+
===DONE===
26+
<?php exit(0); ?>
27+
--EXPECTF--
28+
object(MongoDB\Driver\Query)#%d (%d) {
29+
["query"]=>
30+
object(stdClass)#%d (%d) {
31+
["$comment"]=>
32+
string(3) "foo"
33+
["$maxTimeMS"]=>
34+
int(500)
35+
["$orderby"]=>
36+
object(stdClass)#%d (%d) {
37+
["b"]=>
38+
int(-1)
39+
}
40+
["$query"]=>
41+
object(stdClass)#%d (%d) {
42+
["a"]=>
43+
int(123)
44+
}
45+
}
46+
["selector"]=>
47+
object(stdClass)#%d (%d) {
48+
["c"]=>
49+
int(1)
50+
}
51+
["flags"]=>
52+
int(0)
53+
["skip"]=>
54+
int(10)
55+
["limit"]=>
56+
int(5)
57+
["batch_size"]=>
58+
int(0)
59+
["readConcern"]=>
60+
array(1) {
61+
["level"]=>
62+
string(5) "local"
63+
}
64+
}
65+
===DONE===

0 commit comments

Comments
 (0)