Upgrade sqlalchemy

Adapt code to prevent new warnings and errors (as of SQLAlchemy 1.4):
- Overlapping foreign key columns could be set in a conflicting way
  => This is prevented by the application logic
  => Ignore the warning by setting a `overlaps` flag
- Transaction already rolled back
  => This only happens when tests cause an `IntegrityError` on purpose
  => Filter away the corresponding warning in the fixture
- Query returns `Row` objects and not scalars
  => Add genexpr to pull out `primary_id`
This commit is contained in:
Alexander Hess 2021-09-12 12:13:26 +02:00
commit 2d08afa309
Signed by: alexander
GPG key ID: 344EA5AB10D868E0
6 changed files with 75 additions and 68 deletions

View file

@ -89,13 +89,12 @@ class DistanceMatrix(meta.Base):
# Relationships
first_address = orm.relationship(
'Address',
back_populates='_distances1',
foreign_keys='[DistanceMatrix.first_address_id, DistanceMatrix.city_id]',
)
second_address = orm.relationship(
'Address',
back_populates='_distances2',
foreign_keys='[DistanceMatrix.second_address_id, DistanceMatrix.city_id]',
overlaps='first_address',
)
@classmethod