You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 14, 2024. It is now read-only.
For this to happend without bringing the users table columns has_many_through has this two functions that returns the columns to select living out all the parent table columns.
The problem with the get function is that add_select overriding our self._query selects or get(columns=[]) because the get is on a Post model query, so we don't have access to filter the results.
def _get_select_columns(self, columns=None):
"""
Set the select clause for the relation query.
:param columns: The columns
:type columns: list
:rtype: list
"""
if columns == ["*"] or columns is None:
columns = ["%s.*" % self._related.get_table()]
return columns + ["%s.%s" % (self._parent.get_table(), self._first_key)]
def get(self, columns=None):
"""
Execute the query as a "select" statement.
:type columns: list
:rtype: orator.Collection
"""
if columns is None:
columns = ["*"]
select = self._get_select_columns(columns)
models = self._query.add_select(*select).get_models()
if len(models) > 0:
models = self._query.eager_load_relations(models)
return self._related.new_collection(models)
The text was updated successfully, but these errors were encountered:
Sure! Let me know if you have questions. It's useful to read the ORM white paper which explains how all the pieces of the ORM are built and how they relate with each other
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Using the same example as the documentation where we have 3 tables countries, users and posts
And the same model as the documentation
If we make a query like this
The result will be a json with the country and post like this
For this to happend without bringing the users table columns has_many_through has this two functions that returns the columns to select living out all the parent table columns.
The problem with the get function is that add_select overriding our self._query selects or get(columns=[]) because the get is on a Post model query, so we don't have access to filter the results.
The text was updated successfully, but these errors were encountered: