Hello, i implemented a generic foreign key/relationship, using this example:
http://docs.sqlalchemy.org/en/latest/_modules/examples/generic_associations/discriminator_on_association.html

In the example addresses is passing in constructor:

session.add_all([
    Customer(
        name='customer 1',
        addresses=[
            Address(
                    street='123 anywhere street',
                    city="New York",
                    zip="10110"),
            Address(
                    street='40 main street',
                    city="San Francisco",
                    zip="95732")
        ]
    ),
    Supplier(
        company_name="Ace Hammers",
        addresses=[
            Address(
                    street='2569 west elm',
                    city="Detroit",
                    zip="56785")
        ]
    ),
])



But if i try to do something like this:

_cust = Customer('name')
session.add(_cust)
session.commit()

#And After try to use "addresses"

_cust.addresses.append(Address(street='2569 west elm',city="Detroit", 
zip="56785"))
#It doens't work, "addresses" is None.


Is there any way to use this without pass "addresses" in the constructor? 
I'm using mysql and sqlachemy version is '1.1.15'.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to