Skip to content

Commit

Permalink
- Changed countDistinct to be used only with joinRelation operator
Browse files Browse the repository at this point in the history
- Bumped version to 4.4.3
  • Loading branch information
Dekel Barzilay committed Oct 11, 2019
1 parent ec3e409 commit b6234cb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "feathers-objection",
"description": "A service plugin for ObjectionJS an ORM based on KnexJS",
"version": "4.4.2",
"version": "4.4.3",
"homepage": "https://github.com/feathersjs-ecosystem/feathers-objection",
"keywords": [
"feathers",
Expand Down
13 changes: 9 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,15 @@ class Service extends AdapterService {
if (count) {
const idColumns = Array.isArray(this.id) ? this.id.map(idKey => `${this.Model.tableName}.${idKey}`) : [`${this.Model.tableName}.${this.id}`];

const countQuery = this._createQuery(params)
.skipUndefined()
.joinRelation(query.$joinRelation)
.countDistinct({ total: idColumns });
const countQuery = this._createQuery(params);

if (query.$joinRelation) {
countQuery
.joinRelation(query.$joinRelation)
.countDistinct({ total: idColumns });
} else {
countQuery.count({ total: idColumns });
}

this.objectify(countQuery, query);

Expand Down

0 comments on commit b6234cb

Please sign in to comment.