DISQUS

johnreilly: subqueries: sqlite3 vs. mysql

  • a · 10 months ago
    You've probably figured it out but it's because you're using a hash of conditions and your syntax is not database agnostic
  • a · 10 months ago
    aka sqlite3 is being nice in letting you use NOT IN (NULL)
  • johnreilly · 10 months ago
    Interesting... So is it the case that sqlite3 doesn't support subqueries, and instead of throwing an error is just returning an empty set instead? Or does it simply have a different syntax for subqueries than mysql does?

    I see that using a conditions hash can lead to syntax that isn't portable, but how can you do a subquery in rails agnostically? Does Active Record have some magic up its sleeves that I don't know?

    Thanks for the response. (BTW, my "solution" was to just use mysql for the dev environment instead of sqlite3 because mysql gave me the result I wanted, and I'll be using mysql in production anyway.) ;-)

    -John