diff options
| author | Raphael Collet <rco@odoo.com> | 2017-07-10 12:35:02 +0200 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2017-07-10 12:38:25 +0200 |
| commit | faacacb45fbda8cb444365dff2137ae3f56ce247 (patch) | |
| tree | b69fc5efecb5ed092586c8be809e16c2dc2d90de /odoo/tools | |
| parent | e2739d6e49db5c6d70f4dd5b0942269e88ab366a (diff) | |
[IMP] registry: check existence of tables with a single SQL query
Diffstat (limited to 'odoo/tools')
| -rw-r--r-- | odoo/tools/sql.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/odoo/tools/sql.py b/odoo/tools/sql.py index 2772d99e3e7..6c783fe27e7 100644 --- a/odoo/tools/sql.py +++ b/odoo/tools/sql.py @@ -21,6 +21,13 @@ _CONFDELTYPES = { 'SET DEFAULT': 'd', } +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' """ + 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'" |
