On Thursday, March 15, 2018 at 7:59:42 AM UTC-4, Leonel Câmara wrote:
>
> I'm going to say it outright I don't think this should be supported.
>
> I don't think this should be considered a backwards compatibility problem, 
> because you're not using the DAL API you're just sending SQL in a string.
>

Agreed, it's not strictly a backward compatibility issue. Therefore, we 
don't necessarily need to restore the old functionality exactly (i.e., 
allow SQL strings to be passed to .select() and expect SQLTABLE to display 
the results), but it would be good to provide some means of achieving 
similar results.
 

> from pydal.objects import Expression
> dialect = db._adapter.dialect
>
> def group_concat(first, second, query_env={}):
>     return "GROUP_CONCAT(%s, '%s')" % (dialect.expand(first, query_env), 
> second)
>
> rischi_della_mansione = Expression(db, group_concat, db.RISCHI.id, ', ', 
> 'string')
>
>
> We need to define that the proper way to put custom SQL mixed with DAL 
> code is using Expression and document how to use it. SQL in strings isn't 
> acceptable, for that you use executesql.
>

The above is not part of the DAL public API either, and it is a rather 
cumbersome way to add custom SQL to a select. So, rather than simply 
documenting the above, it would be better if we could come up with a 
simplified API for adding custom SQL expressions to both queries  (i.e., 
"WHERE" clauses) and selects. In the short term, I suppose we could 
document the above as a workaround, but I'm not sure we want to commit to 
that as a public API that must be supported indefinitely (we then lose the 
freedom to change any of those exposed internal implementation details).

Anthony

-- 
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