Firebird parameter type casts

16 views
Skip to first unread message

Oskar Berggren

unread,
Jul 31, 2016, 5:02:54 PM7/31/16
to Amro El-Fakharany, nhibernate-...@googlegroups.com
Hi Amro,

Back in 2014 you did some work on the FirebirdClientDriver to make it add cast clauses around SQL parameters for Firebird. I'm hoping you may be able to weigh in on this:

Consider these two SQL statements:

 select ... from StringClass stringclas0_
    where stringclas0_.StringValue like @p0;

 select ... from StringClass stringclas0_
    where stringclas0_.StringValue = @p0;

Given the way the regexp in FirebirdClientDriver is written, a cast will be inserted for the parameter to like, but not for equality.

Without the cast, the second query fails with "arithmetic exception, numeric overflow, or string truncation" if the parameter value is longer than the length of the mapped column. Yes, if the query were executed, it would return an empty result set, but I believe that is preferable to getting an exception, considering that the parameter value may be entered by a user. GT and LT raise the same error.

What's your take on this? Any particular reason to exclude this from the regexp? Any suggestion?

Btw, the regexp from the driver is:
(?<![=<>]\s?|first\s?|skip\s?|between\s|between\s@\bp\w+\b\sand\s)@\bp\w+\b(?!\s?[=<>])


/Oskar
Reply all
Reply to author
Forward
0 new messages