Uploaded image for project: 'NHibernate'
  1. NHibernate
  2. NH-2254

The new Linq provider generates LIKE statements in a form that is not supported by some databases

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: External Issue
    • Affects Version/s: 3.0.0.Alpha1
    • Fix Version/s: None
    • Component/s: Linq Provider
    • Labels:
      None

      Description

      For a query like db.Users.Where(user => user.Name.StartsWith("A")), the old provider generates:
      SELECT
      this_.id as id0_0_,
      this_.Name as Name0_0_
      FROM
      User this_
      WHERE
      this_.Name like @p0;
      @p0 = 'X%' Type: String (4000)

      ...which is consistent with
      session.CreateCriteria<User>().Add(Restrictions.Like("Name", "A", MatchMode.Start));

      The new provider generates the following:
      select
      user0_.id as id0_,
      user0_.Name as Name0_
      from
      User user0_
      where
      user0_.Name like (@p0+'%');
      @p0 = 'X' Type: String (4000)

      (note the parameter concatenation)

      This breaks in DBs like Informix, which do not support string concatenation with a parameter.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              diegose Diego Mijelshon
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Who's Looking?