From: RamonWill Date: Thu, 9 Jul 2020 13:21:50 +0000 (+0100) Subject: new test case for #4670. closes #4670 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2312512ed7e89c43728d4bab3ff1cc2bc867519;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git new test case for #4670. closes #4670 --- diff --git a/test/orm/test_query.py b/test/orm/test_query.py index 7ef2a455ea..5beb75c1a4 100644 --- a/test/orm/test_query.py +++ b/test/orm/test_query.py @@ -12,6 +12,7 @@ from sqlalchemy import collate from sqlalchemy import column from sqlalchemy import desc from sqlalchemy import distinct +from sqlalchemy import event from sqlalchemy import exc as sa_exc from sqlalchemy import exists from sqlalchemy import ForeignKey @@ -5820,6 +5821,23 @@ class ExecutionOptionsTest(QueryTest): q1 = sess.query(User).execution_options(**execution_options) q1.all() + def test_options_before_compile(self): + @event.listens_for(Query, "before_compile", retval=True) + def _before_compile(query): + return query.execution_options(my_option=True) + + opts = {} + + @event.listens_for(testing.db, "before_cursor_execute") + def _before_cursor_execute( + conn, cursor, statement, parameters, context, executemany + ): + opts.update(context.execution_options) + + sess = create_session(bind=testing.db, autocommit=False) + sess.query(column("1")).all() + eq_(opts["my_option"], True) + class BooleanEvalTest(fixtures.TestBase, testing.AssertsCompiledSQL): """test standalone booleans being wrapped in an AsBoolean, as well