fixed issue 1273, default int as_dict, thanks Alan

This commit is contained in:
mdipierro
2013-01-14 09:42:59 -06:00
parent fb5e6e927f
commit 10af0102f4
2 changed files with 17 additions and 1 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.4.1-alpha.2+timestamp.2013.01.14.09.18.01
Version 2.4.1-alpha.2+timestamp.2013.01.14.09.41.53
+16
View File
@@ -9577,6 +9577,22 @@ class Rows(object):
:param storage_to_dict: when True returns a dict, otherwise a list(default True)
:param datetime_to_str: convert datetime fields as strings (default True)
"""
# test for multiple rows
multi = False
f = self.first()
if f:
multi = any([isinstance(v, f.__class__) for v in f.values()])
if (not "." in key) and multi:
# No key provided, default to int indices
def new_key():
i = 0
while True:
yield i
i += 1
key_generator = new_key()
key = lambda r: key_generator.next()
rows = self.as_list(compact, storage_to_dict, datetime_to_str, custom_types)
if isinstance(key,str) and key.count('.')==1:
(table, field) = key.split('.')