get_things_by_sql queries should select *, not just ID.

By passing the ids into get_things_by_id which checks the cache first
before querying the rest, any orderby statements in the query would
effectively become useless.
This commit is contained in:
voussoir 2021-01-09 11:26:19 -08:00
parent 4f1471c41e
commit fb65138266

View file

@ -415,11 +415,11 @@ class PDBCacheManagerMixin:
def get_things_by_sql(self, thing_type, query, bindings=None): def get_things_by_sql(self, thing_type, query, bindings=None):
''' '''
Use an arbitrary SQL query to select things from the database. Use an arbitrary SQL query to select things from the database.
Your query should *only* select the id column. Your query select *, all the columns of the thing's table.
''' '''
thing_rows = self.sql_select(query, bindings) thing_rows = self.sql_select(query, bindings)
thing_ids = (thing_id for (thing_id,) in thing_rows) for thing_row in thing_rows:
return self.get_things_by_id(thing_type, thing_ids) yield self.get_cached_instance(thing_type, thing_row)
#################################################################################################### ####################################################################################################