magfest-archive / mivs

MAGFest Indie Videogame Showcase
GNU Affero General Public License v3.0
2 stars 2 forks source link

warning message: 'name' not found #41

Closed binary1230 closed 6 years ago

binary1230 commented 8 years ago

This line:

def indie_games(self):
        return self.query(IndieGame).options(joinedload(IndieGame.studio), joinedload(IndieGame.reviews)).order_by('name').all()

Is causing this warning message to be printed on a fresh install:

/home/vagrant/uber/sideboard/env/lib/python3.4/site-packages/sqlalchemy/sql/compiler.py:572: SAWarning: Can't resolve label reference 'name'; converting to text() (this warning may be suppressed after 10 occurrences)
  util.ellipses_string(element.element))

I think it's because we are using text in the order_by() clause instead of a reference to something in the original query.

Here I think it may be because 'name' is a reference to a field in IndieStudio, but the sqlalchemy compiler at this stage might not have that in scope which means it doesn't know how to resolve as text. Might have to explicity reference studio.name there, or something, since IndieStudio is loaded as a join

binary1230 commented 8 years ago

Did some more reading and looks like we may need another .join() there to do this order_by() correctly. http://docs.sqlalchemy.org/en/latest/orm/loading_relationships.html

For now, this doesn't look like it's hurting anything but will emit warnings, so we should prob fix it.

EliAndrewC commented 7 years ago

Ahhh yeah, instead of .order_by('name') we should instead be saying .order_by(IndieGame.name) since that's more unambiguous.