From 11743db0ff3b14fcb723af27cd7e28a33a32f4a5 Mon Sep 17 00:00:00 2001 From: Kieren Eaton <499977+circulon@users.noreply.github.com> Date: Sun, 1 Dec 2024 11:57:44 +0800 Subject: [PATCH] Fixed using model default select columns correctly Only use model get_selects() if no other columns are specified --- src/masoniteorm/models/Model.py | 2 +- src/masoniteorm/query/QueryBuilder.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/masoniteorm/models/Model.py b/src/masoniteorm/models/Model.py index 7a6a6a9c..c0a67a6f 100644 --- a/src/masoniteorm/models/Model.py +++ b/src/masoniteorm/models/Model.py @@ -354,7 +354,7 @@ def get_builder(self): dry=self.__dry__, ) - return self.builder.select(*self.get_selects()) + return self.builder def get_selects(self): return self.__selects__ diff --git a/src/masoniteorm/query/QueryBuilder.py b/src/masoniteorm/query/QueryBuilder.py index f5005cd8..ecc27c29 100644 --- a/src/masoniteorm/query/QueryBuilder.py +++ b/src/masoniteorm/query/QueryBuilder.py @@ -1229,6 +1229,7 @@ def or_where_doesnt_have(self, relationship, callback): return self def with_count(self, relationship, callback=None): + self.select(*self._model.get_selects()) return getattr(self._model, relationship).get_with_count_query( self, callback=callback ) @@ -2067,6 +2068,9 @@ def get_grammar(self): # Either _creates when creating, otherwise use columns columns = self._creates or self._columns + if not columns and not self._aggregates and self._model: + self.select(*self._model.get_selects()) + columns = self._columns return self.grammar( columns=columns,