1
0
Fork 0
mirror of https://github.com/veekun/pokedex.git synced 2024-08-20 18:16:34 +00:00

Joinedload current-language names.

This commit is contained in:
Eevee 2011-03-29 18:39:37 -07:00
parent 4445305e7c
commit 1268a76832
2 changed files with 33 additions and 5 deletions
pokedex/db

View file

@ -9,7 +9,7 @@ from sqlalchemy.sql.expression import and_, bindparam, select
from sqlalchemy.types import Integer
def create_translation_table(_table_name, foreign_class, relation_name,
language_class, **kwargs):
language_class, relation_lazy='select', **kwargs):
"""Creates a table that represents some kind of data attached to the given
foreign class, but translated across several languages. Returns the new
table's mapped class. It won't be declarative, but it will have a
@ -107,8 +107,6 @@ def create_translation_table(_table_name, foreign_class, relation_name,
setattr(foreign_class, relation_name, relationship(Translations,
primaryjoin=foreign_class.id == Translations.foreign_id,
collection_class=attribute_mapped_collection('local_language'),
# TODO
lazy='select',
))
# Foo.bars_local
# This is a bit clever; it uses bindparam() to make the join clause
@ -128,8 +126,8 @@ def create_translation_table(_table_name, foreign_class, relation_name,
),
),
uselist=False,
# TODO MORESO HERE
lazy='select',
#innerjoin=True,
lazy=relation_lazy,
))
# Add per-column proxies to the original class