Python/Gadfly and SQL wildcards

aaron_watters at my-deja.com aaron_watters at my-deja.com
Tue Jul 20 09:54:29 EDT 1999


In article <1279735665-4809662 at hypernet.com>,
  gmcm at hypernet.com wrote:
> Colm Rafferty writes:
>
> > Does anyone know how to implement the wildcard in gadfly SQL?
> > e.g.
> > Select * from table where fieldname = 'A*'
> > or
> > Select * from table where fieldname like 'A*'
> >
> > * does not work!
> > Though it does in other SQL languages
>
> In ANSI SQL, that would be "fieldname like 'A%'"
>
> Last I used Gadfly, it didn't support 'like'

Yes and no.  I actually posted an extension view for gadfly that
allowed a more powerful, but highly awkward, analogue to "LIKE"
which is based on the python "re" regular expression matching
library.

  http://www.egroups.com/group/gadfly-rdbms/149.html?raw=1

In this case you'd translate

  Select * from table where fieldname like 'A*'

into

  SELECT * FROM table WHERE EXISTS
  (SELECT * FROM re where table.fieldname=re.string AND
                          re.pattern='A.*')

Here we use a "virtual infinite table" re(string, pattern)
which "includes" all possible pairs where pattern is an "re"
syntax regular expression and string matches the pattern.

Unfortunately you have to use "EXISTS" to force the gadfly
optimizer to not screw up at present.  I'm working on fixing
the query engine and optimizer to work better with predicates
like LIKE and other extensions -- so I'm holding off on adding
features to the current way of doing things.

   Aaron Watters http://www.chordate.com

===

What's a chicken crossed with a dog?
dog chicken sine theta


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




More information about the Python-list mailing list