Hi,
docs suggests (Mapping a Class against Multiple Tables) to build a mapper
as this:
class AddressUser(object): pass
j = join(users_table, addresses_table)
mapper(AddressUser, j, properties={
'user_id': [users_table.c.user_id, addresses_table.c.user_id]
})
as a way to "keep both of those columns set at the same value". That works
perfectly when I want to use one mapper to present the join and to add
new instances for both tables.
As far as I can test it fails if I want to add a joined record composed of
one existent record and another that doesn't ye exists::
new = AddressUser()
new.name = 'myself'
new.address = '[email protected]'
It correctly creates a User instance and an Address instance.
But now I can't see how to add a record where the User is the already
existent user 'myself' and the address is a new one. Even if the user.id
is an already existent one SA will try to create a new obj (and in my real
case it complains about not present not nullable fields, clearly).
Is it possible to create a mapper that does that too? In the particular
context I have I'd really would prefere not to split the operation in two
steps (User / address).
Any hints?
thanks in advance
sandro
*:-)
--
Sandro Dentella *:-)
http://sqlkit.argolinux.org SQLkit home page - PyGTK/python/sqlalchemy
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.