This repository was archived by the owner on Sep 23, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +32
-6
lines changed Expand file tree Collapse file tree 2 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -62,12 +62,14 @@ def open_connection(conn_config, logical_replication=False):
6262def prepare_columns_for_select_sql (c , md_map ):
6363 column_name = ' "{}" ' .format (canonicalize_identifier (c ))
6464
65- if ('properties' , c ) in md_map and md_map [('properties' , c )]['sql-datatype' ].startswith ('timestamp' ):
66- return f'CASE ' \
67- f'WHEN { column_name } < \' 0001-01-01 00:00:00.000\' ' \
68- f'OR { column_name } > \' 9999-12-31 23:59:59.999\' THEN \' 9999-12-31 23:59:59.999\' ' \
69- f'ELSE { column_name } ' \
70- f'END AS { column_name } '
65+ if ('properties' , c ) in md_map :
66+ sql_datatype = md_map [('properties' , c )]['sql-datatype' ]
67+ if sql_datatype .startswith ('timestamp' ) and not sql_datatype .endswith ('[]' ):
68+ return f'CASE ' \
69+ f'WHEN { column_name } < \' 0001-01-01 00:00:00.000\' ' \
70+ f'OR { column_name } > \' 9999-12-31 23:59:59.999\' THEN \' 9999-12-31 23:59:59.999\' ' \
71+ f'ELSE { column_name } ' \
72+ f'END AS { column_name } '
7173 return column_name
7274
7375def prepare_columns_sql (c ):
Original file line number Diff line number Diff line change @@ -70,6 +70,30 @@ def test_prepare_columns_for_select_sql_with_timestamp_tz_column(self):
7070 )
7171 )
7272
73+ def test_prepare_columns_for_select_sql_with_timestamp_ntz_array_column (self ):
74+ self .assertEqual (
75+ ' "my_column" ' ,
76+ db .prepare_columns_for_select_sql ('my_column' ,
77+ {
78+ ('properties' , 'my_column' ): {
79+ 'sql-datatype' : 'timestamp without time zone[]'
80+ }
81+ }
82+ )
83+ )
84+
85+ def test_prepare_columns_for_select_sql_with_timestamp_tz_array_column (self ):
86+ self .assertEqual (
87+ ' "my_column" ' ,
88+ db .prepare_columns_for_select_sql ('my_column' ,
89+ {
90+ ('properties' , 'my_column' ): {
91+ 'sql-datatype' : 'timestamp with time zone[]'
92+ }
93+ }
94+ )
95+ )
96+
7397 def test_prepare_columns_for_select_sql_with_not_timestamp_column (self ):
7498 self .assertEqual (
7599 ' "my_column" ' ,
You can’t perform that action at this time.
0 commit comments