Skip to content
Snippets Groups Projects
Commit 3573fe07 authored by Fabien Meghazi's avatar Fabien Meghazi
Browse files

[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#122010

Signed-off-by: default avatarFabien Meghazi (fme) <fme@odoo.com>
parent fa252066
No related branches found
No related tags found
No related merge requests found
......@@ -688,14 +688,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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment