diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-09-06 13:29:05 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-09-06 13:29:05 +0200 |
| commit | b8dd34fcbb895b8d62f3e133dcf5ee6f40a1400d (patch) | |
| tree | 196c99a14d51d88a2f81f12be98fb8ff2c4359f7 /odoo/tools/sql.py | |
| parent | 16541ae2ae953195f1bd0036e474aac0014aee4b (diff) | |
| parent | 64d56995e049d7e7bc3aa7af5a16603220b0d4bc (diff) | |
[MERGE] forward port branch saas-16 up to 64d56995e04
Diffstat (limited to 'odoo/tools/sql.py')
| -rw-r--r-- | odoo/tools/sql.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/odoo/tools/sql.py b/odoo/tools/sql.py index 6c783fe27e7..d15bd027176 100644 --- a/odoo/tools/sql.py +++ b/odoo/tools/sql.py @@ -23,14 +23,18 @@ _CONFDELTYPES = { def existing_tables(cr, tablenames): """ Return the names of existing tables among ``tablenames``. """ - query = """ SELECT table_name FROM information_schema.tables - WHERE table_name IN %s AND table_schema != 'information_schema' """ + query = """ + SELECT relname + FROM pg_class + WHERE relname IN %s + AND relkind IN ('r', 'v', 'm') + """ cr.execute(query, [tuple(tablenames)]) return [row[0] for row in cr.fetchall()] def table_exists(cr, tablename): """ Return whether the given table exists. """ - query = "SELECT 1 FROM information_schema.tables WHERE table_name=%s AND table_schema != 'information_schema'" + query = "SELECT 1 FROM pg_class WHERE relkind IN ('r', 'v', 'm') AND relname=%s" cr.execute(query, (tablename,)) return cr.rowcount |
