From c76fd4bbf13a51c41429b7e14cba387d36536006 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 17 Oct 2022 08:52:55 -0400 Subject: [PATCH] fix search path indicator Change-Id: I341a57f0bbf7c237c86cb8de4c94a37d737c3c85 Fixes: #1096 --- docs/build/cookbook.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 -- 2.47.2