OPENJPA-487: After simplifying SQL generation for LOCATE function, the function works on Firebird 2.1 (wow!).

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1143985 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Milosz Tylenda 2011-07-07 19:15:42 +00:00
parent ff4dc0c5ce
commit dae5ba7def
2 changed files with 16 additions and 11 deletions

View File

@ -384,16 +384,26 @@ public class FirebirdDictionary
}
/**
* Throw {@link UnsupportedException}. Firebird in version earlier than 2.1
* has no suitable function. Firebird 2.1 has the <code>POSITION</code>
* function but using it here results in errors like "data type unknown" or
* "expression evaluation not supported".
* On Firebird 2.1 return <code>POSITION(&lt;find&gt;, &lt;str&gt; [, &lt;start&gt;])<code>.
* On older versions throw {@link UnsupportedException} - no suitable function exists.
*/
@Override
public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find,
FilterValue start) {
throw new UnsupportedException(_loc.get("function-not-supported",
getClass(), "LOCATE"));
if (firebirdVersion < FB_VERSION_21) {
throw new UnsupportedException(_loc.get("function-not-supported", getClass(), "LOCATE"));
}
buf.append("POSITION(");
find.appendTo(buf);
buf.append(", ");
str.appendTo(buf);
if (start != null) {
buf.append(", ");
buf.append("CAST(");
start.appendTo(buf);
buf.append(" AS INTEGER)");
}
buf.append(")");
}
/**

View File

@ -848,11 +848,6 @@ In order to use many of JPQL functions with Firebird 1.5, Interbase UDFs
have to be available in the database.
</para>
</listitem>
<listitem>
<para>
<literal>LOCATE</literal> JPQL function is not supported.
</para>
</listitem>
</itemizedlist>
</section>
</section>