File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 21
21
## New additions
22
22
23
23
## Fixes and improvements
24
+ * Fix handling of date types in ` snow sql ` command when using JSON for output format
24
25
25
26
26
27
# v3.4.1
Original file line number Diff line number Diff line change 16
16
17
17
import json
18
18
import sys
19
- from datetime import datetime
19
+ from datetime import date , datetime
20
20
from json import JSONEncoder
21
21
from pathlib import Path
22
22
from textwrap import indent
@@ -57,7 +57,7 @@ def default(self, o):
57
57
return o .result
58
58
if isinstance (o , (CollectionResult , MultipleResults )):
59
59
return list (o .result )
60
- if isinstance (o , datetime ):
60
+ if isinstance (o , ( date , datetime ) ):
61
61
return o .isoformat ()
62
62
if isinstance (o , Path ):
63
63
return str (o )
Original file line number Diff line number Diff line change
1
+ import datetime
2
+
3
+ from snowflake .cli ._app .printing import print_structured
4
+ from snowflake .cli .api .output .types import QueryResult
5
+
6
+
7
+ def test_print_structured_output_date (mock_cursor , capsys ):
8
+ cmd_result = QueryResult (
9
+ cursor = mock_cursor (
10
+ [(datetime .date .fromisoformat ("2025-02-17" ),)], ["CURRENT_DATE()" ]
11
+ )
12
+ )
13
+ print_structured (cmd_result )
14
+ captured = capsys .readouterr ()
15
+ assert (
16
+ captured .out
17
+ == """[\n {\n "CURRENT_DATE()": "2025-02-17"\n }\n ]\n """
18
+ )
You can’t perform that action at this time.
0 commit comments