Skip to content

Commit 9cef30d

Browse files
committed
fix(metadata): views when cast null
1 parent e6b7977 commit 9cef30d

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

redshift_connector/cursor.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -1210,13 +1210,13 @@ def __build_local_schema_columns_query(
12101210
"when 'int4' THEN 10 "
12111211
"when 'bit' THEN 1 "
12121212
"when 'bool' THEN 1 "
1213-
"when 'varchar' THEN atttypmod -4 "
1214-
"when 'character varying' THEN atttypmod -4 "
1215-
"when 'char' THEN atttypmod -4 "
1216-
"when 'character' THEN atttypmod -4 "
1217-
"when 'nchar' THEN atttypmod -4 "
1218-
"when 'bpchar' THEN atttypmod -4 "
1219-
"when 'nvarchar' THEN atttypmod -4 "
1213+
"when 'varchar' THEN CASE atttypmod WHEN -1 THEN 0 ELSE atttypmod -4 END "
1214+
"when 'character varying' THEN CASE atttypmod WHEN -1 THEN 0 ELSE atttypmod -4 END "
1215+
"when 'char' THEN CASE atttypmod WHEN -1 THEN 0 ELSE atttypmod -4 END "
1216+
"when 'character' THEN CASE atttypmod WHEN -1 THEN 0 ELSE atttypmod -4 END "
1217+
"when 'nchar' THEN CASE atttypmod WHEN -1 THEN 0 ELSE atttypmod -4 END "
1218+
"when 'bpchar' THEN CASE atttypmod WHEN -1 THEN 0 ELSE atttypmod -4 END "
1219+
"when 'nvarchar' THEN CASE atttypmod WHEN -1 THEN 0 ELSE atttypmod -4 END "
12201220
"when 'date' THEN 13 "
12211221
"when 'timestamp' THEN 29 "
12221222
"when 'smallint' THEN 5 "
@@ -1312,13 +1312,13 @@ def __build_local_schema_columns_query(
13121312
"when 'int4' THEN 10 "
13131313
"when 'bit' THEN 1 "
13141314
"when 'bool' THEN 1 "
1315-
"when 'varchar' THEN atttypmod -4 "
1316-
"when 'character varying' THEN atttypmod -4 "
1317-
"when 'char' THEN atttypmod -4 "
1318-
"when 'character' THEN atttypmod -4 "
1319-
"when 'nchar' THEN atttypmod -4 "
1320-
"when 'bpchar' THEN atttypmod -4 "
1321-
"when 'nvarchar' THEN atttypmod -4 "
1315+
"when 'varchar' THEN CASE atttypmod WHEN -1 THEN 0 ELSE atttypmod -4 END "
1316+
"when 'character varying' THEN CASE atttypmod WHEN -1 THEN 0 ELSE atttypmod -4 END "
1317+
"when 'char' THEN CASE atttypmod WHEN -1 THEN 0 ELSE atttypmod -4 END "
1318+
"when 'character' THEN CASE atttypmod WHEN -1 THEN 0 ELSE atttypmod -4 END "
1319+
"when 'nchar' THEN CASE atttypmod WHEN -1 THEN 0 ELSE atttypmod -4 END "
1320+
"when 'bpchar' THEN CASE atttypmod WHEN -1 THEN 0 ELSE atttypmod -4 END "
1321+
"when 'nvarchar' THEN CASE atttypmod WHEN -1 THEN 0 ELSE atttypmod -4 END "
13221322
"when 'date' THEN 13 "
13231323
"when 'timestamp' THEN 29 "
13241324
"when 'smallint' THEN 5 "

0 commit comments

Comments
 (0)