Error in paginate using inner join and distinct

First: Sorry My english.


I create a “select” with inner join, include a distinct to not see repeated items and paginate to page the items. The problem is that the paginate total comes in a different value than the actual amount. Follows code and evidence.

const newsbanner = await NewsBanner.query()
      .innerJoin('news_banner_permission_groups', '', 'news_banner_permission_groups.news_banner_id')
      .where(function() { = || "true"; === "false" ? this : this.where("active", true);
      .where(function() { = || null; === null ? this : this.where("title", "like", `%${}%`);
      .where(function() {
        this.whereIn('group', userGroups).orWhere("news_banners.type", 1)
        this.whereRaw(`'${date}' BETWEEN initialDate AND finaldate`)
      .paginate(, data.perPage);

In the image I have a total of 27 items, but the second page no longer has any items.

My question is, am I doing something wrong or is it a framework bug?

Can anyone help me?