假设我有一组条件:
Person.where{(name =~ 'Ernie%') & (salary < 50000) | (name =~ 'Joe%') & (salary > 100000)}
...这将生成如下 SQL:
SELECT "people".* FROM people
WHERE ("people"."name" LIKE 'Ernie%' AND "people"."salary" < 50000)
OR ("people"."name" LIKE 'Joe%' AND "people"."salary" > 100000)
如何反转返回的集合,即更新 Squeel 以返回以下 sql:
SELECT "people".* FROM people
WHERE NOT(("people"."name" LIKE 'Ernie%' AND "people"."salary" < 50000)
OR ("people"."name" LIKE 'Joe%' AND "people"."salary" > 100000))
这有点做作,因为我的问题还涉及一组动态生成的条件 - 我无法更改实际条件,只需要将它们包装在 NOT() 中。
有人对在哪里看有任何想法或建议吗?