-
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
Closed
+46
−4
Closed
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3819c51
add identity mapping grammars in cql3handling for ADD DROP autocomplete
8007fc3
change USER to IDENTITY for identityMapping autocompletes
0930359
consolidate identity tests into test_cqlsh_completion.py
55959b9
add NOT EXISTS completion test to test_cqlsh_completion.py
5a78cfd
Delete pylib/cqlshlib/test/test_identity_mappings_completion.py
shalnisundram ee5eeb5
add more ADD, DROP tests, correct identies in test_cqlsh_completion.py
c434d9a
include ADD keyword in test_complete_in_insert() choices set in test_…
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
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 |
---|---|---|
|
@@ -166,7 +166,7 @@ class TestCqlshCompletion(CqlshCompletionCase): | |
cqlver = '3.1.6' | ||
|
||
def test_complete_on_empty_string(self): | ||
self.trycompletions('', choices=('?', 'ALTER', 'BEGIN', 'CAPTURE', 'CONSISTENCY', | ||
self.trycompletions('', choices=('?', 'ADD', 'ALTER', 'BEGIN', 'CAPTURE', 'CONSISTENCY', | ||
'COPY', 'CREATE', 'DEBUG', 'DELETE', 'DESC', 'DESCRIBE', | ||
'DROP', 'GRANT', 'HELP', 'INSERT', 'LIST', 'LOGIN', 'PAGING', 'REVOKE', | ||
'SELECT', 'SHOW', 'SOURCE', 'TRACING', 'ELAPSED', 'EXPAND', 'SERIAL', 'TRUNCATE', | ||
|
@@ -613,7 +613,7 @@ def test_complete_in_string_literals(self): | |
def test_complete_in_drop(self): | ||
self.trycompletions('DR', immediate='OP ') | ||
self.trycompletions('DROP ', | ||
choices=['AGGREGATE', 'COLUMNFAMILY', 'FUNCTION', | ||
choices=['AGGREGATE', 'COLUMNFAMILY', 'FUNCTION', 'IDENTITY', | ||
'INDEX', 'KEYSPACE', 'ROLE', 'TABLE', | ||
'TRIGGER', 'TYPE', 'USER', 'MATERIALIZED']) | ||
|
||
|
@@ -1048,12 +1048,12 @@ def test_complete_in_use(self): | |
'system_virtual_schema', 'system_cluster_metadata']) | ||
|
||
def test_complete_in_create_index(self): | ||
self.trycompletions('CREATE I', immediate='NDEX ') | ||
self.trycompletions('CREATE IN', immediate='DEX ') | ||
self.trycompletions('CREATE INDEX ', choices=['<new_index_name>', 'IF', 'ON']) | ||
self.trycompletions('CREATE INDEX example ', immediate='ON ') | ||
|
||
def test_complete_in_drop_index(self): | ||
self.trycompletions('DROP I', immediate='NDEX ') | ||
self.trycompletions('DROP IN', immediate='DEX ') | ||
frankgh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def test_complete_in_alter_keyspace(self): | ||
self.trycompletions('ALTER KEY', 'SPACE ') | ||
|
@@ -1184,9 +1184,15 @@ def test_complete_in_alter_type(self): | |
self.trycompletions('ALTER TYPE IF EXISTS new_type ADD IF NOT EXISTS ', choices=['<new_field_name>']) | ||
self.trycompletions('ALTER TYPE IF EXISTS new_type RENAME ', choices=['IF', '<quotedName>', '<identifier>']) | ||
|
||
# USER checks | ||
def test_complete_in_create_user(self): | ||
self.trycompletions('CREATE USER ', choices=['<username>', 'IF']) | ||
self.trycompletions('CREATE USER IF ', immediate='NOT EXISTS ') | ||
shalnisundram marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
def test_complete_in_alter_user(self): | ||
self.trycompletions('ALTER USER ', choices=['<identifier>', 'IF', '<pgStringLiteral>', '<quotedStringLiteral>']) | ||
|
||
# ROLE checks | ||
def test_complete_in_create_role(self): | ||
self.trycompletions('CREATE ROLE ', choices=['<rolename>', 'IF']) | ||
self.trycompletions('CREATE ROLE IF ', immediate='NOT EXISTS ') | ||
|
@@ -1205,18 +1211,45 @@ def test_complete_in_alter_role(self): | |
self.trycompletions('ALTER ROLE foo WITH ACCESS TO ', choices=['ALL', 'DATACENTERS']) | ||
self.trycompletions('ALTER ROLE foo WITH ACCESS FROM ', choices=['ALL', 'CIDRS']) | ||
|
||
def test_complete_in_create_user(self): | ||
self.trycompletions('CREATE USER ', choices=['<username>', 'IF']) | ||
self.trycompletions('CREATE USER IF ', immediate='NOT EXISTS ') | ||
|
||
def test_complete_in_drop_role(self): | ||
self.trycompletions('DROP ROLE ', choices=['<identifier>', 'IF', '<quotedName>']) | ||
|
||
|
||
# IDENTITY checks | ||
def test_complete_in_add_identity(self): | ||
self.trycompletions('ADD ID', immediate='ENTITY ') | ||
frankgh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.trycompletions('ADD IDENTITY IF ', immediate='NOT EXISTS ') | ||
self.trycompletions('ADD IDENTITY IF NOT ', immediate='EXISTS ') | ||
self.trycompletions('ADD IDENTITY ', | ||
choices=['<pgStringLiteral>', '<quotedStringLiteral>', 'IF']) | ||
self.trycompletions("ADD IDENTITY '[email protected]' TO R", immediate='OLE ') | ||
shalnisundram marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
self.trycompletions("ADD IDENTITY '[email protected]' ", immediate='TO ROLE ') | ||
self.trycompletions("ADD IDENTITY '[email protected]' TO ROLE ", | ||
choices=['<identifier>', '<quotedName>'], other_choices_ok=True) | ||
self.trycompletions("ADD IDENTITY '[email protected]' TO ROLE data_engineer ", | ||
choices=[';']) | ||
self.trycompletions("ADD IDENTITY IF NOT EXISTS '[email protected]' TO ROLE data_engineer ", | ||
choices=[';']) | ||
|
||
def test_complete_in_drop_identity(self): | ||
self.trycompletions('DROP IDENTITY ', | ||
frankgh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
choices=['<pgStringLiteral>', '<quotedStringLiteral>', 'IF']) | ||
self.trycompletions('DROP IDENTITY IF ', immediate='EXISTS ') | ||
self.trycompletions('DROP IDENTITY IF EXISTS ', | ||
choices=['<pgStringLiteral>', '<quotedStringLiteral>']) | ||
self.trycompletions("DROP IDENTITY '[email protected]' ", choices=[';']) | ||
self.trycompletions("DROP IDENTITY IF EXISTS '[email protected]' ", choices=[';']) | ||
|
||
def test_complete_in_list(self): | ||
self.trycompletions('LIST ', | ||
choices=['ALL', 'AUTHORIZE', 'DESCRIBE', 'EXECUTE', 'ROLES', 'USERS', 'ALTER', | ||
'CREATE', 'DROP', 'MODIFY', 'SELECT', 'UNMASK', 'SELECT_MASKED', 'SUPERUSERS']) | ||
|
||
def test_complete_drop_end(self): | ||
shalnisundram marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
self.trycompletions("DROP USER '[email protected]' ", choices=[';']) | ||
self.trycompletions("DROP USER IF EXISTS '[email protected]' ", choices=[';']) | ||
|
||
# Non-CQL Shell Commands | ||
|
||
def test_complete_in_capture(self): | ||
|
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.