mirror of
https://github.com/pikami/cosmium.git
synced 2025-03-04 08:56:57 +00:00
OrderBy should bring NULL values to front
This commit is contained in:
parent
1711c8fb5c
commit
058b3271b7
@ -670,6 +670,14 @@ func hasAggregateFunctions(selectItems []parsers.SelectItem) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func compareValues(val1, val2 interface{}) int {
|
func compareValues(val1, val2 interface{}) int {
|
||||||
|
if val1 == nil && val2 == nil {
|
||||||
|
return 0
|
||||||
|
} else if val1 == nil {
|
||||||
|
return -1
|
||||||
|
} else if val2 == nil {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
if reflect.TypeOf(val1) != reflect.TypeOf(val2) {
|
if reflect.TypeOf(val1) != reflect.TypeOf(val2) {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,10 @@ import (
|
|||||||
|
|
||||||
func Test_Execute_Select(t *testing.T) {
|
func Test_Execute_Select(t *testing.T) {
|
||||||
mockData := []memoryexecutor.RowType{
|
mockData := []memoryexecutor.RowType{
|
||||||
map[string]interface{}{"id": "12345", "pk": 123, "_self": "self1", "_rid": "rid1", "_ts": 123456, "isCool": false, "order": 1},
|
map[string]interface{}{"id": "12345", "pk": 123, "_self": "self1", "_rid": "rid1", "_ts": 123456, "isCool": false, "order": nil},
|
||||||
map[string]interface{}{"id": "67890", "pk": 456, "_self": "self2", "_rid": "rid2", "_ts": 789012, "isCool": true, "order": 2},
|
map[string]interface{}{"id": "67890", "pk": 456, "_self": "self2", "_rid": "rid2", "_ts": 789012, "isCool": true, "order": 1},
|
||||||
map[string]interface{}{"id": "456", "pk": 456, "_self": "self2", "_rid": "rid2", "_ts": 789012, "isCool": true, "order": 3},
|
map[string]interface{}{"id": "456", "pk": 456, "_self": "self2", "_rid": "rid2", "_ts": 789012, "isCool": true, "order": 2},
|
||||||
map[string]interface{}{"id": "123", "pk": 456, "_self": "self2", "_rid": "rid2", "_ts": 789012, "isCool": true, "order": 4},
|
map[string]interface{}{"id": "123", "pk": 456, "_self": "self2", "_rid": "rid2", "_ts": 789012, "isCool": true, "order": 3},
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run("Should execute simple SELECT", func(t *testing.T) {
|
t.Run("Should execute simple SELECT", func(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user