[FIX] sql_db: use psycopg2.extensions.parse_dsn for dsn parsing
Before this patch the naive dsn parser `_dsn_to_dict` would choke on `application_name` containing spaces or the equal sign. closes odoo/odoo#122212 X-original-commit: 3573fe0726f8dde1c5714b7d501f6c43d97ce731 Signed-off-by: Fabien Meghazi (fme) <fme@odoo.com>
This commit is contained in:
+1
-4
@@ -679,14 +679,11 @@ class ConnectionPool(object):
|
||||
ignore_keys = ['password']
|
||||
dsn1, dsn2 = ({
|
||||
alias_keys.get(key, key): str(value)
|
||||
for key, value in (isinstance(dsn, str) and self._dsn_to_dict(dsn) or dsn).items()
|
||||
for key, value in (psycopg2.extensions.parse_dsn(dsn) if isinstance(dsn, str) else dsn).items()
|
||||
if key not in ignore_keys
|
||||
} for dsn in (dsn1, dsn2))
|
||||
return dsn1 == dsn2
|
||||
|
||||
def _dsn_to_dict(self, dsn):
|
||||
return dict(value.split('=', 1) for value in dsn.strip().split())
|
||||
|
||||
|
||||
class Connection(object):
|
||||
""" A lightweight instance of a connection to postgres
|
||||
|
||||
Reference in New Issue
Block a user