Re: pgsql and like qualifier
Re: pgsql and like qualifier
- Subject: Re: pgsql and like qualifier
- From: Arturo PĂ©rez <email@hidden>
- Date: Fri, 30 Apr 2004 08:12:55 -0400
On Apr 30, 2004, at 7:35 AM, Greg Hulands wrote:
Hi,
I am trying to construct a qualifier for a search component and I am
having difficulty getting postgres plugin to generate the correct sql.
Here is the qualifier construction
private EOQualifier searchQualifier() {
NSMutableArray strings = new NSMutableArray();
NSMutableArray objs = new NSMutableArray();
if (useBarcode)
{
if (barcode != null)
{
strings.addObject("barcode caseInsensitiveLike '%s'");
objs.addObject(barcode);
}
}
if (useCat)
{
if (selectedCat != null) {
strings.addObject("category caseInsensitiveLike '%s'");
objs.addObject(selectedCat);
}
}
if (useDescription)
{
if (description != null) {
strings.addObject("name caseInsensitiveLike '%s'");
objs.addObject(description);
}
}
EOQualifier q =
EOQualifier.qualifierWithQualifierFormat(strings.componentsJoinedByStri
n
g(" AND "), objs);
return q;
}
What I am after is the sql to be "barcode like '%search_string%", but
when I do '%%%s%%' the sql it generates is "|%|%|%s|%|%"(barcode). The
qualifier does not return any results when it should.
Yep, the plugin or EOF is escaping the % character. I don't know why.
Try this instead (I'm not a fan of qualifierWithQualifierFormat too
SQL-like).
if (useBarcode)
{
if (barcode != null)
{
objs.addObject(new EOKeyValueQualifier("barcode",
EOQualifier.QualifierOperatorCaseInsensitiveLike,
barcode);
}
}
if (useCat)
{
if (selectedCat != null) {
objs.addObject(new EOKeyValueQualifier("category",
EOQualifier.QualifierOperatorCaseInsensitiveLike,
selectedCat);
}
}
if (useDescription)
{
if (description != null) {
objs.addObject(new EOKeyValueQualifier("name",
EOQualifier.QualifierOperatorCaseInsensitiveLike,
description);
}
}
EOQualifier q = new EOAndQualifier(objs);
return q;
----
WO in philadelphia - wanna cheesesteak with that?
Please visit webobjects.meetup.com.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.