From a2dab46cae35a06fd5c5500037177492a047c252 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Mon, 16 Jan 2012 21:14:34 +0000 Subject: Deprecate inferred JOINs with includes + SQL snippets. See the CHANGELOG for details. Fixes #950. --- activerecord/CHANGELOG.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'activerecord/CHANGELOG.md') diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index bba6447bf9..7173f44df6 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,5 +1,35 @@ ## Rails 4.0.0 (unreleased) ## +* In previous releases, the following would generate a single query with + an `OUTER JOIN comments`, rather than two separate queries: + + Post.includes(:comments) + .where("comments.name = 'foo'") + + This behaviour relies on matching SQL string, which is an inherently + flawed idea unless we write an SQL parser, which we do not wish to + do. + + Therefore, you must explicitly state which tables you reference, + when using SQL snippets: + + Post.includes(:comments) + .where("comments.name = 'foo'") + .references(:comments) + + Note that you do not need to explicitly specify references in the + following cases, as they can be automatically inferred: + + Post.where(comments: { name: 'foo' }) + Post.where('comments.name' => 'foo') + Post.order('comments.name') + + You also do not need to worry about this unless you are doing eager + loading. Basically, don't worry unless you see a deprecation warning + or (in future releases) an SQL error due to a missing JOIN. + + [Jon Leighton] + * Support for the `schema_info` table has been dropped. Please switch to `schema_migrations`. -- cgit v1.2.3