colname_fields now includes virtual fields, thanks Paolo
@@ -2587,9 +2587,25 @@ class BasicRows(object):
@property
def colnames_fields(self):
+ """
+ Returns the list of fields matching colnames, possibly
+ including virtual fields (i.e. Field.Virtual and
+ Field.Method instances).
+ Use this property instead of plain fields attribute
+ whenever you have an entry in colnames which references
+ a virtual field, and you still need a correspondance
+ between column names and fields.
+
+ NOTE that references to the virtual fields must have been
+ **forced** in some way within colnames, because in the general
+ case it is not possible to have them as a result of a select.
+ """
colnames = self.colnames
+ # instances of Field or Expression only are allowed in fields
plain_fields = self.fields
if len(colnames) > len(plain_fields):
+ # correspondance between colnames and fields is broken,
+ # search for missing virtual fields
fields = []; fi = 0
for col in colnames:
m = re.match(REGEX_TABLE_DOT_FIELD_OPTIONAL_QUOTES, col)
@@ -2801,8 +2817,6 @@ class Rows(BasicRows):
fields=self.fields)
def __getitem__(self, i):
- if isinstance(i, slice):
- return self.__getslice__(i.start, i.stop)
row = self.records[i]
keys = list(row.keys())
if self.compact and len(keys) == 1 and keys[0] != '_extra':
