Skip to content

Commit

Permalink
MariaDB 10.3 updates
Browse files Browse the repository at this point in the history
MariaDB seems to handle some additional UPDATE/DELETE FROM
syntaxes as well as some forms of INTERSECT and EXCEPT. Open
up tests that expect failure for MySQL to allow success for
MariaDB 10.3.

Change-Id: Ia9341a82485ef7201bb8130d8dbf4a9b6976035a
  • Loading branch information
zzzeek committed Aug 30, 2018
1 parent d8bb208 commit 081d427
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/sqlalchemy/testing/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,8 @@ def delete_from(self):

@property
def update_where_target_in_subquery(self):
"""Target must support UPDATE where the same table is present in a
subquery in the WHERE clause.
"""Target must support UPDATE (or DELETE) where the same table is
present in a subquery in the WHERE clause.
This is an ANSI-standard syntax that apparently MySQL can't handle,
such as:
Expand Down
2 changes: 1 addition & 1 deletion test/orm/test_update_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def test_delete_with_fetch_strategy(self):

eq_(sess.query(User).order_by(User.id).all(), [jack, jane])

@testing.fails_on('mysql', 'FIXME: unknown')
@testing.requires.update_where_target_in_subquery
def test_delete_invalid_evaluation(self):
User = self.classes.User

Expand Down
27 changes: 18 additions & 9 deletions test/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ def delete_from(self):

@property
def update_where_target_in_subquery(self):
"""Target must support UPDATE where the same table is present in a
subquery in the WHERE clause.
"""Target must support UPDATE (or DELETE) where the same table is
present in a subquery in the WHERE clause.
This is an ANSI-standard syntax that apparently MySQL can't handle,
such as:
Expand All @@ -371,9 +371,10 @@ def update_where_target_in_subquery(self):
FROM documents GROUP BY documents.user_id
)
"""
return fails_if('mysql',
'MySQL error 1093 "Cant specify target table '
'for update in FROM clause"')
return fails_if(
self._mysql_not_mariadb_103,
'MySQL error 1093 "Cant specify target table '
'for update in FROM clause", resolved by MariaDB 10.3')

@property
def savepoints(self):
Expand Down Expand Up @@ -521,15 +522,17 @@ def intersect(self):
"""Target database must support INTERSECT or equivalent."""

return fails_if([
"firebird", "mysql", "sybase",
], 'no support for INTERSECT')
"firebird", self._mysql_not_mariadb_103,
"sybase",
], 'no support for INTERSECT')

@property
def except_(self):
"""Target database must support EXCEPT or equivalent (i.e. MINUS)."""
return fails_if([
"firebird", "mysql", "sybase",
], 'no support for EXCEPT')
"firebird", self._mysql_not_mariadb_103,
"sybase",
], 'no support for EXCEPT')

@property
def order_by_col_from_union(self):
Expand Down Expand Up @@ -1185,6 +1188,12 @@ def _mysql_not_mariadb_102(self, config):
config.db.dialect._mariadb_normalized_version_info < (10, 2)
)

def _mysql_not_mariadb_103(self, config):
return against(config, "mysql") and (
not config.db.dialect._is_mariadb or
config.db.dialect._mariadb_normalized_version_info < (10, 3)
)

def _has_mysql_on_windows(self, config):
return against(config, 'mysql') and \
config.db.dialect._detect_casing(config.db) == 1
Expand Down
6 changes: 4 additions & 2 deletions test/sql/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,8 @@ def test_except_style2(self):
found2 = self._fetchall_sorted(e.alias().select().execute())
eq_(found2, wanted)

@testing.fails_on('sqlite', "Can't handle this style of nesting")
@testing.fails_on(
['sqlite', 'mysql'], "Can't handle this style of nesting")
@testing.requires.except_
def test_except_style3(self):
# aaa, bbb, ccc - (aaa, bbb, ccc - (ccc)) = ccc
Expand Down Expand Up @@ -1040,7 +1041,8 @@ def test_except_style4(self):
)

@testing.requires.intersect
@testing.fails_on('sqlite', "sqlite can't handle leading parenthesis")
@testing.fails_on(['sqlite', 'mysql'],
"sqlite can't handle leading parenthesis")
def test_intersect_unions(self):
u = intersect(
union(
Expand Down

0 comments on commit 081d427

Please sign in to comment.