From e880017fc87f45453f79fc25ffcf9d12041eed77 Mon Sep 17 00:00:00 2001 From: "Gavin M. Roy" Date: Tue, 11 Aug 2020 19:40:56 -0400 Subject: [PATCH] Add a little context of why this code exists --- sprockets_postgres.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sprockets_postgres.py b/sprockets_postgres.py index 16560dd..9ca953e 100644 --- a/sprockets_postgres.py +++ b/sprockets_postgres.py @@ -266,6 +266,13 @@ class PostgresConnector: 'Unexpected value for ProgrammingError(%s).pgcode: %r', err, err.pgcode) + # This logic exists so that we can wrap the results and quickly free + # the cursor / connection. We do not know if the query was a SELECT, + # INSERT, UPDATE, or DELETE and we may impact multiple rows, but not + # have any data to retrieve. The ProgrammingErrror is raised in this + # context. It is raised in other contexts, such as when there is an + # error in the query, but that will be caught on L248 + if self.cursor.rowcount == 1: try: row = dict(await self.cursor.fetchone())