Skip to content

Commit b74c492

Browse files
Merge pull request #965 from jverswijver/ephys_regression_sql_mode
Fix regression sql mode
2 parents 87451c4 + 588926e commit b74c492

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Bugfix - Replace use of numpy aliases of built-in types with built-in type. (#938) PR #939
77
* Bugfix - `ExternalTable.delete` should not remove row on error (#953) PR #956
88
* Bugfix - Fix error handling of remove_object function in `s3.py` (#952) PR #955
9+
* Bugfix - Fix sql code generation to comply with sql mode `ONLY_FULL_GROUP_BY` (#916) PR #965
910
* Bugfix - Fix count for left-joined `QueryExpressions` (#951) PR #966
1011
* Bugfix - Fix assertion error when performing a union into a join (#930) PR #967
1112

datajoint/expression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ def create(cls, arg, group, keep_all_rows=False):
558558
if inspect.isclass(group) and issubclass(group, QueryExpression):
559559
group = group() # instantiate if a class
560560
assert isinstance(group, QueryExpression)
561-
if keep_all_rows and len(group.support) > 1:
561+
if keep_all_rows and len(group.support) > 1 or group.heading.new_attributes:
562562
group = group.make_subquery() # subquery if left joining a join
563563
join = arg.join(group, left=keep_all_rows) # reuse the join logic
564564
result = cls()

docs-parts/intro/Releases_lang1.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Bugfix - Replace use of numpy aliases of built-in types with built-in type. (#938) PR #939
66
* Bugfix - `ExternalTable.delete` should not remove row on error (#953) PR #956
77
* Bugfix - Fix error handling of remove_object function in `s3.py` (#952) PR #955
8+
* Bugfix - Fix sql code generation to comply with sql mode ``ONLY_FULL_GROUP_BY`` (#916) PR #965
89
* Bugfix - Fix count for left-joined ``QueryExpressions`` (#951) PR #966
910
* Bugfix - Fix assertion error when performing a union into a join (#930) PR #967
1011

tests/test_aggr_regressions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import itertools
6-
from nose.tools import assert_equal, raises
6+
from nose.tools import assert_equal
77
import datajoint as dj
88
from . import PREFIX, CONN_INFO
99
import uuid

tests/test_groupby.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from .schema_simple import A, D
2+
3+
4+
def test_aggr_with_proj():
5+
# issue #944 - only breaks with MariaDB
6+
# MariaDB implements the SQL:1992 standard that prohibits fields in the select statement that are
7+
# not also in the GROUP BY statement.
8+
# An improved specification in SQL:2003 allows fields that are functionally dependent on the group by
9+
# attributes to be allowed in the select. This behavior is implemented by MySQL correctly but not MariaDB yet.
10+
# See MariaDB issue: https://jira.mariadb.org/browse/MDEV-11588
11+
A.aggr(D.proj(m='id_l'), ..., n='max(m) - min(m)')

0 commit comments

Comments
 (0)