-
Notifications
You must be signed in to change notification settings - Fork 3.8k
CASSANDRA-20021 Add cqlsh autocompletion for the identity mapping feature #4408
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
base: trunk
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Shalni for the patch.
pylib/cqlshlib/cql3handling.py
Outdated
|
||
|
||
syntax_rules += r''' | ||
<addIdentityStatement> ::= "ADD" "USER" ("IF" "NOT" "EXISTS")? <stringLiteral> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the statement is ADD IDENTITY IF NOT EXISTS '<identity>' TO ROLE '<role>'
similarly for drop statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK. Changes also reflected in test file
Let me know if a grammar should be expressed specifically for identity
instead of using stringliteral
|
||
def test_expect_str_literal_autocomplete_add(self): | ||
self.trycompletions('ADD IDENTITY ', | ||
choices=['<pgStringLiteral>', '<quotedStringLiteral>', 'IF']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.trycompletions('ADD IDENTITY IF NOT EXISTS',
choices=['<pgStringLiteral>', '<quotedStringLiteral>'])
?
choices=[';']) | ||
|
||
def test_autocomplete_drop(self): | ||
self.trycompletions('DROP ', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah! This is the same we are testing here
https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/test/test_cqlsh_completion.py#L615-L618
I wonder then why that one is not failing. I think we should consolidate those.
other_choices_ok=True) | ||
|
||
def test_complete_user_full_statement_add(self): | ||
self.trycompletions("ADD IDENTITY IF NOT EXISTS '[email protected]' TO ROLE data_engineer ", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test the same without "IF NOT EXISTS" maybe?
from .test_cqlsh_completion import CqlshCompletionCase | ||
|
||
|
||
class TestIdentityMappingsCompletion(CqlshCompletionCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I like the fact that we are splitting it into a new test file, I see that the pattern is to have them all consolidated in test_cqlsh_completion.py
(that would have helped catching the DROP completion test duplication).
I think we should add these tests there to follow the existing pattern, and maybe start a conversation on the dev slack (or Mailing list?) about splitting the completion tests (right now, a python file of 1242 lines and counting).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree here with Bernardo. We should probably try to consolidate the testing logic in test_cqlsh_completion.py
. I think some existing autocompletion test scenarios will fail in test_cqlsh_completion.py
.
I don't think we need a mailing list discussion for this change, I think it's pretty straightforward to make the change in test_cqlsh_completion.py
, and we shouldn't really think too much about it.
And thanks for the contribution @shalnisundram! These UX improvements are a huge benefit that enhance usability and discoverability of everything Cassandra has to offer. |
Add support for keyword autocompletion following ADD and DROP in cqlsh.
This change adds the IdentityStatement grammars needed in cql3handling.py in order to support keyword suggestions upon for identity assignments and drops. Accompanying test suite included.
See original CASSANDRA-20021 JIRA ticket for commit history and example functionality.
patch by Shalni Sundram