-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-133439: Fix dot commands with trailing spaces are mistaken for multi-line sqlite statements in the sqlite3 command-line interface #133440
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
Merged
serhiy-storchaka
merged 11 commits into
python:main
from
tanloong:sqlite3-cli-strip-whitespaces
May 9, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
080d0c8
gh-133439: fix dot commands with trailing spaces are not recognized i…
tanloong cd277f3
Add news entry
tanloong e2703b4
Only strip trailing whitespaces
tanloong a4498ab
Support spaces after dot
tanloong 9b3ed39
Handle unknown dot commands
tanloong 4023fb1
Add tests for unknown dot commands
tanloong b473fe9
Handle empty string input; Add test; Improve news entry
tanloong bb0c7d9
Use as-patern to capture the unknow command
tanloong 5ec7198
Ignore empty dot command
tanloong caf47bc
Remove "Enter .help" message; Redirect error to stderr
tanloong e1ea159
Fix test
tanloong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,17 +48,25 @@ def runsource(self, source, filename="<input>", symbol="single"): | |
Return True if more input is needed; buffering is done automatically. | ||
Return False if input is a complete statement ready for execution. | ||
""" | ||
match source: | ||
case ".version": | ||
print(f"{sqlite3.sqlite_version}") | ||
case ".help": | ||
print("Enter SQL code and press enter.") | ||
case ".quit": | ||
sys.exit(0) | ||
case _: | ||
if not sqlite3.complete_statement(source): | ||
return True | ||
execute(self._cur, source) | ||
if not source or source.isspace(): | ||
return False | ||
if source[0] == ".": | ||
match source[1:].strip(): | ||
serhiy-storchaka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
case "version": | ||
print(f"{sqlite3.sqlite_version}") | ||
case "help": | ||
print("Enter SQL code and press enter.") | ||
case "quit": | ||
sys.exit(0) | ||
case "": | ||
pass | ||
case _ as unknown: | ||
self.write("Error: unknown command or invalid arguments:" | ||
erlend-aasland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
f' "{unknown}".\n') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error messages do not end with a '.' e.g.:
|
||
else: | ||
if not sqlite3.complete_statement(source): | ||
return True | ||
execute(self._cur, source) | ||
return False | ||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Library/2025-05-05-22-11-24.gh-issue-133439.LpmyFz.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fix dot commands with trailing spaces are mistaken for multi-line SQL | ||
statements in the sqlite3 command-line interface. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.