kazanzhy opened a new pull request #21307:
URL: https://github.com/apache/airflow/pull/21307


   Attribute `description` of simple psycopg2 cursor is available after 
`.execute()` method.  But for named cursor (server-side cursor) any `.fetch*` 
method call is needed.
   
   In case of an empty result set like `"SELECT 1 LIMIT 0"`:
   - for the simple cursor, we have initialized `.description` and an empty 
iterator
   - for the server-side cursor, we have initialized `.description`and an empty 
original iterator.
   But also we have `[None]` in `self.rows` (as a result of `fetchone()` on 
empty iterator of server-side cursor. This `None` makes 
`_PostgresServerSideCursorDecorator` non-empty iterator.
   
   I decided to remove `rows` attribute because it could consist of a maximum 
of one row, and also psycopg2 server-side cursor have `.scroll()` method and it 
is safe to call `.scroll(-1)` or `.scroll(0, mode='absolute')` on empty 
resultset even without `.fetchone()`
   
   closes #20007
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to