FTR, pickling of metadata is a covered use case (meaning a regression of basic 
FK activity would have been detected), here's a simple test which passes:

from sqlalchemy import *

m = MetaData()

a = Table('a', m, 
    Column('x', Integer, primary_key=True),
    Column('z', Integer)
)

b = Table('b', m, 
    Column('x', Integer, primary_key=True),
    Column('y', Integer, ForeignKey('a.x'))
)

assert b.c.y.references(a.c.x)
assert not b.c.y.references(a.c.z)

import pickle

m2 = pickle.loads(pickle.dumps(m))

a2 = m2.tables['a']
b2 = m2.tables['b']

assert b2.c.y.references(a2.c.x)
assert not b2.c.y.references(a2.c.z)



On Nov 5, 2011, at 7:30 AM, Michael Bayer wrote:

> can you provide a very simple and pared down test case using table metadata 
> only?
> 
> 
> On Nov 5, 2011, at 6:41 AM, botz wrote:
> 
>> version 0.7.3.
>> 
>> I have tables with foreign keys defined, and the orm mapping (with
>> relationships corresponding to the foreign keys)  works fine with
>> autoload=True on the tables.
>> 
>> If I persist the metadata then with pickle, and then reload the app
>> using pickled metadata and autoload=False, I get the following:
>> 
>> sqlalchemy.exc.ArgumentError: Could not locate any foreign-key-
>> equated, locally mapped column pairs for primaryjoin condition
>> 'client_statuses.client_status_code = clients.client_status_code' on
>> relationship Client.status.  Ensure that the referencing Column
>> objects have a ForeignKey present, or are otherwise part of a
>> ForeignKeyConstraint on their parent Table, or specify the
>> foreign_keys parameter to this relationship.  For more relaxed rules
>> on join conditions, the relationship may be marked as viewonly=True.
>> 
>> Error occurs for both values of extend_existing.
>> 
>> Seems to be a regression from 0.6 where it worked ok.
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sqlalchemy" group.
>> To post to this group, send email to sqlalchemy@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> sqlalchemy+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/sqlalchemy?hl=en.
>> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to