]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
fix search path indicator
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 17 Oct 2022 12:52:55 +0000 (08:52 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 17 Oct 2022 12:52:55 +0000 (08:52 -0400)
Change-Id: I341a57f0bbf7c237c86cb8de4c94a37d737c3c85
Fixes: #1096
docs/build/cookbook.rst

index e2b923332b093ddf9636f80b62b3c365e7680b22..1dc4d79371cd52e0f70fe426db665367a7e867bb 100644 (file)
@@ -829,6 +829,8 @@ schema or another.
    In ``env.py`` an approach like the following allows ``-xtenant=some_schema``
    to be supported by making use of :meth:`.EnvironmentContext.get_x_argument`::
 
+        from sqlalchemy import text
+
         def run_migrations_online():
             connectable = engine_from_config(
                 config.get_section(config.config_ini_section),
@@ -842,7 +844,7 @@ schema or another.
                 # set search path on the connection, which ensures that
                 # PostgreSQL will emit all CREATE / ALTER / DROP statements
                 # in terms of this schema by default
-                connection.execute("set search_path to %s" % current_tenant)
+                connection.execute(text('set search_path to "%s"' % current_tenant))
 
                 # make use of non-supported SQLAlchemy attribute to ensure
                 # the dialect reflects tables in terms of the current tenant name