Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit b6234cb

Browse files
author
Dekel Barzilay
committed
- Changed countDistinct to be used only with joinRelation operator
- Bumped version to 4.4.3
1 parent ec3e409 commit b6234cb

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "feathers-objection",
33
"description": "A service plugin for ObjectionJS an ORM based on KnexJS",
4-
"version": "4.4.2",
4+
"version": "4.4.3",
55
"homepage": "https://github.com/feathersjs-ecosystem/feathers-objection",
66
"keywords": [
77
"feathers",

src/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,15 @@ class Service extends AdapterService {
349349
if (count) {
350350
const idColumns = Array.isArray(this.id) ? this.id.map(idKey => `${this.Model.tableName}.${idKey}`) : [`${this.Model.tableName}.${this.id}`];
351351

352-
const countQuery = this._createQuery(params)
353-
.skipUndefined()
354-
.joinRelation(query.$joinRelation)
355-
.countDistinct({ total: idColumns });
352+
const countQuery = this._createQuery(params);
353+
354+
if (query.$joinRelation) {
355+
countQuery
356+
.joinRelation(query.$joinRelation)
357+
.countDistinct({ total: idColumns });
358+
} else {
359+
countQuery.count({ total: idColumns });
360+
}
356361

357362
this.objectify(countQuery, query);
358363

0 commit comments

Comments
 (0)