Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/track cloned connections #2

Merged
merged 2 commits into from
Aug 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions sqlalchemy_continuum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)


__version__ = '1.3.1'
__version__ = '1.3.2'


versioning_manager = VersioningManager()
Expand Down Expand Up @@ -70,12 +70,6 @@ def make_versioned(
manager.track_association_operations
)

sa.event.listen(
sa.engine.Engine,
'set_connection_execution_options',
manager.track_cloned_connections
)


def remove_versioning(
mapper=sa.orm.mapper,
Expand Down
14 changes: 8 additions & 6 deletions sqlalchemy_continuum/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ def wrapper(self, mapper, connection, target):
try:
uow = self.units_of_work[conn]
except KeyError:
uow = self.units_of_work[conn.engine]
try:
uow = self.units_of_work[conn.engine]
except KeyError:
for connection, uow in dict(self.units_of_work).items():
if connection.connection is conn.connection:
break # The ConnectionFairy is the same, this connection is a clone
else:
raise KeyError
return func(self, uow, target)
return wrapper

Expand Down Expand Up @@ -378,11 +385,6 @@ def append_association_operation(self, conn, table_name, params, op):
uow = self.units_of_work[conn.engine]
uow.pending_statements.append(stmt)

def track_cloned_connections(self, c, opt):
for connection, uow in self.units_of_work.items():
if connection.connection is c.connection: # ConnectionFairy is the same - this is our clone
self.units_of_work[c] = uow

def track_association_operations(
self, conn, cursor, statement, parameters, context, executemany
):
Expand Down