mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-12 19:59:09 -04:00
- fixed bug in result proxy where anonymously generated
column labels would not be accessible using their straight string name
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)])
|
||||
|
||||
|
||||
+17
-3
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user