[FIX] base: allow using another postgres schema than public
Before 1721ec1363 and fdc4ef97c9, Odoo did work fine when the
user had another default schema than 'public'.
This commit restores this behaviour by searching
for existing objects in the user's current schema,
which is the first in the schema search path and
the one used when no schema is specified when
creating objects.
closes odoo/odoo#68144
X-original-commit: 223781b34afacd1c0c5674d395cece6d472b048c
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
This commit is contained in:
+2
-2
@@ -24,7 +24,7 @@ def existing_tables(cr, tablenames):
|
||||
JOIN pg_namespace n ON (n.oid = c.relnamespace)
|
||||
WHERE c.relname IN %s
|
||||
AND c.relkind IN ('r', 'v', 'm')
|
||||
AND n.nspname = 'public'
|
||||
AND n.nspname = current_schema
|
||||
"""
|
||||
cr.execute(query, [tuple(tablenames)])
|
||||
return [row[0] for row in cr.fetchall()]
|
||||
@@ -43,7 +43,7 @@ def table_kind(cr, tablename):
|
||||
FROM pg_class c
|
||||
JOIN pg_namespace n ON (n.oid = c.relnamespace)
|
||||
WHERE c.relname = %s
|
||||
AND n.nspname = 'public'
|
||||
AND n.nspname = current_schema
|
||||
"""
|
||||
cr.execute(query, (tablename,))
|
||||
return cr.fetchone()[0] if cr.rowcount else None
|
||||
|
||||
Reference in New Issue
Block a user