|
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-17 22:25:51
|
[ http://216.121.112.228/browse/NH-2415?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21108#action_21108 ]
Fabio Maulo commented on NH-2415:
---------------------------------
I would have a failing test.
The direction is this:
http://nhforge.org/blogs/nhibernate/archive/2008/10/04/the-best-way-to-solve-nhibernate-bugs-submit-good-unit-test.aspx
> HQL parameters not converted correctly to SQL
> ---------------------------------------------
>
> Key: NH-2415
> URL: http://216.121.112.228/browse/NH-2415
> Project: NHibernate
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.1.2.GA, 3.0.0.Beta2
> Reporter: Brian Berns
> Priority: Major
>
> Parameters added to an HQL query are jumbled in the resulting SQL. I have created a simple test case that demonstrates this problem using the BasicClassFixture:
> [Test]
> public void TestHQL()
> {
> var bc = InsertBasicClass(1);
> using (var session = OpenSession())
> using (var trans = session.BeginTransaction())
> {
> var hql = "from BasicClass bc where (bc.StringProperty = :prop) and (bc.StringMap[:key] = :value)";
> bc = session.CreateQuery(hql)
> .SetParameter("prop", "string property")
> .SetParameter("key", "keyZero")
> .SetParameter("value", "string zero")
> .UniqueResult<BasicClass>();
> Assert.NotNull(bc);
> session.Delete(bc);
> trans.Commit();
> }
> }
> The generated SQL is:
> exec sp_executesql N'select basicclass0_.id as id16_, basicclass0_.char_p as char2_16_, basicclass0_.class_p as class3_16_, basicclass0_.cinfo_p as cinfo4_16_, basicclass0_.dtm_p as dtm5_16_, basicclass0_.shrt_p as shrt6_16_, basicclass0_.int_p as int7_16_, basicclass0_.lng_p as lng8_16_, basicclass0_.flt_p as flt9_16_, basicclass0_.str_p as str10_16_, basicclass0_.ticks_p as ticks11_16_, basicclass0_.tf_p as tf12_16_, basicclass0_.yn_p as yn13_16_, basicclass0_.priv_fld as priv14_16_ from bc basicclass0_, bc_stmap stringmap1_ where basicclass0_.id=stringmap1_.bc_id and stringmap1_.strm_idx = @p0 and basicclass0_.str_p=@p1 and stringmap1_.str_val=@p2',N'@p0 nvarchar(4000),@p1 nvarchar(10),@p2 nvarchar(4000)',@p0=N'string property',@p1=N'keyZero',@p2=N'string zero'
> This query returns no rows when it should return exactly one. This is because @p0 and @p1 have been swapped.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|