diff --git a/query_executors/memory_executor/memory_executor.go b/query_executors/memory_executor/memory_executor.go index 2d049e5..6c5c460 100644 --- a/query_executors/memory_executor/memory_executor.go +++ b/query_executors/memory_executor/memory_executor.go @@ -670,6 +670,14 @@ func hasAggregateFunctions(selectItems []parsers.SelectItem) bool { } 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) { return 1 } diff --git a/query_executors/memory_executor/select_test.go b/query_executors/memory_executor/select_test.go index 3b9e83d..331723b 100644 --- a/query_executors/memory_executor/select_test.go +++ b/query_executors/memory_executor/select_test.go @@ -10,10 +10,10 @@ import ( func Test_Execute_Select(t *testing.T) { mockData := []memoryexecutor.RowType{ - map[string]interface{}{"id": "12345", "pk": 123, "_self": "self1", "_rid": "rid1", "_ts": 123456, "isCool": false, "order": 1}, - map[string]interface{}{"id": "67890", "pk": 456, "_self": "self2", "_rid": "rid2", "_ts": 789012, "isCool": true, "order": 2}, - map[string]interface{}{"id": "456", "pk": 456, "_self": "self2", "_rid": "rid2", "_ts": 789012, "isCool": true, "order": 3}, - map[string]interface{}{"id": "123", "pk": 456, "_self": "self2", "_rid": "rid2", "_ts": 789012, "isCool": true, "order": 4}, + 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": 1}, + 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": 3}, } t.Run("Should execute simple SELECT", func(t *testing.T) {