Sequel 有类似 ActiveRecord 的 `merge` 方法吗?
Does Sequel have anything like ActiveRecord's `merge` method?
使用 ActiveRecord's merge
method,如果我在 Author
上有一个名为 name_like
的范围,我可以使用它来使用 Book.joins(:author).merge(Author.name_like("lew"))
[=19= 按作者姓名查找书籍]
生成此查询(对于 name_like
的一个版本):
SELECT "books".* FROM "books"
INNER JOIN "authors" ON "authors"."id" = "books"."author_id"
WHERE (concat(first_name, ' ', last_name) ILIKE '%lew%')
是否 Sequel have something equivilent to this? I don't see it in Sequel for ActiveRecord Users.
没有 merge
。对于 Sequel 中的查询,您可以这样做:
Book.association_join(:author).
where(Sequel.join([:first_name, :last_name], ' ').ilike('%lew%'))
使用 ActiveRecord's merge
method,如果我在 Author
上有一个名为 name_like
的范围,我可以使用它来使用 Book.joins(:author).merge(Author.name_like("lew"))
[=19= 按作者姓名查找书籍]
生成此查询(对于 name_like
的一个版本):
SELECT "books".* FROM "books"
INNER JOIN "authors" ON "authors"."id" = "books"."author_id"
WHERE (concat(first_name, ' ', last_name) ILIKE '%lew%')
是否 Sequel have something equivilent to this? I don't see it in Sequel for ActiveRecord Users.
没有 merge
。对于 Sequel 中的查询,您可以这样做:
Book.association_join(:author).
where(Sequel.join([:first_name, :last_name], ' ').ilike('%lew%'))