From fb65138266bb45db0c3a1028b51a78d90db11f08 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 9 Jan 2021 11:26:19 -0800 Subject: [PATCH] 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. --- etiquette/photodb.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etiquette/photodb.py b/etiquette/photodb.py index c47636d..a6527a6 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -415,11 +415,11 @@ class PDBCacheManagerMixin: def get_things_by_sql(self, thing_type, query, bindings=None): ''' 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_ids = (thing_id for (thing_id,) in thing_rows) - return self.get_things_by_id(thing_type, thing_ids) + for thing_row in thing_rows: + yield self.get_cached_instance(thing_type, thing_row) ####################################################################################################