From a867cce4069bf107a479045b06d41dcfd8b1f313 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 27 Jul 2017 12:05:57 +0200 Subject: [IMP] sql: harvest less information from pg's information_schema (Fixes #18490) Avoid `SELECT *` on `information_schema.columns` because specific access right restrictions in the context of shared hosting (Heroku, OVH, ...) might prevent a postgres user to read this field. --- odoo/tools/sql.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'odoo/tools/sql.py') diff --git a/odoo/tools/sql.py b/odoo/tools/sql.py index 6c783fe27e7..75f71b2e6b4 100644 --- a/odoo/tools/sql.py +++ b/odoo/tools/sql.py @@ -53,7 +53,11 @@ def table_columns(cr, tablename): """ Return a dict mapping column names to their configuration. The latter is a dict with the data from the table ``information_schema.columns``. """ - query = 'SELECT * FROM information_schema.columns WHERE table_name=%s' + # Do not select the field `character_octet_length` from `information_schema.columns` + # because specific access right restriction in the context of shared hosting (Heroku, OVH, ...) + # might prevent a postgres user to read this field. + query = '''SELECT column_name, udt_name, character_maximum_length, is_nullable + FROM information_schema.columns WHERE table_name=%s''' cr.execute(query, (tablename,)) return {row['column_name']: row for row in cr.dictfetchall()} -- cgit v1.2.3