我想使用 aLEFT JOIN
来获取产品及其(可选)属性。我有如下类型:
type ProductPGR = ProductPoly (Column (PGID Product)) (Column PGText)
type ProductAttributePGR = ProductAttributePoly (Column (PGID ProductAttribute)) (Column (PGID Product)) (Column PGInt4)
我的意图是使用:
(p :: ProductPGR, pa :: Maybe ProductAttributePGR) <- leftJoinF
(\p' pa' -> (p', Just pa'))
(\p' -> (p', Nothing))
(\p' pa' -> productId p' .== paProductId pa')
productQuery
productAttributeQuery -< ()
这不会编译,因为:
No instance for (Default
IfPP
(Maybe
(ProductAttributePoly
(Column (PGID ProductAttribute))
(Column (PGID Product))
(Column PGInt4))))
(Maybe
(ProductAttributePoly
(Column (PGID ProductAttribute))
(Column (PGID Product))
(Column PGInt4))))
arising from a use of ‘leftJoinF’
我真的应该定义这个实例吗?它有什么用,我该怎么做?
或者如果我不应该使用Maybe
,我还能做什么?