From 059cc7c3b7e2a2793b9774ca4b7d61da66631baf Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Sat, 13 Jul 2019 16:25:26 +0200 Subject: [PATCH] Allow adapters to be passed as arguments of cursor's execute() psycopg2 allows to pass Adapter instances as arguments of cursor's execute(). This patch will make psycopg2cffi behave the same way. --- psycopg2cffi/_impl/adapters.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/psycopg2cffi/_impl/adapters.py b/psycopg2cffi/_impl/adapters.py index 108a7da..20e91cf 100644 --- a/psycopg2cffi/_impl/adapters.py +++ b/psycopg2cffi/_impl/adapters.py @@ -289,7 +289,10 @@ def _getquoted(param, conn): """Helper method""" if param is None: return b'NULL' - adapter = adapt(param) + if isinstance(param, _BaseAdapter): + adapter = param + else: + adapter = adapt(param) try: adapter.prepare(conn) except AttributeError: