diff options
author | RamonWill <ramonwilliams@hotmail.co.uk> | 2020-08-13 17:04:13 -0400 |
---|---|---|
committer | sqla-tester <sqla-tester@sqlalchemy.org> | 2020-08-13 17:04:13 -0400 |
commit | 0d874b36664d2f817edaa009358d5d2455711fdc (patch) | |
tree | adc87fef2e45cdc39277747fa2f7f9ec9981eb06 | |
parent | cd03b8f0cecbf72ecd6c99c4d3a6338c8278b40d (diff) | |
download | sqlalchemy-0d874b36664d2f817edaa009358d5d2455711fdc.tar.gz |
Test execution_options on Query object before compilation
A test that checks if the execution options are being set on the Query object before compilation
### Description
Since Issue #4670 has been open there have changes to the execution mechanics that resolved it. I have just created a test case that will enable the issue to be closed.
This pull request is:
- [ X] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [ ] A short code fix
- please include the issue number, and create an issue if none exists, which
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests. one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.
**Have a nice day!**
Fixes: #4670
Closes: #5446
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5446
Pull-request-sha: c98639ec94279760caacf9f288b180198511dfd3
Change-Id: I686dc7a4735000748c94bff5ba6dc7bd57b2d1c4
-rw-r--r-- | test/orm/test_events.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/orm/test_events.py b/test/orm/test_events.py index df48cfe63..aff47d96e 100644 --- a/test/orm/test_events.py +++ b/test/orm/test_events.py @@ -2768,6 +2768,25 @@ class QueryEventsTest( ) ) + def test_before_compile_execution_options(self): + User = self.classes.User + + @event.listens_for(query.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(User).first() + eq_(opts["my_option"], True) + class RefreshFlushInReturningTest(fixtures.MappedTest): """test [ticket:3427]. |