Fixed #20014 -- implemented get_key_columns() for Oracle

Thanks Aymeric Augustin for reporting
This commit is contained in:
Shai Berger 2013-05-27 21:05:59 +03:00
parent 0268aba96b
commit 0027f13904
1 changed files with 12 additions and 0 deletions

View File

@ -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,