From 4d4d75709dcd46ffa957a68fa2f884ec59042718 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 4 Sep 2017 17:51:50 +0200 Subject: [PATCH] [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 --- odoo/tools/sql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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