[Sqlalchemy-tickets] Issue #4141: ARRAY does not fire attachment events (zzzeek/sqlalchemy)
Brought to you by:
zzzeek
From: Michael B. <iss...@bi...> - 2017-12-04 21:25:59
|
New issue 4141: ARRAY does not fire attachment events https://bitbucket.org/zzzeek/sqlalchemy/issues/4141/array-does-not-fire-attachment-events Michael Bayer: this is the same issue as #3832 ``` #!python from sqlalchemy import * from sqlalchemy import event my_type = ARRAY(String) @event.listens_for(my_type, "before_parent_attach") def go(target, parent): print "yes" Column('q', my_type) ``` second test: ``` #!python from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declared_attr from sqlalchemy.dialects import postgresql from sqlalchemy.ext.mutable import MutableList Base = declarative_base() class Mixin(object): data = Column(MutableList.as_mutable(postgresql.ARRAY(String))) class A(Base): __tablename__ = 'a' id = Column(Integer, primary_key=True) data = Column(MutableList.as_mutable(postgresql.ARRAY(String))) class B(Mixin, Base): __tablename__ = 'b' id = Column(Integer, primary_key=True) e = create_engine('postgresql://scott:tiger@localhost/test', echo=True) Base.metadata.drop_all(e) Base.metadata.create_all(e) s = Session(e) a = A(data=['1']) b = B(data=['1']) s.add(a) s.add(b) s.commit() a.data.append('2') b.data.append('2') s.commit() print a.data print b.data ``` |