count()方法会干扰select()的结果
//计算总数 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, []
这并不合理
上下文无关的最好不复用 db 对象, 文档有说明原因和解决方法
这2个查询明显是上下文有关的啊,这个设计很反不合常规和反人类
头疼,这个有方案吗?
您的邮件我已收到,我会尽快给您回复。
两个查询的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: @.***>
显然,这个问题只发生事务情况下,因此不能分开orm
这个框架没办法处理这种情况,要实现功能,查询的数据先获取到就好了,可以解决大部分的问题
---原始邮件--- 发件人: @.> 发送时间: 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: @.***>