-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from clio/table-alias-name
When the association scope is chained with conditions of other tables, the names of join tables are also added to `references_values`. It becomes impossible to identify the table alias name from the `references_values`. The PR provides a way to customize the table alias name when the default way cannot figure out the correct value.
- Loading branch information
Showing
5 changed files
with
22 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module JitPreloader | ||
VERSION = "0.2.4" | ||
VERSION = "0.2.5" | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,19 @@ | |
expect(contact_books.first.children).to include(child1, child2, child3) | ||
end | ||
end | ||
|
||
context "when preloading an aggregate for a child model scoped by another join table" do | ||
let!(:contact_book) { ContactBook.create(name: "The Yellow Pages") } | ||
let!(:contact1) { Company.create(name: "Without Email", contact_book: contact_book) } | ||
let!(:contact2) { Company.create(name: "With Blank Email", email_address: EmailAddress.new(address: ""), contact_book: contact_book) } | ||
let!(:contact3) { Company.create(name: "With Email", email_address: EmailAddress.new(address: "[email protected]"), contact_book: contact_book) } | ||
|
||
it "can handle queries" do | ||
contact_books = ContactBook.jit_preload.to_a | ||
expect(contact_books.first.companies_with_blank_email_address_count).to eq 1 | ||
expect(contact_books.first.companies_with_blank_email_address).to eq [contact2] | ||
end | ||
end | ||
end | ||
|
||
context "when preloading an aggregate as polymorphic" do | ||
|
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