On May 17, 2012, at 6:33 PM, Michael Bayer wrote:

> OK this is way too much verbiage.  If the error is as you describe, a bug 
> involving reflection of two tables across two schemas, I'd need a test which 
> illustrates this alone, no ORM or full database dumps, with a simple failure 
> to identify a foreign key constraint between them.   I've attached a sample 
> of exactly what I'd like to see.
> 
> If the issue is not as simple as this, then we will have to dig into multiple 
> tables, mappings, etc. but you should be able to reproduce the specific case 
> here with just two tables.

I've refactored the example to the simplest case. We can see if the fix 
addresses many-to-many relationships as well.

Demitri

-- 
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.

from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base

"""
CREATE TABLE people.band ( id integer primary key, name text, venue_id integer );
CREATE TABLE things.venue ( id integer primary key, name text );
ALTER TABLE ONLY people.band
    ADD CONSTRAINT venue_fk FOREIGN KEY (venue_id) REFERENCES things.venue(id) ON UPDATE CASCADE ON DELETE SET NULL;

"""

e = create_engine("postgresql://scott:tiger@localhost/test", echo=True)
#e = create_engine("postgresql://schema_test:schema_test@localhost:9000/schema_test_db", echo=True)

Base = declarative_base(bind=e)

class Band(Base):
	__tablename__ = 'band'
	__table_args__ = {'autoload' : True, 'schema' : 'people'}

class Venue(Base):
	__tablename__ = 'venue'
	__table_args__ = {'autoload' : True, 'schema' : 'things'}

assert Band.__table__.c.venue_id.references(Venue.__table__.c.id)

Reply via email to