diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-02-14 18:22:47 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-02-14 18:22:47 +0000 |
| commit | 84485fb7bbc31ecc20176c088af671b2c27311bc (patch) | |
| tree | 7cbfaf85175ca0e318d6f5f47382f540a6317af4 | |
| parent | eddae08fdfbae0f43c7355896604c455f576ca7e (diff) | |
| download | sqlalchemy-84485fb7bbc31ecc20176c088af671b2c27311bc.tar.gz | |
- fixed bug in result proxy where anonymously generated
column labels would not be accessible using their straight
string name
| -rw-r--r-- | CHANGES | 4 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 2 | ||||
| -rw-r--r-- | test/sql/query.py | 20 |
3 files changed, 22 insertions, 4 deletions
@@ -39,6 +39,10 @@ CHANGES - cast() accepts text('something') and other non-literal operands properly [ticket:962] + - fixed bug in result proxy where anonymously generated + column labels would not be accessible using their straight + string name + - Deferrable constraints can now be defined. - Added "autocommit=True" keyword argument to select() and diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index e87d3d2fb..3f32778d6 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -236,7 +236,7 @@ class DefaultCompiler(engine.Compiled): labelname = self._truncated_identifier("colident", label.name) if result_map is not None: - result_map[labelname.lower()] = (label.name, (label, label.obj), label.obj.type) + result_map[labelname.lower()] = (label.name, (label, label.obj, labelname), label.obj.type) return " ".join([self.process(label.obj), self.operator_string(operators.as_), self.preparer.format_label(label, labelname)]) diff --git a/test/sql/query.py b/test/sql/query.py index 533f40fb5..2cc4ab0d0 100644 --- a/test/sql/query.py +++ b/test/sql/query.py @@ -129,15 +129,29 @@ class QueryTest(TestBase): table.drop() def test_row_iteration(self): - users.insert().execute(user_id = 7, user_name = 'jack') - users.insert().execute(user_id = 8, user_name = 'ed') - users.insert().execute(user_id = 9, user_name = 'fred') + users.insert().execute( + {'user_id':7, 'user_name':'jack'}, + {'user_id':8, 'user_name':'ed'}, + {'user_id':9, 'user_name':'fred'}, + ) r = users.select().execute() l = [] for row in r: l.append(row) self.assert_(len(l) == 3) + def test_anonymous_rows(self): + users.insert().execute( + {'user_id':7, 'user_name':'jack'}, + {'user_id':8, 'user_name':'ed'}, + {'user_id':9, 'user_name':'fred'}, + ) + + sel = select([users.c.user_id]).where(users.c.user_name=='jack').as_scalar() + for row in select([sel + 1, sel + 3], bind=users.bind).execute(): + assert row['anon_1'] == 8 + assert row['anon_2'] == 10 + def test_row_comparison(self): users.insert().execute(user_id = 7, user_name = 'jack') rp = users.select().execute().fetchone() |
