SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

CLI - Fix: SQL `update` and `delete` are throwing exceptions

Open bfops opened this issue 9 months ago • 4 comments

It seems like any update and delete query in spacetime sql will cause the CLI to throw an exception.

The updates do go through, but the CLI crashes.

bfops avatar Mar 06 '25 16:03 bfops

This only happens in the interactive view. The queries succeed without complaint when they're provided on the command line.

bfops avatar Mar 06 '25 16:03 bfops

This seems to be due to passing with_stats: true to run_sql. If I change it to false, we do not see this issue.

bfops avatar Mar 06 '25 16:03 bfops

It seems to be down to the table.with line in run_sql here:

                // The `tabled::count_rows` add the header as a row, so subtract it.
                let row_count = print_row_count(table.count_rows().wrapping_sub(1));
                table.with(tabled::settings::panel::Footer::new(row_count));

This is from the api module, which I don't have any context on.

Edit: Nope I didn't read carefully. The table is a tabled::Table.

bfops avatar Mar 06 '25 16:03 bfops

I believe this is down to the row_count being zero.

bfops avatar Mar 06 '25 16:03 bfops