Skip to content

Commit c529071

Browse files
committed
Fix merge conflicts.
2 parents 269d4d4 + b74c492 commit c529071

File tree

6 files changed

+35
-6
lines changed

6 files changed

+35
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
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
99
* Bugfix - Fix regression issue with `DISTINCT` clause and `GROUP_BY` (#914) PR #963
10+
* Bugfix - Fix sql code generation to comply with sql mode `ONLY_FULL_GROUP_BY` (#916) PR #965
11+
* Bugfix - Fix count for left-joined `QueryExpressions` (#951) PR #966
1012
* Bugfix - Fix assertion error when performing a union into a join (#930) PR #967
1113

1214
### 0.13.2 -- May 7, 2021

datajoint/expression.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,10 @@ def tail(self, limit=25, **fetch_kwargs):
444444
def __len__(self):
445445
""":return: number of elements in the result set e.g. ``len(q1)``."""
446446
return self.connection.query(
447-
'SELECT count(DISTINCT {fields}) FROM {from_}{where}'.format(
448-
fields=self.heading.as_sql(self.primary_key, include_aliases=False),
447+
'SELECT {select_} FROM {from_}{where}'.format(
448+
select_=('count(*)' if any(self._left)
449+
else 'count(DISTINCT {fields})'.format(fields=self.heading.as_sql(
450+
self.primary_key, include_aliases=False))),
449451
from_=self.from_clause(),
450452
where=self.where_clause())).fetchone()[0]
451453

@@ -558,7 +560,7 @@ def create(cls, arg, group, keep_all_rows=False):
558560
if inspect.isclass(group) and issubclass(group, QueryExpression):
559561
group = group() # instantiate if a class
560562
assert isinstance(group, QueryExpression)
561-
if keep_all_rows and len(group.support) > 1:
563+
if keep_all_rows and len(group.support) > 1 or group.heading.new_attributes:
562564
group = group.make_subquery() # subquery if left joining a join
563565
join = arg.join(group, left=keep_all_rows) # reuse the join logic
564566
result = cls()

docs-parts/intro/Releases_lang1.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
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
9+
* Bugfix - Fix count for left-joined ``QueryExpressions`` (#951) PR #966
810
* Bugfix - Fix assertion error when performing a union into a join (#930) PR #967
911
* Bugfix - Fix regression issue with `DISTINCT` clause and `GROUP_BY` (#914) PR #963
1012

tests/test_aggr_regressions.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
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
9-
9+
import uuid
10+
from .schema_uuid import Topic, Item, top_level_namespace_id
1011
schema = dj.Schema(PREFIX + '_aggr_regress', connection=dj.conn(**CONN_INFO))
1112

1213
# --------------- ISSUE 386 -------------------
@@ -104,6 +105,17 @@ def test_issue558_part2():
104105
assert_equal(len(X & d), len((X & d).proj(id2='3')))
105106

106107

108+
def test_left_join_len():
109+
Topic().add('jeff')
110+
Item.populate()
111+
Topic().add('jeff2')
112+
Topic().add('jeff3')
113+
q = Topic.join(Item - dict(topic_id=uuid.uuid5(top_level_namespace_id, 'jeff')),
114+
left=True)
115+
qf = q.fetch()
116+
assert len(q) == len(qf)
117+
118+
107119
def test_union_join():
108120
# https://github.com/datajoint/datajoint-python/issues/930
109121
A.insert(zip([100, 200, 300, 400, 500, 600]))

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)')

tests/test_s3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_remove_object_exception():
7070

7171
# Apply our new minio client which has a user that does not exist
7272
schema.external['share'].s3.client = Minio(
73-
'minio:9000',
73+
S3_CONN_INFO['endpoint'],
7474
access_key='jeffjeff',
7575
secret_key='jeffjeff',
7676
secure=False)

0 commit comments

Comments
 (0)