Just as a workaround for this common filter issue and for possible hidden similar problems, it could be created a WHERE clause like '1=1' when user does not specify any query at all.
It's dirty, but it seems to me it has no side effects. Can we state 'WHERE 1=1' is identical to no WHERE at all?. Regards. El sábado, 1 de noviembre de 2014 16:04:50 UTC+1, Anthony escribió: > > On Saturday, November 1, 2014 9:20:18 AM UTC-4, Niphlod wrote: >> >> the only sure thing about this whole thing is "once fixed, add a test for >> it". Leonel is right: we have two very different syntaxes for the same >> exact outcome and it makes difficult to track all variables when >> implementing (or fixing) a feature. >> > > Just to be clear, this is not two different syntaxes for the same outcome: > > In [1]: db()._select(db.person.name) > Out[1]: 'SELECT person.name FROM person;' > > In [2]: db(db.person)._select(db.person.name) > Out[2]: 'SELECT person.name FROM person WHERE (person.id IS NOT NULL);' > > Yes, the two queries will return the same results, but the two syntaxes > represent different logic at the Python level and consequently yield > different valid SQL statements. In fact, the first syntax is probably > preferable, as it more naturally represents what you really want (a table > select with no filtering) and more closely parallels the SQL you would > write in this case (i.e., no WHERE clause). It would be odd for the DAL api > to force the user to construct a completely superfluous query (WHERE > clause) when no filtering is desired. > > Also, note that db(db.person).select(db.person.name) doesn't work at all > for keyed tables (i.e., tables with a _primarkey attribute). In that case, > if the api required a query, you would be forced to write something like > db(db.person.pk1 > != None).select(db.person.name). > > 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

