On Tuesday, 14 July 2015 19:34:50 UTC-5, 黄祥 wrote: > > is it possible to have the query in sqlform.autocomplete.widgets? > *e.g. no error occured but the result is not expected* > table.customer.widget = SQLFORM.widgets.autocomplete(request, > db.customer.keywords, id_field = db.customer.id, db = > db(db.customer.keywords.contains(request) ) ) >
this should work. What you mean by result is not expected? > > *e.g. an error occured* > table.customer.widget = SQLFORM.widgets.autocomplete(request, > db.customer.keywords, id_field = db.customer.id, db = > db(db.customer.keywords.contains(r) for r in request) ) > error : > This could be q = reduce(lambda a,b: a|b, [db.customer.keywords.contains(r) for r in request]) widget = SQLFORM.widgets.autocomplete(request, db.customer.keywords, id_field = db.customer.id, db = db(q)) But I against using the autocomplete this way. Accessing the database every time you use the autocomplete is a big bottle neck. The best way it compile a cached dictionary of ids and corresponding words and than use the cached list instead of the db. > Error snapshot [image: help] > <https://127.0.0.1/admin/default/ticket/delivery/127.0.0.1.2015-07-15.07-33-12.3ccf3534-b59c-403b-b0b0-3f1f6fae9dc6#> > > > <class 'sqlite3.OperationalError'>(near "<": syntax error) > > > thanks and best regards, > stifan > -- 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.