Skip to content

Commit

Permalink
new isolation mode testing
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Mar 23, 2015
1 parent 8abf733 commit 24dd9da
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
6 changes: 6 additions & 0 deletions data/src/entity_manager/system.py
Expand Up @@ -4466,6 +4466,12 @@ def _lock_query_f(self, entity_class, options, query_buffer):
lock = options.get("lock", False)
if not lock: return

# verifies if the current engine operation is running under
# a serializable transaction isolation mode, if that's the
# case there's no need for lock (isolation is enought)
is_serializable = self.engine._is_serializable()
if is_serializable: return

# checks if the current engine allows (contains support)
# for the for update part of the query
allow_for_update = self.engine._allow_for_update()
Expand Down
7 changes: 4 additions & 3 deletions data/src/entity_mysql/system.py
Expand Up @@ -687,6 +687,10 @@ def _encode_query(self, query):
def _resolve_operator(self, operator):
return operator

def _is_serializable(self):
connection = self.entity_manager.get_connection()
return connection._isolation == "serializable"

def _escape_slash(self):
return True

Expand All @@ -699,9 +703,6 @@ def _allow_alter_drop(self):
def _allow_for_update(self):
return True

def _allow_serializable(self):
return False

class MysqlConnection(object):
"""
Class representing an abstraction on top of
Expand Down
8 changes: 5 additions & 3 deletions data/src/entity_pgsql/system.py
Expand Up @@ -159,6 +159,7 @@ def connect(self, connection, parameters = {}):
connection._user = user
connection._host = host
connection._database = database
connection._isolation = isolation
connection._show_sql = show_sql
connection.open()
self._execute_query_t(
Expand Down Expand Up @@ -598,6 +599,10 @@ def _has_table_definition_result(self, table_name, cursor):
def _resolve_operator(self, operator):
return OPERATORS_MAP.get(operator, operator)

def _is_serializable(self):
connection = self.entity_manager.get_connection()
return connection._isolation == "serializable"

def _escape_slash(self):
return False

Expand All @@ -615,8 +620,5 @@ def _allow_for_update(self):
# this is considered a major drawback towards pgsql usage
return False

def _allow_serializable(self):
return True

class IntegrityError(RuntimeError):
pass
6 changes: 3 additions & 3 deletions data/src/entity_sqlite/system.py
Expand Up @@ -482,6 +482,9 @@ def _get_temporary(self):
def _resolve_operator(self, operator):
return operator

def _is_serializable(self):
return False

def _escape_slash(self):
return False

Expand All @@ -494,9 +497,6 @@ def _allow_alter_drop(self):
def _allow_for_update(self):
return False

def _allow_serializable(self):
return False

class SqliteConnection(object):
"""
Class representing an abstraction on top of
Expand Down

0 comments on commit 24dd9da

Please sign in to comment.