Skip to content

Commit

Permalink
Fixed using model default select columns correctly
Browse files Browse the repository at this point in the history
Only use model get_selects() if no other columns are specified
  • Loading branch information
circulon committed Dec 1, 2024
1 parent ccf9025 commit 11743db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/masoniteorm/models/Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
4 changes: 4 additions & 0 deletions src/masoniteorm/query/QueryBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 11743db

Please sign in to comment.