Skip to content

Commit 64e79e4

Browse files
GromNaNjmikola
andcommitted
Review fixes
Co-authored-by: Jeremy Mikola <jmikola@gmail.com>
1 parent 339b357 commit 64e79e4

16 files changed

+56
-112
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ rector.php export-ignore
2323
/src/Builder/Expression/*.php linguist-generated=true
2424
/src/Builder/Query/*.php linguist-generated=true
2525
/src/Builder/Projection/*.php linguist-generated=true
26+
/src/Builder/Search/*.php linguist-generated=true
2627
/src/Builder/Stage/*.php linguist-generated=true
2728
/tests/Builder/*/Pipelines.php linguist-generated=true

generator/config/search/autocomplete.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ arguments:
2222
name: tokenOrder
2323
optional: true
2424
type:
25-
- string #tokenOrder
25+
- string # any|sequential
2626
-
2727
name: fuzzy
2828
optional: true

generator/config/search/compound.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# $schema: ../schema.json
22
name: compound
3-
link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/'
3+
link: 'https://www.mongodb.com/docs/atlas/atlas-search/compound/'
44
type:
55
- searchOperator
66
encode: object

generator/config/search/embeddedDocument.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# $schema: ../schema.json
22
name: embeddedDocument
3-
link: 'https://www.mongodb.com/docs/atlas/atlas-search/embeddedDocument/'
3+
link: 'https://www.mongodb.com/docs/atlas/atlas-search/embedded-document/'
44
type:
55
- searchOperator
66
encode: object

generator/config/search/exists.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# $schema: ../schema.json
22
name: exists
3-
link: 'https://www.mongodb.com/docs/atlas/atlas-search/equals/'
3+
link: 'https://www.mongodb.com/docs/atlas/atlas-search/exists/'
44
type:
55
- searchOperator
66
encode: object
77
description: |
8-
The equals operator checks whether a field matches a value you specify.
8+
The exists operator tests if a path to a specified indexed field name exists in a document.
99
arguments:
1010
-
1111
name: path

generator/config/search/facet.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ arguments:
1111
-
1212
name: facets
1313
type:
14-
- object # of facetDefinition
14+
- object # map of facetDefinition
1515
-
1616
name: operator
1717
optional: true

generator/config/search/geoShape.yaml

Lines changed: 24 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,10 @@ tests:
3838
type: 'Polygon'
3939
coordinates:
4040
-
41-
-
42-
- -161.323242
43-
- 22.512557
44-
-
45-
- -152.446289
46-
- 22.065278
47-
-
48-
- -156.09375
49-
- 17.811456
50-
-
51-
- -161.323242
52-
- 22.512557
41+
- [-161.323242, 22.512557]
42+
- [-152.446289, 22.065278]
43+
- [-156.09375, 17.811456]
44+
- [-161.323242, 22.512557]
5345
path: 'address.location'
5446
-
5547
$limit: 3
@@ -74,44 +66,20 @@ tests:
7466
coordinates:
7567
-
7668
-
77-
-
78-
- 2.16942
79-
- 41.40082
80-
-
81-
- 2.17963
82-
- 41.40087
83-
-
84-
- 2.18146
85-
- 41.39716
86-
-
87-
- 2.15533
88-
- 41.40686
89-
-
90-
- 2.14596
91-
- 41.38475
92-
-
93-
- 2.17519
94-
- 41.41035
95-
-
96-
- 2.16942
97-
- 41.40082
69+
- [2.16942, 41.40082]
70+
- [2.17963, 41.40087]
71+
- [2.18146, 41.39716]
72+
- [2.15533, 41.40686]
73+
- [2.14596, 41.38475]
74+
- [2.17519, 41.41035]
75+
- [2.16942, 41.40082]
9876
-
9977
-
100-
-
101-
- 2.16365
102-
- 41.39416
103-
-
104-
- 2.16963
105-
- 41.39726
106-
-
107-
- 2.15395
108-
- 41.38005
109-
-
110-
- 2.17935
111-
- 41.43038
112-
-
113-
- 2.16365
114-
- 41.39416
78+
- [2.16365, 41.39416]
79+
- [2.16963, 41.39726]
80+
- [2.15395, 41.38005]
81+
- [2.17935, 41.43038]
82+
- [2.16365, 41.39416]
11583
path: 'address.location'
11684
-
11785
$limit: 3
@@ -135,30 +103,14 @@ tests:
135103
type: 'Polygon'
136104
coordinates:
137105
-
138-
-
139-
- -74.3994140625
140-
- 40.5305017757
141-
-
142-
- -74.7290039063
143-
- 40.5805846641
144-
-
145-
- -74.7729492188
146-
- 40.9467136651
147-
-
148-
- -74.0698242188
149-
- 41.1290213475
150-
-
151-
- -73.65234375
152-
- 40.9964840144
153-
-
154-
- -72.6416015625
155-
- 40.9467136651
156-
-
157-
- -72.3559570313
158-
- 40.7971774152
159-
-
160-
- -74.3994140625
161-
- 40.5305017757
106+
- [-74.3994140625, 40.5305017757]
107+
- [-74.7290039063, 40.5805846641]
108+
- [-74.7729492188, 40.9467136651]
109+
- [-74.0698242188, 41.1290213475]
110+
- [-73.65234375, 40.9964840144]
111+
- [-72.6416015625, 40.9467136651]
112+
- [-72.3559570313, 40.7971774152]
113+
- [-74.3994140625, 40.5305017757]
162114
path: 'address.location'
163115
-
164116
$limit: 3

