findAndCount无法使用count(distinct()) #2070

Open
opened 2021-11-16 07:24:41 +00:00 by yuerdongni · 5 comments

if len(session.statement.ColumnMap) > 0 {

https://gitea.com/xorm/xorm/src/branch/master/session_find.go

if len(session.statement.ColumnMap) > 0 {
	session.statement.ColumnMap = []string{}
}

这里的columnMap为什么要置空 那我如何在findAndCount的字段里面传递count(distinct(cols))的cols?
columnMap置空导致sql变成了count(distinct )

https://gitea.com/xorm/xorm/src/commit/aea91cc7dede96f071514cea007bd792613ae748/session_find.go#L60 https://gitea.com/xorm/xorm/src/branch/master/session_find.go if len(session.statement.ColumnMap) > 0 { session.statement.ColumnMap = []string{} } 这里的columnMap为什么要置空 那我如何在findAndCount的字段里面传递count(distinct(cols))的cols? columnMap置空导致sql变成了count(distinct )
yuerdongni changed title from 无法使用count(distinct()) to findAndCount无法使用count(distinct()) 2021-11-16 08:29:05 +00:00
Owner

Could you paste your codes here?

Could you paste your codes here?
lunny added the
need
feedback
label 2021-11-17 06:29:13 +00:00
Author

the demo like this

the demo like this
Author

Could you paste your codes here?

https://gitea.com/attachments/36708640-1e57-4c15-adbd-d2539e363019

here here

> Could you paste your codes here? https://gitea.com/attachments/36708640-1e57-4c15-adbd-d2539e363019 here here
Author

if the length of columnMap gt 0,set empty? how to use distinct in count(distinct(cols)) of function findAndCount,the cols would be empty.

if the length of columnMap gt 0,set empty? how to use distinct in count(distinct(`cols`)) of function `findAndCount`,the `cols` would be empty.

这个问题解决了吗

这个问题解决了吗
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#2070
No description provided.