Skip to content

Commit 8110827

Browse files
authored
Upper casing information_schema table for case sensitive databases. (#216)
1 parent 663c46a commit 8110827

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

mssqlcli/mssqlqueries.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ def get_table_columns():
3838
column_name,
3939
data_type,
4040
column_default
41-
FROM information_schema.columns
41+
FROM INFORMATION_SCHEMA.COLUMNS
4242
) AS isc
4343
INNER JOIN
4444
(
4545
SELECT table_schema,
4646
table_name
47-
FROM information_schema.tables
47+
FROM INFORMATION_SCHEMA.TABLES
4848
WHERE TABLE_TYPE = 'BASE TABLE'
4949
) AS ist
50-
ON ist.table_name = isc.table_name AND ist.TABLE_SCHEMA = isc.TABLE_SCHEMA
50+
ON ist.table_name = isc.table_name AND ist.table_schema = isc.table_schema
5151
ORDER BY 1, 2'''
5252

5353

@@ -69,16 +69,16 @@ def get_view_columns():
6969
column_name,
7070
data_type,
7171
column_default
72-
FROM information_schema.columns
72+
FROM INFORMATION_SCHEMA.COLUMNS
7373
) AS isc
7474
INNER JOIN
7575
(
7676
SELECT table_schema,
7777
table_name
78-
FROM information_schema.tables
78+
FROM INFORMATION_SCHEMA.TABLES
7979
WHERE TABLE_TYPE = 'VIEW'
8080
) AS ist
81-
ON ist.table_name = isc.table_name AND ist.TABLE_SCHEMA = isc.TABLE_SCHEMA
81+
ON ist.table_name = isc.table_name AND ist.table_schema = isc.table_schema
8282
ORDER BY 1, 2'''
8383

8484

@@ -90,7 +90,7 @@ def get_views():
9090
return '''
9191
SELECT table_schema,
9292
table_name
93-
FROM information_schema.tables
93+
FROM INFORMATION_SCHEMA.TABLES
9494
WHERE table_type = 'View'
9595
ORDER BY 1, 2'''
9696

@@ -103,7 +103,7 @@ def get_tables():
103103
return '''
104104
SELECT table_schema,
105105
table_name
106-
FROM information_schema.tables
106+
FROM INFORMATION_SCHEMA.TABLES
107107
WHERE table_type = 'BASE TABLE'
108108
ORDER BY 1, 2'''
109109

@@ -137,7 +137,7 @@ def get_functions():
137137
"""
138138
return '''
139139
SELECT specific_schema, specific_name
140-
FROM information_schema.routines
140+
FROM INFORMATION_SCHEMA.ROUTINES
141141
ORDER BY 1, 2'''
142142

143143

@@ -154,12 +154,12 @@ def get_foreignkeys():
154154
kcu2.table_schema AS referenced_table_schema,
155155
kcu2.table_name AS referenced_table_name,
156156
kcu2.column_name AS referenced_column_name
157-
FROM information_schema.referential_constraints AS rc
158-
INNER JOIN information_schema.key_column_usage AS kcu1
157+
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS rc
158+
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS kcu1
159159
ON kcu1.constraint_catalog = rc.constraint_catalog
160160
AND kcu1.constraint_schema = rc.constraint_schema
161161
AND kcu1.constraint_name = rc.constraint_name
162-
INNER JOIN information_schema.key_column_usage AS kcu2
162+
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS kcu2
163163
ON kcu2.constraint_catalog = rc.unique_constraint_catalog
164164
AND kcu2.constraint_schema = rc.unique_constraint_schema
165165
AND kcu2.constraint_name = rc.unique_constraint_name

0 commit comments

Comments
 (0)