From 0027f1390443f199087d0784920450d93a359614 Mon Sep 17 00:00:00 2001 From: Shai Berger Date: Mon, 27 May 2013 21:05:59 +0300 Subject: [PATCH] Fixed #20014 -- implemented get_key_columns() for Oracle Thanks Aymeric Augustin for reporting --- django/db/backends/oracle/introspection.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/django/db/backends/oracle/introspection.py b/django/db/backends/oracle/introspection.py index 58d25eeffd..361308a62c 100644 --- a/django/db/backends/oracle/introspection.py +++ b/django/db/backends/oracle/introspection.py @@ -90,6 +90,18 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): relations[row[0]] = (row[2], row[1].lower()) return relations + def get_key_columns(self, cursor, table_name): + cursor.execute(""" + SELECT ccol.column_name, rcol.table_name AS referenced_table, rcol.column_name AS referenced_column + FROM user_constraints c + JOIN user_cons_columns ccol + ON ccol.constraint_name = c.constraint_name + JOIN user_cons_columns rcol + ON rcol.constraint_name = c.r_constraint_name + WHERE c.table_name = %s AND c.constraint_type = 'R'""" , [table_name.upper()]) + return [tuple(cell.lower() for cell in row) + for row in cursor.fetchall()] + def get_indexes(self, cursor, table_name): sql = """ SELECT LOWER(uic1.column_name) AS column_name,