diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-11-11 12:34:00 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-11-11 12:34:00 -0500 |
commit | b013fb82f5a5d891c6fd776e0e6ed926cdf2ffe1 (patch) | |
tree | 4b6bff8cba6409032a6450e399aeb102e6edc0d1 /test/sql/test_compiler.py | |
parent | 21022f9760e32cf54d59eaccc12cc9e2fea1d37a (diff) | |
download | sqlalchemy-b013fb82f5a5d891c6fd776e0e6ed926cdf2ffe1.tar.gz |
- Fixed issue where the columns from a SELECT embedded in an
INSERT, either through the values clause or as a "from select",
would pollute the column types used in the result set produced by
the RETURNING clause when columns from both statements shared the
same name, leading to potential errors or mis-adaptation when
retrieving the returning rows.
fixes #3248
Diffstat (limited to 'test/sql/test_compiler.py')
-rw-r--r-- | test/sql/test_compiler.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index 5d1afe616..9e99a947b 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -3437,3 +3437,32 @@ class ResultMapTest(fixtures.TestBase): is_( comp.result_map['t1_a'][1][2], t1.c.a ) + + def test_insert_with_select_values(self): + astring = Column('a', String) + aint = Column('a', Integer) + m = MetaData() + Table('t1', m, astring) + t2 = Table('t2', m, aint) + + stmt = t2.insert().values(a=select([astring])).returning(aint) + comp = stmt.compile(dialect=postgresql.dialect()) + eq_( + comp.result_map, + {'a': ('a', (aint, 'a', 'a'), aint.type)} + ) + + def test_insert_from_select(self): + astring = Column('a', String) + aint = Column('a', Integer) + m = MetaData() + Table('t1', m, astring) + t2 = Table('t2', m, aint) + + stmt = t2.insert().from_select(['a'], select([astring])).\ + returning(aint) + comp = stmt.compile(dialect=postgresql.dialect()) + eq_( + comp.result_map, + {'a': ('a', (aint, 'a', 'a'), aint.type)} + ) |