Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI - Fix sql --interactive case where returned rows are 0 #2359

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bfops
Copy link
Collaborator

@bfops bfops commented Mar 6, 2025

Description of Changes

See #2358 for more context on this issue and why this was needed.

I think we recently removed the functionality where we return row counts for update and delete statements. This means that the CLI can no longer say things like "N rows updated".

API and ABI breaking changes

No.

Expected complexity level and risk

1

Testing

  • No longer crashes when running update or delete commands in interactive mode:
$ "$WORK"/SpacetimeDBPrivate/public/target/debug/spacetimedb-cli sql -s local test-project --interactive
WARNING: This command is UNSTABLE and subject to breaking changes.

┌──────────────────────────────────────────────────────────┐
│ .exit: Exit the REPL                                     │
│ .clear: Clear the Screen                                 │
│                                                          │
│ Give us feedback in our Discord server:                  │
│    https://discord.gg/w2DVqNZXdN                         │
└──────────────────────────────────────────────────────────┘
🪐test-project>update person set name='foo'

Time: 1.28ms
🪐test-project>delete from person

Time: 1.34ms
🪐test-project>

@bfops bfops marked this pull request as ready for review March 6, 2025 17:11
@bfops bfops linked an issue Mar 6, 2025 that may be closed by this pull request
Comment on lines +98 to +99
if row_count > 0 {
let row_count = print_row_count(row_count);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if row_count > 0 {
let row_count = print_row_count(row_count);
let row_count = print_row_count(row_count);
if row_count > 0 {

I think you should move this up one line outside of the if because then you would still get the output:

0 rows

Instead of getting no output.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is poorly named. It doesn't actually print anything. It just formats it as a string.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even if it were the case, I think that would be misleading. I believe we've just stopped returning the row count from the API calls, but in fact we are updating/deleting rows.

@bfops bfops requested a review from jdetter March 7, 2025 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI - Fix: SQL update and delete are throwing exceptions
2 participants