On 5/2/15 5:00 AM, uralbash wrote:
Hello,
I have the following code, which sets UniqueConstraint using fields
("foo", "bar") from inherit class.
|
fromsqlalchemy.ext.declarative importdeclarative_base,declared_attr
fromsqlalchemy importColumn,Integer,Unicode,UniqueConstraint
Base=declarative_base()
classFoo(object):
foo =Column(Unicode(64),nullable=False)
@declared_attr
defbar(cls):
returnColumn("bar",Integer)
classItemCategory(Base,Foo):
__tablename__ ='item_category'
id =Column(Integer,primary_key=True)
name =Column(Unicode(64),nullable=False)
__table_args__ =(
UniqueConstraint(name,"foo","bar",
name='unique_category_and_parent'),)Введитекод...
|
It's work ok with sqlalchemy==0.9.9, but sqlalchemy>=1.0 raises an
exception.
"foo" field work ok, "bar" defined with declared_attr raises KeyError.
I've made a new term for regression called "unexpected use" regression,
since we've had a lot of regressions in 1.0 and I want to separate out
those that could not have well been anticipated. This case is very
unusual because of the combination of Column and string arguments sent
to UniqueConstraint was not anticipated by the enhancements in
http://docs.sqlalchemy.org/en/rel_1_0/changelog/changelog_10.html#change-6995af73c8bb8ff0a94424837ca173bf.
This will be resolved in the next hour, but you should generally be
sending all string names to UniqueConstraint if it is being declared
inline with the Table.
--
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 [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.