@@ -107,6 +107,7 @@ class BsonTypesIntegrationTests: FSTIntegrationTestCase {
107
107
" binary " : BSONBinaryData ( subtype: 1 , data: Data ( [ 1 , 2 , 3 ] ) ) ,
108
108
" objectId " : BSONObjectId ( " 507f191e810c19729de860ea " ) ,
109
109
" int32 " : Int32Value ( 1 ) ,
110
+ " decimal128 " : Decimal128Value ( " 1.2e3 " ) ,
110
111
" min " : MinKey . shared,
111
112
" max " : MaxKey . shared,
112
113
" regex " : RegexValue ( pattern: " ^foo " , options: " i " ) ,
@@ -127,6 +128,10 @@ class BsonTypesIntegrationTests: FSTIntegrationTestCase {
127
128
snapshot. get ( " int32 " ) as? Int32Value ,
128
129
Int32Value ( 2 )
129
130
)
131
+ XCTAssertEqual (
132
+ snapshot. get ( " decimal128 " ) as? Decimal128Value ,
133
+ Decimal128Value ( " 1.2e3 " )
134
+ )
130
135
XCTAssertEqual (
131
136
snapshot. get ( " min " ) as? MinKey ,
132
137
MinKey . shared
@@ -160,6 +165,7 @@ class BsonTypesIntegrationTests: FSTIntegrationTestCase {
160
165
" binary " : BSONBinaryData ( subtype: 1 , data: Data ( [ 1 , 2 , 3 ] ) ) ,
161
166
" objectId " : BSONObjectId ( " 507f191e810c19729de860ea " ) ,
162
167
" int32 " : Int32Value ( 1 ) ,
168
+ " decimal128 " : Decimal128Value ( " -1.23e-4 " ) ,
163
169
" min " : MinKey . shared,
164
170
" max " : MaxKey . shared,
165
171
" regex " : RegexValue ( pattern: " ^foo " , options: " i " ) ,
@@ -179,6 +185,10 @@ class BsonTypesIntegrationTests: FSTIntegrationTestCase {
179
185
snapshot. get ( " int32 " ) as? Int32Value ,
180
186
Int32Value ( 2 )
181
187
)
188
+ XCTAssertEqual (
189
+ snapshot. get ( " decimal128 " ) as? Decimal128Value ,
190
+ Decimal128Value ( " -1.23e-4 " )
191
+ )
182
192
XCTAssertEqual (
183
193
snapshot. get ( " min " ) as? MinKey ,
184
194
MinKey . shared
@@ -268,6 +278,42 @@ class BsonTypesIntegrationTests: FSTIntegrationTestCase {
268
278
)
269
279
}
270
280
281
+ func testCanFilterAndOrderDecimal128Values( ) async throws {
282
+ let testDocs : [ String : [ String : Any ] ] = [
283
+ " a " : [ " key " : Decimal128Value ( " -Infinity " ) ] ,
284
+ " b " : [ " key " : Decimal128Value ( " NaN " ) ] ,
285
+ " c " : [ " key " : Decimal128Value ( " -0 " ) ] ,
286
+ " d " : [ " key " : Decimal128Value ( " 0 " ) ] ,
287
+ " e " : [ " key " : Decimal128Value ( " 0.0 " ) ] ,
288
+ " f " : [ " key " : Decimal128Value ( " -01.23e-4 " ) ] ,
289
+ " g " : [ " key " : Decimal128Value ( " 1.5e6 " ) ] ,
290
+ " h " : [ " key " : Decimal128Value ( " Infinity " ) ] ,
291
+ ]
292
+
293
+ let collection = collectionRef ( )
294
+ await setDocumentData ( testDocs, toCollection: collection)
295
+
296
+ var query = collection
297
+ . whereField ( " key " , isGreaterThanOrEqualTo: Decimal128Value ( " 0 " ) )
298
+ . order ( by: " key " , descending: true )
299
+ try await assertSdkQueryResultsConsistentWithBackend (
300
+ testDocs,
301
+ collection: collection,
302
+ query: query,
303
+ expectedResult: [ " h " , " g " , " e " , " d " , " c " ]
304
+ )
305
+
306
+ query = collection
307
+ . whereField ( " key " , notIn: [ Decimal128Value ( " NaN " ) , Decimal128Value ( " Infinity " ) ] )
308
+ . order ( by: " key " , descending: true )
309
+ try await assertSdkQueryResultsConsistentWithBackend (
310
+ testDocs,
311
+ collection: collection,
312
+ query: query,
313
+ expectedResult: [ " g " , " e " , " d " , " c " , " f " , " a " ]
314
+ )
315
+ }
316
+
271
317
func testCanFilterAndOrderTimestampValues( ) async throws {
272
318
let testDocs : [ String : [ String : Any ] ] = [
273
319
" a " : [ " key " : BSONTimestamp ( seconds: 1 , increment: 1 ) ] ,
@@ -584,9 +630,17 @@ class BsonTypesIntegrationTests: FSTIntegrationTestCase {
584
630
" bsonBinary1 " : [ " key " : BSONBinaryData ( subtype: 1 , data: Data ( [ 1 , 2 , 3 ] ) ) ] ,
585
631
" bsonBinary2 " : [ " key " : BSONBinaryData ( subtype: 1 , data: Data ( [ 1 , 2 , 4 ] ) ) ] ,
586
632
" bsonBinary3 " : [ " key " : BSONBinaryData ( subtype: 2 , data: Data ( [ 1 , 2 , 2 ] ) ) ] ,
633
+ " decimal128Value1 " : [ " key " : Decimal128Value ( " NaN " ) ] ,
634
+ " decimal128Value2 " : [ " key " : Decimal128Value ( " -Infinity " ) ] ,
635
+ " decimal128Value3 " : [ " key " : Decimal128Value ( " -1.0 " ) ] ,
587
636
" int32Value1 " : [ " key " : Int32Value ( - 1 ) ] ,
637
+ " decimal128Value4 " : [ " key " : Decimal128Value ( " 1.0 " ) ] ,
588
638
" int32Value2 " : [ " key " : Int32Value ( 1 ) ] ,
639
+ " decimal128Value5 " : [ " key " : Decimal128Value ( " -0.0 " ) ] ,
640
+ " decimal128Value6 " : [ " key " : Decimal128Value ( " 0.0 " ) ] ,
589
641
" int32Value3 " : [ " key " : Int32Value ( 0 ) ] ,
642
+ " decimal128Value7 " : [ " key " : Decimal128Value ( " 1.23e-4 " ) ] ,
643
+ " decimal128Value8 " : [ " key " : Decimal128Value ( " Infinity " ) ] ,
590
644
" minKey1 " : [ " key " : MinKey . shared] ,
591
645
" minKey2 " : [ " key " : MinKey . shared] ,
592
646
" maxKey1 " : [ " key " : MaxKey . shared] ,
@@ -614,9 +668,17 @@ class BsonTypesIntegrationTests: FSTIntegrationTestCase {
614
668
" bsonTimestamp1 " ,
615
669
" bsonTimestamp2 " ,
616
670
" bsonTimestamp3 " ,
671
+ " decimal128Value8 " ,
672
+ " decimal128Value7 " ,
617
673
" int32Value2 " ,
674
+ " decimal128Value4 " ,
618
675
" int32Value3 " ,
676
+ " decimal128Value6 " ,
677
+ " decimal128Value5 " ,
619
678
" int32Value1 " ,
679
+ " decimal128Value3 " ,
680
+ " decimal128Value2 " ,
681
+ " decimal128Value1 " ,
620
682
" minKey2 " ,
621
683
" minKey1 " ,
622
684
] )
@@ -631,9 +693,13 @@ class BsonTypesIntegrationTests: FSTIntegrationTestCase {
631
693
" minValue " : [ " key " : MinKey . shared] ,
632
694
" booleanValue " : [ " key " : true ] ,
633
695
" nanValue " : [ " key " : Double . nan] ,
696
+ " nanValue2 " : [ " key " : Decimal128Value ( " NaN " ) ] ,
697
+ " negativeInfinity " : [ " key " : Decimal128Value ( " -Infinity " ) ] ,
634
698
" int32Value " : [ " key " : Int32Value ( 1 ) ] ,
635
699
" doubleValue " : [ " key " : 2.0 ] ,
636
700
" integerValue " : [ " key " : 3 ] ,
701
+ " decimal128Value " : [ " key " : Decimal128Value ( " 3.4e-5 " ) ] ,
702
+ " infinity " : [ " key " : Decimal128Value ( " Infinity " ) ] ,
637
703
" timestampValue " : [ " key " : Timestamp ( seconds: 100 , nanoseconds: 123_456_000 ) ] ,
638
704
" bsonTimestampValue " : [ " key " : BSONTimestamp ( seconds: 1 , increment: 2 ) ] ,
639
705
" stringValue " : [ " key " : " string " ] ,
@@ -660,9 +726,13 @@ class BsonTypesIntegrationTests: FSTIntegrationTestCase {
660
726
" minValue " ,
661
727
" booleanValue " ,
662
728
" nanValue " ,
729
+ " nanValue2 " ,
730
+ " negativeInfinity " ,
663
731
" int32Value " ,
664
732
" doubleValue " ,
665
733
" integerValue " ,
734
+ " decimal128Value " ,
735
+ " infinity " ,
666
736
" timestampValue " ,
667
737
" bsonTimestampValue " ,
668
738
" stringValue " ,
0 commit comments