On May 26, 2011, at 11:41 AM, Jan Dittberner wrote:

> Hello,
> 
> I work on making sqlalchemy-migrate [1] work with SQLAlchemy 0.7. I
> fixed all broken unit tests except for one related to adding a new
> column with a foreign key to an existing table. We have a continues
> integration system (Jenkins CI) at [2] that provides the output of the
> failing test. The problem is with some changed behaviour of the
> SchemaVisitor API (or the Column objects). Until SQLAlchemy 0.6 it was
> possible to get the constraints object for the ForeignKey arguments of
> a column. The test at [3] creates a new Column instance and adds it to
> the table.

the linked samples don't make it clear what specific behavior in SQLAlchemy has 
changed.   From your description, it appears as though you are saying 
ForeignKeyConstraint is not generated for an append_column() operation.  Below 
is a test which illustrates this usage, it is the same in 0.6 and 0.7.  If you 
can alter this test case to illustrate the specific functionality that has 
changed on the SQLA side from 0.6 to 0.7, it may very well be a bug in 0.7 or 
some usage in Migrate that was never supported, but at the very least it would 
isolate the issue.

from sqlalchemy import Table, Column, ForeignKey, MetaData, Integer, 
ForeignKeyConstraint

m1 = MetaData()

t1 = Table('t1', m1,
    Column('x', Integer, primary_key=True)
)

t2 = Table('t2', m1, 
    Column('x', Integer, primary_key=True),
    Column('added_inline', Integer, ForeignKey('t1.x'))
)

assert set([
    fkc.columns[0].name 
    for fkc in t2.constraints 
    if isinstance(fkc, ForeignKeyConstraint)]) == set(['added_inline'])

t2.append_column(
    Column('added_externally', Integer, ForeignKey('t1.x'))
)

assert set([
    fkc.columns[0].name 
    for fkc in t2.constraints 
    if isinstance(fkc, ForeignKeyConstraint)]) == set(['added_externally', 
'added_inline'])



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

Reply via email to