226 ORDER BY ''' + str(order), [schema, table]) |
226 ORDER BY ''' + str(order), [schema, table]) |
227 |
227 |
228 def list_constraints(self, table, schema='public'): |
228 def list_constraints(self, table, schema='public'): |
229 return self._query(''' |
229 return self._query(''' |
230 SELECT |
230 SELECT |
231 conname as "name", |
231 r.conname AS "name", |
232 r.contype as "type", |
232 r.contype AS "type", |
|
233 cf.relname AS "fname", |
|
234 nf.nspname AS "fschema", |
233 pg_catalog.pg_get_constraintdef(r.oid, true) as "definition" |
235 pg_catalog.pg_get_constraintdef(r.oid, true) as "definition" |
234 FROM pg_catalog.pg_constraint r |
236 FROM pg_catalog.pg_constraint r |
235 JOIN pg_catalog.pg_class c ON r.conrelid = c.oid |
237 JOIN pg_catalog.pg_class c ON r.conrelid = c.oid |
236 JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace |
238 JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace |
|
239 LEFT JOIN pg_catalog.pg_class cf ON r.confrelid = cf.oid |
|
240 LEFT JOIN pg_catalog.pg_namespace nf ON nf.oid = cf.relnamespace |
237 WHERE n.nspname = %s AND c.relname = %s |
241 WHERE n.nspname = %s AND c.relname = %s |
238 ORDER BY 1 |
242 ORDER BY 1 |
239 ''', [schema, table]) |
243 ''', [schema, table]) |
240 |
244 |
241 def list_indexes(self, table, schema='public'): |
245 def list_indexes(self, table, schema='public'): |