I merged the following recently.

NH-3067: Linq - substring function does not work
https://github.com/nhibernate/nhibernate-core/pull/89


Unfortunately it causes problems on Firebird due to Firebird only
supporting integer literals, not expressions, for the substring index.
The problem is that if two-argument substring is used in linq, the
linq-provider constructs the third argument to hql substring as a
calculation based on column length and the start index. This is
because not all dialects support two argument substring.

One solution idea: If the third argument needs to be added by the linq
provider, pass Int32.MaxValue. Some databases seem to handle this
nicely, but at least DB2 claims this is an error.

Another idea: Make HQL substring() ALWAYS support either two or three
arguments. Some dialects already do this, and IMHO this is something
the dialect should abstract. This is easy if "all" databases support a
third argument that is either optional or can be specified as
Int32.MaxValue. Haven't checked this yet.


Btw, anyone using DB2? I suspect it's dialect's substring
implementation doesn't work at all.


Any input on this?


/Oskar

Reply via email to