docs(postgrest): document that order() defaults to descending - #1637
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe ChangesOrder documentation
Estimated code review effort: 1 (Trivial) | ~2 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
spydon
left a comment
There was a problem hiding this comment.
Thanks, we'll change the default of this in v3 (the default was changed in the js SDK a few years ago)
What kind of change does this PR introduce?
Documentation.
What is the current behavior?
order()declaresbool ascending = false, so a call that omits the parameterreturns rows in descending order. The doc comment never states this. It only
says:
Both examples in the doc comment then pass
ascending: falseexplicitly, whichsuggests the opposite — that the parameter has to be passed to get descending
order, and that omitting it yields ascending.
This is easy to get wrong, because the default is inverted relative to two things
a developer is likely to expect:
ORDER BY, which defaults toASCpostgrest-js, whereorder()destructures{ ascending = true }The failure is silent: the query succeeds and returns data, just in the wrong
order. In my case it survived unit tests and only surfaced when a historical
backfill read a series inverted.
There is also a small rendering bug in the same doc comment — the first code
fence is closed with four backticks instead of three, which breaks the block in
generated dartdoc.
What is the new behavior?
ascendingandnullsFirstexplicitly, and notes the divergence from SQL and
postgrest-js.ascending, showing the actual default; a secondexample shows how to request ascending order.
Doc comment only — no behavioural change. Changing the default itself would be
breaking and is deliberately not proposed here.
Additional context
Happy to open a follow-up for the equivalent JSDoc in
postgrest-js, whichlikewise does not state its default. Let me know if that would be useful.
Summary by CodeRabbit