Massimo,
I see the problem, in my dal.py in _select function:
def _select(self, query, fields, attributes):
tables = self.tables
for key in set(attributes.keys())-SELECT_ARGS:
raise SyntaxError, 'invalid select attribute: %s' % key
args_get = attributes.get
tablenames = tables(query)
for field in fields:
if isinstance(field, basestring) \
and REGEX_TABLE_DOT_FIELD.match(field):
tn,fn = field.split('.')
field = self.db[tn][fn]
for tablename in tables(field):
if not tablename in tablenames:
tablenames.append(tablename)
if use_common_filters(query):
query = self.common_filter(query,tablenames)
if len(tablenames) < 1:
raise SyntaxError, 'Set: no tables selected'
sql_f = ', '.join(map(self.expand, fields))
* self._colnames = [c.strip() for c in sql_f.split(', ')]*
if query:
sql_w = ' WHERE ' + self.expand(query)
else:
sql_w = ''
sql_o = ''
The problem is in: *self._colnames = [c.strip() for c in sql_f.split(', ')]*
Because *sql_f* value is
tickets.name, tickets.created_on, SUBSTRING(tickets.name, 5)
Now, I see that in the new dal.py trunk version you have:
*self._colnames = map(self.expand, fields)
*
It's solve the problem? I have web2py version: (2, 2, 1,
datetime.datetime(2012, 10, 21, 16, 57, 4), 'stable')
Regards.
On Sunday, January 20, 2013 3:09:59 PM UTC-6, Massimo Di Pierro wrote:
>
> I cannot reproduce. Can you post the model?
>
> On Sunday, 20 January 2013 14:43:58 UTC-6, Ignacio Ocampo wrote:
>>
>> When I use custom expression, that contains comma within, it fails if I
>> use an space after comma.
>>
>> *Example 1*
>> --- WORKS ---
>> query = ac(tickets.id>0).select(tickets.name, tickets.created_on,
>> "DATEDIFF(tickets.created_*on,N*OW())")
>> colnames=['tickets.name', 'tickets.created_on',
>> 'DATEDIFF(tickets.created_o*n,N*OW())']
>>
>> --- DON'T WORKS ---
>> query = ac(tickets.id>0).select(tickets.name, tickets.created_on,
>> "DATEDIFF(tickets.created_*on, N*OW())")
>> colnames=['tickets.name', 'tickets.created_on',
>> 'DATEDIFF(tickets.created_on*', '*NOW())']
>>
>> *Example 2*
>> --- WORKS ---
>> query = ac(tickets.id>0).select(tickets.name, tickets.created_on,
>> "SUBSTRING(tickets.nam*e,5*)")
>> colnames=['tickets.name', 'tickets.created_on', 'SUBSTRING(tickets.nam*
>> e,5*)']
>> --- DON'T WORKS ---
>> query = ac(tickets.id>0).select(tickets.name, tickets.created_on,
>> "SUBSTRING(tickets.nam*e, 5*)")
>> colnames=['tickets.name', 'tickets.created_on', 'SUBSTRING(tickets.name*',
>> '*5)']
>>
>>
--