Skip to content

Commit 25b6f41

Browse files
authored
rkey: scan - order by id (#35)
1 parent 9a4edc6 commit 25b6f41

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

internal/rkey/tx.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ const (
8484
where
8585
id > ? and key glob ? and (type = ? or true)
8686
and (etime is null or etime > ?)
87+
order by id asc
8788
limit ?`
8889
)
8990

@@ -347,10 +348,8 @@ func (tx *Tx) Scan(cursor int, pattern string, ktype core.TypeID, count int) (Sc
347348

348349
// Select the maximum ID.
349350
maxID := 0
350-
for _, key := range keys {
351-
if key.ID > maxID {
352-
maxID = key.ID
353-
}
351+
if len(keys) > 0 {
352+
maxID = keys[len(keys)-1].ID
354353
}
355354

356355
return ScanResult{maxID, keys}, nil

0 commit comments

Comments
 (0)