pgsql and like qualifier
pgsql and like qualifier
- Subject: pgsql and like qualifier
- From: Greg Hulands <email@hidden>
- Date: Fri, 30 Apr 2004 21:35:41 +1000
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.componentsJoinedByStrin
g(" AND "), objs);
return q;
}
Here is the sql:
[2004-04-30 21:29:29 EST] <WorkerThread3> evaluateExpression:
<com.webobjects.jdbcadaptor.PostgresqlExpression: "SELECT
t0.annotation, t0.assetAccountID, t0.barcode, t0.catNumber,
t0.categoryID, t0.costAccountID, t0.expiry, t0.fotowireCode, t0.ibuy,
t0.isell, t0.istock, t0.isStorage, t0.minX, t0.minY, t0.name,
t0.productID, t0.reorderQty, t0.saleAccountID, t0.size, t0.supplierID,
t0.taxBoughtID, t0.taxSoldID, t0.visible, t0.webProduct, t0.xRes,
t0.yRes FROM Product t0 WHERE UPPER(t0.barcode) LIKE UPPER(?) ESCAPE
'|' ORDER BY t0.barcode ASC" withBindings: 1:"|%s"(barcode)>
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.
Is this a problem with my string qualifier format or a problem in the
postgres plugin. I have searched the archives but could not find
anything like this.
Any help is greatly appreciated.
Regards,
Greg
_______________________________________________
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.