gorose icon indicating copy to clipboard operation
gorose copied to clipboard

count()方法会干扰select()的结果

Open xlqroot opened this issue 5 years ago • 7 comments

//计算总数 total,err := orm.Count() if err != nil { logger.Error(err.Error()) return total,nil,err } fmt.Println(orm.LastSql()) err = orm.Offset(offset).Limit(limit).Select() fmt.Println(orm.LastSql())

//结果 SELECT count() as count FROM ub_store LIMIT 1, [] SELECT count() as count FROM ub_store LIMIT 10, []

这并不合理

xlqroot avatar May 28 '20 10:05 xlqroot

上下文无关的最好不复用 db 对象, 文档有说明原因和解决方法

fizzday avatar Jun 01 '20 07:06 fizzday

这2个查询明显是上下文有关的啊,这个设计很反不合常规和反人类

danmeiyihen avatar Jan 19 '21 05:01 danmeiyihen

头疼,这个有方案吗?

yveshield avatar Apr 11 '22 07:04 yveshield

您的邮件我已收到,我会尽快给您回复。

LazyNeo avatar Apr 11 '22 07:04 LazyNeo

两个查询的orm分离开就好了,就是建两个orm对象分开操作

---原始邮件--- 发件人: @.> 发送时间: 2022年4月11日(周一) 下午3:04 收件人: @.>; 抄送: @.@.>; 主题: Re: [gohouse/gorose] count()方法会干扰select()的结果 (#124)

头疼,这个有方案吗?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

xlqroot avatar Apr 11 '22 07:04 xlqroot

显然,这个问题只发生事务情况下,因此不能分开orm

yveshield avatar Apr 11 '22 07:04 yveshield

这个框架没办法处理这种情况,要实现功能,查询的数据先获取到就好了,可以解决大部分的问题

---原始邮件--- 发件人: @.> 发送时间: 2022年4月11日(周一) 下午3:15 收件人: @.>; 抄送: @.@.>; 主题: Re: [gohouse/gorose] count()方法会干扰select()的结果 (#124)

显然,这个问题只发生事务情况下,因此不能分开orm

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

xlqroot avatar Apr 15 '22 15:04 xlqroot