#12575·sqlalchemy

prefixing Composite Column Types

Author: choucavalierCreated May 6, 2025Updated Sep 10, 2026
Labelsormuse casecode review in progress

Describe the use case

python
@dataclasses.dataclass
class Person:
  first_name: int
  last_name: str

# ...

class Housing(Base):
  person: composite(Person, column_prefix='person')

would result in mapped column names person_first_name and person_last_name

right now, the API is a bit verbose and hard to read:

python
class Housing(Base):
  person: composite(*(mapped_column(f'person_{f}') for f in Person.__dataclass_fields__)))

plus, the Mapper already has a column_prefix arg. so it's just a matter of transferring it, if it's set in the composite(...) call.

Databases / Backends / Drivers targeted

all databases

Example Use

see example

Additional context

No response