Revision 3340
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
1051 | 1051 |
else: raise NotImplementedError("Can't list index columns for "+module+ |
1052 | 1052 |
' database') |
1053 | 1053 |
|
1054 |
def constraint_cols(db, table, constraint): |
|
1055 |
module = util.root_module(db.db) |
|
1056 |
if module == 'psycopg2': |
|
1057 |
return list(values(run_query(db, '''\ |
|
1058 |
SELECT attname |
|
1059 |
FROM pg_constraint |
|
1060 |
JOIN pg_class ON pg_class.oid = conrelid |
|
1061 |
JOIN pg_attribute ON attrelid = conrelid AND attnum = ANY (conkey) |
|
1062 |
WHERE |
|
1063 |
relname = '''+db.esc_value(table)+''' |
|
1064 |
AND conname = '''+db.esc_value(constraint)+''' |
|
1065 |
ORDER BY attnum |
|
1066 |
''' |
|
1067 |
))) |
|
1068 |
else: raise NotImplementedError("Can't list constraint columns for "+module+ |
|
1069 |
' database') |
|
1070 |
|
|
1071 | 1054 |
#### Functions |
1072 | 1055 |
|
1073 | 1056 |
def function_exists(db, function): |
Also available in: Unified diff
sql.py: Removed no longer used constraint_cols(). index_cols() can always be used for a UNIQUE constraint because a UNIQUE index is automatically created for it.