Skip to content

Commit 588926e

Browse files
committed
Fix merge conflicts.
2 parents 22eb1c3 + 87451c4 commit 588926e

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
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 sql code generation to comply with sql mode `ONLY_FULL_GROUP_BY` (#916) PR #965
10+
* 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

1213
### 0.13.2 -- May 7, 2021

datajoint/expression.py

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

docs-parts/intro/Releases_lang1.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
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
88
* 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
910
* Bugfix - Fix assertion error when performing a union into a join (#930) PR #967
1011

1112
0.13.2 -- May 7, 2021

tests/test_aggr_regressions.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from nose.tools import assert_equal
77
import datajoint as dj
88
from . import PREFIX, CONN_INFO
9+
import uuid
10+
from .schema_uuid import Topic, Item, top_level_namespace_id
911
schema = dj.Schema(PREFIX + '_aggr_regress', connection=dj.conn(**CONN_INFO))
1012

1113
# --------------- ISSUE 386 -------------------
@@ -103,6 +105,17 @@ def test_issue558_part2():
103105
assert_equal(len(X & d), len((X & d).proj(id2='3')))
104106

105107

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+
106119
def test_union_join():
107120
# https://github.com/datajoint/datajoint-python/issues/930
108121
A.insert(zip([100, 200, 300, 400, 500, 600]))

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)