mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Use viewonly=True
to suppress relationship warnings in SQLA 1.4
This commit is contained in:
parent
62c8ca421a
commit
716ad75dbc
2 changed files with 8 additions and 0 deletions
|
@ -185,6 +185,7 @@ def create_translation_table(_table_name, foreign_class, relation_name,
|
|||
foreign_keys=[Translations.foreign_id, Translations.local_language_id],
|
||||
uselist=False,
|
||||
lazy=relation_lazy,
|
||||
viewonly=True,
|
||||
))
|
||||
|
||||
# Add per-column proxies to the original class
|
||||
|
|
|
@ -30,6 +30,7 @@ from functools import partial
|
|||
import six
|
||||
|
||||
from sqlalchemy import Column, ForeignKey, MetaData, PrimaryKeyConstraint, UniqueConstraint
|
||||
from sqlalchemy import __version__ as sqla_version
|
||||
from sqlalchemy.ext.declarative import declarative_base, DeclarativeMeta
|
||||
from sqlalchemy.ext.associationproxy import association_proxy
|
||||
from sqlalchemy.ext.hybrid import hybrid_property
|
||||
|
@ -39,6 +40,12 @@ from sqlalchemy.types import Boolean, Enum, Integer, SmallInteger, Unicode, Unic
|
|||
|
||||
from pokedex.db import markdown, multilang
|
||||
|
||||
relationship = partial(relationship, viewonly=True)
|
||||
if (1, 3, 17) <= tuple(int(x) for x in sqla_version.split(".")) < (1, 4):
|
||||
# `sync_backref` was introduced in 1.3.17
|
||||
# Since 1.4 it defaults to False if `viewonly` is True
|
||||
relationship = partial(relationship, sync_backref=False)
|
||||
|
||||
class TableSuperclass(object):
|
||||
"""Superclass for declarative tables, to give them some generic niceties
|
||||
like stringification.
|
||||
|
|
Loading…
Reference in a new issue