You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For a query that contains a raw select and is grouped by those columns, the count query generated by fetchPage is incorrect and fails. This issues was introduced in our system after we upgraded Bookshelf from 0.10.3 to 1.2.0, and knex from 0.13.0 to 0.21.12.
Issue Description
We have queries that extracts year and month from a single date column. We then group them by year and month and select some aggregate functions. When we do fetchPage, the count query generate selects count(distinct("year", "month")) directly from the table, which fails because these columns do not exist.
I am not sure about the implementation so can't comment on what the fix would be, but it clear that this worked as expected in the older version so it should be a bug.
Steps to reproduce issue
This is a simplified query that replicates the bug (Postgres):
AvgTouchesToEnroll.query((qb)=>{qb.where('user_id',query.userId);qb.select(knex.raw('extract(year from date) :: integer as year, extract(month from date) :: integer as month, sum(avg_touches) as avg_touches, sum(count) as count'));qb.groupBy('year');qb.groupBy('month');}).fetchPage({page: query.page,pageSize: query.pageSize,});
The generated count query and error is:
selectcount(distinct("year", "month")) from"average_touches_to_enroll"where"user_id"= $1- column "year" does not exist
Expected behaviour
It should return the requested page with pagination data.
Actual behaviour
It fails with an SQL error.
The text was updated successfully, but these errors were encountered:
Introduction
For a query that contains a raw select and is grouped by those columns, the count query generated by fetchPage is incorrect and fails. This issues was introduced in our system after we upgraded Bookshelf from 0.10.3 to 1.2.0, and knex from 0.13.0 to 0.21.12.
Issue Description
We have queries that extracts year and month from a single date column. We then group them by year and month and select some aggregate functions. When we do
fetchPage
, the count query generate selectscount(distinct("year", "month"))
directly from the table, which fails because these columns do not exist.I am not sure about the implementation so can't comment on what the fix would be, but it clear that this worked as expected in the older version so it should be a bug.
Steps to reproduce issue
This is a simplified query that replicates the bug (Postgres):
The generated count query and error is:
Expected behaviour
It should return the requested page with pagination data.
Actual behaviour
It fails with an SQL error.
The text was updated successfully, but these errors were encountered: