question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

None result should be None (fetchrow and fetch)

See original GitHub issue
query = ...  # some SA select query
row = await conn.fetchrow(query)  # conn is SAConnection

When the underlying asyncpg connection returns None as the “empty” result, row should become None as well. Currently, row is not None but row.row is None. This would confuse the users who expect the API semantics to be same to asyncpg.

The same applies to fetch and execute which returns a RecordGenerator because it does not check None when instantiating Record objects.

Q: What’s the purpose of having seem-to-be-redundant Record and RecordGenerator classes? They look like a no-op proxy to asyncpg’s return objects.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
nhumrichcommented, Apr 18, 2017

@rbcarson Good catch. This is fixed in 0.8.2. RecordGenerator will now be falsey on an empty list.

1reaction
nhumrichcommented, Mar 8, 2017

Ya, thats valid. I’ll leave this open until I do something about it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prepared_stmt.fetch() should explicitly either return None or ...
While fetchval and fetchrow both explicitly return None if __bind_execute does not return any data, it's not made clear what will be ...
Read more >
Python cursor's fetchall, fetchmany(), fetchone() to ... - PYnative
To fetch a single row from a result set we can use cursor.fetchone() . This method returns a single tuple. It can return...
Read more >
API Reference — asyncpg Documentation
Copy the results of a query to a file or file-like object. Parameters ... coroutine fetchrow(query, *args, timeout=None, record_class=None)[source]¶.
Read more >
How to check if a result set is empty? - python - Stack Overflow
Just an empty list ( [] ) for cursor.fetchall() and None for cursor.fetchone() . For any other statement, e.g. INSERT or UPDATE , ......
Read more >
How to use Python cursor's fetchall, fetchmany(), fetchone() to ...
To fetch a single row from a result set we can use cursor.fetchone() . This method returns a single tuple. It can return...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found