summaryrefslogtreecommitdiff
path: root/odoo/tools/sql.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-09-04 17:51:50 +0200
committerChristophe Simonis <chs@odoo.com>2017-09-04 17:51:50 +0200
commit4d4d75709dcd46ffa957a68fa2f884ec59042718 (patch)
tree5b0b70cabf0d4fa927233a8d31b8d2cbfcb41ac3 /odoo/tools/sql.py
parentfc2a39cc7d083727af00e920aa0f66fb8785a8a5 (diff)
[FIX] core: also consider materialized views as existing
At the end of registry loading, a check is made on every model to verify its table exists in the database. Materialized views weren't considered during this check. Note that we can't use `information_schema` views in this case because it does include materialized views on purpose [1]. Forward-port of 4ca6945256f9353ab7f9633552872fd1fa7fdaca [1] http://www.postgresql-archive.org/Materialized-views-don-t-show-up-in-information-schema-tp5822643p5822644.html
Diffstat (limited to 'odoo/tools/sql.py')
-rw-r--r--odoo/tools/sql.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/odoo/tools/sql.py b/odoo/tools/sql.py
index c4e9a143a8e..a0300e0c500 100644
--- a/odoo/tools/sql.py
+++ b/odoo/tools/sql.py
@@ -23,7 +23,7 @@ _CONFDELTYPES = {
def table_exists(cr, tablename):
""" Return whether the given table exists. """
- query = "SELECT 1 FROM information_schema.tables WHERE table_name=%s"
+ query = "SELECT 1 FROM pg_class WHERE relkind IN ('r', 'v', 'm') AND relname=%s"
cr.execute(query, (tablename,))
return cr.rowcount