Revision 3348
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
1048 | 1048 |
if not_null_col in table_cols(db, table, recover): return not_null_col |
1049 | 1049 |
else: return pkey(db, table, recover) |
1050 | 1050 |
|
1051 |
def constraint_cond(db, constraint): |
|
1052 |
module = util.root_module(db.db) |
|
1053 |
if module == 'psycopg2': |
|
1054 |
table_str = sql_gen.Literal(constraint.table.to_str(db)) |
|
1055 |
name_str = sql_gen.Literal(constraint.name) |
|
1056 |
return value(run_query(db, '''\ |
|
1057 |
SELECT consrc |
|
1058 |
FROM pg_constraint |
|
1059 |
WHERE |
|
1060 |
conrelid = '''+table_str.to_str(db)+'''::regclass |
|
1061 |
AND conname = '''+name_str.to_str(db)+''' |
|
1062 |
''' |
|
1063 |
, cacheable=True, log_level=4)) |
|
1064 |
else: raise NotImplementedError("Can't list index columns for "+module+ |
|
1065 |
' database') |
|
1066 |
|
|
1051 | 1067 |
def index_cols(db, index): |
1052 | 1068 |
'''Can also use this for UNIQUE constraints, because a UNIQUE index is |
1053 | 1069 |
automatically created. When you don't know whether something is a UNIQUE |
Also available in: Unified diff
sql.py: Added constraint_cond()