OR条件式
適応バージョン
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.2.1
- 7.0.0
説明
OR条件式
使い方
モデル.or(条件式)
例
A or B
Post.where("id = 1").or(Post.where("author_id = 3"))
# SELECT `posts`.* FROM `posts` WHERE ((id = 1) OR (author_id = 3))
A, B or C
Post.where(id: 1, name: "名前").or(Post.where(age: nil))
# SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 1 AND "posts"."name" = "名前" OR "posts"."age" IS NULL)
A or B, C
Post.where(id: 1).or(Post.where(name: "名前", age: nil))
# SELECT "posts".* FROM "posts" WHERE ("posts"."id" = 1 OR "posts"."name" = "名前" AND "posts"."age" IS NULL)