Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • M massive-js
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 11
    • Issues 11
    • List
    • Boards
    • Service Desk
    • Milestones
    • Requirements
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Dian Fay
  • massive-js
  • Issues
  • #726
Closed
Open
Created 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
Time tracking