My below active record statements are working fine:
Requirement.where(no: 0)
Requirement.yes_no.or(Requirement.where.not(parent_req: nil))
In Requirement model I have an enum
field, which is working fine too:
enum response_type: { yes_no: 0, document: 1, interviewee: 2, sample_set: 3, brief_desc: 4 }
But when I combine above two statements:
Requirement.where(no: 0).where(Requirement.yes_no.or(Requirement.where.not(parent_req: nil)))
It is giving me error:
ArgumentError: Unsupported argument type: #<Requirement::ActiveRecord_Relation:0x005567c7c9bf88> (Requirement::ActiveRecord_Relation)
I expect the following query to be run:
SELECT `requirements`.*
FROM `requirements`
WHERE `requirements`.`no` = 0
AND (`requirements`.`response_type` = 0
OR (`requirements`.`parent_req` IS NOT NULL))