2024-08-09 19:14:28 +00:00
|
|
|
package builder
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestConvertSort(t *testing.T) {
|
2024-08-15 07:06:11 +00:00
|
|
|
ctx := CommonDialect{
|
2024-08-09 19:14:28 +00:00
|
|
|
TableAlias: "t",
|
|
|
|
FieldName: "test",
|
|
|
|
}
|
2024-08-09 22:33:10 +00:00
|
|
|
result, err := convertSort(ctx, Map{
|
2024-08-09 19:14:28 +00:00
|
|
|
"a": -1,
|
|
|
|
"c": "desc",
|
|
|
|
"b": 1,
|
|
|
|
"d": nil,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
if result != `ORDER BY t.a DESC, t.b ASC, t.c DESC, t.d` {
|
|
|
|
t.Errorf("Expected ORDER BY t.a DESC, t.b ASC, t.c DESC, t.d, got %s", result)
|
|
|
|
}
|
|
|
|
}
|