[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 4ca6945256

[1] http://www.postgresql-archive.org/Materialized-views-don-t-show-up-in-information-schema-tp5822643p5822644.html
This commit is contained in:
Christophe Simonis
2017-09-04 17:51:50 +02:00
parent fc2a39cc7d
commit 4d4d75709d
+1 -1
View File
@@ -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