lib/logstorage: allow typing asc in sort pipe for the sake of consistency with desc

This commit is contained in:
Aliaksandr Valialkin 2024-06-04 02:29:10 +02:00
parent 68c07b0599
commit 96c29ab403
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
2 changed files with 9 additions and 3 deletions

View file

@ -725,9 +725,12 @@ func parsePipeSort(lex *lexer) (*pipeSort, error) {
ps.byFields = bfs
}
if lex.isKeyword("desc") {
switch {
case lex.isKeyword("desc"):
lex.nextToken()
ps.isDesc = true
case lex.isKeyword("asc"):
lex.nextToken()
}
for {
@ -797,9 +800,12 @@ func parseBySortFields(lex *lexer) ([]*bySortField, error) {
bf := &bySortField{
name: fieldName,
}
if lex.isKeyword("desc") {
switch {
case lex.isKeyword("desc"):
lex.nextToken()
bf.isDesc = true
case lex.isKeyword("asc"):
lex.nextToken()
}
bfs = append(bfs, bf)
switch {

View file

@ -60,7 +60,7 @@ func TestPipeSort(t *testing.T) {
})
// Sort by a single field
f("sort by (a)", [][]Field{
f("sort by (a asc) asc", [][]Field{
{
{"_msg", `abc`},
{"a", `2`},