Hi there..

Is is it possible to describe multi-column foreign keys with SA metadata?

I.e.

create table customers (
customer_id string,
primary key (customer_id)
)

create table users (
customer_id string,
username string,
primary key (customer_id, username),
foreign key (customer_id) references customers (customer_id)
)

create table preferences (
customer_id string,
username string,
preference_id string,
preference_value string,
primary key (customer_id, username, perference_id),
foreign key (customer_id, username) references users (customer_id, username)
)

This model is a made-up simplification of what I need to do.. but
basically it's the last foreign key I can't figure out if I can
describe with SA metadata.

The only solution I see is to put a relation property on the "user"
mapper that uses a custom join condition. However, this is standard
SQL so shouldn't SA be able to handle this automatically if there is a
ForeignKey specification on the table-object?

Arnar


_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to