Returns a function that will be used to instantiate query results

def _get_result_constructor(self):
        """ Returns a function that will be used to instantiate query results """
        if not self._values_list: # we want models
            return lambda rows: self.model._construct_instance(rows)
        elif self._flat_values_list: # the user has requested flattened list (1 value per row)
            return lambda row: row.popitem()[1]
        else:
            return lambda row: self._get_row_value_list(self._only_fields, row)