-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: mssql2005: SetFirstResult vs. "order by" (bug?)
PostPosted: Fri Jul 24, 2009 8:46 pm 
Newbie

Joined: Sun Jan 25, 2009 4:37 pm
Posts: 3
When using sql queries with "order by" immediately followed by a line break, the mssql2005 dialect breaks the SetFirstResult/SetMaxResults query. From MsSql2005Dialect.cs (line 53, NHibernate 2.0.1):

Code:
int orderIndex = querySqlString.LastIndexOfCaseInsensitive(" order by ");


This part fails if "order by" is followed by '\n' or '\r', and I assume that it fails for any whitespace character other than space.

MS SQL 2008 accepts '\n' as valid whitespace characters at this point. However, I'm not sure whether it is legal to pass these characters to NHibernate, so it might be a bug on my side.


Top
 Profile  
 
 Post subject: Re: mssql2005: SetFirstResult vs. "order by" (bug?)
PostPosted: Fri Jul 24, 2009 10:13 pm 
Newbie

Joined: Sun Jan 25, 2009 4:37 pm
Posts: 3
The same line also breaks ordered subqueries:
Code:
select a.id from A a where a.id = (select top 1 b.id from B b order by b.x)

In this case, the "order by" of the subquery is cut off and reused, even including the closing parenthesis.

Right now, I have to exploit the first bug (hide the subquery "order by" by appending '\n') to circumvent the second one.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.