Yeah, this is a bit awkward.
My code used to be able to say:
=================================
constraint_list = list(tab.constraints)
for cnsts in constraint_list:
if cnsts.contains_column(col):
=================================
And I can't replace that with this:
=================================
constraint_list = list(tab.constraints)
for cnsts in constraint_list:
if cnsts.columns.contains_column(col):
=================================
because cnsts.columns is a ColumnCollection for PrimaryKeyConstraint but
it is a list for ForeignKeyConstraint.
So, in the end, this works for either:
=================================
constraint_list = list(tab.constraints)
for cnsts in constraint_list:
if col in list(cnsts.columns):
=================================
On 5/1/2010 4:06 PM, Kent Bower wrote:
Oh, I get it, you are saying ColumnCollection has "contains_column()"
method.
On 5/1/2010 4:05 PM, Kent Bower wrote:
Wait a second... ForeignKeyConstraint doesn't but
PrimaryKeyConstraint does?
(Not trying to be sassy, just wondering why I got the error in the
first place)
On 5/1/2010 2:11 PM, Michael Bayer wrote:
On May 1, 2010, at 2:04 PM, Kent Bower wrote:
May help others:
instead of "col in const.columns"
I needed "col in list(const.columns)"
to avoid: "sqlalchemy.exc.ArgumentError: __contains__ requires a
string argument" with the ColumnCollection object
dont hate me but const.columns should have a "contains_column()"
method...
On 4/30/2010 4:16 PM, Michael Bayer wrote:
Kent wrote:
I did read 0.6 Migration document.
I was using the contains_column method of ForeignKeyConstraint.
Apparently removed?
AttributeError: 'ForeignKeyConstraint' object has no attribute
'contains_column'
Easy workaround or replacement call?
it has a "columns" collection where you can say "col in
const.columns".
--
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.
--
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.
--
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.