Invental/Review lessons/Code that silently does the wrong thing

Code that silently does the wrong thing

A timestamp alone is not a paging cursor

A pagination cursor must be unique and self-contained: pair the timestamp with the row id, and store the values you compare against rather than a pointer to a row that might be deleted.

01 · Before and afterThe pattern

SQL
-- before: ties at the same timestamp are skipped
WHERE created_at > $cursor_ts ORDER BY created_at

-- after: total order, cursor = (ts, id) stored by value
WHERE (created_at, id) > ($cursor_ts, $cursor_id)
ORDER BY created_at, id

02 · Run it on your appThe check

Does your “load newer” or sync endpoint page by timestamp alone?

If the honest answer is no or not sure, this is worth a look before it reaches production.

Want this checked on your code?

Tell us what you are building and what worries you. We match a senior reviewer to your code and confirm scope before anything starts.

— Get in touch
hi@invental.co ↗
— Or
— What to include

A link or short description of the code or system, what you want checked, your stack, and when you need the answer. No repository access is needed until scope is agreed.

— Or leave a note
We reply within one business day.