Skip to content

Commit

Permalink
listSQL do subquery first then order by - fix k3s-io#77
Browse files Browse the repository at this point in the history
  • Loading branch information
wenerme authored Feb 19, 2021
1 parent 7736cde commit 6045391
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions pkg/drivers/generic/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,22 @@ var (
ikv.id <= ?)`

listSQL = fmt.Sprintf(`
SELECT (%s), (%s), %s
FROM kine AS kv
JOIN (
SELECT MAX(mkv.id) AS id
FROM kine AS mkv
SELECT *
FROM (
SELECT (%s), (%s), %s
FROM kine AS kv
JOIN (
SELECT MAX(mkv.id) AS id
FROM kine AS mkv
WHERE
mkv.name LIKE ?
%%s
GROUP BY mkv.name) maxkv
ON maxkv.id = kv.id
WHERE
mkv.name LIKE ?
%%s
GROUP BY mkv.name) maxkv
ON maxkv.id = kv.id
WHERE
(kv.deleted = 0 OR ?)
ORDER BY kv.id ASC
(kv.deleted = 0 OR ?)
) as t
ORDER BY t.id ASC
`, revSQL, compactRevSQL, columns)
)

Expand Down

0 comments on commit 6045391

Please sign in to comment.