Hello I have a query where the possibility for belongs can be a set of values or it can be empty. In case the set is empty I want the query to act as 1=1 and not 1=0, so all values would be selected.
Any suggestions?? Thank you This is my query selected = list(selected_values_str.split(",")) selected_int = tuple([int(i) for i in selected]) rows = db((db.counters.c_date >= datum_od) & (db.counters.c_user_inserted.belongs(selected_int)) & (db.counters.c_date <= datum_do) & (db.machines.m_status != 100)).select(#db.counters.c_machine_id, db.counters.c_total, db.counters.c_black, db.counters.c_color, db.counters.c_level1, db.counters.c_level2, db.counters.c_level3, db.counters.c_a3_color, db.counters.c_date, db.counters.c_datetime, db.counters.c_datetime_dataread, db.counters.c_scans, db.counters.c_note, db.machines.m_code, db.auth_user.first_name, db.auth_user.last_name, db.auth_user.email, left=[db.machines.on(db.counters.c_machine_id == db.machines.id), db.auth_user.on(db.counters.c_user_inserted== db.auth_user.id)] ).as_list() -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/32d92a1e-9964-4ed2-a76c-fe4b7d19fe54%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.