document.write('<link rel="stylesheet" href="http://gist.github.com/stylesheets/gist/embed.css"/>')





document.write('<div id=\"gist-33606\" class=\"gist\">\n  \n  \n    \n            \n\n      <div class=\"gist-file\">\n        <div class=\"gist-data gist-syntax\">\n          \n          \n          \n            <div class=\"gist-highlight\"><pre><div class=\"line\" id=\"LC1\">Subqueries are handled differently in sqlite3 and mysql?  <\/div><div class=\"line\" id=\"LC2\">Rails generates the same SQL, databases return different results.<\/div><div class=\"line\" id=\"LC3\">&nbsp;<\/div><div class=\"line\" id=\"LC4\">Using sqlite3:<\/div><div class=\"line\" id=\"LC5\">----------------<\/div><div class=\"line\" id=\"LC6\">&nbsp;<\/div><div class=\"line\" id=\"LC7\">&gt;&gt; Person.count<\/div><div class=\"line\" id=\"LC8\">&nbsp;&nbsp;SQL (0.2ms)   SELECT count(*) AS count_all FROM &quot;people&quot; <\/div><div class=\"line\" id=\"LC9\">=&gt; 2<\/div><div class=\"line\" id=\"LC10\">&nbsp;<\/div><div class=\"line\" id=\"LC11\">&gt;&gt; Person.all(:conditions =&gt; [&#39;id NOT IN (?)&#39;, []])<\/div><div class=\"line\" id=\"LC12\">&nbsp;&nbsp;Person Load (0.9ms)   SELECT * FROM &quot;people&quot; WHERE (id NOT IN (NULL)) <\/div><div class=\"line\" id=\"LC13\">=&gt; [#&lt;Person id: 1, ...&gt;, #&lt;Person id: 2, ...&gt;]<\/div><div class=\"line\" id=\"LC14\">&nbsp;<\/div><div class=\"line\" id=\"LC15\">&nbsp;<\/div><div class=\"line\" id=\"LC16\">&nbsp;<\/div><div class=\"line\" id=\"LC17\">Using mysql:<\/div><div class=\"line\" id=\"LC18\">----------------<\/div><div class=\"line\" id=\"LC19\">&nbsp;<\/div><div class=\"line\" id=\"LC20\">&gt;&gt; Person.count<\/div><div class=\"line\" id=\"LC21\">&nbsp;&nbsp;SQL (0.0ms)   SELECT count(*) AS count_all FROM `people` <\/div><div class=\"line\" id=\"LC22\">=&gt; 2<\/div><div class=\"line\" id=\"LC23\">&nbsp;<\/div><div class=\"line\" id=\"LC24\">&gt;&gt; Person.all(:conditions =&gt; [&#39;id NOT IN (?)&#39;, []])<\/div><div class=\"line\" id=\"LC25\">&nbsp;&nbsp;Person Load (0.0ms)   SELECT * FROM `people` WHERE (id NOT IN (NULL)) <\/div><div class=\"line\" id=\"LC26\">=&gt; []  <\/div><div class=\"line\" id=\"LC27\">&nbsp;<\/div><div class=\"line\" id=\"LC28\">&nbsp;<\/div><\/pre><\/div>\n          \n        <\/div>\n\n        <div class=\"gist-meta\">\n          <a href=\"http://gist.github.com/raw/33606/29b9bb949b02f72c19579e0201a9124a1d7f8bc1/gistfile1.txt\" style=\"float:right;\">view raw<\/a>\n          <a href=\"http://gist.github.com/33606#file_gistfile1.txt\" style=\"float:right;margin-right:10px;color:#666\">gistfile1.txt<\/a>\n          <a href=\"http://gist.github.com/33606\">This Gist<\/a> brought to you by <a href=\"http://github.com\">GitHub<\/a>.\n        <\/div>\n      <\/div>\n    \n  \n<\/div>\n')
