Skip to content

Commit b2f14dc

Browse files
Dialects: Workaround to avoid an error in the Firebird "locate" function.
1 parent fbc88b0 commit b2f14dc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/NHibernate/Dialect/FirebirdDialect.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public FirebirdDialect()
123123
RegisterFunction("strlen", new StandardSQLFunction("strlen", NHibernateUtil.Int16));
124124
RegisterFunction("substr", new StandardSQLFunction("substr"));
125125
RegisterFunction("substrlen", new StandardSQLFunction("substrlen", NHibernateUtil.Int16));
126-
RegisterFunction("locate", new SQLFunctionTemplate(NHibernateUtil.Int32, "position(?1, ?2, ?3)"));
126+
RegisterFunction("locate", new SQLFunctionTemplate(NHibernateUtil.Int32, "position(?1, ?2, cast(?3 as int))")); // The cast is needed, at least in the case that ?3 is a named integer parameter, otherwise firebird will generate an error. We have a unit test to cover this potential firebird bug.
127127
RegisterFunction("replace", new StandardSafeSQLFunction("replace", NHibernateUtil.String, 3));
128128
//BLOB Functions
129129
RegisterFunction("string2blob", new StandardSQLFunction("string2blob"));

0 commit comments

Comments
 (0)