summaryrefslogtreecommitdiff
path: root/odoo/tools/sql.py
diff options
context:
space:
mode:
Diffstat (limited to 'odoo/tools/sql.py')
-rw-r--r--odoo/tools/sql.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/odoo/tools/sql.py b/odoo/tools/sql.py
index e1e4256dc7f..28cbe3ab25f 100644
--- a/odoo/tools/sql.py
+++ b/odoo/tools/sql.py
@@ -8,13 +8,6 @@ import psycopg2
_schema = logging.getLogger('odoo.schema')
-_TABLE_KIND = {
- 'BASE TABLE': 'r',
- 'VIEW': 'v',
- 'FOREIGN TABLE': 'f',
- 'LOCAL TEMPORARY': 't',
-}
-
_CONFDELTYPES = {
'RESTRICT': 'r',
'NO ACTION': 'a',
@@ -42,11 +35,12 @@ def table_exists(cr, tablename):
def table_kind(cr, tablename):
""" Return the kind of a table: ``'r'`` (regular table), ``'v'`` (view),
- ``'f'`` (foreign table), ``'t'`` (temporary table), or ``None``.
+ ``'f'`` (foreign table), ``'t'`` (temporary table),
+ ``'m'`` (materialized view), or ``None``.
"""
- query = "SELECT table_type FROM information_schema.tables WHERE table_name=%s"
+ query = "SELECT relkind FROM pg_class WHERE relname = %s"
cr.execute(query, (tablename,))
- return _TABLE_KIND[cr.fetchone()[0]] if cr.rowcount else None
+ return cr.fetchone()[0] if cr.rowcount else None
def create_model_table(cr, tablename, comment=None):
""" Create the table for a model. """