summaryrefslogtreecommitdiff
path: root/alembic/templates
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-04-07 12:36:51 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-04-07 12:41:46 -0400
commit0e1c0989894f13b29a00c9504b887568a40d6648 (patch)
treee05ebe211e0c5f227840d1a2895288b77c62cbc0 /alembic/templates
parent54e4f58d1f5315a6bb4c579d1ac8cdb802e7439e (diff)
downloadalembic-0e1c0989894f13b29a00c9504b887568a40d6648.tar.gz
- Added a new option
:paramref:`.EnvironmentContext.configure.literal_binds`, which will pass the ``literal_binds`` flag into the compilation of SQL constructs when using "offline" mode. This has the effect that SQL objects like inserts, updates, deletes as well as textual statements sent using ``text()`` will be compiled such that the dialect will attempt to render literal values "inline" automatically. Only a subset of types is typically supported; the :meth:`.Operations.inline_literal` construct remains as the construct used to force a specific literal representation of a value. The :paramref:`.EnvironmentContext.configure.literal_binds` flag is added to the "offline" section of the ``env.py`` files generated in new environments. fixes #255 - enhance the op_fixture as well as MigrationContext._stdout_connection() so that it uses the real DefaultImpl and MigrationContext fully in tests.
Diffstat (limited to 'alembic/templates')
-rw-r--r--alembic/templates/generic/env.py3
-rw-r--r--alembic/templates/multidb/env.py3
-rw-r--r--alembic/templates/pylons/env.py3
3 files changed, 6 insertions, 3 deletions
diff --git a/alembic/templates/generic/env.py b/alembic/templates/generic/env.py
index 280006d..058378b 100644
--- a/alembic/templates/generic/env.py
+++ b/alembic/templates/generic/env.py
@@ -36,7 +36,8 @@ def run_migrations_offline():
"""
url = config.get_main_option("sqlalchemy.url")
- context.configure(url=url, target_metadata=target_metadata)
+ context.configure(
+ url=url, target_metadata=target_metadata, literal_binds=True)
with context.begin_transaction():
context.run_migrations()
diff --git a/alembic/templates/multidb/env.py b/alembic/templates/multidb/env.py
index ab37199..453b41c 100644
--- a/alembic/templates/multidb/env.py
+++ b/alembic/templates/multidb/env.py
@@ -67,7 +67,8 @@ def run_migrations_offline():
logger.info("Writing output to %s" % file_)
with open(file_, 'w') as buffer:
context.configure(url=rec['url'], output_buffer=buffer,
- target_metadata=target_metadata.get(name))
+ target_metadata=target_metadata.get(name),
+ literal_binds=True)
with context.begin_transaction():
context.run_migrations(engine_name=name)
diff --git a/alembic/templates/pylons/env.py b/alembic/templates/pylons/env.py
index 70eea4e..5ad9fd5 100644
--- a/alembic/templates/pylons/env.py
+++ b/alembic/templates/pylons/env.py
@@ -46,7 +46,8 @@ def run_migrations_offline():
"""
context.configure(
- url=meta.engine.url, target_metadata=target_metadata)
+ url=meta.engine.url, target_metadata=target_metadata,
+ literal_binds=True)
with context.begin_transaction():
context.run_migrations()