Lua's pattern matcher is too poor to make both cases work with a single pattern... you can make the second case work with
self:find_all_by_vehicle_type_and_oem{ "BMW 5 Series", "BMW" } A more general solution needs to retrofit orbit.model to use LPEG instead of string.gsub... it is not hard, but does introduce another dependency. -- Fabio Mascarenhas On Mon, Jan 25, 2010 at 3:10 PM, Ryan Pusztai <rpusz...@gmail.com> wrote: > On Wed, Jan 20, 2010 at 1:47 PM, Ryan Pusztai <rpusz...@gmail.com> wrote: >> >> Hi Fabio, >> >> On Mon, Jan 18, 2010 at 9:41 AM, Ryan Pusztai <rpusz...@gmail.com> wrote: >>>> >>>> Use >>>> string.gsub(condition, "([%w_]+)%s*([%a%s<>!=]+)%s*%?", >>>> >>>> In the line you quoted above. It is somewhat a dirty hack, but it will >>>> do for now, Lua's pattern matching is very limited. :-) >> >> OK I did more testing and now when I have two or more search criteria it >> errors out. >> Example Code: >>> >>> self:find_all( "vehicle_type = ? and oem = ?", { "BMW 5 Series", "BMW" } >>> ) >> >> Error: >>> >>> /usr/local/rocks//orbit/2.0.2-1/lua/orbit/model.lua:311: attempt to index >>> field '?' (a nil value) >>> stack traceback: >>> /usr/local/rocks//orbit/2.0.2-1/lua/orbit/model.lua:311: in function >>> [C]: in function 'gsub' >>> /usr/local/rocks//orbit/2.0.2-1/lua/orbit/model.lua:296: in function >>> 'build_query' >>> /usr/local/rocks//orbit/2.0.2-1/lua/orbit/model.lua:343: in function >>> (tail call): ? >>> ./search_controller.lua:44: in function <./search_controller.lua:28> >>> (tail call): ?/usr/local/rocks//orbit/2.0.2-1/lua/orbit/model.lua:311: >>> attempt to index field '?' (a nil value) >>> stack traceback: >>> /usr/local/rocks//coxpcall/1.13.0-1/lua/coxpcall.lua:24: in function >>> (tail call): ? >>> (tail call): ? >>> /usr/local/rocks//orbit/2.0.2-1/lua/orbit.lua:497: in function >>> (tail call): ? >>> (tail call): ? > > I hate to bug, but does anyone have any ideas on this? Thanks. > -- > Regards, > Ryan > > _______________________________________________ > Kepler-Project mailing list > Kepler-Project@lists.luaforge.net > http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project > http://www.keplerproject.org/ > _______________________________________________ Kepler-Project mailing list Kepler-Project@lists.luaforge.net http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project http://www.keplerproject.org/