diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-07 12:48:13 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-03-07 17:18:31 -0500 |
commit | b3d3795de0d45fe4adda7393881f0f955409a45d (patch) | |
tree | e1ed366f07f596388cfca024ae20128131565f61 /test/sql/test_query.py | |
parent | 0a1f720355f02d38da2a5a8444712dd7d199c713 (diff) | |
download | sqlalchemy-positional_targeting.tar.gz |
- The SQL compiler now generates the mapping of expected columnspositional_targeting
such that they are matched to the received result set positionally,
rather than by name. Originally, this was seen as a way to handle
cases where we had columns returned with difficult-to-predict names,
though in modern use that issue has been overcome by anonymous
labeling. In this version, the approach basically reduces function
call count per-result by a few dozen calls, or more for larger
sets of result columns. The approach still degrades into a modern
version of the old approach if textual elements modify the result
map, or if any discrepancy in size exists between
the compiled set of columns versus what was received, so there's no
issue for partially or fully textual compilation scenarios where these
lists might not line up. fixes #918
- callcounts still need to be adjusted down for this so zoomark
tests won't pass at the moment
Diffstat (limited to 'test/sql/test_query.py')
-rw-r--r-- | test/sql/test_query.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/sql/test_query.py b/test/sql/test_query.py index 2f13486eb..eeec487be 100644 --- a/test/sql/test_query.py +++ b/test/sql/test_query.py @@ -1175,6 +1175,48 @@ class QueryTest(fixtures.TestBase): row[1], 1 ) + def test_fetch_partial_result_map(self): + users.insert().execute(user_id=7, user_name='ed') + + t = text("select * from query_users").columns( + user_name=String() + ) + eq_( + testing.db.execute(t).fetchall(), [(7, 'ed')] + ) + + def test_fetch_unordered_result_map(self): + users.insert().execute(user_id=7, user_name='ed') + + class Goofy1(TypeDecorator): + impl = String + + def process_result_value(self, value, dialect): + return value + "a" + + class Goofy2(TypeDecorator): + impl = String + + def process_result_value(self, value, dialect): + return value + "b" + + class Goofy3(TypeDecorator): + impl = String + + def process_result_value(self, value, dialect): + return value + "c" + + t = text( + "select user_name as a, user_name as b, " + "user_name as c from query_users").columns( + a=Goofy1(), b=Goofy2(), c=Goofy3() + ) + eq_( + testing.db.execute(t).fetchall(), [ + ('eda', 'edb', 'edc') + ] + ) + @testing.requires.subqueries def test_column_label_targeting(self): users.insert().execute(user_id=7, user_name='ed') |