Skip to content

"named" is not accepted for attribute events, engine events #3197

Closed
@sqlalchemy-bot

Description

@sqlalchemy-bot
Collaborator

Migrated issue, originally created by Michael Bayer (@zzzeek)

diff --git a/lib/sqlalchemy/orm/events.py b/lib/sqlalchemy/orm/events.py
index c50a7b0..bd0b48f 100644
--- a/lib/sqlalchemy/orm/events.py
+++ b/lib/sqlalchemy/orm/events.py
@@ -1490,7 +1490,7 @@ class AttributeEvents(event.Events):
     @classmethod
     def _listen(cls, event_key, active_history=False,
                 raw=False, retval=False,
-                propagate=False):
+                propagate=False, **kw):
 
         target, identifier, fn = \
             event_key.dispatch_target, event_key.identifier, event_key.fn
@@ -1509,14 +1509,14 @@ class AttributeEvents(event.Events):
                     return fn(target, value, *arg)
             event_key = event_key.with_wrapper(wrap)
 
-        event_key.base_listen(propagate=propagate)
+        event_key.base_listen(propagate=propagate, **kw)
 
         if propagate:
             manager = instrumentation.manager_of_class(target.class_)
 
             for mgr in manager.subclass_managers(True):
                 event_key.with_dispatch_target(
-                    mgr[target.key]).base_listen(propagate=True)
+                    mgr[target.key]).base_listen(propagate=True, **kw)
 
     def append(self, target, value, initiator):
         """Receive a collection append event.
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import event

Base = declarative_base()

class A(Base):
    __tablename__ = 'a'

    id = Column(Integer, primary_key=True)
    bs = relationship("B")


class B(Base):
    __tablename__ = 'b'

    id = Column(Integer, primary_key=True)
    a_id = Column(Integer, ForeignKey('a.id'))

e = create_engine("sqlite://", echo=True)

sess = Session(e)


@event.listens_for(A.bs, 'set', named=True)
def update_challenge_points(target, **kw):
    pass

Activity

sqlalchemy-bot

sqlalchemy-bot commented on Sep 17, 2014

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • edited description
sqlalchemy-bot

sqlalchemy-bot commented on Sep 17, 2014

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • removed labels: orm
  • added labels: engine
sqlalchemy-bot

sqlalchemy-bot commented on Sep 17, 2014

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • changed title from ""named" is not accepted for attribute events" to ""named" is not accepted for attribute events engin"
sqlalchemy-bot

sqlalchemy-bot commented on Sep 17, 2014

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

Issue #3201 was marked as a duplicate of this issue.

sqlalchemy-bot

sqlalchemy-bot commented on Sep 17, 2014

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

see #3201, same thing in engine reported at the same time, wacky!

sqlalchemy-bot

sqlalchemy-bot commented on Sep 18, 2014

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

  • Fixed bug that affected generally the same classes of event
    as that of 🎫3199, when the named=True parameter
    would be used. Some events would fail to register, and others
    would not invoke the event arguments correctly, generally in the
    case of when an event was "wrapped" for adaption in some other way.
    The "named" mechanics have been rearranged to not interfere with
    the argument signature expected by internal wrapper functions.
    fixes "named" is not accepted for attribute events, engine events #3197

b36cdef

sqlalchemy-bot

sqlalchemy-bot commented on Sep 18, 2014

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

  • Fixed bug that affected generally the same classes of event
    as that of 🎫3199, when the named=True parameter
    would be used. Some events would fail to register, and others
    would not invoke the event arguments correctly, generally in the
    case of when an event was "wrapped" for adaption in some other way.
    The "named" mechanics have been rearranged to not interfere with
    the argument signature expected by internal wrapper functions.
    fixes "named" is not accepted for attribute events, engine events #3197

Conflicts:
test/base/test_events.py
test/orm/test_attributes.py
test/orm/test_events.py

912ebaa

sqlalchemy-bot

sqlalchemy-bot commented on Sep 18, 2014

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
added
bugSomething isn't working
engineengines, connections, transactions, isolation levels, execution options
on Nov 27, 2018
added this to the 0.9.8 milestone on Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingengineengines, connections, transactions, isolation levels, execution options

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sqlalchemy-bot

        Issue actions

          "named" is not accepted for attribute events, engine events · Issue #3197 · sqlalchemy/sqlalchemy