<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-8601579266012455634.post5018885840163838386..comments</id><updated>2011-03-21T21:09:06.401-07:00</updated><category term='flash'/><category term='icons'/><category term='pojo'/><category term='hosting'/><category term='scaling'/><category term='algorithms'/><category term='rubyonrails'/><category term='owl'/><category term='audio'/><category term='activewarehouse'/><category term='sudoku'/><category term='sqlserver'/><category term='git'/><category term='javapolis'/><category term='rails'/><category term='video'/><category term='email'/><category term='combinations'/><category term='xhtml'/><category term='mashup'/><category term='work'/><category term='googleio'/><category term='scripting'/><category term='thespringexperience'/><category term='facebook'/><category term='fixtures'/><category term='i18n'/><category term='aop'/><category term='information'/><category term='swoop'/><category term='aspectj'/><category term='tune'/><category term='networking'/><category term='crud'/><category term='rest'/><category term='io2011'/><category term='mvc'/><category term='controller'/><category term='interview'/><category term='qotd'/><category term='springwebflow'/><category term='Web Architecture'/><category term='dns'/><category term='groovy'/><category term='flickr'/><category term='view'/><category term='delicious'/><category term='rocketboom'/><category term='mac'/><category term='railsconf'/><category term='mp3'/><category term='framework'/><category term='j2ee'/><category term='owl1.1'/><category term='json'/><category term='subversion'/><category term='google'/><category term='pig'/><category term='Python'/><category term='activerecord'/><category term='alohaonrails'/><category term='messaging'/><category term='opendns'/><category term='song'/><category term='documentary'/><category term='osx'/><category term='consensus'/><category term='dhtml'/><category term='protege'/><category term='bigtable'/><category term='sparql'/><category term='tdd'/><category term='dataweb'/><category term='Crypto'/><category term='Social Networking'/><category term='Agile Programming'/><category term='springframework'/><category term='foaf'/><category term='math'/><category term='charts'/><category term='startup'/><category term='deployment'/><category term='arpanet'/><category term='music'/><category term='xslt'/><category term='cube'/><category term='bookmarks'/><category term='tivo'/><category term='netbeans'/><category term='inference'/><category term='railsconf07'/><category term='switchtower'/><category term='javascript extjs'/><category term='Ruby'/><category term='drools'/><category term='hioug'/><category term='health'/><category term='gmail'/><category term='html5 ruby rails'/><category term='openid'/><category term='magazine'/><category term='html5'/><category term='erlang'/><category term='web'/><category term='coucdb'/><category term='annotations'/><category term='deliciouslinks'/><category term='storage'/><category term='puzzle'/><category term='box2d'/><category term='ontology'/><category term='mapreduce'/><category term='hadoop'/><category term='presentation'/><category term='HTTP'/><category term='reasoner'/><category term='applications'/><category term='css'/><category term='folksonomy'/><category term='spring'/><category term='coordination'/><category term='migrations'/><category term='performance'/><category term='jess'/><category term='eclipse'/><category term='errorlytics'/><category term='chrome web store'/><category term='http://dmoz.org/Computers/Internet/On_the_Web/Weblogs/'/><category term='xp'/><category term='blogs'/><category term='grddl'/><category term='humor'/><category term='vanity'/><category term='contest'/><category term='acegi'/><category term='buttons'/><category term='business'/><category term='scala'/><category term='mysql'/><category term='soundboard'/><category term='semantic web'/><category term='esb'/><category term='XML'/><category term='algorithm'/><category term='cloud'/><category term='olap'/><category term='oracle'/><category term='microformats'/><category term='movie'/><category term='rspec'/><category term='dartlang'/><category term='expertspringmvc'/><category term='filesystem'/><category term='software'/><category term='#io2011'/><category term='html'/><category term='distributedsystems'/><category term='trendline'/><category term='newgame'/><category term='hjug'/><category term='jms'/><category term='xmlschema'/><category term='thespringframework'/><category term='w3c'/><category term='uri'/><category term='web design'/><category term='uh'/><category term='couchdb'/><category term='rules'/><category term='trust'/><category term='javascript'/><category term='fuse'/><category term='mule'/><category term='jena'/><category term='im'/><category term='postfix'/><category term='graphs'/><category term='conference'/><category term='graph'/><category term='Ontologies'/><category term='Programming'/><category term='browsers'/><category term='dart'/><category term='rdf'/><category term='transactions'/><category term='General'/><category term='browser'/><category term='forms'/><category term='aspects'/><category term='windows'/><category term='science'/><category term='database'/><category term='linux'/><category term='hibernate'/><category term='unittests'/><category term='php'/><category term='supermariobrothers'/><category term='ajax'/><category term='patterns'/><category term='tutorial'/><category term='timbl'/><category term='games'/><category term='oop'/><category term='petstore'/><category term='Java'/><category term='blog'/><category term='book'/><category term='springmvc'/><category term='nas'/><category term='regressionline'/><category term='Blogging'/><category term='pagination'/><category term='activeresource'/><category term='hawaii'/><category term='tags'/><category term='tests'/><category term='appengine'/><category term='radrails'/><category term='web2.0'/><category term='food'/><category term='search'/><category term='softwareengineering'/><category term='tagging'/><category term='model'/><category term='HTML amp; CSS'/><category term='spring.net'/><category term='capistrano'/><category term='data'/><category term='metadata'/><category term='pellet'/><title type='text'>Comments on Seth Ladd's Blog: Fixing Rails Pagination for SQL Server</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.sethladd.com/feeds/5018885840163838386/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8601579266012455634/5018885840163838386/comments/default'/><link rel='alternate' type='text/html' href='http://blog.sethladd.com/2007/07/fixing-rails-pagination-for-sql-server.html'/><author><name>Seth Ladd</name><uri>https://profiles.google.com/118397406534237711570</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-_3znrz32MsU/AAAAAAAAAAI/AAAAAAAAI_M/fidbIxEQoH8/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8601579266012455634.post-8397598785688437662</id><published>2011-03-21T21:09:06.402-07:00</published><updated>2011-03-21T21:09:06.402-07:00</updated><title type='text'>Bless you!  I was going crazy with this function a...</title><content type='html'>Bless you!  I was going crazy with this function adding extra back-slashes to the query, among other things.  I did have to make a couple changes to the snippet you posted - there seemed to be a couple extra &amp;quot;n&amp;quot;s in there:&lt;br&gt;&lt;br&gt;      def add_limit_offset!(sql, options)&lt;br&gt;        if options[:limit] and options[:offset]&lt;br&gt;          options[:order] ||= sql.match(&amp;#39;FROM (.*) &amp;#39;)[1] + &amp;#39;.id&amp;#39;&lt;br&gt;          sql.sub!(/ORDER BY.*$/i, &amp;#39;&amp;#39;)&lt;br&gt;          sql.sub!(/SELECT/i,&lt;br&gt;                  &amp;quot;SELECT row_number() over( order by #{options[:order]} ) as row_num, &amp;quot;)&lt;br&gt;          sql.replace(&amp;quot;SELECT TOP #{options[:limit]} * FROM (#{sql}) as tmp1 &amp;quot; +&lt;br&gt;                &amp;quot;WHERE row_num &amp;gt; #{options[:offset]}&amp;quot;)&lt;br&gt;        end&lt;br&gt;      end</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8601579266012455634/5018885840163838386/comments/default/8397598785688437662'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8601579266012455634/5018885840163838386/comments/default/8397598785688437662'/><link rel='alternate' type='text/html' href='http://blog.sethladd.com/2007/07/fixing-rails-pagination-for-sql-server.html?showComment=1300766946402#c8397598785688437662' title=''/><author><name>Sydney</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.sethladd.com/2007/07/fixing-rails-pagination-for-sql-server.html' ref='tag:blogger.com,1999:blog-8601579266012455634.post-5018885840163838386' source='http://www.blogger.com/feeds/8601579266012455634/posts/default/5018885840163838386' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-652145844'/></entry><entry><id>tag:blogger.com,1999:blog-8601579266012455634.post-5102863509264710874</id><published>2008-09-26T01:32:02.000-07:00</published><updated>2008-09-26T01:32:02.000-07:00</updated><title type='text'>Hi everyone,&lt;br&gt;&lt;br&gt;I posted an updated version of...</title><content type='html'>Hi everyone,&lt;br&gt;&lt;br&gt;I posted an updated version of the patch for SQL Server 2005 at my blog&lt;br&gt;&lt;br&gt;http://alexle.net/archives/292&lt;br&gt;&lt;br&gt;Cheers!&lt;br&gt;&lt;br&gt;Alex</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8601579266012455634/5018885840163838386/comments/default/5102863509264710874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8601579266012455634/5018885840163838386/comments/default/5102863509264710874'/><link rel='alternate' type='text/html' href='http://blog.sethladd.com/2007/07/fixing-rails-pagination-for-sql-server.html?showComment=1222417922000#c5102863509264710874' title=''/><author><name>Alex Le</name><uri>http://alexle.net</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.sethladd.com/2007/07/fixing-rails-pagination-for-sql-server.html' ref='tag:blogger.com,1999:blog-8601579266012455634.post-5018885840163838386' source='http://www.blogger.com/feeds/8601579266012455634/posts/default/5018885840163838386' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1514779454'/></entry><entry><id>tag:blogger.com,1999:blog-8601579266012455634.post-2814647870539125655</id><published>2007-12-28T06:37:39.000-08:00</published><updated>2007-12-28T06:37:39.000-08:00</updated><title type='text'>Bless you!  I was going crazy with this function a...</title><content type='html'>Bless you!  I was going crazy with this function adding extra back-slashes to the query, among other things.  I did have to make a couple changes to the snippet you posted - there seemed to be a couple extra &amp;quot;n&amp;quot;s in there:&lt;br&gt;&lt;br&gt;      def add_limit_offset!(sql, options)&lt;br&gt;        if options[:limit] and options[:offset]&lt;br&gt;          options[:order] ||= sql.match(&amp;#39;FROM (.*) &amp;#39;)[1] + &amp;#39;.id&amp;#39;&lt;br&gt;          sql.sub!(/ORDER BY.*$/i, &amp;#39;&amp;#39;)&lt;br&gt;          sql.sub!(/SELECT/i,&lt;br&gt;                  &amp;quot;SELECT row_number() over( order by #{options[:order]} ) as row_num, &amp;quot;)&lt;br&gt;          sql.replace(&amp;quot;SELECT TOP #{options[:limit]} * FROM (#{sql}) as tmp1 &amp;quot; +&lt;br&gt;                &amp;quot;WHERE row_num &amp;gt; #{options[:offset]}&amp;quot;)&lt;br&gt;        end&lt;br&gt;      end</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8601579266012455634/5018885840163838386/comments/default/2814647870539125655'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8601579266012455634/5018885840163838386/comments/default/2814647870539125655'/><link rel='alternate' type='text/html' href='http://blog.sethladd.com/2007/07/fixing-rails-pagination-for-sql-server.html?showComment=1198852659000#c2814647870539125655' title=''/><author><name>Sydney</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.sethladd.com/2007/07/fixing-rails-pagination-for-sql-server.html' ref='tag:blogger.com,1999:blog-8601579266012455634.post-5018885840163838386' source='http://www.blogger.com/feeds/8601579266012455634/posts/default/5018885840163838386' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1514779454'/></entry><entry><id>tag:blogger.com,1999:blog-8601579266012455634.post-3709808235335356320</id><published>2007-10-17T00:57:22.000-07:00</published><updated>2007-10-17T00:57:22.000-07:00</updated><title type='text'>Thanks for this!  I&amp;#39;ve been banging my head ag...</title><content type='html'>Thanks for this!  I&amp;#39;ve been banging my head against the wall, trying to get some intelligent support for :offset on SQL Server.&lt;br&gt;&lt;br&gt;I&amp;#39;m not sure what the deal is with the &amp;quot;n&amp;quot;s at the end of lines 10 and 11 (inside the strings).  I assumed they were typos, and it seems to work for me without them (but not with them).&lt;br&gt;&lt;br&gt;Also, your monkey-patch broke two things (that I could find): the ability to use :join or :include, and the ability to use just :limit (without :offset).&lt;br&gt;&lt;br&gt;I *think* that I fixed both of those bugs here: http://pastie.caboo.se/108142&lt;br&gt;&lt;br&gt;&lt;br&gt;module ActiveRecord&lt;br&gt;  module ConnectionAdapters&lt;br&gt;    class SQLServerAdapter&lt;br&gt;&lt;br&gt;      def add_limit_offset!(sql, options)&lt;br&gt;        if options[:limit] and options[:offset]&lt;br&gt;          options[:order] ||= sql.match(&amp;#39;FROM (\w*) &amp;#39;)[1] + &amp;#39;.id&amp;#39;&lt;br&gt;          sql.sub!(/ORDER BY.*$/i, &amp;#39;&amp;#39;)&lt;br&gt;          sql.sub!(/SELECT/i,&lt;br&gt;                   &amp;quot;SELECT row_number() over( order by #{options[:order]} ) as row_num, &amp;quot;)&lt;br&gt;          sql.replace(&amp;quot;select top #{options[:limit]} * from (#{sql}) as tmp_table1 &amp;quot; +&lt;br&gt;                      &amp;quot;where row_num &amp;gt; #{options[:offset]}&amp;quot;)&lt;br&gt;        elsif sql !~ /^\s*SELECT (@@|COUNT\()/i&lt;br&gt;          sql.sub!(/^\s*SELECT(\s+DISTINCT)?/i) do&lt;br&gt;            &amp;quot;SELECT#{$1} TOP #{options[:limit]}&amp;quot;&lt;br&gt;          end unless options[:limit].nil?&lt;br&gt;        end&lt;br&gt;      end&lt;br&gt;&lt;br&gt;    end&lt;br&gt;  end&lt;br&gt;end</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8601579266012455634/5018885840163838386/comments/default/3709808235335356320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8601579266012455634/5018885840163838386/comments/default/3709808235335356320'/><link rel='alternate' type='text/html' href='http://blog.sethladd.com/2007/07/fixing-rails-pagination-for-sql-server.html?showComment=1192607842000#c3709808235335356320' title=''/><author><name>nicholas a. evans</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.sethladd.com/2007/07/fixing-rails-pagination-for-sql-server.html' ref='tag:blogger.com,1999:blog-8601579266012455634.post-5018885840163838386' source='http://www.blogger.com/feeds/8601579266012455634/posts/default/5018885840163838386' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1514779454'/></entry><entry><id>tag:blogger.com,1999:blog-8601579266012455634.post-7290874040929114902</id><published>2007-10-11T23:04:42.000-07:00</published><updated>2007-10-11T23:04:42.000-07:00</updated><title type='text'>Tried it against ActiveScaffold and it breaks on s...</title><content type='html'>Tried it against ActiveScaffold and it breaks on some JOINS&lt;br&gt;&lt;br&gt;Also tried&lt;br&gt;&amp;quot;WITH MyTmp AS&lt;br&gt;(SELECT ROW_NUMBER() OVER( order by #{options[:order]} ) as row_num , * FROM (#{sql})&lt;br&gt;SELECT * FROM MyTmp where row-num between  #{options[:offset]} AND ( #{options[:offset]} +  #{options[:limit]} - 1)&amp;quot;&lt;br&gt;&lt;br&gt;But the OLE connector couldn&amp;#39;t understand - probably needs a native 2005 connector&lt;br&gt;&lt;br&gt;Cool idea though -</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8601579266012455634/5018885840163838386/comments/default/7290874040929114902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8601579266012455634/5018885840163838386/comments/default/7290874040929114902'/><link rel='alternate' type='text/html' href='http://blog.sethladd.com/2007/07/fixing-rails-pagination-for-sql-server.html?showComment=1192169082000#c7290874040929114902' title=''/><author><name>Dave</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.sethladd.com/2007/07/fixing-rails-pagination-for-sql-server.html' ref='tag:blogger.com,1999:blog-8601579266012455634.post-5018885840163838386' source='http://www.blogger.com/feeds/8601579266012455634/posts/default/5018885840163838386' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1514779454'/></entry></feed>
