3
0
Fork 0

fix: add assocation proxies for User.first_name and User.last_name

for a rather dubious purpose though..so may need to undo this, we'll see
This commit is contained in:
Lance Edgar 2026-02-16 18:39:09 -06:00
parent 5ec0a8e82d
commit 589f279f04

View file

@ -44,7 +44,7 @@ from sqlalchemy import orm
from sqlalchemy.ext.associationproxy import association_proxy
from wuttjamaican.db.util import uuid_column, uuid_fk_column
from wuttjamaican.db.model.base import Base
from wuttjamaican.db.model.base import Base, Person
from wuttjamaican.util import make_utc
@ -204,8 +204,6 @@ class User(Base): # pylint: disable=too-few-public-methods
person_uuid = uuid_fk_column("person.uuid", nullable=True)
person = orm.relationship(
"Person",
# TODO: seems like this is not needed?
# uselist=False,
back_populates="users",
cascade_backrefs=False,
doc="""
@ -214,6 +212,21 @@ class User(Base): # pylint: disable=too-few-public-methods
""",
)
# TODO: these may or may not be good ideas? i added them mostly
# for sake of testing association proxy behavior in wuttaweb, b/c
# i was lazy and didn't want to write proper fixtures. so if
# they are a problem then doing that should fix it..
first_name = association_proxy(
"person",
"first_name",
creator=lambda n: Person(first_name=n, full_name=n),
)
last_name = association_proxy(
"person",
"last_name",
creator=lambda n: Person(last_name=n, full_name=n),
)
active = sa.Column(
sa.Boolean(),
nullable=False,