@@ -147,43 +147,6 @@ module Ransack
147147 expect ( s . result . to_sql ) . to include 'published'
148148 end
149149
150- # The failure/oversight in Ransack::Nodes::Condition#arel_predicate or deeper is beyond my understanding of the structures
151- it 'preserves (inverts) default scope and conditions for negative subqueries' do
152- # the positive case (published_articles_title_eq) is
153- # SELECT "people".* FROM "people"
154- # LEFT OUTER JOIN "articles" ON "articles"."person_id" = "people"."id"
155- # AND "articles"."published" = 't'
156- # AND ('default_scope' = 'default_scope')
157- # WHERE "articles"."title" = 'Test' ORDER BY "people"."id" DESC
158- #
159- # negative case was
160- # SELECT "people".* FROM "people" WHERE "people"."id" NOT IN (
161- # SELECT "articles"."person_id" FROM "articles"
162- # WHERE "articles"."person_id" = "people"."id"
163- # AND NOT ("articles"."title" != 'Test')
164- # ) ORDER BY "people"."id" DESC
165- #
166- # Should have been like
167- # SELECT "people".* FROM "people" WHERE "people"."id" NOT IN (
168- # SELECT "articles"."person_id" FROM "articles"
169- # WHERE "articles"."person_id" = "people"."id"
170- # AND "articles"."title" = 'Test' AND "articles"."published" = 't' AND ('default_scope' = 'default_scope')
171- # ) ORDER BY "people"."id" DESC
172- #
173- # With tenanting (eg default_scope with column reference), NOT IN should be like
174- # SELECT "people".* FROM "people" WHERE "people"."tenant_id" = 'tenant_id' AND "people"."id" NOT IN (
175- # SELECT "articles"."person_id" FROM "articles"
176- # WHERE "articles"."person_id" = "people"."id"
177- # AND "articles"."tenant_id" = 'tenant_id'
178- # AND "articles"."title" = 'Test' AND "articles"."published" = 't' AND ('default_scope' = 'default_scope')
179- # ) ORDER BY "people"."id" DESC
180-
181- pending ( "spec should pass, but I do not know how/where to fix lib code" )
182- s = Search . new ( Person , published_articles_title_not_eq : 'Test' )
183- expect ( s . result . to_sql ) . to include 'default_scope'
184- expect ( s . result . to_sql ) . to include 'published'
185- end
186-
187150 it 'discards empty conditions' do
188151 s = Search . new ( Person , children_name_eq : '' )
189152 condition = s . base [ :children_name_eq ]
0 commit comments