关于FindAndCount与Find方法执行差异情况 #1500
Labels
No Label
backport/done
backport/v1
blocked
db
oracle
db
sqlserver
duplicate
feature
cache
frontport/done
frontport/main
invalid
kind
breaking
kind
bug
kind
build
kind
dependencies
kind
docs
kind
driver
kind
enhancement
kind
feature
kind
performance
kind
proposal
kind
question
kind
refactor
kind
testing
need
feedback
need
test
proposal:accepted
RaspBerry Pi
regression
skip-changelog
upstream
wip
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: xorm/xorm#1500
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
有一阵子没用Go写东西了,最近写一项目用到了xorm。在分页场景下用到了FindAndCount()方法,可是这个方法给人的感觉总是很奇怪,奇怪到了开始怀疑自己。首先是使用这个方法后会有莫明的异常,开始以为是结构体字段定义有问题,尤其是和xorm相关的tag部分。一遍遍的翻阅文档,无果…只能拆分成Find() 和 Count()单独执行,但是增加了好多代码量。尤其是复杂查询的时候感觉强迫症要犯了。
在使用这个方法中具体遇到过几种异常情况:
吐槽一下,这个MD编辑器好难用啊,退格删除太累了…
针对上述情况编写了简单的单元测试用例,完整工程见附件:
文件
go.mod
文件
main.go
文件
find_test.go
文件
find_and_count_test.go
测试结果:
This should be fixed and #1621 could confirm this.