order by function support empty value #2423
No reviewers
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#2423
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "leiwingqueen/xorm:fix_order_by_empty"
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?
what happen
xorm 1.3.2 support order by clause support empty string and v1.3.8 throw an error to the caller. I want xorm support this feature in the future.
it will throw an error "order by string is empty" when I invoke the function OrderBy("").
We need this feature in the case that user can change order clause and empty string means no need to order the rows
expectation
testEngine.Where("age =1 ").OrderBy("") return success
@ -273,0 +275,4 @@
assertSync(t, new(NullStruct))
if true {
err := testEngine.Where("`age` IS NOT NULL").OrderBy("").Iterate(new(NullStruct),
Maybe we should keep orderByStr as
*string
. I thinkOrderBy("")
should return error.I suppose to be ok that if the old version throw an error. But I find the version 1.3.2 will ignore the empty string. May stay the same action with the old version is a better way
The old version will hide the possible error which I don't think it's better. Returning the error will let you find the code problem. If it hidden it, the error may never be found.
yeah, maybe you're right. I will fix it today, thanks for your advice.
Do we need to treat the orderStr as *string nor string in orderBy struct?
The caller need to change OrderBy("abc") to OrderBy(&"abc") when they upgrade the new version
@lunny
Looks like a break change.
Same idea. That makes user confuse about this change.
So xorm framework stay the same is a better way? If user use a variable to pass the "order by param" in old version, they will only find that error in special case when they upgrade the new version.
It seems that both two solutions are not good enough.
Pull request closed