<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sagar Patil</title>
    <description>The latest articles on DEV Community by Sagar Patil (@sagar18041).</description>
    <link>https://dev.to/sagar18041</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F293653%2F6d5ac1e0-fd08-4f0d-8667-06f326095ce7.jpeg</url>
      <title>DEV Community: Sagar Patil</title>
      <link>https://dev.to/sagar18041</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sagar18041"/>
    <language>en</language>
    <item>
      <title>Rails 6.1 supports order DESC for find_each, find_in_batches, and in_batches</title>
      <dc:creator>Sagar Patil</dc:creator>
      <pubDate>Wed, 28 Oct 2020 05:09:44 +0000</pubDate>
      <link>https://dev.to/sagar18041/rails-6-1-supports-order-desc-for-findeach-findinbatches-and-inbatches-58mn</link>
      <guid>https://dev.to/sagar18041/rails-6-1-supports-order-desc-for-findeach-findinbatches-and-inbatches-58mn</guid>
      <description>&lt;p&gt;Rails 6.1 now supports &lt;em&gt;ORDER BY&lt;/em&gt; id for ActiveRecord batch processing methods like &lt;em&gt;find_each&lt;/em&gt;, &lt;em&gt;find_in_batches&lt;/em&gt;, and &lt;em&gt;in_batches&lt;/em&gt;. This would allow us to retrieve the records in ascending or descending order of ID.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Points to remember:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;em&gt;ORDER BY&lt;/em&gt; clause only works with the primary key column.&lt;/li&gt;
&lt;li&gt;Valid values for the &lt;em&gt;ORDER BY&lt;/em&gt; clause are &lt;em&gt;[:asc,:desc]&lt;/em&gt; and it’s case sensitive. &lt;/li&gt;
&lt;li&gt;If we use caps or title case (like DESC or Asc) then we’ll get an &lt;em&gt;ArgumentError&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://blog.bigbinary.com/2020/10/22/rails-6-1-supports-order-desc-for-find_each-find_in_batches-and-in_batches.html"&gt;Read more&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rails</category>
      <category>sql</category>
    </item>
  </channel>
</rss>
