1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib
Sarah Vessels f7d7a22d01
Add has_one through disable_joins
This is similar to the `disable_joins` option on `has_many :through`
associations applied to `has_one :through` associations. When
`disable_joins` is set Rails will create 2 or more queries to get
associations instead of generating a join.

```ruby
class Person
  belongs_to :dog
  has_one :veterinarian, through: :dog, disable_joins: true
end
```

Then instead of generating join SQL, two queries are used for `@person.veterinarian`:

```
SELECT "dogs"."id" FROM "dogs" WHERE "dogs"."person_id" = ?  [["person_id", 1]]
SELECT "veterinarians".* FROM "veterinarians" WHERE "veterinarians"."dog_id" = ?  [["dog_id", 1]]
```

Co-authored-by: Eileen M. Uchitelle <eileencodes@gmail.com>
2021-05-07 09:00:42 -04:00
..
active_record Add has_one through disable_joins 2021-05-07 09:00:42 -04:00
arel Arel::Visitors::Dot renders all attributes of some AST node types 2021-05-03 09:35:23 -04:00
rails/generators Used double quotes in template file for consistency. 2021-04-30 02:58:51 +05:30
active_record.rb Add option to skip joins for associations. 2021-04-19 11:17:31 -04:00
arel.rb