From: Daniele Varrazzo Date: Mon, 23 Nov 2020 08:43:56 +0000 (+0000) Subject: Dropped params from Cursor.copy() X-Git-Tag: 3.0.dev0~323 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d227716b94ce3a3ed5419493ffb36e24bc2319c;p=thirdparty%2Fpsycopg.git Dropped params from Cursor.copy() Never tested... and they don't work. --- diff --git a/docs/cursor.rst b/docs/cursor.rst index c60bb522e..245afeeda 100644 --- a/docs/cursor.rst +++ b/docs/cursor.rst @@ -73,12 +73,10 @@ The `!Cursor` class See :ref:`query-parameters` for all the details about executing queries. - .. automethod:: copy(statement: Query, vars: Optional[Args]=None) -> Copy + .. automethod:: copy(statement: Query) -> Copy :param statement: The copy operation to execute :type statement: `!str`, `!bytes`, or `sql.Composable` - :param args: The parameters to pass to the query, if any - :type args: Mapping, Sequence .. note:: it must be called as ``with cur.copy() as copy: ...`` @@ -136,7 +134,7 @@ The `!AsyncCursor` class .. automethod:: execute(query: Query, vars: Optional[Args]=None) -> AsyncCursor .. automethod:: executemany(query: Query, vars_seq: Sequence[Args]) -> AsyncCursor - .. automethod:: copy(statement: Query, vars: Optional[Args]=None) -> AsyncCopy + .. automethod:: copy(statement: Query) -> AsyncCopy .. note:: it must be called as ``async with cur.copy() as copy: ...`` diff --git a/psycopg3/psycopg3/cursor.py b/psycopg3/psycopg3/cursor.py index 4a96df26b..f077c244a 100644 --- a/psycopg3/psycopg3/cursor.py +++ b/psycopg3/psycopg3/cursor.py @@ -500,24 +500,20 @@ class Cursor(BaseCursor["Connection"]): yield row @contextmanager - def copy( - self, statement: Query, vars: Optional[Params] = None - ) -> Iterator[Copy]: + def copy(self, statement: Query) -> Iterator[Copy]: """ Initiate a :sql:`COPY` operation and return an object to manage it. """ - with self._start_copy(statement, vars) as copy: + with self._start_copy(statement) as copy: yield copy - def _start_copy( - self, statement: Query, vars: Optional[Params] = None - ) -> Copy: + def _start_copy(self, statement: Query) -> Copy: with self._conn.lock: self._start_query() self._conn._start_query() # Make sure to avoid PQexec to avoid receiving a mix of COPY and # other operations. - self._execute_send(statement, vars, no_pqexec=True) + self._execute_send(statement, None, no_pqexec=True) gen = execute(self._conn.pgconn) results = self._conn.wait(gen) self._check_copy_results(results) @@ -626,22 +622,18 @@ class AsyncCursor(BaseCursor["AsyncConnection"]): yield row @asynccontextmanager - async def copy( - self, statement: Query, vars: Optional[Params] = None - ) -> AsyncIterator[AsyncCopy]: - copy = await self._start_copy(statement, vars) + async def copy(self, statement: Query) -> AsyncIterator[AsyncCopy]: + copy = await self._start_copy(statement) async with copy: yield copy - async def _start_copy( - self, statement: Query, vars: Optional[Params] = None - ) -> AsyncCopy: + async def _start_copy(self, statement: Query) -> AsyncCopy: async with self._conn.lock: self._start_query() await self._conn._start_query() # Make sure to avoid PQexec to avoid receiving a mix of COPY and # other operations. - self._execute_send(statement, vars, no_pqexec=True) + self._execute_send(statement, None, no_pqexec=True) gen = execute(self._conn.pgconn) results = await self._conn.wait(gen) self._check_copy_results(results)