开发者

Set operations in DBIx::Class

开发者 https://www.devze.com 2023-03-26 13:46 出处:网络
What is the best way to perform set operations using DBIx::Class? I saw that one solution would be to create a Result Source based on my query, but my c开发者_StackOverflowonditions will be defined by

What is the best way to perform set operations using DBIx::Class? I saw that one solution would be to create a Result Source based on my query, but my c开发者_StackOverflowonditions will be defined by the user and I don know if the best answer is to create the result source on the fly.

Basically i need to translate this type of query to DBIC where code, attr_name and value is defined by the user:

SELECT pid FROM product WHERE code = 48
INTERSECT
(
  ( SELECT pid FROM attr WHERE attr_name = 'color' AND value = 'blue'
    INTERSECT
    SELECT pid FROM attr WHERE attr_name = 'size' AND value = 'big'
  )
  UNION
  ( SELECT pid FROM attr WHERE attr_name = 'color' AND value = 'green'
    INTERSECT
    SELECT pid FROM attr WHERE attr_name = 'size' AND value = 'small'
  )
)


Could DBIx::Class::Helper::ResultSet::SetOperations be what you need?

0

精彩评论

暂无评论...
验证码 换一张
取 消