-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix status line display of the executed SQL command
`sqlparse.sql.Statement.token_first()` provides the `skip_cm` option already: if *skip_cm* is ``True`` (default: ``False``), comments are ignored too. Using `statement.get_type()` would be even more DWIM: The returned value is a string holding an upper-cased reprint of the first DML or DDL keyword. If the first token in this group isn't a DML or DDL keyword "UNKNOWN" is returned. Whitespaces and comments at the beginning of the statement are ignored. However, that would introduce a regression that the outcome of non-DML/DDL keywords like `BEGIN` would yield `UNKNOWN`.
- Loading branch information
Showing
6 changed files
with
142 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,23 @@ | ||
from unittest.mock import Mock | ||
|
||
from crate.client.cursor import Cursor | ||
|
||
|
||
def mocked_cursor(description, records, duration=0.1): | ||
""" | ||
Provide a mocked `crate.client.cursor.Cursor` instance. | ||
""" | ||
rowcount = len(records) | ||
fake_cursor = Mock(name='fake_cursor', description=description, rowcount=rowcount, duration=duration) | ||
fake_cursor.fetchall.return_value = records | ||
FakeCursor = Mock(name='FakeCursor', spec=Cursor) | ||
FakeCursor.return_value = fake_cursor | ||
return FakeCursor | ||
|
||
|
||
def fake_cursor(): | ||
""" | ||
Provide an empty/minimal mocked cursor object, | ||
that just works if you do not care about results. | ||
""" | ||
return mocked_cursor(description=[('undef',)], records=[('undef', None)]) |