{"action":"created","comment":{"url":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/comments/35544481","id":35544481,"diff_hunk":"@@ -417,7 +417,113 @@ class Cat < ActiveRecord::Base\n       it \"should find the 3 tags that are related to dogs record\" do\n         Tag.search_for('baz').length.should == 3\n       end\n+    end\n+\n+\n+    context 'querying a :has_many => :through relation with alternate name' do\n+\n+      before do\n+\n+        # Create some tables\n+        ActiveRecord::Migration.create_table(:zaps) { |t| t.integer :moo_id; t.integer :paz_id }\n+        ActiveRecord::Migration.create_table(:pazs) { |t| t.string :related }\n+        ActiveRecord::Migration.create_table(:moos) { |t| t.string :foo }   \n+\n+        # The related classes\n+        class Zap < ActiveRecord::Base; belongs_to :paz; belongs_to :moo; end\n+        class Paz < ActiveRecord::Base; has_many :other_zaps, :class_name => \"Zap\", :foreign_key => :paz_id; end\n+\n+        # The class on which to call search_for\n+        class Moo < ActiveRecord::Base\n+          has_many :zaps\n+          has_many :pazs, :through => :zaps\n+\n+          scoped_search :in => :pazs, :on => :related\n+        end\n+\n+        @moo_1 = Moo.create!(:foo => 'foo')\n+        @moo_2 = Moo.create!(:foo => 'foo too')\n+        @moo_3 = Moo.create!(:foo => 'foo three')\n+\n+        @paz_1 = Paz.create(:related => 'paz')\n+        @paz_2 = Paz.create(:related => 'paz too!')\n+\n+        @bar_1 = Zap.create!(:moo => @moo_1, :paz => @paz_1)\n+        @bar_2 = Zap.create!(:moo => @moo_1)\n+        @bar_3 = Zap.create!(:moo => @moo_2, :paz => @paz_1)\n+        @bar_3 = Zap.create!(:moo => @moo_2, :paz => @paz_2)\n+        @bar_3 = Zap.create!(:moo => @moo_2, :paz => @paz_2)\n+        @bar_4 = Zap.create!(:moo => @moo_3)\n+      end\n+\n+      after do\n+        ActiveRecord::Migration.drop_table(:pazs)\n+        ActiveRecord::Migration.drop_table(:zaps)\n+        ActiveRecord::Migration.drop_table(:moos)\n+      end\n+\n+      it \"should find the two records that are related to a paz record\" do\n+        Moo.search_for('paz').length.should == 2\n+      end\n \n+      it \"should find the two records that are related to a paz record\" do\n+        Moo.search_for('related=paz AND related=\"paz too!\"').length.should == 1\n+      end\n+    end\n+\n+\n+    context 'querying a :has_many => :through relation with modules' do\n+\n+      before do\n+\n+        # Create some tables with namespaces\n+        ActiveRecord::Migration.create_table(:zan_mars) { |t| t.integer :koo_id; t.integer :baz_id }\n+        ActiveRecord::Migration.create_table(:zan_bazs) { |t| t.string :related }\n+        ActiveRecord::Migration.create_table(:zan_koos) { |t| t.string :foo }   \n+\n+        # The related classes\n+        module Zan; class Mar < ActiveRecord::Base; belongs_to :baz; belongs_to :koo; self.table_name = \"zan_mars\"; end; end\n+        module Zan; class Baz < ActiveRecord::Base; has_many :mars; self.table_name = \"zan_bazs\"; end; end\n+\n+        # The class on which to call search_for\n+        module Zan\n+          class Koo < ActiveRecord::Base\n+            has_many :mars, :class_name => \"Zan::Mar\"\n+            has_many :bazs, :through => :mars\n+            self.table_name = \"zan_koos\"\n+\n+            scoped_search :in => :bazs, :on => :related\n+          end\n+        end\n+\n+        @koo_1 = Zan::Koo.create!(:foo => 'foo')\n+        @koo_2 = Zan::Koo.create!(:foo => 'foo too')\n+        @koo_3 = Zan::Koo.create!(:foo => 'foo three')\n+\n+        @baz_1 = Zan::Baz.create(:related => 'baz')\n+        @baz_2 = Zan::Baz.create(:related => 'baz too!')\n+\n+        @bar_1 = Zan::Mar.create!(:koo => @koo_1, :baz => @baz_1)\n+        @bar_2 = Zan::Mar.create!(:koo => @koo_1)\n+        @bar_3 = Zan::Mar.create!(:koo => @koo_2, :baz => @baz_1)\n+        @bar_3 = Zan::Mar.create!(:koo => @koo_2, :baz => @baz_2)\n+        @bar_3 = Zan::Mar.create!(:koo => @koo_2, :baz => @baz_2)\n+        @bar_4 = Zan::Mar.create!(:koo => @koo_3)\n+      end\n+\n+      after do\n+        ActiveRecord::Migration.drop_table(:zan_bazs)\n+        ActiveRecord::Migration.drop_table(:zan_mars)\n+        ActiveRecord::Migration.drop_table(:zan_koos)\n+      end\n+\n+      it \"should find the two records that are related to a baz record\" do\n+        Zan::Koo.search_for('baz').length.should == 2\n+      end\n+\n+      it \"should find the two records that are related to a baz record\" do","path":"spec/integration/relation_querying_spec.rb","position":null,"original_position":108,"commit_id":"5dd9f6bfd2aa5f32f1a886434cf77bebb9b2fa51","original_commit_id":"6f92a94a7d23f532800d985e478aa74309a1ab68","user":{"login":"johnpmitsch","id":5964462,"avatar_url":"https://avatars.githubusercontent.com/u/5964462?v=3","gravatar_id":"","url":"https://api.github.com/users/johnpmitsch","html_url":"https://github.com/johnpmitsch","followers_url":"https://api.github.com/users/johnpmitsch/followers","following_url":"https://api.github.com/users/johnpmitsch/following{/other_user}","gists_url":"https://api.github.com/users/johnpmitsch/gists{/gist_id}","starred_url":"https://api.github.com/users/johnpmitsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnpmitsch/subscriptions","organizations_url":"https://api.github.com/users/johnpmitsch/orgs","repos_url":"https://api.github.com/users/johnpmitsch/repos","events_url":"https://api.github.com/users/johnpmitsch/events{/privacy}","received_events_url":"https://api.github.com/users/johnpmitsch/received_events","type":"User","site_admin":false},"body":"thanks, updated","created_at":"2015-07-27T14:55:15Z","updated_at":"2015-07-27T14:55:15Z","html_url":"https://github.com/wvanbergen/scoped_search/pull/133#discussion_r35544481","pull_request_url":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/133","_links":{"self":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/comments/35544481"},"html":{"href":"https://github.com/wvanbergen/scoped_search/pull/133#discussion_r35544481"},"pull_request":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/133"}}},"pull_request":{"url":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/133","id":39822818,"html_url":"https://github.com/wvanbergen/scoped_search/pull/133","diff_url":"https://github.com/wvanbergen/scoped_search/pull/133.diff","patch_url":"https://github.com/wvanbergen/scoped_search/pull/133.patch","issue_url":"https://api.github.com/repos/wvanbergen/scoped_search/issues/133","number":133,"state":"open","locked":false,"title":"changed has_many through to use association when building query","user":{"login":"johnpmitsch","id":5964462,"avatar_url":"https://avatars.githubusercontent.com/u/5964462?v=3","gravatar_id":"","url":"https://api.github.com/users/johnpmitsch","html_url":"https://github.com/johnpmitsch","followers_url":"https://api.github.com/users/johnpmitsch/followers","following_url":"https://api.github.com/users/johnpmitsch/following{/other_user}","gists_url":"https://api.github.com/users/johnpmitsch/gists{/gist_id}","starred_url":"https://api.github.com/users/johnpmitsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnpmitsch/subscriptions","organizations_url":"https://api.github.com/users/johnpmitsch/orgs","repos_url":"https://api.github.com/users/johnpmitsch/repos","events_url":"https://api.github.com/users/johnpmitsch/events{/privacy}","received_events_url":"https://api.github.com/users/johnpmitsch/received_events","type":"User","site_admin":false},"body":"Fixes #131 ","created_at":"2015-07-13T15:17:23Z","updated_at":"2015-07-27T14:55:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eec1baf756bd94baa57666e8b1c4a8f3acdcb7a9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/133/commits","review_comments_url":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/133/comments","review_comment_url":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wvanbergen/scoped_search/issues/133/comments","statuses_url":"https://api.github.com/repos/wvanbergen/scoped_search/statuses/5dd9f6bfd2aa5f32f1a886434cf77bebb9b2fa51","head":{"label":"johnpmitsch:has_many_through","ref":"has_many_through","sha":"5dd9f6bfd2aa5f32f1a886434cf77bebb9b2fa51","user":{"login":"johnpmitsch","id":5964462,"avatar_url":"https://avatars.githubusercontent.com/u/5964462?v=3","gravatar_id":"","url":"https://api.github.com/users/johnpmitsch","html_url":"https://github.com/johnpmitsch","followers_url":"https://api.github.com/users/johnpmitsch/followers","following_url":"https://api.github.com/users/johnpmitsch/following{/other_user}","gists_url":"https://api.github.com/users/johnpmitsch/gists{/gist_id}","starred_url":"https://api.github.com/users/johnpmitsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnpmitsch/subscriptions","organizations_url":"https://api.github.com/users/johnpmitsch/orgs","repos_url":"https://api.github.com/users/johnpmitsch/repos","events_url":"https://api.github.com/users/johnpmitsch/events{/privacy}","received_events_url":"https://api.github.com/users/johnpmitsch/received_events","type":"User","site_admin":false},"repo":{"id":38892994,"name":"scoped_search","full_name":"johnpmitsch/scoped_search","owner":{"login":"johnpmitsch","id":5964462,"avatar_url":"https://avatars.githubusercontent.com/u/5964462?v=3","gravatar_id":"","url":"https://api.github.com/users/johnpmitsch","html_url":"https://github.com/johnpmitsch","followers_url":"https://api.github.com/users/johnpmitsch/followers","following_url":"https://api.github.com/users/johnpmitsch/following{/other_user}","gists_url":"https://api.github.com/users/johnpmitsch/gists{/gist_id}","starred_url":"https://api.github.com/users/johnpmitsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnpmitsch/subscriptions","organizations_url":"https://api.github.com/users/johnpmitsch/orgs","repos_url":"https://api.github.com/users/johnpmitsch/repos","events_url":"https://api.github.com/users/johnpmitsch/events{/privacy}","received_events_url":"https://api.github.com/users/johnpmitsch/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/johnpmitsch/scoped_search","description":"Easily search you ActiveRecord models with a simple query language that converts to SQL.","fork":true,"url":"https://api.github.com/repos/johnpmitsch/scoped_search","forks_url":"https://api.github.com/repos/johnpmitsch/scoped_search/forks","keys_url":"https://api.github.com/repos/johnpmitsch/scoped_search/keys{/key_id}","collaborators_url":"https://api.github.com/repos/johnpmitsch/scoped_search/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/johnpmitsch/scoped_search/teams","hooks_url":"https://api.github.com/repos/johnpmitsch/scoped_search/hooks","issue_events_url":"https://api.github.com/repos/johnpmitsch/scoped_search/issues/events{/number}","events_url":"https://api.github.com/repos/johnpmitsch/scoped_search/events","assignees_url":"https://api.github.com/repos/johnpmitsch/scoped_search/assignees{/user}","branches_url":"https://api.github.com/repos/johnpmitsch/scoped_search/branches{/branch}","tags_url":"https://api.github.com/repos/johnpmitsch/scoped_search/tags","blobs_url":"https://api.github.com/repos/johnpmitsch/scoped_search/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/johnpmitsch/scoped_search/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/johnpmitsch/scoped_search/git/refs{/sha}","trees_url":"https://api.github.com/repos/johnpmitsch/scoped_search/git/trees{/sha}","statuses_url":"https://api.github.com/repos/johnpmitsch/scoped_search/statuses/{sha}","languages_url":"https://api.github.com/repos/johnpmitsch/scoped_search/languages","stargazers_url":"https://api.github.com/repos/johnpmitsch/scoped_search/stargazers","contributors_url":"https://api.github.com/repos/johnpmitsch/scoped_search/contributors","subscribers_url":"https://api.github.com/repos/johnpmitsch/scoped_search/subscribers","subscription_url":"https://api.github.com/repos/johnpmitsch/scoped_search/subscription","commits_url":"https://api.github.com/repos/johnpmitsch/scoped_search/commits{/sha}","git_commits_url":"https://api.github.com/repos/johnpmitsch/scoped_search/git/commits{/sha}","comments_url":"https://api.github.com/repos/johnpmitsch/scoped_search/comments{/number}","issue_comment_url":"https://api.github.com/repos/johnpmitsch/scoped_search/issues/comments{/number}","contents_url":"https://api.github.com/repos/johnpmitsch/scoped_search/contents/{+path}","compare_url":"https://api.github.com/repos/johnpmitsch/scoped_search/compare/{base}...{head}","merges_url":"https://api.github.com/repos/johnpmitsch/scoped_search/merges","archive_url":"https://api.github.com/repos/johnpmitsch/scoped_search/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/johnpmitsch/scoped_search/downloads","issues_url":"https://api.github.com/repos/johnpmitsch/scoped_search/issues{/number}","pulls_url":"https://api.github.com/repos/johnpmitsch/scoped_search/pulls{/number}","milestones_url":"https://api.github.com/repos/johnpmitsch/scoped_search/milestones{/number}","notifications_url":"https://api.github.com/repos/johnpmitsch/scoped_search/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/johnpmitsch/scoped_search/labels{/name}","releases_url":"https://api.github.com/repos/johnpmitsch/scoped_search/releases{/id}","created_at":"2015-07-10T17:24:35Z","updated_at":"2015-07-10T17:24:36Z","pushed_at":"2015-07-27T14:54:19Z","git_url":"git://github.com/johnpmitsch/scoped_search.git","ssh_url":"git@github.com:johnpmitsch/scoped_search.git","clone_url":"https://github.com/johnpmitsch/scoped_search.git","svn_url":"https://github.com/johnpmitsch/scoped_search","homepage":"","size":769,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wvanbergen:master","ref":"master","sha":"5dcd928f8cfdd39408f5492c12aa39de630bab72","user":{"login":"wvanbergen","id":15870,"avatar_url":"https://avatars.githubusercontent.com/u/15870?v=3","gravatar_id":"","url":"https://api.github.com/users/wvanbergen","html_url":"https://github.com/wvanbergen","followers_url":"https://api.github.com/users/wvanbergen/followers","following_url":"https://api.github.com/users/wvanbergen/following{/other_user}","gists_url":"https://api.github.com/users/wvanbergen/gists{/gist_id}","starred_url":"https://api.github.com/users/wvanbergen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wvanbergen/subscriptions","organizations_url":"https://api.github.com/users/wvanbergen/orgs","repos_url":"https://api.github.com/users/wvanbergen/repos","events_url":"https://api.github.com/users/wvanbergen/events{/privacy}","received_events_url":"https://api.github.com/users/wvanbergen/received_events","type":"User","site_admin":false},"repo":{"id":37427,"name":"scoped_search","full_name":"wvanbergen/scoped_search","owner":{"login":"wvanbergen","id":15870,"avatar_url":"https://avatars.githubusercontent.com/u/15870?v=3","gravatar_id":"","url":"https://api.github.com/users/wvanbergen","html_url":"https://github.com/wvanbergen","followers_url":"https://api.github.com/users/wvanbergen/followers","following_url":"https://api.github.com/users/wvanbergen/following{/other_user}","gists_url":"https://api.github.com/users/wvanbergen/gists{/gist_id}","starred_url":"https://api.github.com/users/wvanbergen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wvanbergen/subscriptions","organizations_url":"https://api.github.com/users/wvanbergen/orgs","repos_url":"https://api.github.com/users/wvanbergen/repos","events_url":"https://api.github.com/users/wvanbergen/events{/privacy}","received_events_url":"https://api.github.com/users/wvanbergen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wvanbergen/scoped_search","description":"Easily search you ActiveRecord models with a simple query language that converts to SQL.","fork":false,"url":"https://api.github.com/repos/wvanbergen/scoped_search","forks_url":"https://api.github.com/repos/wvanbergen/scoped_search/forks","keys_url":"https://api.github.com/repos/wvanbergen/scoped_search/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wvanbergen/scoped_search/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wvanbergen/scoped_search/teams","hooks_url":"https://api.github.com/repos/wvanbergen/scoped_search/hooks","issue_events_url":"https://api.github.com/repos/wvanbergen/scoped_search/issues/events{/number}","events_url":"https://api.github.com/repos/wvanbergen/scoped_search/events","assignees_url":"https://api.github.com/repos/wvanbergen/scoped_search/assignees{/user}","branches_url":"https://api.github.com/repos/wvanbergen/scoped_search/branches{/branch}","tags_url":"https://api.github.com/repos/wvanbergen/scoped_search/tags","blobs_url":"https://api.github.com/repos/wvanbergen/scoped_search/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wvanbergen/scoped_search/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wvanbergen/scoped_search/git/refs{/sha}","trees_url":"https://api.github.com/repos/wvanbergen/scoped_search/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wvanbergen/scoped_search/statuses/{sha}","languages_url":"https://api.github.com/repos/wvanbergen/scoped_search/languages","stargazers_url":"https://api.github.com/repos/wvanbergen/scoped_search/stargazers","contributors_url":"https://api.github.com/repos/wvanbergen/scoped_search/contributors","subscribers_url":"https://api.github.com/repos/wvanbergen/scoped_search/subscribers","subscription_url":"https://api.github.com/repos/wvanbergen/scoped_search/subscription","commits_url":"https://api.github.com/repos/wvanbergen/scoped_search/commits{/sha}","git_commits_url":"https://api.github.com/repos/wvanbergen/scoped_search/git/commits{/sha}","comments_url":"https://api.github.com/repos/wvanbergen/scoped_search/comments{/number}","issue_comment_url":"https://api.github.com/repos/wvanbergen/scoped_search/issues/comments{/number}","contents_url":"https://api.github.com/repos/wvanbergen/scoped_search/contents/{+path}","compare_url":"https://api.github.com/repos/wvanbergen/scoped_search/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wvanbergen/scoped_search/merges","archive_url":"https://api.github.com/repos/wvanbergen/scoped_search/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wvanbergen/scoped_search/downloads","issues_url":"https://api.github.com/repos/wvanbergen/scoped_search/issues{/number}","pulls_url":"https://api.github.com/repos/wvanbergen/scoped_search/pulls{/number}","milestones_url":"https://api.github.com/repos/wvanbergen/scoped_search/milestones{/number}","notifications_url":"https://api.github.com/repos/wvanbergen/scoped_search/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wvanbergen/scoped_search/labels{/name}","releases_url":"https://api.github.com/repos/wvanbergen/scoped_search/releases{/id}","created_at":"2008-07-26T13:46:16Z","updated_at":"2015-07-17T14:57:33Z","pushed_at":"2015-07-27T14:54:20Z","git_url":"git://github.com/wvanbergen/scoped_search.git","ssh_url":"git@github.com:wvanbergen/scoped_search.git","clone_url":"https://github.com/wvanbergen/scoped_search.git","svn_url":"https://github.com/wvanbergen/scoped_search","homepage":"","size":1644,"stargazers_count":165,"watchers_count":165,"language":"Ruby","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":14,"forks":39,"open_issues":14,"watchers":165,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/133"},"html":{"href":"https://github.com/wvanbergen/scoped_search/pull/133"},"issue":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/issues/133"},"comments":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/issues/133/comments"},"review_comments":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/133/comments"},"review_comment":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/133/commits"},"statuses":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/statuses/5dd9f6bfd2aa5f32f1a886434cf77bebb9b2fa51"}}}}