Code very similar to this has worked in prior versions of Web2py.

pertinent code from controller:

PRODS = db.purchased_products
POPRODS = db.purchase_order_products

#base query just does a join
q = LOTS.product_id==PRODS.id

# find out if we need to add to the base query
field = request.get_vars.search_field.lower()
key = request.get_vars.search_key

# lengthy code validates keyset is a list of two dates where the earlier 
date is first

elif 'between' in field:
   # commented code fails as discussed below
    #                q &= ((LOTS.received_date>=keyset[0]) &
     #                     (LOTS.received_date<=keyset[1]))
# this fails also
                    q &= LOTS.received_date>=keyset[0]
                    q &= LOTS.received_date<=keyset[1]

adding these lines to dal.py at line 1752

        print '*' * 80
        for item in a:
            print item
        for key in b.keys():
            print 'key %s: item: %s' %(key, b[key])

produces this output from a[0], which is the query generated by dal
SELECT  product_lots.id, product_lots.received_date, 
product_lots.qty_received, purchased_products.purchased_product_name FROM 
product_lots, purchased_products WHERE ((((product_lots.product_id = 
purchased_products.id) AND (product_lots.received_date <= '4/1/13 and 
4/5/13')) AND (product_lots.is_active = 'T')) AND 
(purchased_products.is_active = 'T')) ORDER BY product_lots.received_date;

which has this defect in the where clause:  AND (product_lots.received_date 
<= '4/1/13 and 4/5/13'))
it should be: AND(product_lots.received_date >= '4/1/13') 
AND(product_lots.received_date <='4/5/13')

which raises this exception:


DataError: invalid input syntax for type date: "4/1/13 and 4/5/13"
LINE 1: ...d_products.id) AND (product_lots.received_date <= '4/1/13 an...
                                                             ^

-- 

--- 
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/groups/opt_out.


Reply via email to