|
13 | 13 | from sqlalchemy.engine import characteristics, reflection |
14 | 14 | from sqlalchemy.engine.default import DefaultExecutionContext, StrCompileDialect |
15 | 15 | from sqlalchemy.exc import CompileError, NoSuchTableError |
16 | | -from sqlalchemy.sql import functions, literal_column |
| 16 | +from sqlalchemy.sql import ddl, functions, literal_column |
17 | 17 | from sqlalchemy.sql.compiler import ( |
18 | 18 | DDLCompiler, |
19 | 19 | IdentifierPreparer, |
@@ -462,7 +462,7 @@ def visit_upsert(self, insert_stmt, visited_bindparam=None, **kw): |
462 | 462 |
|
463 | 463 |
|
464 | 464 | class YqlDDLCompiler(DDLCompiler): |
465 | | - def visit_create_index(self, create, include_schema=False, include_table_schema=True, **kw): |
| 465 | + def visit_create_index(self, create: ddl.CreateIndex, **kw) -> str: |
466 | 466 | index: sa.Index = create.element |
467 | 467 | ydb_opts = index.dialect_options.get("ydb", {}) |
468 | 468 |
|
@@ -491,6 +491,16 @@ def visit_create_index(self, create, include_schema=False, include_table_schema= |
491 | 491 |
|
492 | 492 | return text |
493 | 493 |
|
| 494 | + def visit_drop_index(self, drop: ddl.DropIndex, **kw) -> str: |
| 495 | + index: sa.Index = drop.element |
| 496 | + |
| 497 | + self._verify_index_table(index) |
| 498 | + |
| 499 | + table_name = self.preparer.format_table(index.table) |
| 500 | + index_name = self._prepared_index_name(index) |
| 501 | + |
| 502 | + return f"ALTER TABLE {table_name} DROP INDEX {index_name}" |
| 503 | + |
494 | 504 | def post_create_table(self, table: sa.Table) -> str: |
495 | 505 | ydb_opts = table.dialect_options["ydb"] |
496 | 506 | with_clause_list = self._render_table_partitioning_settings(ydb_opts) |
|
0 commit comments