diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-02-27 16:43:59 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-03-30 14:58:50 -0400 |
| commit | 4eb4010c1a1c3e5c2529b9be9d8d56f1d6a4ec00 (patch) | |
| tree | bac9c2f192b43d097ee9122a1add4c4f952d2d8e /test/engine | |
| parent | 74f6c21747d07a8cf9902900df9280a84aadc2bb (diff) | |
| download | sqlalchemy-4eb4010c1a1c3e5c2529b9be9d8d56f1d6a4ec00.tar.gz | |
Apply type processing to untyped preexec default clause
Fixed bug where a SQL-oriented Python-side column default could fail to
be executed properly upon INSERT in the "pre-execute" codepath, if the
SQL itself were an untyped expression, such as plain text. The "pre-
execute" codepath is fairly uncommon however can apply to non-integer
primary key columns with SQL defaults when RETURNING is not used.
Tests exist here to ensure typing is applied to
a typed expression for default, but in the case of
an untyped SQL value, we know the type from the column,
so apply this.
Change-Id: I5d8b391611c137b9f700115a50a2bf5b30abfe94
Fixes: #3923
Diffstat (limited to 'test/engine')
| -rw-r--r-- | test/engine/test_execute.py | 79 |
1 files changed, 26 insertions, 53 deletions
diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index eff1026cd..8437aca37 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -1350,34 +1350,19 @@ class EngineEventsTest(fixtures.TestBase): ('select * from t1', {}, None), ('DROP TABLE t1', {}, None)] - # or engine.dialect.preexecute_pk_sequences: - if not testing.against('oracle+zxjdbc'): - cursor = [ - ('CREATE TABLE t1', {}, ()), - ('INSERT INTO t1 (c1, c2)', { - 'c2': 'some data', 'c1': 5}, - (5, 'some data')), - ('SELECT lower', {'lower_2': 'Foo'}, - ('Foo', )), - ('INSERT INTO t1 (c1, c2)', - {'c2': 'foo', 'c1': 6}, - (6, 'foo')), - ('select * from t1', {}, ()), - ('DROP TABLE t1', {}, ()), - ] - else: - insert2_params = 6, 'Foo' - if testing.against('oracle+zxjdbc'): - insert2_params += (ReturningParam(12), ) - cursor = [('CREATE TABLE t1', {}, ()), - ('INSERT INTO t1 (c1, c2)', - {'c2': 'some data', 'c1': 5}, (5, 'some data')), - ('INSERT INTO t1 (c1, c2)', - {'c1': 6, 'lower_2': 'Foo'}, insert2_params), - ('select * from t1', {}, ()), - ('DROP TABLE t1', {}, ())] - # bind param name 'lower_2' might - # be incorrect + cursor = [ + ('CREATE TABLE t1', {}, ()), + ('INSERT INTO t1 (c1, c2)', { + 'c2': 'some data', 'c1': 5}, + (5, 'some data')), + ('SELECT lower', {'lower_1': 'Foo'}, + ('Foo', )), + ('INSERT INTO t1 (c1, c2)', + {'c2': 'foo', 'c1': 6}, + (6, 'foo')), + ('select * from t1', {}, ()), + ('DROP TABLE t1', {}, ()), + ] self._assert_stmts(compiled, stmts) self._assert_stmts(cursor, cursor_stmts) @@ -2363,31 +2348,19 @@ class ProxyConnectionTest(fixtures.TestBase): ('INSERT INTO t1 (c1, c2)', {'c1': 6}, None), ('select * from t1', {}, None), ('DROP TABLE t1', {}, None)] - # or engine.dialect.pr eexecute_pk_sequence s: - # original comment above moved here for pep8 fix - if not testing.against('oracle+zxjdbc'): - cursor = [ - ('CREATE TABLE t1', {}, ()), - ('INSERT INTO t1 (c1, c2)', { - 'c2': 'some data', 'c1': 5}, (5, 'some data')), - ('SELECT lower', {'lower_2': 'Foo'}, - ('Foo', )), - ('INSERT INTO t1 (c1, c2)', {'c2': 'foo', 'c1': 6}, - (6, 'foo')), - ('select * from t1', {}, ()), - ('DROP TABLE t1', {}, ()), - ] - else: - insert2_params = 6, 'Foo' - if testing.against('oracle+zxjdbc'): - insert2_params += (ReturningParam(12), ) - cursor = [('CREATE TABLE t1', {}, ()), - ('INSERT INTO t1 (c1, c2)', { - 'c2': 'some data', 'c1': 5}, (5, 'some data')), - ('INSERT INTO t1 (c1, c2)', - {'c1': 6, 'lower_2': 'Foo'}, insert2_params), - ('select * from t1', {}, ()), - ('DROP TABLE t1', {}, ())] + + cursor = [ + ('CREATE TABLE t1', {}, ()), + ('INSERT INTO t1 (c1, c2)', { + 'c2': 'some data', 'c1': 5}, (5, 'some data')), + ('SELECT lower', {'lower_1': 'Foo'}, + ('Foo', )), + ('INSERT INTO t1 (c1, c2)', {'c2': 'foo', 'c1': 6}, + (6, 'foo')), + ('select * from t1', {}, ()), + ('DROP TABLE t1', {}, ()), + ] + assert_stmts(compiled, stmts) assert_stmts(cursor, cursor_stmts) |
