Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • M massive-js
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 13
    • Issues 13
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Terraform modules
    • Model experiments
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • 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
Issue 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