@@ -2636,6 +2636,18 @@ select jsonb_path_query('[2, true]', '$.string()');
2636
2636
"true"
2637
2637
(2 rows)
2638
2638
2639
+ select jsonb_path_query_array('[1.23, "yes", false]', '$[*].string()');
2640
+ jsonb_path_query_array
2641
+ --------------------------
2642
+ ["1.23", "yes", "false"]
2643
+ (1 row)
2644
+
2645
+ select jsonb_path_query_array('[1.23, "yes", false]', '$[*].string().type()');
2646
+ jsonb_path_query_array
2647
+ --------------------------------
2648
+ ["string", "string", "string"]
2649
+ (1 row)
2650
+
2639
2651
select jsonb_path_query('"2023-08-15 12:34:56 +5:30"', '$.timestamp().string()');
2640
2652
ERROR: cannot convert value from timestamptz to timestamp without time zone usage
2641
2653
HINT: Use *_tz() function for time zone support.
@@ -2645,18 +2657,95 @@ select jsonb_path_query_tz('"2023-08-15 12:34:56 +5:30"', '$.timestamp().string(
2645
2657
"Tue Aug 15 00:04:56 2023"
2646
2658
(1 row)
2647
2659
2648
- select jsonb_path_query_array('[1.23, "yes", false]', '$[*].string()');
2649
- jsonb_path_query_array
2650
- --------------------------
2651
- ["1.23", "yes", "false"]
2660
+ select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp_tz().string()');
2661
+ ERROR: cannot convert value from timestamp to timestamptz without time zone usage
2662
+ HINT: Use *_tz() function for time zone support.
2663
+ select jsonb_path_query_tz('"2023-08-15 12:34:56"', '$.timestamp_tz().string()'); -- should work
2664
+ jsonb_path_query_tz
2665
+ --------------------------------
2666
+ "Tue Aug 15 12:34:56 2023 PDT"
2652
2667
(1 row)
2653
2668
2654
- select jsonb_path_query_array('[1.23, "yes", false] ', '$[*].string ().type ()');
2655
- jsonb_path_query_array
2669
+ select jsonb_path_query('"2023-08-15 12:34:56 +5:30" ', '$.timestamp_tz ().string ()');
2670
+ jsonb_path_query
2656
2671
--------------------------------
2657
- ["string", "string", "string"]
2672
+ "Tue Aug 15 00:04:56 2023 PDT"
2673
+ (1 row)
2674
+
2675
+ select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp().string()');
2676
+ jsonb_path_query
2677
+ ----------------------------
2678
+ "Tue Aug 15 12:34:56 2023"
2679
+ (1 row)
2680
+
2681
+ select jsonb_path_query('"12:34:56 +5:30"', '$.time_tz().string()');
2682
+ jsonb_path_query
2683
+ ------------------
2684
+ "12:34:56+05:30"
2685
+ (1 row)
2686
+
2687
+ select jsonb_path_query_tz('"12:34:56"', '$.time_tz().string()');
2688
+ jsonb_path_query_tz
2689
+ ---------------------
2690
+ "12:34:56-07"
2691
+ (1 row)
2692
+
2693
+ select jsonb_path_query('"12:34:56"', '$.time().string()');
2694
+ jsonb_path_query
2695
+ ------------------
2696
+ "12:34:56"
2697
+ (1 row)
2698
+
2699
+ select jsonb_path_query('"2023-08-15"', '$.date().string()');
2700
+ jsonb_path_query
2701
+ ------------------
2702
+ "08-15-2023"
2703
+ (1 row)
2704
+
2705
+ set datestyle = 'ISO';
2706
+ select jsonb_path_query_tz('"2023-08-15 12:34:56"', '$.timestamp_tz().string()');
2707
+ jsonb_path_query_tz
2708
+ --------------------------
2709
+ "2023-08-15 12:34:56-07"
2710
+ (1 row)
2711
+
2712
+ select jsonb_path_query('"2023-08-15 12:34:56 +5:30"', '$.timestamp_tz().string()');
2713
+ jsonb_path_query
2714
+ --------------------------
2715
+ "2023-08-15 00:04:56-07"
2716
+ (1 row)
2717
+
2718
+ select jsonb_path_query('"2023-08-15 12:34:56"', '$.timestamp().string()');
2719
+ jsonb_path_query
2720
+ -----------------------
2721
+ "2023-08-15 12:34:56"
2722
+ (1 row)
2723
+
2724
+ select jsonb_path_query('"12:34:56 +5:30"', '$.time_tz().string()');
2725
+ jsonb_path_query
2726
+ ------------------
2727
+ "12:34:56+05:30"
2728
+ (1 row)
2729
+
2730
+ select jsonb_path_query_tz('"12:34:56"', '$.time_tz().string()');
2731
+ jsonb_path_query_tz
2732
+ ---------------------
2733
+ "12:34:56-07"
2734
+ (1 row)
2735
+
2736
+ select jsonb_path_query('"12:34:56"', '$.time().string()');
2737
+ jsonb_path_query
2738
+ ------------------
2739
+ "12:34:56"
2740
+ (1 row)
2741
+
2742
+ select jsonb_path_query('"2023-08-15"', '$.date().string()');
2743
+ jsonb_path_query
2744
+ ------------------
2745
+ "2023-08-15"
2658
2746
(1 row)
2659
2747
2748
+ reset datestyle;
2660
2749
-- Test .time()
2661
2750
select jsonb_path_query('null', '$.time()');
2662
2751
ERROR: jsonpath item method .time() can only be applied to a string
0 commit comments