mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-09 15:27:11 +00:00
lib/logstorage: allow typing asc
in sort
pipe for the sake of consistency with desc
This commit is contained in:
parent
68c07b0599
commit
96c29ab403
2 changed files with 9 additions and 3 deletions
|
@ -725,9 +725,12 @@ func parsePipeSort(lex *lexer) (*pipeSort, error) {
|
||||||
ps.byFields = bfs
|
ps.byFields = bfs
|
||||||
}
|
}
|
||||||
|
|
||||||
if lex.isKeyword("desc") {
|
switch {
|
||||||
|
case lex.isKeyword("desc"):
|
||||||
lex.nextToken()
|
lex.nextToken()
|
||||||
ps.isDesc = true
|
ps.isDesc = true
|
||||||
|
case lex.isKeyword("asc"):
|
||||||
|
lex.nextToken()
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
@ -797,9 +800,12 @@ func parseBySortFields(lex *lexer) ([]*bySortField, error) {
|
||||||
bf := &bySortField{
|
bf := &bySortField{
|
||||||
name: fieldName,
|
name: fieldName,
|
||||||
}
|
}
|
||||||
if lex.isKeyword("desc") {
|
switch {
|
||||||
|
case lex.isKeyword("desc"):
|
||||||
lex.nextToken()
|
lex.nextToken()
|
||||||
bf.isDesc = true
|
bf.isDesc = true
|
||||||
|
case lex.isKeyword("asc"):
|
||||||
|
lex.nextToken()
|
||||||
}
|
}
|
||||||
bfs = append(bfs, bf)
|
bfs = append(bfs, bf)
|
||||||
switch {
|
switch {
|
||||||
|
|
|
@ -60,7 +60,7 @@ func TestPipeSort(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Sort by a single field
|
// Sort by a single field
|
||||||
f("sort by (a)", [][]Field{
|
f("sort by (a asc) asc", [][]Field{
|
||||||
{
|
{
|
||||||
{"_msg", `abc`},
|
{"_msg", `abc`},
|
||||||
{"a", `2`},
|
{"a", `2`},
|
||||||
|
|
Loading…
Reference in a new issue