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
My English is not good, so please forgive me if there are any mistakes in my expression.
Environment:
GORM version: v1.25.9
Gen version: v0.3.25
go-mssqldb version: v1.6.0
The findbypage function generated by GORM returns a count of 0.
I suspect the issue lies in the SQL generated by Gen when calling *.Offset(-1).Limit(-1).Count().
The generated SQL orders by the primary key column, causing an error due to the primary key column not being included in any aggregation function or Group clause.
The generated SQL looks like this: select count(*) from "user" order by "id".
Also I noticed that the generated similar function ScanByPage uses *.Count() directly to return the quantity.
The document you expected this should be explained
Expected answer
Since my current environment only supports SQL Server, I found that temporarily replacing *.Offset(-1).Limit(-1).Count() with *.Count() resolves the issue.
However, I am still interested in understanding why the original SQL is generated and how to address it properly.
The text was updated successfully, but these errors were encountered:
Your Question
My English is not good, so please forgive me if there are any mistakes in my expression.
Environment:
The
findbypage
function generated by GORM returns a count of 0.I suspect the issue lies in the SQL generated by Gen when calling
*.Offset(-1).Limit(-1).Count()
.The generated SQL orders by the primary key column, causing an error due to the primary key column not being included in any aggregation function or Group clause.
The generated SQL looks like this:
select count(*) from "user" order by "id"
.Also I noticed that the generated similar function ScanByPage uses *.Count() directly to return the quantity.
The document you expected this should be explained
Expected answer
Since my current environment only supports SQL Server, I found that temporarily replacing
*.Offset(-1).Limit(-1).Count()
with*.Count()
resolves the issue.However, I am still interested in understanding why the original SQL is generated and how to address it properly.
The text was updated successfully, but these errors were encountered: