Commit aafcfd38 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[SQL/OPALEYE] leftJoin3. thanks to tomjaguarpaw...

[SQL/OPALEYE] leftJoin3. thanks to tomjaguarpaw https://github.com/tomjaguarpaw/haskell-opaleye/issues/364#issuecomment-367804503
parent def4b5d8
...@@ -8,15 +8,17 @@ Stability : experimental ...@@ -8,15 +8,17 @@ Stability : experimental
Portability : POSIX Portability : POSIX
-} -}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-} {-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE Arrows #-}
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE Arrows #-} {-# LANGUAGE MultiParamTypeClasses #-}
{-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
module Gargantext.Database.Facet where module Gargantext.Database.Facet where
...@@ -127,6 +129,7 @@ nodeNodeNgramLeftJoin' nId = leftJoin queryNodeTable queryNodeNodeNgramTable (eq ...@@ -127,6 +129,7 @@ nodeNodeNgramLeftJoin' nId = leftJoin queryNodeTable queryNodeNodeNgramTable (eq
((.==) nId' (toNullable n2)) ((.==) nId' (toNullable n2))
leftJoin3 :: (Default NullMaker (columnsL1, nullableColumnsR) nullableColumnsR1, leftJoin3 :: (Default NullMaker (columnsL1, nullableColumnsR) nullableColumnsR1,
Default NullMaker columnsR nullableColumnsR, Default NullMaker columnsR nullableColumnsR,
Default Unpackspec columnsR columnsR, Default Unpackspec columnsR columnsR,
...@@ -140,15 +143,15 @@ leftJoin3 :: (Default NullMaker (columnsL1, nullableColumnsR) nullableColumnsR1, ...@@ -140,15 +143,15 @@ leftJoin3 :: (Default NullMaker (columnsL1, nullableColumnsR) nullableColumnsR1,
leftJoin3 q1 q2 q3 cond12 cond23 = leftJoin q3 (leftJoin q1 q2 cond12) cond23 leftJoin3 q1 q2 q3 cond12 cond23 = leftJoin q3 (leftJoin q1 q2 cond12) cond23
--leftJoin3' :: Query (NodeRead, NodeNodeNgramReadNull) leftJoin3' :: Query (NodeRead, (NodeReadNull, NodeNodeNgramReadNull))
--leftJoin3' = leftJoin3 queryNodeTable queryNodeNodeNgramTable queryNodeTable cond12 cond23 leftJoin3' = leftJoin3 queryNodeTable queryNodeNodeNgramTable queryNodeTable cond12 cond23
-- where where
-- cond12 (Node _ _ _ _ _ _ _, NodeNodeNgram _ _ _ _) cond12 (Node favId _ _ _ _ _ _, NodeNodeNgram favId' _ _ _)
-- = pgBool True = (.==) favId favId'
--
-- cond23 (Node _ _ _ _ _ _ _, (Node _ _ _ _ _ _ _, NodeNodeNgram _ _ _ _))
-- = pgBool True
cond23 :: (NodeRead, (NodeRead, NodeNodeNgramReadNull)) -> Column PGBool
cond23 (Node docId _ _ _ _ _ _, (Node _ _ _ _ _ _ _, NodeNodeNgram _ docId' _ _))
= (.||) ((.==) (toNullable docId) docId') (isNull docId')
-- | Building the facet -- | Building the facet
......
...@@ -46,6 +46,19 @@ type NodeRead = NodePoly (Column PGInt4 ) ...@@ -46,6 +46,19 @@ type NodeRead = NodePoly (Column PGInt4 )
(Column PGJsonb) (Column PGJsonb)
-- (Column PGTSVector) -- (Column PGTSVector)
type NodeReadNull = NodePoly (Column (Nullable PGInt4 ))
(Column (Nullable PGInt4 ))
(Column (Nullable PGInt4 ))
(Column (Nullable PGInt4 ))
(Column (Nullable PGText ))
(Column (Nullable PGTimestamptz ))
(Column (Nullable PGJsonb))
join3 :: Query columnsA -> Query columnsB -> Query columnsC join3 :: Query columnsA -> Query columnsB -> Query columnsC
-> ((columnsA, columnsB, columnsC) -> Column PGBool) -> ((columnsA, columnsB, columnsC) -> Column PGBool)
-> Query (columnsA, columnsB, columnsC) -> Query (columnsA, columnsB, columnsC)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment