summaryrefslogtreecommitdiff
path: root/alembic/ddl/oracle.py
diff options
context:
space:
mode:
Diffstat (limited to 'alembic/ddl/oracle.py')
-rw-r--r--alembic/ddl/oracle.py43
1 files changed, 25 insertions, 18 deletions
diff --git a/alembic/ddl/oracle.py b/alembic/ddl/oracle.py
index e528744..3376155 100644
--- a/alembic/ddl/oracle.py
+++ b/alembic/ddl/oracle.py
@@ -1,13 +1,21 @@
from sqlalchemy.ext.compiler import compiles
from .impl import DefaultImpl
-from .base import alter_table, AddColumn, ColumnName, \
- format_column_name, ColumnNullable, \
- format_server_default, ColumnDefault, format_type, ColumnType
+from .base import (
+ alter_table,
+ AddColumn,
+ ColumnName,
+ format_column_name,
+ ColumnNullable,
+ format_server_default,
+ ColumnDefault,
+ format_type,
+ ColumnType,
+)
class OracleImpl(DefaultImpl):
- __dialect__ = 'oracle'
+ __dialect__ = "oracle"
transactional_ddl = False
batch_separator = "/"
command_terminator = ""
@@ -15,8 +23,8 @@ class OracleImpl(DefaultImpl):
def __init__(self, *arg, **kw):
super(OracleImpl, self).__init__(*arg, **kw)
self.batch_separator = self.context_opts.get(
- "oracle_batch_separator",
- self.batch_separator)
+ "oracle_batch_separator", self.batch_separator
+ )
def _exec(self, construct, *args, **kw):
result = super(OracleImpl, self)._exec(construct, *args, **kw)
@@ -31,7 +39,7 @@ class OracleImpl(DefaultImpl):
self._exec("COMMIT")
-@compiles(AddColumn, 'oracle')
+@compiles(AddColumn, "oracle")
def visit_add_column(element, compiler, **kw):
return "%s %s" % (
alter_table(compiler, element.table_name, element.schema),
@@ -39,47 +47,46 @@ def visit_add_column(element, compiler, **kw):
)
-@compiles(ColumnNullable, 'oracle')
+@compiles(ColumnNullable, "oracle")
def visit_column_nullable(element, compiler, **kw):
return "%s %s %s" % (
alter_table(compiler, element.table_name, element.schema),
alter_column(compiler, element.column_name),
- "NULL" if element.nullable else "NOT NULL"
+ "NULL" if element.nullable else "NOT NULL",
)
-@compiles(ColumnType, 'oracle')
+@compiles(ColumnType, "oracle")
def visit_column_type(element, compiler, **kw):
return "%s %s %s" % (
alter_table(compiler, element.table_name, element.schema),
alter_column(compiler, element.column_name),
- "%s" % format_type(compiler, element.type_)
+ "%s" % format_type(compiler, element.type_),
)
-@compiles(ColumnName, 'oracle')
+@compiles(ColumnName, "oracle")
def visit_column_name(element, compiler, **kw):
return "%s RENAME COLUMN %s TO %s" % (
alter_table(compiler, element.table_name, element.schema),
format_column_name(compiler, element.column_name),
- format_column_name(compiler, element.newname)
+ format_column_name(compiler, element.newname),
)
-@compiles(ColumnDefault, 'oracle')
+@compiles(ColumnDefault, "oracle")
def visit_column_default(element, compiler, **kw):
return "%s %s %s" % (
alter_table(compiler, element.table_name, element.schema),
alter_column(compiler, element.column_name),
- "DEFAULT %s" %
- format_server_default(compiler, element.default)
+ "DEFAULT %s" % format_server_default(compiler, element.default)
if element.default is not None
- else "DEFAULT NULL"
+ else "DEFAULT NULL",
)
def alter_column(compiler, name):
- return 'MODIFY %s' % format_column_name(compiler, name)
+ return "MODIFY %s" % format_column_name(compiler, name)
def add_column(compiler, column, **kw):