Skip to content
This repository was archived by the owner on Mar 30, 2022. It is now read-only.
This repository was archived by the owner on Mar 30, 2022. It is now read-only.

AREL merge (&) causes redundant joins #42

@nikhilgupte

Description

@nikhilgupte

Without meta_where:

> (UserVote.joins(:user) & User.verified).to_sql
=> "SELECT `votes`.* FROM `votes` INNER JOIN `users` ON `users`.`id` = `votes`.`user_id` WHERE `votes`.`type` = 'UserVote' AND (verified_at is not null)"

With meta_where:

> (UserVote.joins(:user) & User.verified).to_sql
=> "SELECT `votes`.* FROM `votes` INNER JOIN `users` ON `users`.`id` = `votes`.`user_id` INNER JOIN `users` `voting_users_votes` ON `voting_users_votes`.`id` = `votes`.`user_id` WHERE `votes`.`type` = 'UserVote' AND (verified_at is not null)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions