incorrect parameter replacement when one variable is the prefix of another

Description

Here's my code:

CurrentSession.CreateQuery(
@"FROM Opportunity o WHERE Id IN (:foo) OR Id = :foobar")
.SetParameterList("foo", new long[] { 1, 2 })
.SetInt64("foobar", 3)
.List<Opportunity>();

I get an exception that says that it can't find the variable foobar in the query, and the query so far looks something like this:

WHERE Id IN (:foo0_, :foo1_) OR Id = :foo0_, :foo1_bar

It's easy to see that :foo is replaced in both places, even in :foobar, resulting in the replaced value of foo and then bar staying there without being touched. Solution: ":foo" should be replaced with "foo", but, although ":foobar" starts with ":foo", it doesn't end there with a parenthesis or whitespace or any other special token delimiter, it has some more characters following in its name, therefore it's a different variable.

Environment

None

Activity

Show:

Fabio Maulo July 31, 2008 at 7:55 AM

Demostration in NHibernate.Test.NHSpecificTest.NH1253.Fixture.TestSamePartialName()

Fabio Maulo July 31, 2008 at 7:10 AM

Probably the bug was fixed in trunk some weeks ago.
Check it soon.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created July 30, 2008 at 11:31 AM
Updated July 31, 2008 at 7:55 AM
Resolved July 31, 2008 at 7:55 AM
Who's Looking?