summaryrefslogtreecommitdiff
path: root/alembic/autogenerate
diff options
context:
space:
mode:
authorCarlos Eduardo Rivera <cerivera@fastmail.fm>2014-08-27 05:35:47 -0500
committerCarlos Eduardo Rivera <cerivera@fastmail.fm>2014-08-27 05:35:47 -0500
commit19930ce67a79a5253f22ce15d605e3ca476a7968 (patch)
tree01e754ced99382f6bce20fcae1c5016116bb3d18 /alembic/autogenerate
parent6396ccfb775be8a242db1518b6abf1357a23a0a6 (diff)
downloadalembic-19930ce67a79a5253f22ce15d605e3ca476a7968.tar.gz
adding mike's patch
Diffstat (limited to 'alembic/autogenerate')
-rw-r--r--alembic/autogenerate/render.py24
1 files changed, 4 insertions, 20 deletions
diff --git a/alembic/autogenerate/render.py b/alembic/autogenerate/render.py
index fc8dfa5..1b49804 100644
--- a/alembic/autogenerate/render.py
+++ b/alembic/autogenerate/render.py
@@ -320,29 +320,13 @@ def _render_server_default(default, autogen_context, repr_=True):
if rendered is not False:
return rendered
- add_text_wrap = False
if isinstance(default, sa_schema.DefaultClause):
- add_text_wrap = isinstance(default.arg, sql.elements.TextClause)
+ default = _render_potential_expr(default.arg, autogen_context)
- if isinstance(default.arg, string_types):
- default = default.arg
- else:
- default = str(default.arg.compile(
- dialect=autogen_context['dialect']))
-
- if isinstance(default, string_types):
- if repr_:
- default = repr(re.sub(r"^'|'$", "", default))
-
- if add_text_wrap:
- default = "%(prefix)stext(%(default)s)" % {
- 'prefix': _sqlalchemy_autogenerate_prefix(autogen_context),
- 'default': default
- }
+ elif isinstance(default, string_types) and repr_:
+ default = repr(re.sub(r"^'|'$", "", default))
- return default
- else:
- return None
+ return default
def _repr_type(type_, autogen_context):
rendered = _user_defined_render("type", type_, autogen_context)