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

Add AlterIndex completion #935

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/core/shared/src/main/scala/data/Completion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ object Completion {
case object Explain extends Completion
case object Grant extends Completion
case object Revoke extends Completion
case object AlterIndex extends Completion
// more ...

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ object CommandComplete {
case "EXPLAIN" => apply(Completion.Explain)
case "GRANT" => apply(Completion.Grant)
case "REVOKE" => apply(Completion.Revoke)
case "ALTER INDEX" => apply(Completion.AlterIndex)
// more .. fill in as we hit them

case s => apply(Completion.Unknown(s))
Expand Down
15 changes: 11 additions & 4 deletions modules/tests/shared/src/test/scala/CommandTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,14 @@ class CommandTest extends SkunkTest {
)
""".command

val alterIndex: Command[Void] =
sql"""
ALTER INDEX IF EXISTS id_index RENAME TO pk_index
""".command

val dropIndex: Command[Void] =
sql"""
DROP INDEX id_index
DROP INDEX pk_index
""".command

val createView: Command[Void] =
Expand Down Expand Up @@ -319,16 +324,18 @@ class CommandTest extends SkunkTest {
FROM skunk_role
""".command

sessionTest("create table, create index, drop index, alter table and drop table") { s =>
sessionTest("create table, create index, alter table, alter index, drop index and drop table") { s =>
for {
c <- s.execute(createTable)
_ <- assert("completion", c == Completion.CreateTable)
c <- s.execute(createIndex)
_ <- assert("completion", c == Completion.CreateIndex)
c <- s.execute(dropIndex)
_ <- assert("completion", c == Completion.DropIndex)
c <- s.execute(alterTable)
_ <- assert("completion", c == Completion.AlterTable)
c <- s.execute(alterIndex)
_ <- assert("completion", c == Completion.AlterIndex)
c <- s.execute(dropIndex)
_ <- assert("completion", c == Completion.DropIndex)
c <- s.execute(dropTable)
_ <- assert("completion", c == Completion.DropTable)
_ <- s.assertHealthy
Expand Down