generator/config/search/geoWithin.yaml

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,10 @@ tests:
4545
box:
4646
bottomLeft:
4747
type: 'Point'
48-
coordinates:
49-
- 112.467
50-
- -55.05
48+
coordinates: [112.467, -55.05]
5149
topRight:
5250
type: 'Point'
53-
coordinates:
54-
- 168
55-
- -9.133
51+
coordinates: [168, -9.133]
5652
-
5753
$limit: 3
5854
-
@@ -71,9 +67,7 @@ tests:
7167
circle:
7268
center:
7369
type: 'Point'
74-
coordinates:
75-
- -73.54
76-
- 45.54
70+
coordinates: [-73.54, 45.54]
7771
radius: 1600
7872
path: 'address.location'
7973
-
@@ -95,18 +89,10 @@ tests:
9589
type: 'Polygon'
9690
coordinates:
9791
-
98-
-
99-
- -161.323242
100-
- 22.512557
101-
-
102-
- -152.446289
103-
- 22.065278
104-
-
105-
- -156.09375
106-
- 17.811456
107-
-
108-
- -161.323242
109-
- 22.512557
92+
- [-161.323242, 22.512557]
93+
- [-152.446289, 22.065278]
94+
- [-156.09375, 17.811456]
95+
- [-161.323242, 22.512557]
11096
path: 'address.location'
11197
-
11298
$limit: 3

generator/js2yaml.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ <h1>Convert JS examples into Yaml</h1>
119119
return ' []';
120120
}
121121

122+
// Inline list of numbers
123+
if (object.every(item => typeof item === 'number')) {
124+
return ' [' + object.map(item => toYaml(item).trim()).join(', ') + ']';
125+
}
126+
122127
return newline + '-' + object.map((item) => toYaml(item, indent + 1)).join(newline + '-');
123128
}
124129

generator/src/OperatorTestGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
use function base64_decode;
2929
use function basename;
3030
use function get_object_vars;
31+
use function hex2bin;
3132
use function is_array;
3233
use function is_numeric;
3334
use function is_object;
3435
use function json_decode;
3536
use function json_encode;
3637
use function ksort;
37-
use function pack;
3838
use function sprintf;
3939
use function str_replace;
4040
use function ucwords;
@@ -148,7 +148,7 @@ private function convertYamlTaggedValues(mixed $object): mixed
148148
'bson_utcdatetime' => new UTCDateTime(is_numeric($value) ? $value : new DateTimeImmutable($value)),
149149
'bson_binary' => new Binary(base64_decode($value)),
150150
'bson_objectId' => new ObjectId($value),
151-
'bson_uuid' => new Binary(pack('h*', str_replace('-', '', $value)), Binary::TYPE_UUID),
151+
'bson_uuid' => new Binary(hex2bin(str_replace('-', '', $value)), Binary::TYPE_UUID),
152152
default => throw new InvalidArgumentException(sprintf('Yaml tag "%s" is not supported.', $object->getTag())),
153153
};
154154
}

src/Builder/Search/CompoundOperator.php

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Search/EmbeddedDocumentOperator.php

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Search/ExistsOperator.php

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Builder/Search/FactoryTrait.php

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/Builder/Search/EqualsOperatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use MongoDB\Builder\Stage;
1414
use MongoDB\Tests\Builder\PipelineTestCase;
1515

16-
use function pack;
16+
use function hex2bin;
1717

1818
/**
1919
* Test equals search
@@ -115,7 +115,7 @@ public function testUUID(): void
115115
Stage::search(
116116
Search::equals(
117117
path: 'uuid',
118-
value: new Binary(pack('h*', 'fac32260b5114c698485a2be5b7dda9e'), Binary::TYPE_UUID),
118+
value: new Binary(hex2bin('fac32260b5114c698485a2be5b7dda9e'), Binary::TYPE_UUID),
119119
),
120120
),
121121
);

tests/Builder/Search/Pipelines.php

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)