tamara6, el 5 de febrero a las 06:23 me escribiste:
>
> 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.
>
> Any tips?
This is not a good solution if you have a big set of data, but it's the
recommended way to do it in SO (the OO way):
smiths = [x for x in SOClass.select() if x.lastname.find('smith.') >= 0]
If your dataset is too big for doing this you could /optimize/ it with
SQLBuilder as Diez said.
--
LUCA - Leandro Lucarella - Usando Debian GNU/Linux Sid - GNU Generation
------------------------------------------------------------------------
E-Mail / JID: [EMAIL PROTECTED]
GPG Fingerprint: D9E1 4545 0F4B 7928 E82C 375D 4B02 0FE0 B08B 4FB2
GPG Key: gpg --keyserver pks.lugmen.org.ar --recv-keys B08B4FB2
------------------------------------------------------------------------
Si pusieramos la máquina de cortar boludos dentro de la máquina del tiempo
y se pusiera a cortar boludos históricos con retroactividad,
otra sería la historieta hoy.
-- Tato Bores
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---