mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-25 01:02:15 +00:00
fix(mavvrik): add dus.id as final tiebreaker in ORDER BY for stable pagination
Previous fix added api_key but the @@unique constraint on LiteLLM_DailyUserSpend is (user_id, date, api_key, model, custom_llm_provider, mcp_namespaced_tool_name, endpoint). Two rows sharing (date, user_id, api_key, model) but differing in provider or endpoint still have indeterminate order, causing OFFSET pagination to duplicate or drop rows at page boundaries. Fix: add dus.id (primary key, always unique) as the final tiebreaker. Cleaner than enumerating all 7 constraint columns. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2bee264939
commit
04dd7c345f
1 changed files with 1 additions and 1 deletions
|
|
@ -54,7 +54,7 @@ LEFT JOIN "LiteLLM_VerificationToken" vt ON dus.api_key = vt.token
|
|||
LEFT JOIN "LiteLLM_TeamTable" tt ON vt.team_id = tt.team_id
|
||||
LEFT JOIN "LiteLLM_UserTable" ut ON dus.user_id = ut.user_id
|
||||
WHERE dus.date = $1
|
||||
ORDER BY dus.date, dus.user_id, dus.api_key, dus.model ASC
|
||||
ORDER BY dus.date, dus.user_id, dus.api_key, dus.model, dus.id ASC
|
||||
"""
|
||||
|
||||
_EARLIEST_DATE_QUERY = 'SELECT MIN(date) AS earliest FROM "LiteLLM_DailyUserSpend"'
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue