mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Tidy up relation creation for name tables.
This commit is contained in:
parent
f773ef02ec
commit
b61acaff69
1 changed files with 14 additions and 16 deletions
|
@ -1886,22 +1886,20 @@ def makeTextTable(object_table, name_plural, name_singular, columns, lazy):
|
||||||
mapper(Strings, table,
|
mapper(Strings, table,
|
||||||
properties={
|
properties={
|
||||||
"object_id": synonym(safe_name + '_id'),
|
"object_id": synonym(safe_name + '_id'),
|
||||||
"language": relation(
|
"language": relation(Language,
|
||||||
Language,
|
|
||||||
primaryjoin=table.c.language_id == Language.id,
|
primaryjoin=table.c.language_id == Language.id,
|
||||||
),
|
),
|
||||||
|
safe_name: relation(object_table,
|
||||||
|
primaryjoin=(object_table.id == table.c[safe_name + "_id"]),
|
||||||
|
backref=backref(name_plural,
|
||||||
|
collection_class=attribute_mapped_collection('language'),
|
||||||
|
lazy=lazy,
|
||||||
|
),
|
||||||
|
),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
# The relation to the object
|
# The relation to the object
|
||||||
setattr(object_table, name_plural, relation(
|
|
||||||
Strings,
|
|
||||||
primaryjoin=(object_table.id == Strings.object_id),
|
|
||||||
backref=safe_name,
|
|
||||||
collection_class=attribute_mapped_collection('language'),
|
|
||||||
lazy=lazy,
|
|
||||||
))
|
|
||||||
str(getattr(object_table, name_plural)) # [MORE MAGIC]. aka do not remove, or entire app fails. XXX what the fuck man
|
|
||||||
Strings.object = getattr(Strings, safe_name)
|
Strings.object = getattr(Strings, safe_name)
|
||||||
|
|
||||||
# Link the tables themselves, so we can get them if needed
|
# Link the tables themselves, so we can get them if needed
|
||||||
|
|
Loading…
Reference in a new issue