Created
December 8, 2008 20:56
-
-
Save johnreilly/33606 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Subqueries are handled differently in sqlite3 and mysql? | |
Rails generates the same SQL, databases return different results. | |
Using sqlite3: | |
---------------- | |
>> Person.count | |
SQL (0.2ms) SELECT count(*) AS count_all FROM "people" | |
=> 2 | |
>> Person.all(:conditions => ['id NOT IN (?)', []]) | |
Person Load (0.9ms) SELECT * FROM "people" WHERE (id NOT IN (NULL)) | |
=> [#<Person id: 1, ...>, #<Person id: 2, ...>] | |
Using mysql: | |
---------------- | |
>> Person.count | |
SQL (0.0ms) SELECT count(*) AS count_all FROM `people` | |
=> 2 | |
>> Person.all(:conditions => ['id NOT IN (?)', []]) | |
Person Load (0.0ms) SELECT * FROM `people` WHERE (id NOT IN (NULL)) | |
=> [] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment