[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.
This commit is contained in:
Fabien Meghazi
2017-08-07 12:59:34 +02:00
parent 623ea43268
commit a867cce406
+5 -1
View File
@@ -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()}