rowyio / rowy

Low-code backend platform. Manage database on spreadsheet-like UI and build cloud functions workflows in JS/TS, all in your browser.
http://rowy.io
Other
5.88k stars 479 forks source link

Fix table sort does not work if table has formula column #1528

Closed bofeiw closed 7 months ago

bofeiw commented 7 months ago

Issue

Sort does not work if table has formula column.

Example: in this table setup, the right-most column is a formula column. The table sort is set to num descending, however the table UI displays rows order incorrectly.

Screenshot 2024-01-23 at 07 26 43

Cause

In a commit related to formula field, it sets all rows to rowsLocal if there is formula column in the table. https://github.com/rowyio/rowy/blob/2715a8094aa740bd6c783ad7e28fb24f6973cded/src/atoms/tableScope/rowActions.ts#L389-L391

rowsLocal is designed to hold our of order rows that are supposed to be a very small set, and they are always displayed at the top of the table UI. They are not sorted or ordered. https://github.com/rowyio/rowy/blob/0099bd1daca3f722b05ebbd5294eb31837382b2d/src/atoms/tableScope/table.ts#L170-L197

However, the commit would set all rows to rowsLocal, as a result, rows are displayed without going through filters or sorts.

Fix

Simply remove the condition for local row would fix this issue.

fieldName.startsWith("_rowy_formulaValue_")

After fix:

Screenshot 2024-01-23 at 07 25 17
vercel[bot] commented 7 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
rowy-os ✅ Ready (Inspect) Visit Preview Jan 23, 2024 0:00am
rowy-typedoc ✅ Ready (Inspect) Visit Preview Jan 23, 2024 0:00am