If you are using SQLite and the field type was originally string a later changed to integer after inserting some records, note that SQLite will not actually change the column type, so the numbers will remain stored as strings, affecting the way comparisons are done.
See http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#SQLite. Anthony On Sunday, March 6, 2016 at 2:22:06 AM UTC-5, [email protected] wrote: > > the following lookup table stores prices based on a width and drop > > db.define_table('rb_prices', > Field('rb_width', type='integer'), > Field('rb_drop', type='integer'), > Field('rb_fabric_group', type='integer'), > Field('rb_price', type='integer')) > > when I submit the following query, it returns the correct result > > ((db.rb_prices.rb_width==2600) & (db.rb_prices.rb_drop==2600)) > > rb_prices.id > <http://127.0.0.1:8000/wbd/appadmin/select/db?orderby=rb_prices.id> > rb_prices.rb_width > <http://127.0.0.1:8000/wbd/appadmin/select/db?orderby=rb_prices.rb_width> > rb_prices.rb_drop > <http://127.0.0.1:8000/wbd/appadmin/select/db?orderby=rb_prices.rb_drop> > rb_prices.rb_fabric_group > <http://127.0.0.1:8000/wbd/appadmin/select/db?orderby=rb_prices.rb_fabric_group> > rb_prices.rb_price > <http://127.0.0.1:8000/wbd/appadmin/select/db?orderby=rb_prices.rb_price> > 7583 <http://127.0.0.1:8000/wbd/appadmin/update/db/rb_prices/7583> 2600 > 2600 0 266 > 7898 <http://127.0.0.1:8000/wbd/appadmin/update/db/rb_prices/7898> 2600 > 2600 3 471 > 8079 <http://127.0.0.1:8000/wbd/appadmin/update/db/rb_prices/8079> 2600 > 2600 2 421 > > but when I change the "==" to ">=" in both clauses, I get a spurious > result set where the server seems to only evaluate the first clause > *db.rb_prices.rb_width==2600.* > > > *((db.rb_prices.rb_width>=2600) & (db.rb_prices.rb_drop>=2600))* > > rb_prices.id > <http://127.0.0.1:8000/wbd/appadmin/select/db?orderby=rb_prices.id> > rb_prices.rb_width > <http://127.0.0.1:8000/wbd/appadmin/select/db?orderby=rb_prices.rb_width> > rb_prices.rb_drop > <http://127.0.0.1:8000/wbd/appadmin/select/db?orderby=rb_prices.rb_drop> > rb_prices.rb_fabric_group > <http://127.0.0.1:8000/wbd/appadmin/select/db?orderby=rb_prices.rb_fabric_group> > rb_prices.rb_price > <http://127.0.0.1:8000/wbd/appadmin/select/db?orderby=rb_prices.rb_price> > 7573 <http://127.0.0.1:8000/wbd/appadmin/update/db/rb_prices/7573> 2600 > 600 0 195 > 7574 <http://127.0.0.1:8000/wbd/appadmin/update/db/rb_prices/7574> 2600 > 800 0 203 > 7583 <http://127.0.0.1:8000/wbd/appadmin/update/db/rb_prices/7583> 2600 > 2600 0 266 > -- 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.

