mirror of https://github.com/django/django.git
Optimized Oracle PKs introspection by adding get_primary_key_column().
This commit is contained in:
parent
fe6d5a2da2
commit
709a8b861d
|
@ -173,6 +173,22 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
||||||
for row in cursor.fetchall()
|
for row in cursor.fetchall()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_primary_key_column(self, cursor, table_name):
|
||||||
|
cursor.execute("""
|
||||||
|
SELECT
|
||||||
|
cols.column_name
|
||||||
|
FROM
|
||||||
|
user_constraints,
|
||||||
|
user_cons_columns cols
|
||||||
|
WHERE
|
||||||
|
user_constraints.constraint_name = cols.constraint_name AND
|
||||||
|
user_constraints.constraint_type = 'P' AND
|
||||||
|
user_constraints.table_name = UPPER(%s) AND
|
||||||
|
cols.position = 1
|
||||||
|
""", [table_name])
|
||||||
|
row = cursor.fetchone()
|
||||||
|
return self.identifier_converter(row[0]) if row else None
|
||||||
|
|
||||||
def get_constraints(self, cursor, table_name):
|
def get_constraints(self, cursor, table_name):
|
||||||
"""
|
"""
|
||||||
Retrieve any constraints or keys (unique, pk, fk, check, index) across
|
Retrieve any constraints or keys (unique, pk, fk, check, index) across
|
||||||
|
|
Loading…
Reference in New Issue