Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
M
massive-js
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 8
    • Issues 8
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 2
    • Merge Requests 2
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Dian Fay
  • massive-js
  • Issues
  • #726

Closed
Open
Opened Jan 22, 2021 by Maurício Jourdan@maujour

Inconsistency between count and actual query results size when using join

Summary

When setting a table A with two LEFT OUTER using a table B it returns inconsistent sizes when running a count and checking the length of the criteria. Moreover, the pagination returns wrong sizes or duplicates on every interaction.

Example

Database setup

    // Table PARTICIPANTS contains 499 entries

    table = dbClient.db[PARTICIPANTS].join({
      [generalJoin]: {
        type: 'LEFT OUTER',
        relation: PARTICIPANTS_STATUS,
        on: {
          participant_id: 'id',
          current: true,
          status: ['open', 'prospecting', 'interviewing', 'offer_made', 'rejected'],
        },
      },
      [hiredJoin]: {
        type: 'LEFT OUTER',
        relation: PARTICIPANTS_STATUS,
        on: {
          participant_id: 'id',
          current: true,
          status: 'hired',
        },
      },
    });

Code demonstrating the behavior

If I have, for example, two current status as 'prospecting', this happens:

console.log((await table.find(criteria)).length); // prints 499
console.log(await table.count(criteria)); // prints 500 (wrong)

Expected behavior

Both console.log should return 499

Actual behavior

The count returns +1 for each duplicated statuses

Additional context

If I use a regular pagination (offset, limit) the result of each page also brings me inconsistent page sizes and items appearing again in other pages.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: dmfay/massive-js#726