Right now the
ident parameter to
query.get is a tuple in the case of composite primary keys with the stipulation:
For a composite primary key, the order of identifiers corresponds in most cases to that of the mapped :class:
.Tableobject's primary key columns.
Having to know and hard code the order of the primary keys seems less than ideal. I suggest accepting a dict mapping names to the values for the primary keys. My implementation of this looks like:
from sqlalchemy.inspection import inspect def get_by_pks(model, **kwargs): return model.query.get( tuple( kwargs[key.name] for key in inspect(model).primary_key ) )