RE: Roadblock to custom qualifiers
RE: Roadblock to custom qualifiers
- Subject: RE: Roadblock to custom qualifiers
- From: <email@hidden>
- Date: Thu, 17 Jun 2004 10:54:11 +0200
- Thread-topic: Roadblock to custom qualifiers
Hi!
The actual code I came up with is:
protected boolean needsPadding(EOSQLExpression expression, String keyPath)
{
EOEntity entity = expression.entity();
EOAttribute attribute = attributeForPath(entity, keyPath);
return needsPadding(attribute);
}
protected boolean needsPadding(EOAttribute attribute)
{
String valueType = attribute.valueType();
return ((valueType != null) && (valueType.startsWith("c")));
}
protected String padSqlStringForValueAsNeeded(
EOSQLExpression expression,
String sqlStringForValue,
String keyPath)
{
EOEntity entity = expression.entity();
EOAttribute attribute = attributeForPath(entity, keyPath);
if (needsPadding(attribute))
{
sqlStringForValue = padSqlStringForValue(attribute, sqlStringForValue);
}
return sqlStringForValue;
}
protected String padSqlStringForValue(EOAttribute attribute, String sqlStringForValue)
{
// TODO: This is ugly as it supposes that we have an Oracle database.
// This should be handled by the plugin
return "RPAD(" + sqlStringForValue + ", " + attribute.width() + ")";
}
This has the distinct disadvantage of containing SQL that most likely is specific to Oracle. I thus resorted to code somewhat ugly, but database vendor independant. I generate SQL for a key-value qualifier and then extract the part representing the value from there.
Pierre.
-----Original Message-----
From: email@hidden
[mailto:email@hidden]On Behalf Of Pierre Bernard
Sent: Wednesday, June 16, 2004 10:44 AM
To: email@hidden
Subject: Roadblock to custom qualifiers
Hi!
I have just run into a limitation to ventures of writing custom qualifiers. Some database vendor specific behavior is not exposed by the adaptor though it is used internally.
The precise case I have run into involves fixed width CHAR attributes in an Oracle database. When querrying against such an attribute the SQL generated for an EOKeyValueQualifier pads the passed values using Oracle's RPAD function. This occurs in a method of the OraclePlugin. Yet there is no means of asking the plugin do do the same for custom qualifiers. What I would need, in a subclass of EOSQLExpression, is something along the lines of:
public String padSqlStringForValue(String sqlStringForValue, String keyPath)
{
EOAttribute attribute = entity.attributeForPath(keyPath);
String valueType = attribute.valueType();
if ((valueType != null) && (valueType.startsWith('0'))
{
sqlStringForValue = "RPAD(" + sqlStringForValue+ ", " + attribute.width() + ")";
}
return sqlStringForValue;
}
The actual behavior of this method would need to be dependant on the adaptor/database.
Pierre
**********************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender
of this message. (email@hidden)
This email message has been checked for the presence of computer
viruses; however this protection does not ensure this message is
virus free.
Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
**********************************************************************
_______________________________________________
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.
**********************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender
of this message. (email@hidden)
This email message has been checked for the presence of computer
viruses; however this protection does not ensure this message is
virus free.
Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
**********************************************************************
_______________________________________________
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.