On Monday 05 February 2007 15:23, tamara6 wrote: > In another thread, this was said: > >>So something that actually had me hung up for a long time was how to > >> do something like this: > >> "select * from Someplace where something like '%word%' " > >> > > >The Django docs show how to do this clearly with the keyword CONTAINS > > >and shows the SQL equivalent. > > > >that is a common misconception of ORM I have to agree that SO takes it a > >little to far into the Object part but you need to stop thinking of > > queries that is not how a ORM is supposed to work, you don't do select * > > or select col1,col2,col3, you ask for the object Foo and it will return > > that object you will ask for all objects of type foo that have lastname = > > var. > > I would like to know what the proper ORM way of searching for all > objects with lastnames that contain "smith." I'd like it to return > names like Smithson, Blacksmith, and Besmither, as well as just plain > Smith. > > I know how to do this with a %like% search in sql, but, I'd like to do > it correctly with SO.
Person.select(LIKE(func.LOWER(Person.q.name), "%%%s%%" % name.lower()))) Diez --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

