@@ -485,10 +485,9 @@ class PipelineIntegrationTests: FSTIntegrationTestCase {
485
485
Constant ( GeoPoint ( latitude: 0.1 , longitude: 0.2 ) ) . as ( " geoPoint " ) ,
486
486
Constant ( refTimestamp) . as ( " timestamp " ) ,
487
487
Constant ( refDate) . as ( " date " ) , // Firestore will convert this to a Timestamp
488
- Constant ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 0 ] as [ UInt8 ] ) . as ( " bytes " ) ,
488
+ Constant ( Data ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 0 ] ) ) . as ( " bytes " ) ,
489
489
Constant ( db. document ( " foo/bar " ) ) . as ( " documentReference " ) ,
490
490
Constant ( VectorValue ( [ 1 , 2 , 3 ] ) ) . as ( " vectorValue " ) ,
491
- Constant ( [ 1 , 2 , 3 ] ) . as ( " arrayValue " ) , // Treated as an array of numbers
492
491
]
493
492
494
493
let constantsSecond : [ Selectable ] = [
@@ -500,7 +499,7 @@ class PipelineIntegrationTests: FSTIntegrationTestCase {
500
499
" geoPoint " : GeoPoint ( latitude: 0.1 , longitude: 0.2 ) ,
501
500
" timestamp " : refTimestamp,
502
501
" date " : refDate,
503
- " uint8Array " : Data ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 0 ] ) ,
502
+ " bytesArray " : Data ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 0 ] ) ,
504
503
" documentReference " : Constant ( db. document ( " foo/bar " ) ) ,
505
504
" vectorValue " : VectorValue ( [ 1 , 2 , 3 ] ) ,
506
505
" map " : [
@@ -517,7 +516,7 @@ class PipelineIntegrationTests: FSTIntegrationTestCase {
517
516
GeoPoint ( latitude: 10.1 , longitude: 20.2 ) ,
518
517
Timestamp ( date: Date ( timeIntervalSince1970: 1_700_000_000 ) ) , // Different timestamp
519
518
Date ( timeIntervalSince1970: 1_700_000_000 ) , // Different date
520
- [ 11 , 22 , 33 ] as [ UInt8 ] ,
519
+ Data ( [ 11 , 22 , 33 ] ) ,
521
520
db. document ( " another/doc " ) ,
522
521
VectorValue ( [ 7 , 8 , 9 ] ) ,
523
522
[
@@ -536,7 +535,7 @@ class PipelineIntegrationTests: FSTIntegrationTestCase {
536
535
" geoPoint " : GeoPoint ( latitude: 0.1 , longitude: 0.2 ) ,
537
536
" timestamp " : refTimestamp,
538
537
" date " : refTimestamp, // Dates are converted to Timestamps
539
- " bytes " : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 0 ] as [ UInt8 ] ,
538
+ " bytes " : Data ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 0 ] ) ,
540
539
" documentReference " : db. document ( " foo/bar " ) ,
541
540
" vectorValue " : VectorValue ( [ 1 , 2 , 3 ] ) ,
542
541
" arrayValue " : [ 1 , 2 , 3 ] ,
@@ -548,7 +547,7 @@ class PipelineIntegrationTests: FSTIntegrationTestCase {
548
547
" geoPoint " : GeoPoint ( latitude: 0.1 , longitude: 0.2 ) ,
549
548
" timestamp " : refTimestamp,
550
549
" date " : refTimestamp,
551
- " uint8Array " : Data ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 0 ] ) ,
550
+ " bytesArray " : Data ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 0 ] ) ,
552
551
" documentReference " : db. document ( " foo/bar " ) ,
553
552
" vectorValue " : VectorValue ( [ 1 , 2 , 3 ] ) ,
554
553
" map " : [
@@ -565,7 +564,7 @@ class PipelineIntegrationTests: FSTIntegrationTestCase {
565
564
GeoPoint ( latitude: 10.1 , longitude: 20.2 ) ,
566
565
Timestamp ( date: Date ( timeIntervalSince1970: 1_700_000_000 ) ) ,
567
566
Timestamp ( date: Date ( timeIntervalSince1970: 1_700_000_000 ) ) , // Dates are converted
568
- [ 11 , 22 , 33 ] as [ UInt8 ] ,
567
+ Data ( [ 11 , 22 , 33 ] ) ,
569
568
db. document ( " another/doc " ) ,
570
569
VectorValue ( [ 7 , 8 , 9 ] ) ,
571
570
[
@@ -586,45 +585,6 @@ class PipelineIntegrationTests: FSTIntegrationTestCase {
586
585
587
586
TestHelper . compare ( pipelineResult: snapshot. results. first!, expected: expectedResultsMap)
588
587
}
589
-
590
-
591
- func testFailed( ) async throws {
592
- let db = firestore ( )
593
- let randomCol = collectionRef ( ) // Ensure a unique collection for the test
594
-
595
- // Add a dummy document to the collection.
596
- // A pipeline query with .select against an empty collection might not behave as expected.
597
- try await randomCol. document ( " dummyDoc " ) . setData ( [ " field " : " value " ] )
598
-
599
- let constantsFirst : [ Selectable ] = [
600
- //Constant([1, 2, 3, 4, 5, 6, 7, 0] as [UInt8]).as("bytes"),
601
- Constant ( [ 1 , 2 , 3 ] ) . as ( " arrayValue " ) , // Treated as an array of numbers
602
- ]
603
-
604
- // let constantsSecond: [Selectable] = [
605
- // ArrayExpression([
606
- // [11, 22, 33] as [UInt8]
607
- // ]).as("array")
608
- // ]
609
-
610
- let expectedResultsMap : [ String : Sendable ? ] = [
611
- // "bytes": [1, 2, 3, 4, 5, 6, 7, 0] as [UInt8],
612
- // "array": [
613
- // [11, 22, 33] as [UInt8]
614
- // ],
615
- " arrayValue " : [ 1 , 2 , 3 ]
616
- ]
617
-
618
- let pipeline = db. pipeline ( )
619
- . collection ( randomCol. path)
620
- . limit ( 1 )
621
- . select (
622
- constantsFirst
623
- )
624
- let snapshot = try await pipeline. execute ( )
625
-
626
- TestHelper . compare ( pipelineResult: snapshot. results. first!, expected: expectedResultsMap)
627
- }
628
588
629
589
func testAcceptsAndReturnsNil( ) async throws {
630
590
let db = firestore ( )
@@ -2632,117 +2592,120 @@ class PipelineIntegrationTests: FSTIntegrationTestCase {
2632
2592
XCTFail ( " No document retrieved for testSupportsTimestampConversions " )
2633
2593
}
2634
2594
}
2635
-
2595
+
2636
2596
func testSupportsTimestampMath( ) async throws {
2637
- let db = firestore ( )
2638
- let randomCol = collectionRef ( )
2639
- try await randomCol. document ( " dummyDoc " ) . setData ( [ " field " : " value " ] )
2597
+ let db = firestore ( )
2598
+ let randomCol = collectionRef ( )
2599
+ try await randomCol. document ( " dummyDoc " ) . setData ( [ " field " : " value " ] )
2640
2600
2641
- let initialTimestamp = Timestamp ( seconds: 1_741_380_235 , nanoseconds: 0 )
2601
+ let initialTimestamp = Timestamp ( seconds: 1_741_380_235 , nanoseconds: 0 )
2642
2602
2643
- let pipeline = db. pipeline ( )
2644
- . collection ( randomCol. path)
2645
- . limit ( 1 )
2646
- . select (
2647
- Constant ( initialTimestamp) . as ( " timestamp " )
2648
- )
2649
- . select (
2650
- Field ( " timestamp " ) . timestampAdd ( . day, 10 ) . as ( " plus10days " ) ,
2651
- Field ( " timestamp " ) . timestampAdd ( . hour, 10 ) . as ( " plus10hours " ) ,
2652
- Field ( " timestamp " ) . timestampAdd ( . minute, 10 ) . as ( " plus10minutes " ) ,
2653
- Field ( " timestamp " ) . timestampAdd ( . second, 10 ) . as ( " plus10seconds " ) ,
2654
- Field ( " timestamp " ) . timestampAdd ( . microsecond, 10 ) . as ( " plus10micros " ) ,
2655
- Field ( " timestamp " ) . timestampAdd ( . millisecond, 10 ) . as ( " plus10millis " ) ,
2656
- Field ( " timestamp " ) . timestampSub ( . day, 10 ) . as ( " minus10days " ) ,
2657
- Field ( " timestamp " ) . timestampSub ( . hour, 10 ) . as ( " minus10hours " ) ,
2658
- Field ( " timestamp " ) . timestampSub ( . minute, 10 ) . as ( " minus10minutes " ) ,
2659
- Field ( " timestamp " ) . timestampSub ( . second, 10 ) . as ( " minus10seconds " ) ,
2660
- Field ( " timestamp " ) . timestampSub ( . microsecond, 10 ) . as ( " minus10micros " ) ,
2661
- Field ( " timestamp " ) . timestampSub ( . millisecond, 10 ) . as ( " minus10millis " )
2662
- )
2603
+ let pipeline = db. pipeline ( )
2604
+ . collection ( randomCol. path)
2605
+ . limit ( 1 )
2606
+ . select (
2607
+ Constant ( initialTimestamp) . as ( " timestamp " )
2608
+ )
2609
+ . select (
2610
+ Field ( " timestamp " ) . timestampAdd ( . day, 10 ) . as ( " plus10days " ) ,
2611
+ Field ( " timestamp " ) . timestampAdd ( . hour, 10 ) . as ( " plus10hours " ) ,
2612
+ Field ( " timestamp " ) . timestampAdd ( . minute, 10 ) . as ( " plus10minutes " ) ,
2613
+ Field ( " timestamp " ) . timestampAdd ( . second, 10 ) . as ( " plus10seconds " ) ,
2614
+ Field ( " timestamp " ) . timestampAdd ( . microsecond, 10 ) . as ( " plus10micros " ) ,
2615
+ Field ( " timestamp " ) . timestampAdd ( . millisecond, 10 ) . as ( " plus10millis " ) ,
2616
+ Field ( " timestamp " ) . timestampSub ( . day, 10 ) . as ( " minus10days " ) ,
2617
+ Field ( " timestamp " ) . timestampSub ( . hour, 10 ) . as ( " minus10hours " ) ,
2618
+ Field ( " timestamp " ) . timestampSub ( . minute, 10 ) . as ( " minus10minutes " ) ,
2619
+ Field ( " timestamp " ) . timestampSub ( . second, 10 ) . as ( " minus10seconds " ) ,
2620
+ Field ( " timestamp " ) . timestampSub ( . microsecond, 10 ) . as ( " minus10micros " ) ,
2621
+ Field ( " timestamp " ) . timestampSub ( . millisecond, 10 ) . as ( " minus10millis " )
2622
+ )
2663
2623
2664
- let snapshot = try await pipeline. execute ( )
2624
+ let snapshot = try await pipeline. execute ( )
2665
2625
2666
- let expectedResults : [ String : Timestamp ] = [
2667
- " plus10days " : Timestamp ( seconds: 1_742_244_235 , nanoseconds: 0 ) ,
2668
- " plus10hours " : Timestamp ( seconds: 1_741_416_235 , nanoseconds: 0 ) ,
2669
- " plus10minutes " : Timestamp ( seconds: 1_741_380_835 , nanoseconds: 0 ) ,
2670
- " plus10seconds " : Timestamp ( seconds: 1_741_380_245 , nanoseconds: 0 ) ,
2671
- " plus10micros " : Timestamp ( seconds: 1_741_380_235 , nanoseconds: 10_000 ) ,
2672
- " plus10millis " : Timestamp ( seconds: 1_741_380_235 , nanoseconds: 10_000_000 ) ,
2673
- " minus10days " : Timestamp ( seconds: 1_740_516_235 , nanoseconds: 0 ) ,
2674
- " minus10hours " : Timestamp ( seconds: 1_741_344_235 , nanoseconds: 0 ) ,
2675
- " minus10minutes " : Timestamp ( seconds: 1_741_379_635 , nanoseconds: 0 ) ,
2676
- " minus10seconds " : Timestamp ( seconds: 1_741_380_225 , nanoseconds: 0 ) ,
2677
- " minus10micros " : Timestamp ( seconds: 1_741_380_234 , nanoseconds: 999_990_000 ) ,
2678
- " minus10millis " : Timestamp ( seconds: 1_741_380_234 , nanoseconds: 990_000_000 )
2679
- ]
2626
+ let expectedResults : [ String : Timestamp ] = [
2627
+ " plus10days " : Timestamp ( seconds: 1_742_244_235 , nanoseconds: 0 ) ,
2628
+ " plus10hours " : Timestamp ( seconds: 1_741_416_235 , nanoseconds: 0 ) ,
2629
+ " plus10minutes " : Timestamp ( seconds: 1_741_380_835 , nanoseconds: 0 ) ,
2630
+ " plus10seconds " : Timestamp ( seconds: 1_741_380_245 , nanoseconds: 0 ) ,
2631
+ " plus10micros " : Timestamp ( seconds: 1_741_380_235 , nanoseconds: 10000 ) ,
2632
+ " plus10millis " : Timestamp ( seconds: 1_741_380_235 , nanoseconds: 10_000_000 ) ,
2633
+ " minus10days " : Timestamp ( seconds: 1_740_516_235 , nanoseconds: 0 ) ,
2634
+ " minus10hours " : Timestamp ( seconds: 1_741_344_235 , nanoseconds: 0 ) ,
2635
+ " minus10minutes " : Timestamp ( seconds: 1_741_379_635 , nanoseconds: 0 ) ,
2636
+ " minus10seconds " : Timestamp ( seconds: 1_741_380_225 , nanoseconds: 0 ) ,
2637
+ " minus10micros " : Timestamp ( seconds: 1_741_380_234 , nanoseconds: 999_990_000 ) ,
2638
+ " minus10millis " : Timestamp ( seconds: 1_741_380_234 , nanoseconds: 990_000_000 ) ,
2639
+ ]
2680
2640
2681
- XCTAssertEqual ( snapshot. results. count, 1 , " Should retrieve one document " )
2682
- if let resultDoc = snapshot. results. first {
2683
- TestHelper . compare ( pipelineResult: resultDoc, expected: expectedResults)
2684
- } else {
2685
- XCTFail ( " No document retrieved for timestamp math test " )
2686
- }
2641
+ XCTAssertEqual ( snapshot. results. count, 1 , " Should retrieve one document " )
2642
+ if let resultDoc = snapshot. results. first {
2643
+ TestHelper . compare ( pipelineResult: resultDoc, expected: expectedResults)
2644
+ } else {
2645
+ XCTFail ( " No document retrieved for timestamp math test " )
2687
2646
}
2688
-
2647
+ }
2648
+
2689
2649
func testSupportsByteLength( ) async throws {
2690
- let db = firestore ( )
2691
- let randomCol = collectionRef ( )
2692
- try await randomCol. document ( " dummyDoc " ) . setData ( [ " field " : " value " ] )
2650
+ let db = firestore ( )
2651
+ let randomCol = collectionRef ( )
2652
+ try await randomCol. document ( " dummyDoc " ) . setData ( [ " field " : " value " ] )
2693
2653
2694
- let bytes : [ UInt8 ] = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 0 ]
2654
+ let bytes = Data ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 0 ] )
2695
2655
2696
- let pipeline = db. pipeline ( )
2697
- . collection ( randomCol. path)
2698
- . limit ( 1 )
2699
- . select (
2700
- Constant ( bytes) . as ( " bytes " )
2701
- )
2702
- . select (
2703
- Field ( " bytes " ) . byteLength ( ) . as ( " byteLength " )
2704
- )
2656
+ let pipeline = db. pipeline ( )
2657
+ . collection ( randomCol. path)
2658
+ . limit ( 1 )
2659
+ . select (
2660
+ Constant ( bytes) . as ( " bytes " )
2661
+ )
2662
+ . select (
2663
+ Field ( " bytes " ) . byteLength ( ) . as ( " byteLength " )
2664
+ )
2705
2665
2706
- let snapshot = try await pipeline. execute ( )
2666
+ let snapshot = try await pipeline. execute ( )
2707
2667
2708
2668
let expectedResults : [ String : Sendable ] = [
2709
- " byteLength " : 8
2710
- ]
2669
+ " byteLength " : 8 ,
2670
+ ]
2711
2671
2712
- XCTAssertEqual ( snapshot. results. count, 1 , " Should retrieve one document " )
2713
- if let resultDoc = snapshot. results. first {
2714
- TestHelper . compare ( pipelineResult: resultDoc, expected: expectedResults. mapValues { $0 as Sendable } )
2715
- } else {
2716
- XCTFail ( " No document retrieved for byte length test " )
2717
- }
2672
+ XCTAssertEqual ( snapshot. results. count, 1 , " Should retrieve one document " )
2673
+ if let resultDoc = snapshot. results. first {
2674
+ TestHelper . compare (
2675
+ pipelineResult: resultDoc,
2676
+ expected: expectedResults. mapValues { $0 as Sendable }
2677
+ )
2678
+ } else {
2679
+ XCTFail ( " No document retrieved for byte length test " )
2718
2680
}
2681
+ }
2719
2682
2720
- func testSupportsNot( ) async throws {
2721
- let db = firestore ( )
2722
- let randomCol = collectionRef ( )
2723
- try await randomCol. document ( " dummyDoc " ) . setData ( [ " field " : " value " ] )
2683
+ func testSupportsNot( ) async throws {
2684
+ let db = firestore ( )
2685
+ let randomCol = collectionRef ( )
2686
+ try await randomCol. document ( " dummyDoc " ) . setData ( [ " field " : " value " ] )
2724
2687
2725
- let pipeline = db. pipeline ( )
2726
- . collection ( randomCol. path)
2727
- . limit ( 1 )
2728
- . select ( Constant ( true ) . as ( " trueField " ) )
2729
- . select (
2730
- Field ( " trueField " ) ,
2731
- ( !( Field ( " trueField " ) . eq ( true ) ) ) . as ( " falseField " )
2732
- )
2688
+ let pipeline = db. pipeline ( )
2689
+ . collection ( randomCol. path)
2690
+ . limit ( 1 )
2691
+ . select ( Constant ( true ) . as ( " trueField " ) )
2692
+ . select (
2693
+ Field ( " trueField " ) ,
2694
+ ( !( Field ( " trueField " ) . eq ( true ) ) ) . as ( " falseField " )
2695
+ )
2733
2696
2734
- let snapshot = try await pipeline. execute ( )
2697
+ let snapshot = try await pipeline. execute ( )
2735
2698
2736
- let expectedResults : [ String : Bool ] = [
2737
- " trueField " : true ,
2738
- " falseField " : false
2739
- ]
2699
+ let expectedResults : [ String : Bool ] = [
2700
+ " trueField " : true ,
2701
+ " falseField " : false ,
2702
+ ]
2740
2703
2741
- XCTAssertEqual ( snapshot. results. count, 1 , " Should retrieve one document " )
2742
- if let resultDoc = snapshot. results. first {
2743
- TestHelper . compare ( pipelineResult: resultDoc, expected: expectedResults)
2744
- } else {
2745
- XCTFail ( " No document retrieved for not operator test " )
2746
- }
2704
+ XCTAssertEqual ( snapshot. results. count, 1 , " Should retrieve one document " )
2705
+ if let resultDoc = snapshot. results. first {
2706
+ TestHelper . compare ( pipelineResult: resultDoc, expected: expectedResults)
2707
+ } else {
2708
+ XCTFail ( " No document retrieved for not operator test " )
2747
2709
}
2710
+ }
2748
2711
}
0 commit comments