OK, got it. You are passing a Set object where you should have a Query 
object. You have:

query = db(...)

and then you have:

rows = db(query).select(...)

which is equivalent to:

rows = db(db(...)).select(...)

which is not allowed. When the Set object is passed to db(), it is 
converted to a string representation, which stars with "<Set", so the final 
SQL that is generated ends up looking like, "...WHERE <Set...". The "<" in 
that part of the SQL is generating the SQL syntax error in the database.

So, just change the code so the initial line defining the query is not 
wrapped in db(), or if you want to leave that line as is, then just call 
.select() directly on the Set object.

Anthony

On Monday, September 19, 2016 at 2:58:39 PM UTC-4, Peter wrote:
>
> Error after changing 
> .select()    to    ._select()
>
> Traceback 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
>
> Traceback (most recent call last):
>   File "/home/peter/web2py/gluon/restricted.py", line 227, in restricted
>     exec ccode in environment
>   File "/home/peter/web2py/applications/PAPAIM/controllers/default.py" 
> <http://127.0.0.1:8000/admin/default/edit/PAPAIM/controllers/default.py>, 
> line 566, in <module>
>   File "/home/peter/web2py/gluon/globals.py", line 417, in <lambda>
>     self._caller = lambda f: f()
>   File "/home/peter/web2py/gluon/tools.py", line 4241, in f
>     return action(*a, **b)
>   File "/home/peter/web2py/applications/PAPAIM/controllers/default.py" 
> <http://127.0.0.1:8000/admin/default/edit/PAPAIM/controllers/default.py>, 
> line 347, in preview_invoice
>     generate_inv_details()
>   File "/home/peter/web2py/applications/PAPAIM/models/extras.py" 
> <http://127.0.0.1:8000/admin/default/edit/PAPAIM/models/extras.py>, line 31, 
> in generate_inv_details
>     session.inv_total += row.task.charge
> AttributeError: 'str' object has no attribute 'task'
>
>
>
> Because this error highlighted    
>
>  session.inv_total += row.task.charge  
>
> as a problem, I changed it to 
>
>
> session.inv_total += 1
>
>
>
> the code now runs through and outputs this using generic view in which the 
> session information provides.. 
>
>
>
>
>  
> company_id : 
> 1
> company_persons : 
> id
> 28
> 37
> 46
> 51
> 52
> 63
> 70
> 81
> 87
> 95
> flash : 
> None
> inv_details : 
> SELECT task.person, person.name, task.title, task.start_time, 
> task.duration, task.task_type, task.task_status, task.charge_to, 
> task.charge, task.payment_status FROM task, person WHERE <Set 
> (((((task.person IN (1)) AND (task.start_time <= '2016-09-19 00:00:00')) 
> AND (task.charge_to = 'COMPANY')) AND (task.task_status = 'BILLABLE')) AND (
> person.id = task.person))>;
> inv_total : 
> 366
>
>
>
>
> The length of company persons (10) matches the actual number of db.person  
> entries that reference db.company.id=1
> however the inv_total (366)  which is now a simple count of tasks found is 
> wrong - it appears none of the filters have been applied ?
>
> This may be totally spurious but for what it's worth...
> I don't know much SQL but using SQLite manager in Firefox I stripped down 
> the SQL from the inv_details extract provided above and ran it as 
>
> Original stripped of its 'Set<((()))>' 
>
> SELECT task.person, person.name, task.title, task.start_time, 
> task.duration, task.task_type, task.task_status, task.charge_to, 
> task.charge, task.payment_status 
> FROM task, person 
> WHERE  ((task.person IN (28,37,46,51,52,63,70,81,87,95)) 
> AND (task.start_time <= '2016-09-19 00:00:00') 
> AND (task.charge_to = 'COMPANY') 
> AND (task.task_status = 'BILLABLE') 
> AND (person.id = task.person));
>
> returns nothing or never ends?
>  
>   
> whereas 
>
> SELECT task.id ,task.start_time
> FROM task
> WHERE ( task.start_time <= '2016-09-19 00:00:00')  
> AND (task.person IN(28,37,46,51,52,63,70,81,87,95) 
> AND (task.charge_to="COMPANY") 
> AND (task.payment_status="BILLABLE"));
>  
> returns 19 rows matchinig the criteria 
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to