From 5898ed30dbe9ecbbc0a995f338e8b0c835e2616e Mon Sep 17 00:00:00 2001 From: alfonsocv12 Date: Thu, 25 Mar 2021 16:02:01 -0700 Subject: [PATCH] Fix has_many_through select error --- orator/orm/relations/has_many_through.py | 9 ++++----- orator/orm/relations/relation.py | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/orator/orm/relations/has_many_through.py b/orator/orm/relations/has_many_through.py index c17db200..4a63f554 100644 --- a/orator/orm/relations/has_many_through.py +++ b/orator/orm/relations/has_many_through.py @@ -162,12 +162,11 @@ def get(self, columns=None): :rtype: orator.Collection """ - if columns is None: - columns = ["*"] + if not columns: + select = self._get_select_columns(["*"]) + self._query.add_select(*select) - select = self._get_select_columns(columns) - - models = self._query.add_select(*select).get_models() + models = self._query.get_models() if len(models) > 0: models = self._query.eager_load_relations(models) diff --git a/orator/orm/relations/relation.py b/orator/orm/relations/relation.py index 7a311b73..f9579bc4 100644 --- a/orator/orm/relations/relation.py +++ b/orator/orm/relations/relation.py @@ -72,7 +72,7 @@ def get_eager(self): :rtype: Collection """ - return self.get() + return self.get(columns=self._query.columns) def touch(self): """