summaryrefslogtreecommitdiff
path: root/django/db/backends/oracle/introspection.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/backends/oracle/introspection.py')
-rw-r--r--django/db/backends/oracle/introspection.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/django/db/backends/oracle/introspection.py b/django/db/backends/oracle/introspection.py
index 41ffb68afb..a5df7f1297 100644
--- a/django/db/backends/oracle/introspection.py
+++ b/django/db/backends/oracle/introspection.py
@@ -95,14 +95,20 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
# user_tab_columns gives data default for columns
cursor.execute("""
SELECT
- column_name,
- data_default,
+ user_tab_cols.column_name,
+ user_tab_cols.data_default,
CASE
- WHEN char_used IS NULL THEN data_length
- ELSE char_length
+ WHEN user_tab_cols.collation = user_tables.default_collation
+ THEN NULL
+ ELSE user_tab_cols.collation
+ END collation,
+ CASE
+ WHEN user_tab_cols.char_used IS NULL
+ THEN user_tab_cols.data_length
+ ELSE user_tab_cols.char_length
END as internal_size,
CASE
- WHEN identity_column = 'YES' THEN 1
+ WHEN user_tab_cols.identity_column = 'YES' THEN 1
ELSE 0
END as is_autofield,
CASE
@@ -117,10 +123,13 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
ELSE 0
END as is_json
FROM user_tab_cols
- WHERE table_name = UPPER(%s)""", [table_name])
+ LEFT OUTER JOIN
+ user_tables ON user_tables.table_name = user_tab_cols.table_name
+ WHERE user_tab_cols.table_name = UPPER(%s)
+ """, [table_name])
field_map = {
- column: (internal_size, default if default != 'NULL' else None, is_autofield, is_json)
- for column, default, internal_size, is_autofield, is_json in cursor.fetchall()
+ column: (internal_size, default if default != 'NULL' else None, collation, is_autofield, is_json)
+ for column, default, collation, internal_size, is_autofield, is_json in cursor.fetchall()
}
self.cache_bust_counter += 1
cursor.execute("SELECT * FROM {} WHERE ROWNUM < 2 AND {} > 0".format(
@@ -129,11 +138,11 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
description = []
for desc in cursor.description:
name = desc[0]
- internal_size, default, is_autofield, is_json = field_map[name]
+ internal_size, default, collation, is_autofield, is_json = field_map[name]
name = name % {} # cx_Oracle, for some reason, doubles percent signs.
description.append(FieldInfo(
self.identifier_converter(name), *desc[1:3], internal_size, desc[4] or 0,
- desc[5] or 0, *desc[6:], default, is_autofield, is_json,
+ desc[5] or 0, *desc[6:], default, collation, is_autofield, is_json,
))
return description