From: Mike Bayer Date: Mon, 17 Oct 2022 12:52:55 +0000 (-0400) Subject: fix search path indicator X-Git-Tag: rel_1_9_0~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c76fd4bbf13a51c41429b7e14cba387d36536006;p=thirdparty%2Fsqlalchemy%2Falembic.git fix search path indicator Change-Id: I341a57f0bbf7c237c86cb8de4c94a37d737c3c85 Fixes: #1096 --- diff --git a/docs/build/cookbook.rst b/docs/build/cookbook.rst index e2b92333..1dc4d793 100644 --- a/docs/build/cookbook.rst +++ b/docs/build/cookbook.rst @@ -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