You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The list() function invokes the BaseQuery's len() function, followed by the iter() function, and then again len() function. Within len() and iter(), Peewee includes a check called _ensure_execution():
def _ensure_execution(self):
if not self._cursor_wrapper:
if not self._database:
raise ValueError('Query has not been executed.')
self.execute()
Despite self._cursor_wrapper existing with a result set size of 0, the query still executes. We're unsure if this behaviour is intentional or if we should modify the condition to:
def _ensure_execution(self):
if self._cursor_wrapper is None:
if not self._database:
raise ValueError('Query has not been executed.')
self.execute()
The text was updated successfully, but these errors were encountered:
Furthermore, I've observed that modifying the code as shown below prevents redundant queries. However, considering our legacy code base, it may not be feasible to implement this change in multiple places:
Observed redundant database queries occurring in select operations when no data is present. Please find below the code snippet:
The list() function invokes the BaseQuery's len() function, followed by the iter() function, and then again len() function. Within len() and iter(), Peewee includes a check called _ensure_execution():
Despite self._cursor_wrapper existing with a result set size of 0, the query still executes. We're unsure if this behaviour is intentional or if we should modify the condition to:
The text was updated successfully, but these errors were encountered: