from .base import ColumnType
from .base import format_column_name
from .base import format_server_default
+from .base import format_table_name
from .base import format_type
+from .base import RenameTable
from .impl import DefaultImpl
)
+@compiles(RenameTable, "oracle")
+def visit_rename_table(element, compiler, **kw):
+ return "%s RENAME TO %s" % (
+ alter_table(compiler, element.table_name, element.schema),
+ format_table_name(compiler, element.new_table_name, None),
+ )
+
+
def alter_column(compiler, name):
return "MODIFY %s" % format_column_name(compiler, name)
--- /dev/null
+.. change::
+ :tags: bug, op directives, oracle
+ :tickets: 670
+
+ Fixed issue in Oracle backend where a table RENAME with a schema-qualified
+ name would include the schema in the "to" portion, which is rejected by
+ Oracle.
+
"INTEGER GENERATED ALWAYS AS (foo * 5)"
)
+ def test_alter_table_rename_oracle(self):
+ context = op_fixture("oracle")
+ op.rename_table("s", "t")
+ context.assert_("ALTER TABLE s RENAME TO t")
+
+ def test_alter_table_rename_schema_oracle(self):
+ context = op_fixture("oracle")
+ op.rename_table("s", "t", schema="myowner")
+ context.assert_("ALTER TABLE myowner.s RENAME TO t")
+
def test_alter_column_rename_oracle(self):
context = op_fixture("oracle")
op.alter_column("t", "c", name="x")