On 2/5/07, Leandro Lucarella <[EMAIL PROTECTED]> wrote:
>
> 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.

I think the point of having an ORM is to have a bridge between a rdbms
and your objects so that you can utilize the best from both worlds. If
the "recommended" SO way is simply not to use the database except for
storing some bytes - why even bother with a RDMBS, cPickle is much
simpler and faster.

And yes, I'm not being serious. But I don't see why this would ever be
considered "the ORM way" of doing things. ORM is not the same as an
object database - it's just (as the name implies) a mapper.

Arnar

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to