Commit 07e34aa5 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

Merge branch 'dev' into dev-docs-download

parents ffa3c28d 33bf8ea5
...@@ -14,9 +14,22 @@ variables: ...@@ -14,9 +14,22 @@ variables:
#- apt-get install make xz-utils #- apt-get install make xz-utils
stages: stages:
- deps
- docs - docs
- test - test
deps:
cache:
# cache per branch name
# key: ${CI_COMMIT_REF_SLUG}
paths:
- .stack
- .stack-root/
- .stack-work/
- target
script:
- stack build --no-terminal --haddock --no-haddock-deps --only-dependencies --fast
docs: docs:
cache: cache:
# cache per branch name # cache per branch name
...@@ -47,3 +60,4 @@ test: ...@@ -47,3 +60,4 @@ test:
- stack test --no-terminal --fast - stack test --no-terminal --fast
# TOOO # TOOO
## Version 0.0.4.9.9.2
* [BACK] Opaleye Upgrade
## Version 0.0.4.9.9.1
* [FRONT] 350-dev-graph-search-in-forms-not-labels
* [FRONT] 359-dev-input-with-autocomplete
## Version 0.0.4.9.9 ## Version 0.0.4.9.9
* [FIX] Continuous Integration (CI) * [FIX] Continuous Integration (CI)
......
name: gargantext name: gargantext
version: '0.0.4.9.9' version: '0.0.4.9.9.2'
synopsis: Search, map, share synopsis: Search, map, share
description: Please see README.md description: Please see README.md
category: Data category: Data
...@@ -58,7 +58,7 @@ library: ...@@ -58,7 +58,7 @@ library:
- Gargantext.API.Admin.EnvTypes - Gargantext.API.Admin.EnvTypes
- Gargantext.API.Admin.Types - Gargantext.API.Admin.Types
- Gargantext.API.Prelude - Gargantext.API.Prelude
- Gargantext.Client - Gargantext.API.Client
- Gargantext.Core - Gargantext.Core
- Gargantext.Core.NodeStory - Gargantext.Core.NodeStory
- Gargantext.Core.Methods.Distances - Gargantext.Core.Methods.Distances
......
{-# OPTIONS_GHC -freduction-depth=0 #-} {-# OPTIONS_GHC -freduction-depth=0 #-}
{-# OPTIONS_GHC -O0 #-} {-# OPTIONS_GHC -O0 #-}
module Gargantext.Client where module Gargantext.API.Client where
import Data.Int import Data.Int
import Data.Maybe import Data.Maybe
......
...@@ -191,9 +191,9 @@ instance FromField HyperdataGraph ...@@ -191,9 +191,9 @@ instance FromField HyperdataGraph
where where
fromField = fromField' fromField = fromField'
instance DefaultFromField PGJsonb HyperdataGraph instance DefaultFromField SqlJsonb HyperdataGraph
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
----------------------------------------------------------- -----------------------------------------------------------
-- This type is used to return graph via API -- This type is used to return graph via API
......
...@@ -52,14 +52,14 @@ import qualified Data.Text as DT ...@@ -52,14 +52,14 @@ import qualified Data.Text as DT
isPairedWith :: NodeId -> NodeType -> Cmd err [NodeId] isPairedWith :: NodeId -> NodeType -> Cmd err [NodeId]
isPairedWith nId nt = runOpaQuery (selectQuery nt nId) isPairedWith nId nt = runOpaQuery (selectQuery nt nId)
where where
selectQuery :: NodeType -> NodeId -> Query (Column PGInt4) selectQuery :: NodeType -> NodeId -> Select (Column SqlInt4)
selectQuery nt' nId' = proc () -> do selectQuery nt' nId' = proc () -> do
(node, node_node) <- queryJoin -< () (node, node_node) <- queryJoin -< ()
restrict -< (node^.node_typename) .== (sqlInt4 $ toDBid nt') restrict -< (node^.node_typename) .== (sqlInt4 $ toDBid nt')
restrict -< (node_node^.nn_node1_id) .== (toNullable $ pgNodeId nId') restrict -< (node_node^.nn_node1_id) .== (toNullable $ pgNodeId nId')
returnA -< node^.node_id returnA -< node^.node_id
queryJoin :: Query (NodeRead, NodeNodeReadNull) queryJoin :: Select (NodeRead, NodeNodeReadNull)
queryJoin = leftJoin2 queryNodeTable queryNodeNodeTable cond queryJoin = leftJoin2 queryNodeTable queryNodeNodeTable cond
where where
cond (node, node_node) = node^.node_id .== node_node^. nn_node2_id cond (node, node_node) = node^.node_id .== node_node^. nn_node2_id
......
...@@ -29,7 +29,7 @@ import Gargantext.Database.Query.Table.NodeNode ...@@ -29,7 +29,7 @@ import Gargantext.Database.Query.Table.NodeNode
import Gargantext.Database.Schema.Node import Gargantext.Database.Schema.Node
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Core.Text.Terms.Mono.Stem.En (stemIt) import Gargantext.Core.Text.Terms.Mono.Stem.En (stemIt)
import Opaleye hiding (Query, Order) import Opaleye hiding (Order)
import Data.Profunctor.Product (p4) import Data.Profunctor.Product (p4)
import qualified Opaleye as O hiding (Order) import qualified Opaleye as O hiding (Order)
...@@ -41,10 +41,10 @@ searchDocInDatabase :: HasDBid NodeType ...@@ -41,10 +41,10 @@ searchDocInDatabase :: HasDBid NodeType
searchDocInDatabase _p t = runOpaQuery (queryDocInDatabase t) searchDocInDatabase _p t = runOpaQuery (queryDocInDatabase t)
where where
-- | Global search query where ParentId is Master Node Corpus Id -- | Global search query where ParentId is Master Node Corpus Id
queryDocInDatabase :: Text -> O.Query (Column PGInt4, Column PGJsonb) queryDocInDatabase :: Text -> O.Select (Column SqlInt4, Column SqlJsonb)
queryDocInDatabase q = proc () -> do queryDocInDatabase q = proc () -> do
row <- queryNodeSearchTable -< () row <- queryNodeSearchTable -< ()
restrict -< (_ns_search row) @@ (pgTSQuery (unpack q)) restrict -< (_ns_search row) @@ (sqlTSQuery (unpack q))
restrict -< (_ns_typename row) .== (sqlInt4 $ toDBid NodeDocument) restrict -< (_ns_typename row) .== (sqlInt4 $ toDBid NodeDocument)
returnA -< (_ns_id row, _ns_hyperdata row) returnA -< (_ns_id row, _ns_hyperdata row)
...@@ -78,14 +78,14 @@ queryInCorpus :: HasDBid NodeType ...@@ -78,14 +78,14 @@ queryInCorpus :: HasDBid NodeType
=> CorpusId => CorpusId
-> IsTrash -> IsTrash
-> Text -> Text
-> O.Query FacetDocRead -> O.Select FacetDocRead
queryInCorpus cId t q = proc () -> do queryInCorpus cId t q = proc () -> do
(n, nn) <- joinInCorpus -< () (n, nn) <- joinInCorpus -< ()
restrict -< (nn^.nn_node1_id) .== (toNullable $ pgNodeId cId) restrict -< (nn^.nn_node1_id) .== (toNullable $ pgNodeId cId)
restrict -< if t restrict -< if t
then (nn^.nn_category) .== (toNullable $ sqlInt4 0) then (nn^.nn_category) .== (toNullable $ sqlInt4 0)
else (nn^.nn_category) .>= (toNullable $ sqlInt4 1) else (nn^.nn_category) .>= (toNullable $ sqlInt4 1)
restrict -< (n ^. ns_search) @@ (pgTSQuery (unpack q)) restrict -< (n ^. ns_search) @@ (sqlTSQuery (unpack q))
restrict -< (n ^. ns_typename ) .== (sqlInt4 $ toDBid NodeDocument) restrict -< (n ^. ns_typename ) .== (sqlInt4 $ toDBid NodeDocument)
returnA -< FacetDoc { facetDoc_id = n^.ns_id returnA -< FacetDoc { facetDoc_id = n^.ns_id
, facetDoc_created = n^.ns_date , facetDoc_created = n^.ns_date
...@@ -96,10 +96,10 @@ queryInCorpus cId t q = proc () -> do ...@@ -96,10 +96,10 @@ queryInCorpus cId t q = proc () -> do
, facetDoc_score = nn^.nn_score , facetDoc_score = nn^.nn_score
} }
joinInCorpus :: O.Query (NodeSearchRead, NodeNodeReadNull) joinInCorpus :: O.Select (NodeSearchRead, NodeNodeReadNull)
joinInCorpus = leftJoin queryNodeSearchTable queryNodeNodeTable cond joinInCorpus = leftJoin queryNodeSearchTable queryNodeNodeTable cond
where where
cond :: (NodeSearchRead, NodeNodeRead) -> Column PGBool cond :: (NodeSearchRead, NodeNodeRead) -> Column SqlBool
cond (n, nn) = nn^.nn_node2_id .== _ns_id n cond (n, nn) = nn^.nn_node2_id .== _ns_id n
------------------------------------------------------------------------ ------------------------------------------------------------------------
...@@ -125,15 +125,15 @@ selectContactViaDoc ...@@ -125,15 +125,15 @@ selectContactViaDoc
=> CorpusId => CorpusId
-> AnnuaireId -> AnnuaireId
-> Text -> Text
-> QueryArr () -> SelectArr ()
( Column (Nullable PGInt4) ( Column (Nullable SqlInt4)
, Column (Nullable PGTimestamptz) , Column (Nullable SqlTimestamptz)
, Column (Nullable PGJsonb) , Column (Nullable SqlJsonb)
, Column (Nullable PGInt4) , Column (Nullable SqlInt4)
) )
selectContactViaDoc cId aId q = proc () -> do selectContactViaDoc cId aId q = proc () -> do
(doc, (corpus_doc, (_contact_doc, (annuaire_contact, contact)))) <- queryContactViaDoc -< () (doc, (corpus_doc, (_contact_doc, (annuaire_contact, contact)))) <- queryContactViaDoc -< ()
restrict -< (doc^.ns_search) @@ (pgTSQuery $ unpack q ) restrict -< (doc^.ns_search) @@ (sqlTSQuery $ unpack q )
restrict -< (doc^.ns_typename) .== (sqlInt4 $ toDBid NodeDocument) restrict -< (doc^.ns_typename) .== (sqlInt4 $ toDBid NodeDocument)
restrict -< (corpus_doc^.nn_node1_id) .== (toNullable $ pgNodeId cId) restrict -< (corpus_doc^.nn_node1_id) .== (toNullable $ pgNodeId cId)
restrict -< (annuaire_contact^.nn_node1_id) .== (toNullable $ pgNodeId aId) restrict -< (annuaire_contact^.nn_node1_id) .== (toNullable $ pgNodeId aId)
...@@ -155,15 +155,15 @@ selectGroup cId aId q = proc () -> do ...@@ -155,15 +155,15 @@ selectGroup cId aId q = proc () -> do
returnA -< FacetPaired a b c d returnA -< FacetPaired a b c d
queryContactViaDoc :: O.Query ( NodeSearchRead queryContactViaDoc :: O.Select ( NodeSearchRead
, ( NodeNodeReadNull , ( NodeNodeReadNull
, ( NodeNodeReadNull , ( NodeNodeReadNull
, ( NodeNodeReadNull , ( NodeNodeReadNull
, NodeReadNull , NodeReadNull
) )
) )
) )
) )
queryContactViaDoc = queryContactViaDoc =
leftJoin5 leftJoin5
queryNodeTable queryNodeTable
...@@ -176,14 +176,14 @@ queryContactViaDoc = ...@@ -176,14 +176,14 @@ queryContactViaDoc =
cond34 cond34
cond45 cond45
where where
cond12 :: (NodeNodeRead, NodeRead) -> Column PGBool cond12 :: (NodeNodeRead, NodeRead) -> Column SqlBool
cond12 (annuaire_contact, contact) = contact^.node_id .== annuaire_contact^.nn_node2_id cond12 (annuaire_contact, contact) = contact^.node_id .== annuaire_contact^.nn_node2_id
cond23 :: ( NodeNodeRead cond23 :: ( NodeNodeRead
, ( NodeNodeRead , ( NodeNodeRead
, NodeReadNull , NodeReadNull
) )
) -> Column PGBool ) -> Column SqlBool
cond23 (contact_doc, (annuaire_contact, _)) = contact_doc^.nn_node1_id .== annuaire_contact^.nn_node2_id cond23 (contact_doc, (annuaire_contact, _)) = contact_doc^.nn_node1_id .== annuaire_contact^.nn_node2_id
cond34 :: ( NodeNodeRead cond34 :: ( NodeNodeRead
...@@ -192,7 +192,7 @@ queryContactViaDoc = ...@@ -192,7 +192,7 @@ queryContactViaDoc =
, NodeReadNull , NodeReadNull
) )
) )
) -> Column PGBool ) -> Column SqlBool
cond34 (corpus_doc, (contact_doc, (_,_))) = corpus_doc^.nn_node2_id .== contact_doc^.nn_node2_id cond34 (corpus_doc, (contact_doc, (_,_))) = corpus_doc^.nn_node2_id .== contact_doc^.nn_node2_id
...@@ -204,7 +204,7 @@ queryContactViaDoc = ...@@ -204,7 +204,7 @@ queryContactViaDoc =
) )
) )
) )
) -> Column PGBool ) -> Column SqlBool
cond45 (doc, (corpus_doc, (_,(_,_)))) = doc^.ns_id .== corpus_doc^.nn_node2_id cond45 (doc, (corpus_doc, (_,(_,_)))) = doc^.ns_id .== corpus_doc^.nn_node2_id
......
...@@ -45,7 +45,7 @@ instance ToSchema HyperdataAny where ...@@ -45,7 +45,7 @@ instance ToSchema HyperdataAny where
instance FromField HyperdataAny where instance FromField HyperdataAny where
fromField = fromField' fromField = fromField'
instance DefaultFromField PGJsonb HyperdataAny instance DefaultFromField SqlJsonb HyperdataAny
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
...@@ -194,12 +194,12 @@ instance FromField HyperdataContact where ...@@ -194,12 +194,12 @@ instance FromField HyperdataContact where
fromField = fromField' fromField = fromField'
-- | Database (Opaleye instance) -- | Database (Opaleye instance)
instance DefaultFromField PGJsonb HyperdataContact where instance DefaultFromField SqlJsonb HyperdataContact where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance DefaultFromField (Nullable PGJsonb) HyperdataContact where instance DefaultFromField (Nullable SqlJsonb) HyperdataContact where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
......
...@@ -90,10 +90,10 @@ instance FromField HyperdataAnnuaire ...@@ -90,10 +90,10 @@ instance FromField HyperdataAnnuaire
where where
fromField = fromField' fromField = fromField'
------------------------------------------------------------------------ ------------------------------------------------------------------------
instance DefaultFromField PGJsonb HyperdataCorpus instance DefaultFromField SqlJsonb HyperdataCorpus
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance DefaultFromField PGJsonb HyperdataAnnuaire instance DefaultFromField SqlJsonb HyperdataAnnuaire
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
...@@ -71,7 +71,7 @@ instance ToSchema HyperdataDashboard where ...@@ -71,7 +71,7 @@ instance ToSchema HyperdataDashboard where
instance FromField HyperdataDashboard where instance FromField HyperdataDashboard where
fromField = fromField' fromField = fromField'
instance DefaultFromField PGJsonb HyperdataDashboard instance DefaultFromField SqlJsonb HyperdataDashboard
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
...@@ -202,11 +202,11 @@ instance ToField HyperdataDocumentV3 where ...@@ -202,11 +202,11 @@ instance ToField HyperdataDocumentV3 where
toField = toJSONField toField = toJSONField
------------------------------------------------------------------------ ------------------------------------------------------------------------
instance DefaultFromField PGJsonb HyperdataDocument instance DefaultFromField SqlJsonb HyperdataDocument
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance DefaultFromField PGJsonb HyperdataDocumentV3 instance DefaultFromField SqlJsonb HyperdataDocumentV3
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
------------------------------------------------------------------------ ------------------------------------------------------------------------
...@@ -54,9 +54,9 @@ instance FromField HyperdataFile ...@@ -54,9 +54,9 @@ instance FromField HyperdataFile
where where
fromField = fromField' fromField = fromField'
instance DefaultFromField PGJsonb HyperdataFile instance DefaultFromField SqlJsonb HyperdataFile
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance ToSchema HyperdataFile where instance ToSchema HyperdataFile where
declareNamedSchema proxy = declareNamedSchema proxy =
......
...@@ -23,10 +23,10 @@ module Gargantext.Database.Admin.Types.Hyperdata.Frame ...@@ -23,10 +23,10 @@ module Gargantext.Database.Admin.Types.Hyperdata.Frame
import Control.Lens import Control.Lens
import Data.ByteString.Lazy (toStrict) import Data.ByteString.Lazy (toStrict)
import qualified Data.Text as T
import Data.Text.Encoding (decodeUtf8) import Data.Text.Encoding (decodeUtf8)
import Gargantext.Prelude
import Gargantext.Database.Admin.Types.Hyperdata.Prelude import Gargantext.Database.Admin.Types.Hyperdata.Prelude
import Gargantext.Prelude
import qualified Data.Text as T
import qualified Network.Wreq as Wreq import qualified Network.Wreq as Wreq
------------------------------------------------------------------------ ------------------------------------------------------------------------
...@@ -58,9 +58,9 @@ instance FromField HyperdataFrame ...@@ -58,9 +58,9 @@ instance FromField HyperdataFrame
where where
fromField = fromField' fromField = fromField'
instance DefaultFromField PGJsonb HyperdataFrame instance DefaultFromField SqlJsonb HyperdataFrame
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance ToSchema HyperdataFrame where instance ToSchema HyperdataFrame where
declareNamedSchema proxy = declareNamedSchema proxy =
......
...@@ -98,12 +98,12 @@ instance FromField HyperdataListCooc ...@@ -98,12 +98,12 @@ instance FromField HyperdataListCooc
where where
fromField = fromField' fromField = fromField'
instance DefaultFromField PGJsonb HyperdataList instance DefaultFromField SqlJsonb HyperdataList
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance DefaultFromField PGJsonb HyperdataListCooc instance DefaultFromField SqlJsonb HyperdataListCooc
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance ToSchema HyperdataList where instance ToSchema HyperdataList where
......
...@@ -48,9 +48,9 @@ instance FromField HyperdataModel ...@@ -48,9 +48,9 @@ instance FromField HyperdataModel
where where
fromField = fromField' fromField = fromField'
instance DefaultFromField PGJsonb HyperdataModel instance DefaultFromField SqlJsonb HyperdataModel
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance ToSchema HyperdataModel where instance ToSchema HyperdataModel where
declareNamedSchema proxy = declareNamedSchema proxy =
......
...@@ -56,6 +56,6 @@ instance ToSchema HyperdataPhylo where ...@@ -56,6 +56,6 @@ instance ToSchema HyperdataPhylo where
instance FromField HyperdataPhylo where instance FromField HyperdataPhylo where
fromField = fromField' fromField = fromField'
instance DefaultFromField PGJsonb HyperdataPhylo instance DefaultFromField SqlJsonb HyperdataPhylo
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
...@@ -48,7 +48,7 @@ import GHC.Generics (Generic) ...@@ -48,7 +48,7 @@ import GHC.Generics (Generic)
import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger, wellNamedSchema) import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger, wellNamedSchema)
import Gargantext.Database.Prelude (fromField') import Gargantext.Database.Prelude (fromField')
import Gargantext.Prelude import Gargantext.Prelude
import Opaleye (DefaultFromField, defaultFromField, PGJsonb, fieldQueryRunnerColumn, Nullable) import Opaleye (DefaultFromField, defaultFromField, Nullable, SqlJsonb, fromPGSFromField)
import Test.QuickCheck (elements) import Test.QuickCheck (elements)
import Test.QuickCheck.Arbitrary hiding (vector) import Test.QuickCheck.Arbitrary hiding (vector)
......
...@@ -54,7 +54,7 @@ instance ToSchema HyperdataTexts where ...@@ -54,7 +54,7 @@ instance ToSchema HyperdataTexts where
instance FromField HyperdataTexts where instance FromField HyperdataTexts where
fromField = fromField' fromField = fromField'
instance DefaultFromField PGJsonb HyperdataTexts instance DefaultFromField SqlJsonb HyperdataTexts
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
...@@ -135,12 +135,12 @@ instance FromField HyperdataPublic where ...@@ -135,12 +135,12 @@ instance FromField HyperdataPublic where
fromField = fromField' fromField = fromField'
-- | Database (Opaleye instance) -- | Database (Opaleye instance)
instance DefaultFromField PGJsonb HyperdataUser where instance DefaultFromField SqlJsonb HyperdataUser where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance DefaultFromField PGJsonb HyperdataPrivate where instance DefaultFromField SqlJsonb HyperdataPrivate where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance DefaultFromField PGJsonb HyperdataPublic where instance DefaultFromField SqlJsonb HyperdataPublic where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
...@@ -35,7 +35,7 @@ import Database.PostgreSQL.Simple.ToField (ToField, toField) ...@@ -35,7 +35,7 @@ import Database.PostgreSQL.Simple.ToField (ToField, toField)
import GHC.Generics (Generic) import GHC.Generics (Generic)
import Servant import Servant
import qualified Opaleye as O import qualified Opaleye as O
import Opaleye (DefaultFromField, defaultFromField, PGInt4, PGText, PGTSVector, Nullable, fieldQueryRunnerColumn) import Opaleye (DefaultFromField, defaultFromField, SqlInt4, SqlText, SqlTSVector, Nullable, fromPGSFromField)
import Test.QuickCheck (elements) import Test.QuickCheck (elements)
import Gargantext.Prelude.Crypto.Hash (Hash) import Gargantext.Prelude.Crypto.Hash (Hash)
import Test.QuickCheck.Arbitrary import Test.QuickCheck.Arbitrary
...@@ -145,7 +145,7 @@ instance (Arbitrary hyperdata ...@@ -145,7 +145,7 @@ instance (Arbitrary hyperdata
<*> arbitrary <*> arbitrary
------------------------------------------------------------------------ ------------------------------------------------------------------------
pgNodeId :: NodeId -> O.Column O.PGInt4 pgNodeId :: NodeId -> O.Column O.SqlInt4
pgNodeId = O.sqlInt4 . id2int pgNodeId = O.sqlInt4 . id2int
where where
id2int :: NodeId -> Int id2int :: NodeId -> Int
...@@ -360,28 +360,28 @@ instance FromField (NodeId, Text) ...@@ -360,28 +360,28 @@ instance FromField (NodeId, Text)
fromField = fromField' fromField = fromField'
-} -}
------------------------------------------------------------------------ ------------------------------------------------------------------------
instance DefaultFromField PGTSVector (Maybe TSVector) instance DefaultFromField SqlTSVector (Maybe TSVector)
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance DefaultFromField PGInt4 (Maybe NodeId) instance DefaultFromField SqlInt4 (Maybe NodeId)
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance DefaultFromField PGInt4 NodeId instance DefaultFromField SqlInt4 NodeId
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance DefaultFromField (Nullable PGInt4) NodeId instance DefaultFromField (Nullable SqlInt4) NodeId
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance (DefaultFromField (Nullable O.PGTimestamptz) UTCTime) instance (DefaultFromField (Nullable O.SqlTimestamptz) UTCTime)
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance DefaultFromField PGText (Maybe Hash) instance DefaultFromField SqlText (Maybe Hash)
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
...@@ -32,7 +32,7 @@ import Database.PostgreSQL.Simple.Internal (Field) ...@@ -32,7 +32,7 @@ import Database.PostgreSQL.Simple.Internal (Field)
import Gargantext.Core.Mail.Types (HasMail) import Gargantext.Core.Mail.Types (HasMail)
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Prelude.Config (readIniFile', val) import Gargantext.Prelude.Config (readIniFile', val)
import Opaleye (Query, Unpackspec, showSql, FromFields, Select, runSelect, PGJsonb, DefaultFromField) import Opaleye (Unpackspec, showSql, FromFields, Select, runSelect, SqlJsonb, DefaultFromField)
import Opaleye.Aggregate (countRows) import Opaleye.Aggregate (countRows)
import System.IO (FilePath) import System.IO (FilePath)
import System.IO (stderr) import System.IO (stderr)
...@@ -57,7 +57,7 @@ instance HasConfig GargConfig where ...@@ -57,7 +57,7 @@ instance HasConfig GargConfig where
hasConfig = identity hasConfig = identity
------------------------------------------------------- -------------------------------------------------------
type JSONB = DefaultFromField PGJsonb type JSONB = DefaultFromField SqlJsonb
------------------------------------------------------- -------------------------------------------------------
type CmdM'' env err m = type CmdM'' env err m =
...@@ -185,6 +185,6 @@ fromField' field mb = do ...@@ -185,6 +185,6 @@ fromField' field mb = do
, show v , show v
] ]
printSqlOpa :: Default Unpackspec a a => Query a -> IO () printSqlOpa :: Default Unpackspec a a => Select a -> IO ()
printSqlOpa = putStrLn . maybe "Empty query" identity . showSql printSqlOpa = putStrLn . maybe "Empty query" identity . showSql
...@@ -8,8 +8,7 @@ Stability : experimental ...@@ -8,8 +8,7 @@ Stability : experimental
Portability : POSIX Portability : POSIX
-} -}
{-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-} {-# LANGUAGE Arrows #-}
{-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE FunctionalDependencies #-}
...@@ -152,28 +151,28 @@ instance ( Arbitrary id ...@@ -152,28 +151,28 @@ instance ( Arbitrary id
) => Arbitrary (FacetPaired id date hyperdata score) where ) => Arbitrary (FacetPaired id date hyperdata score) where
arbitrary = FacetPaired <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary arbitrary = FacetPaired <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
type FacetPairedRead = FacetPaired (Column PGInt4 ) type FacetPairedRead = FacetPaired (Column SqlInt4 )
(Column PGTimestamptz) (Column SqlTimestamptz)
(Column PGJsonb ) (Column SqlJsonb )
(Column PGInt4 ) (Column SqlInt4 )
type FacetPairedReadNull = FacetPaired (Column (Nullable PGInt4) ) type FacetPairedReadNull = FacetPaired (Column (Nullable SqlInt4) )
(Column (Nullable PGTimestamptz)) (Column (Nullable SqlTimestamptz))
(Column (Nullable PGJsonb) ) (Column (Nullable SqlJsonb) )
(Column (Nullable PGInt4) ) (Column (Nullable SqlInt4) )
type FacetPairedReadNullAgg = FacetPaired (Aggregator (Column (Nullable PGInt4) ) type FacetPairedReadNullAgg = FacetPaired (Aggregator (Column (Nullable SqlInt4) )
(Column (Nullable PGInt4) ) (Column (Nullable SqlInt4) )
) )
(Aggregator (Column (Nullable PGTimestamptz)) (Aggregator (Column (Nullable SqlTimestamptz))
(Column (Nullable PGTimestamptz)) (Column (Nullable SqlTimestamptz))
) )
(Aggregator (Column (Nullable PGJsonb) ) (Aggregator (Column (Nullable SqlJsonb) )
(Column (Nullable PGJsonb) ) (Column (Nullable SqlJsonb) )
) )
(Aggregator (Column (Nullable PGInt4) ) (Aggregator (Column (Nullable SqlInt4) )
(Column (Nullable PGInt4) ) (Column (Nullable SqlInt4) )
) )
...@@ -203,13 +202,13 @@ instance Arbitrary FacetDoc where ...@@ -203,13 +202,13 @@ instance Arbitrary FacetDoc where
$(makeAdaptorAndInstance "pFacetDoc" ''Facet) $(makeAdaptorAndInstance "pFacetDoc" ''Facet)
-- $(makeLensesWith abbreviatedFields ''Facet) -- $(makeLensesWith abbreviatedFields ''Facet)
type FacetDocRead = Facet (Column PGInt4 ) type FacetDocRead = Facet (Column SqlInt4 )
(Column PGTimestamptz) (Column SqlTimestamptz)
(Column PGText ) (Column SqlText )
(Column PGJsonb ) (Column SqlJsonb )
(Column (Nullable PGInt4)) -- Category (Column (Nullable SqlInt4)) -- Category
(Column (Nullable PGFloat8)) -- Ngrams Count (Column (Nullable SqlFloat8)) -- Ngrams Count
(Column (Nullable PGFloat8)) -- Score (Column (Nullable SqlFloat8)) -- Score
----------------------------------------------------------------------- -----------------------------------------------------------------------
----------------------------------------------------------------------- -----------------------------------------------------------------------
...@@ -261,13 +260,13 @@ viewAuthorsDoc :: HasDBid NodeType ...@@ -261,13 +260,13 @@ viewAuthorsDoc :: HasDBid NodeType
=> ContactId => ContactId
-> IsTrash -> IsTrash
-> NodeType -> NodeType
-> Query FacetDocRead -> Select FacetDocRead
viewAuthorsDoc cId _ nt = proc () -> do viewAuthorsDoc cId _ nt = proc () -> do
(doc,(_,(_,(_,contact')))) <- queryAuthorsDoc -< () (doc,(_,(_,(_,contact')))) <- queryAuthorsDoc -< ()
{-nn <- queryNodeNodeTable -< () {-nn <- queryNodeNodeTable -< ()
restrict -< nn_node1_id nn .== _node_id doc restrict -< nn_node1_id nn .== _node_id doc
-- restrict -< nn_delete nn .== (pgBool t) -- restrict -< nn_delete nn .== (sqlBool t)
-} -}
restrict -< _node_id contact' .== (toNullable $ pgNodeId cId) restrict -< _node_id contact' .== (toNullable $ pgNodeId cId)
...@@ -278,24 +277,24 @@ viewAuthorsDoc cId _ nt = proc () -> do ...@@ -278,24 +277,24 @@ viewAuthorsDoc cId _ nt = proc () -> do
, facetDoc_title = _node_name doc , facetDoc_title = _node_name doc
, facetDoc_hyperdata = _node_hyperdata doc , facetDoc_hyperdata = _node_hyperdata doc
, facetDoc_category = toNullable $ sqlInt4 1 , facetDoc_category = toNullable $ sqlInt4 1
, facetDoc_ngramCount = toNullable $ pgDouble 1 , facetDoc_ngramCount = toNullable $ sqlDouble 1
, facetDoc_score = toNullable $ pgDouble 1 } , facetDoc_score = toNullable $ sqlDouble 1 }
queryAuthorsDoc :: Query (NodeRead, (NodeNodeNgramsReadNull, (NgramsReadNull, (NodeNodeNgramsReadNull, NodeReadNull)))) queryAuthorsDoc :: Select (NodeRead, (NodeNodeNgramsReadNull, (NgramsReadNull, (NodeNodeNgramsReadNull, NodeReadNull))))
queryAuthorsDoc = leftJoin5 queryNodeTable queryNodeNodeNgramsTable queryNgramsTable queryNodeNodeNgramsTable queryNodeTable cond12 cond23 cond34 cond45 queryAuthorsDoc = leftJoin5 queryNodeTable queryNodeNodeNgramsTable queryNgramsTable queryNodeNodeNgramsTable queryNodeTable cond12 cond23 cond34 cond45
where where
cond12 :: (NodeNodeNgramsRead, NodeRead) -> Column PGBool cond12 :: (NodeNodeNgramsRead, NodeRead) -> Column SqlBool
cond12 (nodeNgram, doc) = _node_id doc cond12 (nodeNgram, doc) = _node_id doc
.== _nnng_node1_id nodeNgram .== _nnng_node1_id nodeNgram
cond23 :: (NgramsRead, (NodeNodeNgramsRead, NodeReadNull)) -> Column PGBool cond23 :: (NgramsRead, (NodeNodeNgramsRead, NodeReadNull)) -> Column SqlBool
cond23 (ngrams', (nodeNgram, _)) = ngrams'^.ngrams_id cond23 (ngrams', (nodeNgram, _)) = ngrams'^.ngrams_id
.== _nnng_ngrams_id nodeNgram .== _nnng_ngrams_id nodeNgram
cond34 :: (NodeNodeNgramsRead, (NgramsRead, (NodeNodeNgramsReadNull, NodeReadNull))) -> Column PGBool cond34 :: (NodeNodeNgramsRead, (NgramsRead, (NodeNodeNgramsReadNull, NodeReadNull))) -> Column SqlBool
cond34 (nodeNgram2, (ngrams', (_,_)))= ngrams'^.ngrams_id .== _nnng_ngrams_id nodeNgram2 cond34 (nodeNgram2, (ngrams', (_,_)))= ngrams'^.ngrams_id .== _nnng_ngrams_id nodeNgram2
cond45 :: (NodeRead, (NodeNodeNgramsRead, (NgramsReadNull, (NodeNodeNgramsReadNull, NodeReadNull)))) -> Column PGBool cond45 :: (NodeRead, (NodeNodeNgramsRead, (NgramsReadNull, (NodeNodeNgramsReadNull, NodeReadNull)))) -> Column SqlBool
cond45 (contact', (nodeNgram2', (_, (_,_)))) = _node_id contact' .== _nnng_node1_id nodeNgram2' cond45 (contact', (nodeNgram2', (_, (_,_)))) = _node_id contact' .== _nnng_node1_id nodeNgram2'
--} --}
...@@ -346,7 +345,7 @@ viewDocuments :: CorpusId ...@@ -346,7 +345,7 @@ viewDocuments :: CorpusId
-> IsTrash -> IsTrash
-> NodeTypeId -> NodeTypeId
-> Maybe Text -> Maybe Text
-> Query FacetDocRead -> Select FacetDocRead
viewDocuments cId t ntId mQuery = viewDocumentsQuery cId t ntId mQuery >>> proc (n, nn) -> do viewDocuments cId t ntId mQuery = viewDocumentsQuery cId t ntId mQuery >>> proc (n, nn) -> do
returnA -< FacetDoc { facetDoc_id = _ns_id n returnA -< FacetDoc { facetDoc_id = _ns_id n
, facetDoc_created = _ns_date n , facetDoc_created = _ns_date n
...@@ -360,7 +359,7 @@ viewDocuments' :: CorpusId ...@@ -360,7 +359,7 @@ viewDocuments' :: CorpusId
-> IsTrash -> IsTrash
-> NodeTypeId -> NodeTypeId
-> Maybe Text -> Maybe Text
-> Query NodeRead -> Select NodeRead
viewDocuments' cId t ntId mQuery = viewDocumentsQuery cId t ntId mQuery >>> proc (n, _nn) -> do viewDocuments' cId t ntId mQuery = viewDocumentsQuery cId t ntId mQuery >>> proc (n, _nn) -> do
returnA -< Node { _node_id = _ns_id n returnA -< Node { _node_id = _ns_id n
, _node_hash_id = "" , _node_hash_id = ""
...@@ -375,7 +374,7 @@ viewDocumentsQuery :: CorpusId ...@@ -375,7 +374,7 @@ viewDocumentsQuery :: CorpusId
-> IsTrash -> IsTrash
-> NodeTypeId -> NodeTypeId
-> Maybe Text -> Maybe Text
-> Query (NodeSearchRead, NodeNodeRead) -> Select (NodeSearchRead, NodeNodeRead)
viewDocumentsQuery cId t ntId mQuery = proc () -> do viewDocumentsQuery cId t ntId mQuery = proc () -> do
n <- queryNodeSearchTable -< () n <- queryNodeSearchTable -< ()
nn <- queryNodeNodeTable -< () nn <- queryNodeNodeTable -< ()
...@@ -389,7 +388,7 @@ viewDocumentsQuery cId t ntId mQuery = proc () -> do ...@@ -389,7 +388,7 @@ viewDocumentsQuery cId t ntId mQuery = proc () -> do
-- iLikeQuery = T.intercalate "" ["%", query, "%"] -- iLikeQuery = T.intercalate "" ["%", query, "%"]
-- restrict -< (n^.node_name) `ilike` (sqlStrictText iLikeQuery) -- restrict -< (n^.node_name) `ilike` (sqlStrictText iLikeQuery)
restrict -< if query == "" restrict -< if query == ""
then pgBool True then sqlBool True
--else (n^.ns_search) @@ (pgTSQuery (T.unpack query)) --else (n^.ns_search) @@ (pgTSQuery (T.unpack query))
else (n^.ns_search) @@ (plaintoTSQuery $ T.unpack query) else (n^.ns_search) @@ (plaintoTSQuery $ T.unpack query)
...@@ -424,5 +423,5 @@ orderWith _ = asc facetDoc_created ...@@ -424,5 +423,5 @@ orderWith _ = asc facetDoc_created
facetDoc_source :: SqlIsJson a facetDoc_source :: SqlIsJson a
=> Facet id created title (Column a) favorite ngramCount score => Facet id created title (Column a) favorite ngramCount score
-> Column (Nullable PGText) -> Column (Nullable SqlText)
facetDoc_source x = toNullable (facetDoc_hyperdata x) .->> pgString "source" facetDoc_source x = toNullable (facetDoc_hyperdata x) .->> sqlString "source"
...@@ -20,12 +20,12 @@ module Gargantext.Database.Query.Filter ...@@ -20,12 +20,12 @@ module Gargantext.Database.Query.Filter
import Gargantext.Core.Types (Limit, Offset) import Gargantext.Core.Types (Limit, Offset)
import Data.Maybe (Maybe, maybe) import Data.Maybe (Maybe, maybe)
import Opaleye (Query, limit, offset) import Opaleye (Select, limit, offset)
limit' :: Maybe Limit -> Query a -> Query a limit' :: Maybe Limit -> Select a -> Select a
limit' maybeLimit query = maybe query (\l -> limit l query) maybeLimit limit' maybeLimit query = maybe query (\l -> limit l query) maybeLimit
offset' :: Maybe Offset -> Query a -> Query a offset' :: Maybe Offset -> Select a -> Select a
offset' maybeOffset query = maybe query (\o -> offset o query) maybeOffset offset' maybeOffset query = maybe query (\o -> offset o query) maybeOffset
...@@ -33,28 +33,34 @@ module Gargantext.Database.Query.Join ( leftJoin2 ...@@ -33,28 +33,34 @@ module Gargantext.Database.Query.Join ( leftJoin2
) )
where where
import Control.Arrow ((>>>)) import Control.Arrow ((>>>), returnA)
import Data.Profunctor.Product.Default import Data.Profunctor.Product.Default
import Gargantext.Prelude import Gargantext.Prelude
import Opaleye import Opaleye hiding (keepWhen)
import Opaleye.Internal.Join (NullMaker(..)) import Opaleye.Internal.Join (NullMaker(..))
import qualified Opaleye.Internal.Unpackspec() import qualified Opaleye.Internal.Unpackspec()
keepWhen :: (a -> Field SqlBool) -> SelectArr a a
keepWhen p = proc a -> do
restrict -< p a
returnA -< a
------------------------------------------------------------------------ ------------------------------------------------------------------------
leftJoin2 :: (Default Unpackspec fieldsL fieldsL, leftJoin2 :: (Default Unpackspec fieldsL fieldsL,
Default Unpackspec fieldsR fieldsR, Default Unpackspec fieldsR fieldsR,
Default NullMaker fieldsR nullableFieldsR) => Default NullMaker fieldsR nullableFieldsR) =>
Select fieldsL Select fieldsL
-> Select fieldsR -> Select fieldsR
-> ((fieldsL, fieldsR) -> Column PGBool) -> ((fieldsL, fieldsR) -> Column SqlBool)
-> Select (fieldsL, nullableFieldsR) -> Select (fieldsL, nullableFieldsR)
leftJoin2 = leftJoin leftJoin2 = leftJoin
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | LeftJoin3 in two ways to write it -- | LeftJoin3 in two ways to write it
_leftJoin3 :: Query columnsA -> Query columnsB -> Query columnsC _leftJoin3 :: Select columnsA -> Select columnsB -> Select columnsC
-> ((columnsA, columnsB, columnsC) -> Column PGBool) -> ((columnsA, columnsB, columnsC) -> Column SqlBool)
-> Query (columnsA, columnsB, columnsC) -> Select (columnsA, columnsB, columnsC)
_leftJoin3 q1 q2 q3 cond = ((,,) <$> q1 <*> q2 <*> q3) >>> keepWhen cond _leftJoin3 q1 q2 q3 cond = ((,,) <$> q1 <*> q2 <*> q3) >>> keepWhen cond
...@@ -68,8 +74,8 @@ leftJoin3 :: ( Default Unpackspec b2 b2 ...@@ -68,8 +74,8 @@ leftJoin3 :: ( Default Unpackspec b2 b2
Select fieldsR Select fieldsR
-> Select b3 -> Select b3
-> Select fieldsL -> Select fieldsL
-> ((b3, fieldsR) -> Column PGBool) -> ((b3, fieldsR) -> Column SqlBool)
-> ((fieldsL, (b3, b2)) -> Column PGBool) -> ((fieldsL, (b3, b2)) -> Column SqlBool)
-> Select (fieldsL, (b4, b5)) -> Select (fieldsL, (b4, b5))
leftJoin3 q1 q2 q3 leftJoin3 q1 q2 q3
...@@ -88,9 +94,9 @@ leftJoin4 :: (Default Unpackspec b2 b2, ...@@ -88,9 +94,9 @@ leftJoin4 :: (Default Unpackspec b2 b2,
-> Select b3 -> Select b3
-> Select b2 -> Select b2
-> Select fieldsL -> Select fieldsL
-> ((b3, fieldsR) -> Column PGBool) -> ((b3, fieldsR) -> Column SqlBool)
-> ((b2, (b3, b4)) -> Column PGBool) -> ((b2, (b3, b4)) -> Column SqlBool)
-> ((fieldsL, (b2, (b5, b6))) -> Column PGBool) -> ((fieldsL, (b2, (b5, b6))) -> Column SqlBool)
-> Select (fieldsL, (b7, (b8, b9))) -> Select (fieldsL, (b7, (b8, b9)))
leftJoin4 q1 q2 q3 q4 leftJoin4 q1 q2 q3 q4
cond12 cond23 cond34 = cond12 cond23 cond34 =
...@@ -117,10 +123,10 @@ leftJoin5 :: (Default Unpackspec b2 b2, Default Unpackspec b3 b3, ...@@ -117,10 +123,10 @@ leftJoin5 :: (Default Unpackspec b2 b2, Default Unpackspec b3 b3,
-> Select b7 -> Select b7
-> Select b8 -> Select b8
-> Select fieldsL -> Select fieldsL
-> ((b5, fieldsR) -> Column PGBool) -> ((b5, fieldsR) -> Column SqlBool)
-> ((b7, (b5, b4)) -> Column PGBool) -> ((b7, (b5, b4)) -> Column SqlBool)
-> ((b8, (b7, (b9, b10))) -> Column PGBool) -> ((b8, (b7, (b9, b10))) -> Column SqlBool)
-> ((fieldsL, (b8, (b6, (b3, b2)))) -> Column PGBool) -> ((fieldsL, (b8, (b6, (b3, b2)))) -> Column SqlBool)
-> Select (fieldsL, (b12, (b11, (b13, b14)))) -> Select (fieldsL, (b12, (b11, (b13, b14))))
leftJoin5 q1 q2 q3 q4 q5 leftJoin5 q1 q2 q3 q4 q5
cond12 cond23 cond34 cond45 = cond12 cond23 cond34 cond45 =
...@@ -155,11 +161,11 @@ leftJoin6 :: (Default Unpackspec b2 b2, Default Unpackspec b3 b3, ...@@ -155,11 +161,11 @@ leftJoin6 :: (Default Unpackspec b2 b2, Default Unpackspec b3 b3,
-> Select b5 -> Select b5
-> Select b6 -> Select b6
-> Select fieldsL -> Select fieldsL
-> ((b8, fieldsR) -> Column PGBool) -> ((b8, fieldsR) -> Column SqlBool)
-> ((b3, (b8, b9)) -> Column PGBool) -> ((b3, (b8, b9)) -> Column SqlBool)
-> ((b5, (b3, (b14, b15))) -> Column PGBool) -> ((b5, (b3, (b14, b15))) -> Column SqlBool)
-> ((b6, (b5, (b7, (b10, b11)))) -> Column PGBool) -> ((b6, (b5, (b7, (b10, b11)))) -> Column SqlBool)
-> ((fieldsL, (b6, (b4, (b2, (b12, b13))))) -> Column PGBool) -> ((fieldsL, (b6, (b4, (b2, (b12, b13))))) -> Column SqlBool)
-> Select (fieldsL, (b17, (b16, (b18, (b19, b20))))) -> Select (fieldsL, (b17, (b16, (b18, (b19, b20)))))
leftJoin6 q1 q2 q3 q4 q5 q6 leftJoin6 q1 q2 q3 q4 q5 q6
cond12 cond23 cond34 cond45 cond56 = cond12 cond23 cond34 cond45 cond56 =
...@@ -203,13 +209,13 @@ leftJoin7 :: (Default Unpackspec b2 b2, Default Unpackspec b3 b3, ...@@ -203,13 +209,13 @@ leftJoin7 :: (Default Unpackspec b2 b2, Default Unpackspec b3 b3,
-> Select b14 -> Select b14
-> Select b13 -> Select b13
-> Select fieldsL -> Select fieldsL
-> ((b7, fieldsR) -> Column PGBool) -> ((b7, fieldsR) -> Column SqlBool)
-> ((b11, (b7, b6)) -> Column PGBool) -> ((b11, (b7, b6)) -> Column SqlBool)
-> ((b16, (b11, (b20, b21))) -> Column PGBool) -> ((b16, (b11, (b20, b21))) -> Column SqlBool)
-> ((b14, (b16, (b8, (b5, b4)))) -> Column PGBool) -> ((b14, (b16, (b8, (b5, b4)))) -> Column SqlBool)
-> ((b13, (b14, (b12, (b10, (b18, b19))))) -> Column PGBool) -> ((b13, (b14, (b12, (b10, (b18, b19))))) -> Column SqlBool)
-> ((fieldsL, (b13, (b15, (b17, (b9, (b3, b2)))))) -> ((fieldsL, (b13, (b15, (b17, (b9, (b3, b2))))))
-> Column PGBool) -> Column SqlBool)
-> Select (fieldsL, (b24, (b25, (b23, (b22, (b26, b27)))))) -> Select (fieldsL, (b24, (b25, (b23, (b22, (b26, b27))))))
leftJoin7 q1 q2 q3 q4 q5 q6 q7 leftJoin7 q1 q2 q3 q4 q5 q6 q7
cond12 cond23 cond34 cond45 cond56 cond67 = cond12 cond23 cond34 cond45 cond56 cond67 =
...@@ -263,14 +269,14 @@ leftJoin8 :: (Default Unpackspec b2 b2, Default Unpackspec b3 b3, ...@@ -263,14 +269,14 @@ leftJoin8 :: (Default Unpackspec b2 b2, Default Unpackspec b3 b3,
-> Select b11 -> Select b11
-> Select b10 -> Select b10
-> Select fieldsL -> Select fieldsL
-> ((b17, fieldsR) -> Column PGBool) -> ((b17, fieldsR) -> Column SqlBool)
-> ((b4, (b17, b18)) -> Column PGBool) -> ((b4, (b17, b18)) -> Column SqlBool)
-> ((b8, (b4, (b27, b28))) -> Column PGBool) -> ((b8, (b4, (b27, b28))) -> Column SqlBool)
-> ((b13, (b8, (b16, (b19, b20)))) -> Column PGBool) -> ((b13, (b8, (b16, (b19, b20)))) -> Column SqlBool)
-> ((b11, (b13, (b5, (b3, (b25, b26))))) -> Column PGBool) -> ((b11, (b13, (b5, (b3, (b25, b26))))) -> Column SqlBool)
-> ((b10, (b11, (b9, (b7, (b15, (b21, b22)))))) -> Column PGBool) -> ((b10, (b11, (b9, (b7, (b15, (b21, b22)))))) -> Column SqlBool)
-> ((fieldsL, (b10, (b12, (b14, (b6, (b2, (b23, b24))))))) -> ((fieldsL, (b10, (b12, (b14, (b6, (b2, (b23, b24)))))))
-> Column PGBool) -> Column SqlBool)
-> Select (fieldsL, (b31, (b32, (b30, (b29, (b33, (b34, b35))))))) -> Select (fieldsL, (b31, (b32, (b30, (b29, (b33, (b34, b35)))))))
leftJoin8 q1 q2 q3 q4 q5 q6 q7 q8 leftJoin8 q1 q2 q3 q4 q5 q6 q7 q8
cond12 cond23 cond34 cond45 cond56 cond67 cond78 = cond12 cond23 cond34 cond45 cond56 cond67 cond78 =
...@@ -336,16 +342,16 @@ leftJoin9 :: (Default Unpackspec b2 b2, Default Unpackspec b3 b3, ...@@ -336,16 +342,16 @@ leftJoin9 :: (Default Unpackspec b2 b2, Default Unpackspec b3 b3,
-> Select b21 -> Select b21
-> Select b22 -> Select b22
-> Select fieldsL -> Select fieldsL
-> ((b9, fieldsR) -> Column PGBool) -> ((b9, fieldsR) -> Column SqlBool)
-> ((b15, (b9, b8)) -> Column PGBool) -> ((b15, (b9, b8)) -> Column SqlBool)
-> ((b28, (b15, (b35, b36))) -> Column PGBool) -> ((b28, (b15, (b35, b36))) -> Column SqlBool)
-> ((b24, (b28, (b10, (b7, b6)))) -> Column PGBool) -> ((b24, (b28, (b10, (b7, b6)))) -> Column SqlBool)
-> ((b19, (b24, (b16, (b14, (b33, b34))))) -> Column PGBool) -> ((b19, (b24, (b16, (b14, (b33, b34))))) -> Column SqlBool)
-> ((b21, (b19, (b27, (b29, (b11, (b5, b4)))))) -> Column PGBool) -> ((b21, (b19, (b27, (b29, (b11, (b5, b4)))))) -> Column SqlBool)
-> ((b22, (b21, (b23, (b25, (b17, (b13, (b31, b32))))))) -> ((b22, (b21, (b23, (b25, (b17, (b13, (b31, b32)))))))
-> Column PGBool) -> Column SqlBool)
-> ((fieldsL, (b22, (b20, (b18, (b26, (b30, (b12, (b3, b2)))))))) -> ((fieldsL, (b22, (b20, (b18, (b26, (b30, (b12, (b3, b2))))))))
-> Column PGBool) -> Column SqlBool)
-> Select -> Select
(fieldsL, (b40, (b39, (b41, (b42, (b38, (b37, (b43, b44)))))))) (fieldsL, (b40, (b39, (b41, (b42, (b38, (b37, (b43, b44))))))))
leftJoin9 q1 q2 q3 q4 q5 q6 q7 q8 q9 leftJoin9 q1 q2 q3 q4 q5 q6 q7 q8 q9
......
...@@ -52,7 +52,7 @@ selectNgramsByDoc lIds dId nt = runOpaQuery (query lIds dId nt) ...@@ -52,7 +52,7 @@ selectNgramsByDoc lIds dId nt = runOpaQuery (query lIds dId nt)
query cIds' dId' nt' = proc () -> do query cIds' dId' nt' = proc () -> do
(ng,nnng) <- join -< () (ng,nnng) <- join -< ()
restrict -< foldl (\b cId -> ((toNullable $ pgNodeId cId) .== nnng^.nnng_node1_id) .|| b) (pgBool True) cIds' restrict -< foldl (\b cId -> ((toNullable $ pgNodeId cId) .== nnng^.nnng_node1_id) .|| b) (sqlBool True) cIds'
restrict -< (toNullable $ pgNodeId dId') .== nnng^.nnng_node2_id restrict -< (toNullable $ pgNodeId dId') .== nnng^.nnng_node2_id
restrict -< (toNullable $ pgNgramsType nt') .== nnng^.nnng_ngramsType restrict -< (toNullable $ pgNgramsType nt') .== nnng^.nnng_ngramsType
returnA -< ng^.ngrams_terms returnA -< ng^.ngrams_terms
......
...@@ -43,16 +43,16 @@ import Gargantext.Database.Schema.Node ...@@ -43,16 +43,16 @@ import Gargantext.Database.Schema.Node
import Gargantext.Prelude hiding (sum, head) import Gargantext.Prelude hiding (sum, head)
queryNodeSearchTable :: Query NodeSearchRead queryNodeSearchTable :: Select NodeSearchRead
queryNodeSearchTable = selectTable nodeTableSearch queryNodeSearchTable = selectTable nodeTableSearch
selectNode :: Column PGInt4 -> Query NodeRead selectNode :: Column SqlInt4 -> Select NodeRead
selectNode id' = proc () -> do selectNode id' = proc () -> do
row <- queryNodeTable -< () row <- queryNodeTable -< ()
restrict -< _node_id row .== id' restrict -< _node_id row .== id'
returnA -< row returnA -< row
runGetNodes :: Query NodeRead -> Cmd err [Node HyperdataAny] runGetNodes :: Select NodeRead -> Cmd err [Node HyperdataAny]
runGetNodes = runOpaQuery runGetNodes = runOpaQuery
------------------------------------------------------------------------ ------------------------------------------------------------------------
...@@ -61,7 +61,7 @@ runGetNodes = runOpaQuery ...@@ -61,7 +61,7 @@ runGetNodes = runOpaQuery
-- Favorites (Bool), node_ngrams -- Favorites (Bool), node_ngrams
selectNodesWith :: HasDBid NodeType selectNodesWith :: HasDBid NodeType
=> ParentId -> Maybe NodeType => ParentId -> Maybe NodeType
-> Maybe Offset -> Maybe Limit -> Query NodeRead -> Maybe Offset -> Maybe Limit -> Select NodeRead
selectNodesWith parentId maybeNodeType maybeOffset maybeLimit = selectNodesWith parentId maybeNodeType maybeOffset maybeLimit =
--offset' maybeOffset $ limit' maybeLimit $ orderBy (asc (hyperdataDocument_Publication_date . node_hyperdata)) $ selectNodesWith' parentId typeId --offset' maybeOffset $ limit' maybeLimit $ orderBy (asc (hyperdataDocument_Publication_date . node_hyperdata)) $ selectNodesWith' parentId typeId
limit' maybeLimit $ offset' maybeOffset limit' maybeLimit $ offset' maybeOffset
...@@ -69,7 +69,7 @@ selectNodesWith parentId maybeNodeType maybeOffset maybeLimit = ...@@ -69,7 +69,7 @@ selectNodesWith parentId maybeNodeType maybeOffset maybeLimit =
$ selectNodesWith' parentId maybeNodeType $ selectNodesWith' parentId maybeNodeType
selectNodesWith' :: HasDBid NodeType selectNodesWith' :: HasDBid NodeType
=> ParentId -> Maybe NodeType -> Query NodeRead => ParentId -> Maybe NodeType -> Select NodeRead
selectNodesWith' parentId maybeNodeType = proc () -> do selectNodesWith' parentId maybeNodeType = proc () -> do
node' <- (proc () -> do node' <- (proc () -> do
row@(Node _ _ typeId _ parentId' _ _ _) <- queryNodeTable -< () row@(Node _ _ typeId _ parentId' _ _ _) <- queryNodeTable -< ()
...@@ -79,7 +79,7 @@ selectNodesWith' parentId maybeNodeType = proc () -> do ...@@ -79,7 +79,7 @@ selectNodesWith' parentId maybeNodeType = proc () -> do
restrict -< if typeId' > 0 restrict -< if typeId' > 0
then typeId .== (sqlInt4 (typeId' :: Int)) then typeId .== (sqlInt4 (typeId' :: Int))
else (pgBool True) else (sqlBool True)
returnA -< row ) -< () returnA -< row ) -< ()
returnA -< node' returnA -< node'
...@@ -198,7 +198,7 @@ getCorporaWithParentId :: HasDBid NodeType => NodeId -> Cmd err [Node HyperdataC ...@@ -198,7 +198,7 @@ getCorporaWithParentId :: HasDBid NodeType => NodeId -> Cmd err [Node HyperdataC
getCorporaWithParentId n = runOpaQuery $ selectNodesWith' n (Just NodeCorpus) getCorporaWithParentId n = runOpaQuery $ selectNodesWith' n (Just NodeCorpus)
------------------------------------------------------------------------ ------------------------------------------------------------------------
selectNodesWithParentID :: NodeId -> Query NodeRead selectNodesWithParentID :: NodeId -> Select NodeRead
selectNodesWithParentID n = proc () -> do selectNodesWithParentID n = proc () -> do
row@(Node _ _ _ _ parent_id _ _ _) <- queryNodeTable -< () row@(Node _ _ _ _ parent_id _ _ _) <- queryNodeTable -< ()
restrict -< parent_id .== (pgNodeId n) restrict -< parent_id .== (pgNodeId n)
...@@ -212,7 +212,7 @@ getNodesWithType :: (HasNodeError err, JSONB a, HasDBid NodeType) => NodeType -> ...@@ -212,7 +212,7 @@ getNodesWithType :: (HasNodeError err, JSONB a, HasDBid NodeType) => NodeType ->
getNodesWithType nt _ = runOpaQuery $ selectNodesWithType nt getNodesWithType nt _ = runOpaQuery $ selectNodesWithType nt
where where
selectNodesWithType :: HasDBid NodeType selectNodesWithType :: HasDBid NodeType
=> NodeType -> Query NodeRead => NodeType -> Select NodeRead
selectNodesWithType nt' = proc () -> do selectNodesWithType nt' = proc () -> do
row@(Node _ _ tn _ _ _ _ _) <- queryNodeTable -< () row@(Node _ _ tn _ _ _ _ _) <- queryNodeTable -< ()
restrict -< tn .== (sqlInt4 $ toDBid nt') restrict -< tn .== (sqlInt4 $ toDBid nt')
...@@ -224,7 +224,7 @@ getNodesIdWithType nt = do ...@@ -224,7 +224,7 @@ getNodesIdWithType nt = do
pure (map NodeId ns) pure (map NodeId ns)
selectNodesIdWithType :: HasDBid NodeType selectNodesIdWithType :: HasDBid NodeType
=> NodeType -> Query (Column PGInt4) => NodeType -> Select (Column SqlInt4)
selectNodesIdWithType nt = proc () -> do selectNodesIdWithType nt = proc () -> do
row@(Node _ _ tn _ _ _ _ _) <- queryNodeTable -< () row@(Node _ _ tn _ _ _ _ _) <- queryNodeTable -< ()
restrict -< tn .== (sqlInt4 $ toDBid nt) restrict -< tn .== (sqlInt4 $ toDBid nt)
...@@ -281,7 +281,7 @@ node nodeType name hyperData parentId userId = ...@@ -281,7 +281,7 @@ node nodeType name hyperData parentId userId =
(pgNodeId <$> parentId) (pgNodeId <$> parentId)
(sqlStrictText name) (sqlStrictText name)
Nothing Nothing
(pgJSONB $ cs $ encode hyperData) (sqlJSONB $ cs $ encode hyperData)
where where
typeId = toDBid nodeType typeId = toDBid nodeType
...@@ -322,7 +322,7 @@ insertNodesWithParentR pid ns = insertNodesR (set node_parent_id (pgNodeId <$> p ...@@ -322,7 +322,7 @@ insertNodesWithParentR pid ns = insertNodesR (set node_parent_id (pgNodeId <$> p
node2table :: HasDBid NodeType node2table :: HasDBid NodeType
=> UserId -> Maybe ParentId -> Node' -> NodeWrite => UserId -> Maybe ParentId -> Node' -> NodeWrite
node2table uid pid (Node' nt txt v []) = Node Nothing Nothing (sqlInt4 $ toDBid nt) (sqlInt4 uid) (fmap pgNodeId pid) (sqlStrictText txt) Nothing (pgStrictJSONB $ cs $ encode v) node2table uid pid (Node' nt txt v []) = Node Nothing Nothing (sqlInt4 $ toDBid nt) (sqlInt4 uid) (fmap pgNodeId pid) (sqlStrictText txt) Nothing (sqlStrictJSONB $ cs $ encode v)
node2table _ _ (Node' _ _ _ _) = panic "node2table: should not happen, Tree insert not implemented yet" node2table _ _ (Node' _ _ _ _) = panic "node2table: should not happen, Tree insert not implemented yet"
......
...@@ -69,7 +69,7 @@ getChildren pId _ maybeNodeType maybeOffset maybeLimit = do ...@@ -69,7 +69,7 @@ getChildren pId _ maybeNodeType maybeOffset maybeLimit = do
selectChildren :: HasDBid NodeType selectChildren :: HasDBid NodeType
=> ParentId => ParentId
-> Maybe NodeType -> Maybe NodeType
-> Query NodeRead -> Select NodeRead
selectChildren parentId maybeNodeType = proc () -> do selectChildren parentId maybeNodeType = proc () -> do
row@(Node nId _ typeName _ parent_id _ _ _) <- queryNodeTable -< () row@(Node nId _ typeName _ parent_id _ _ _) <- queryNodeTable -< ()
(NodeNode n1id n2id _ _) <- queryNodeNodeTable -< () (NodeNode n1id n2id _ _) <- queryNodeNodeTable -< ()
......
...@@ -35,7 +35,7 @@ selectNodesWithUsername nt u = runOpaQuery (q u) ...@@ -35,7 +35,7 @@ selectNodesWithUsername nt u = runOpaQuery (q u)
restrict -< _node_typename n .== (sqlInt4 $ toDBid nt) restrict -< _node_typename n .== (sqlInt4 $ toDBid nt)
returnA -< _node_id n returnA -< _node_id n
join' :: Query (NodeRead, UserReadNull) join' :: Select (NodeRead, UserReadNull)
join' = leftJoin queryNodeTable queryUserTable on1 join' = leftJoin queryNodeTable queryUserTable on1
where where
on1 (n,us) = _node_user_id n .== user_id us on1 (n,us) = _node_user_id n .== user_id us
......
...@@ -37,7 +37,7 @@ updateHyperdataQuery i h = Update ...@@ -37,7 +37,7 @@ updateHyperdataQuery i h = Update
, uWhere = (\row -> _node_id row .== pgNodeId i ) , uWhere = (\row -> _node_id row .== pgNodeId i )
, uReturning = rCount , uReturning = rCount
} }
where h' = (pgJSONB $ cs $ encode $ h) where h' = (sqlJSONB $ cs $ encode $ h)
---------------------------------------------------------------------------------- ----------------------------------------------------------------------------------
updateNodesWithType :: ( HasNodeError err updateNodesWithType :: ( HasNodeError err
......
{-| {-|
Module : Gargantext.Database.Query.Table.NodeNode Module : Gargantext.Database.Select.Table.NodeNode
Description : Description :
Copyright : (c) CNRS, 2017-Present Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3 License : AGPL + CECILL v3
...@@ -53,7 +53,7 @@ import Gargantext.Database.Schema.Node ...@@ -53,7 +53,7 @@ import Gargantext.Database.Schema.Node
import Gargantext.Prelude import Gargantext.Prelude
queryNodeNodeTable :: Query NodeNodeRead queryNodeNodeTable :: Select NodeNodeRead
queryNodeNodeTable = selectTable nodeNodeTable queryNodeNodeTable = selectTable nodeNodeTable
-- | not optimized (get all ngrams without filters) -- | not optimized (get all ngrams without filters)
...@@ -65,7 +65,7 @@ _nodesNodes = runOpaQuery queryNodeNodeTable ...@@ -65,7 +65,7 @@ _nodesNodes = runOpaQuery queryNodeNodeTable
getNodeNode :: NodeId -> Cmd err [NodeNode] getNodeNode :: NodeId -> Cmd err [NodeNode]
getNodeNode n = runOpaQuery (selectNodeNode $ pgNodeId n) getNodeNode n = runOpaQuery (selectNodeNode $ pgNodeId n)
where where
selectNodeNode :: Column PGInt4 -> Query NodeNodeRead selectNodeNode :: Column SqlInt4 -> Select NodeNodeRead
selectNodeNode n' = proc () -> do selectNodeNode n' = proc () -> do
ns <- queryNodeNodeTable -< () ns <- queryNodeNodeTable -< ()
restrict -< _nn_node1_id ns .== n' restrict -< _nn_node1_id ns .== n'
...@@ -81,7 +81,7 @@ getNodeNodeWith pId _ maybeNodeType = runOpaQuery query ...@@ -81,7 +81,7 @@ getNodeNodeWith pId _ maybeNodeType = runOpaQuery query
selectChildren :: ParentId selectChildren :: ParentId
-> Maybe NodeType -> Maybe NodeType
-> Query NodeRead -> Select NodeRead
selectChildren parentId maybeNodeType = proc () -> do selectChildren parentId maybeNodeType = proc () -> do
row@(Node nId typeName _ parent_id _ _ _) <- queryNodeTable -< () row@(Node nId typeName _ parent_id _ _ _) <- queryNodeTable -< ()
(NodeNode _ n1id n2id _ _) <- queryNodeNodeTable -< () (NodeNode _ n1id n2id _ _) <- queryNodeNodeTable -< ()
...@@ -104,7 +104,7 @@ insertNodeNode ns = mkCmd $ \conn -> fromIntegral <$> (runInsert_ conn ...@@ -104,7 +104,7 @@ insertNodeNode ns = mkCmd $ \conn -> fromIntegral <$> (runInsert_ conn
ns' = map (\(NodeNode n1 n2 x y) ns' = map (\(NodeNode n1 n2 x y)
-> NodeNode (pgNodeId n1) -> NodeNode (pgNodeId n1)
(pgNodeId n2) (pgNodeId n2)
(pgDouble <$> x) (sqlDouble <$> x)
(sqlInt4 <$> y) (sqlInt4 <$> y)
) ns ) ns
...@@ -127,21 +127,21 @@ deleteNodeNode n1 n2 = mkCmd $ \conn -> ...@@ -127,21 +127,21 @@ deleteNodeNode n1 n2 = mkCmd $ \conn ->
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | Favorite management -- | Favorite management
_nodeNodeCategory :: CorpusId -> DocId -> Int -> Cmd err [Int] _nodeNodeCategory :: CorpusId -> DocId -> Int -> Cmd err [Int]
_nodeNodeCategory cId dId c = map (\(PGS.Only a) -> a) <$> runPGSQuery favQuery (c,cId,dId) _nodeNodeCategory cId dId c = map (\(PGS.Only a) -> a) <$> runPGSQuery favSelect (c,cId,dId)
where where
favQuery :: PGS.Query favSelect :: PGS.Query
favQuery = [sql|UPDATE nodes_nodes SET category = ? favSelect = [sql|UPDATE nodes_nodes SET category = ?
WHERE node1_id = ? AND node2_id = ? WHERE node1_id = ? AND node2_id = ?
RETURNING node2_id; RETURNING node2_id;
|] |]
nodeNodesCategory :: [(CorpusId, DocId, Int)] -> Cmd err [Int] nodeNodesCategory :: [(CorpusId, DocId, Int)] -> Cmd err [Int]
nodeNodesCategory inputData = map (\(PGS.Only a) -> a) nodeNodesCategory inputData = map (\(PGS.Only a) -> a)
<$> runPGSQuery catQuery (PGS.Only $ Values fields inputData) <$> runPGSQuery catSelect (PGS.Only $ Values fields inputData)
where where
fields = map (\t-> QualifiedIdentifier Nothing t) ["int4","int4","int4"] fields = map (\t-> QualifiedIdentifier Nothing t) ["int4","int4","int4"]
catQuery :: PGS.Query catSelect :: PGS.Query
catQuery = [sql| UPDATE nodes_nodes as nn0 catSelect = [sql| UPDATE nodes_nodes as nn0
SET category = nn1.category SET category = nn1.category
FROM (?) as nn1(node1_id,node2_id,category) FROM (?) as nn1(node1_id,node2_id,category)
WHERE nn0.node1_id = nn1.node1_id WHERE nn0.node1_id = nn1.node1_id
...@@ -152,10 +152,10 @@ nodeNodesCategory inputData = map (\(PGS.Only a) -> a) ...@@ -152,10 +152,10 @@ nodeNodesCategory inputData = map (\(PGS.Only a) -> a)
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | Score management -- | Score management
_nodeNodeScore :: CorpusId -> DocId -> Int -> Cmd err [Int] _nodeNodeScore :: CorpusId -> DocId -> Int -> Cmd err [Int]
_nodeNodeScore cId dId c = map (\(PGS.Only a) -> a) <$> runPGSQuery scoreQuery (c,cId,dId) _nodeNodeScore cId dId c = map (\(PGS.Only a) -> a) <$> runPGSQuery scoreSelect (c,cId,dId)
where where
scoreQuery :: PGS.Query scoreSelect :: PGS.Query
scoreQuery = [sql|UPDATE nodes_nodes SET score = ? scoreSelect = [sql|UPDATE nodes_nodes SET score = ?
WHERE node1_id = ? AND node2_id = ? WHERE node1_id = ? AND node2_id = ?
RETURNING node2_id; RETURNING node2_id;
|] |]
...@@ -198,7 +198,7 @@ selectDocsDates cId = map (head' "selectDocsDates" . splitOn "-") ...@@ -198,7 +198,7 @@ selectDocsDates cId = map (head' "selectDocsDates" . splitOn "-")
selectDocs :: HasDBid NodeType => CorpusId -> Cmd err [HyperdataDocument] selectDocs :: HasDBid NodeType => CorpusId -> Cmd err [HyperdataDocument]
selectDocs cId = runOpaQuery (queryDocs cId) selectDocs cId = runOpaQuery (queryDocs cId)
queryDocs :: HasDBid NodeType => CorpusId -> O.Query (Column PGJsonb) queryDocs :: HasDBid NodeType => CorpusId -> O.Select (Column SqlJsonb)
queryDocs cId = proc () -> do queryDocs cId = proc () -> do
(n, nn) <- joinInCorpus -< () (n, nn) <- joinInCorpus -< ()
restrict -< nn^.nn_node1_id .== (toNullable $ pgNodeId cId) restrict -< nn^.nn_node1_id .== (toNullable $ pgNodeId cId)
...@@ -209,7 +209,7 @@ queryDocs cId = proc () -> do ...@@ -209,7 +209,7 @@ queryDocs cId = proc () -> do
selectDocNodes :: HasDBid NodeType =>CorpusId -> Cmd err [Node HyperdataDocument] selectDocNodes :: HasDBid NodeType =>CorpusId -> Cmd err [Node HyperdataDocument]
selectDocNodes cId = runOpaQuery (queryDocNodes cId) selectDocNodes cId = runOpaQuery (queryDocNodes cId)
queryDocNodes :: HasDBid NodeType =>CorpusId -> O.Query NodeRead queryDocNodes :: HasDBid NodeType =>CorpusId -> O.Select NodeRead
queryDocNodes cId = proc () -> do queryDocNodes cId = proc () -> do
(n, nn) <- joinInCorpus -< () (n, nn) <- joinInCorpus -< ()
restrict -< nn^.nn_node1_id .== (toNullable $ pgNodeId cId) restrict -< nn^.nn_node1_id .== (toNullable $ pgNodeId cId)
...@@ -217,25 +217,25 @@ queryDocNodes cId = proc () -> do ...@@ -217,25 +217,25 @@ queryDocNodes cId = proc () -> do
restrict -< n^.node_typename .== (sqlInt4 $ toDBid NodeDocument) restrict -< n^.node_typename .== (sqlInt4 $ toDBid NodeDocument)
returnA -< n returnA -< n
joinInCorpus :: O.Query (NodeRead, NodeNodeReadNull) joinInCorpus :: O.Select (NodeRead, NodeNodeReadNull)
joinInCorpus = leftJoin queryNodeTable queryNodeNodeTable cond joinInCorpus = leftJoin queryNodeTable queryNodeNodeTable cond
where where
cond :: (NodeRead, NodeNodeRead) -> Column PGBool cond :: (NodeRead, NodeNodeRead) -> Column SqlBool
cond (n, nn) = nn^.nn_node2_id .== (view node_id n) cond (n, nn) = nn^.nn_node2_id .== (view node_id n)
joinOn1 :: O.Query (NodeRead, NodeNodeReadNull) joinOn1 :: O.Select (NodeRead, NodeNodeReadNull)
joinOn1 = leftJoin queryNodeTable queryNodeNodeTable cond joinOn1 = leftJoin queryNodeTable queryNodeNodeTable cond
where where
cond :: (NodeRead, NodeNodeRead) -> Column PGBool cond :: (NodeRead, NodeNodeRead) -> Column SqlBool
cond (n, nn) = nn^.nn_node1_id .== n^.node_id cond (n, nn) = nn^.nn_node1_id .== n^.node_id
------------------------------------------------------------------------ ------------------------------------------------------------------------
selectPublicNodes :: HasDBid NodeType => (Hyperdata a, DefaultFromField PGJsonb a) selectPublicNodes :: HasDBid NodeType => (Hyperdata a, DefaultFromField SqlJsonb a)
=> Cmd err [(Node a, Maybe Int)] => Cmd err [(Node a, Maybe Int)]
selectPublicNodes = runOpaQuery (queryWithType NodeFolderPublic) selectPublicNodes = runOpaQuery (queryWithType NodeFolderPublic)
queryWithType :: HasDBid NodeType =>NodeType -> O.Query (NodeRead, Column (Nullable PGInt4)) queryWithType :: HasDBid NodeType =>NodeType -> O.Select (NodeRead, Column (Nullable SqlInt4))
queryWithType nt = proc () -> do queryWithType nt = proc () -> do
(n, nn) <- joinOn1 -< () (n, nn) <- joinOn1 -< ()
restrict -< n^.node_typename .== (sqlInt4 $ toDBid nt) restrict -< n^.node_typename .== (sqlInt4 $ toDBid nt)
......
...@@ -41,7 +41,7 @@ insertNodeNodeNgrams = insertNodeNodeNgramsW ...@@ -41,7 +41,7 @@ insertNodeNodeNgrams = insertNodeNodeNgramsW
(pgNodeId n2) (pgNodeId n2)
(sqlInt4 ng) (sqlInt4 ng)
(pgNgramsTypeId nt) (pgNgramsTypeId nt)
(pgDouble w) (sqlDouble w)
) )
insertNodeNodeNgramsW :: [NodeNodeNgramsWrite] -> Cmd err Int insertNodeNodeNgramsW :: [NodeNodeNgramsWrite] -> Cmd err Int
......
...@@ -37,7 +37,7 @@ insertNodeNodeNgrams2 = insertNodeNodeNgrams2W ...@@ -37,7 +37,7 @@ insertNodeNodeNgrams2 = insertNodeNodeNgrams2W
. map (\(NodeNodeNgrams2 n1 n2 w) -> . map (\(NodeNodeNgrams2 n1 n2 w) ->
NodeNodeNgrams2 (pgNodeId n1) NodeNodeNgrams2 (pgNodeId n1)
(sqlInt4 n2) (sqlInt4 n2)
(pgDouble w) (sqlDouble w)
) )
insertNodeNodeNgrams2W :: [NodeNodeNgrams2Write] -> Cmd err Int insertNodeNodeNgrams2W :: [NodeNodeNgrams2Write] -> Cmd err Int
......
...@@ -58,7 +58,7 @@ insert_Node_NodeNgrams_NodeNgrams = insert_Node_NodeNgrams_NodeNgrams_W ...@@ -58,7 +58,7 @@ insert_Node_NodeNgrams_NodeNgrams = insert_Node_NodeNgrams_NodeNgrams_W
Node_NodeNgrams_NodeNgrams (pgNodeId n ) Node_NodeNgrams_NodeNgrams (pgNodeId n )
(sqlInt4 <$> ng1) (sqlInt4 <$> ng1)
(sqlInt4 ng2) (sqlInt4 ng2)
(pgDouble <$> maybeWeight) (sqlDouble <$> maybeWeight)
) )
insert_Node_NodeNgrams_NodeNgrams_W :: [Node_NodeNgrams_NodeNgrams_Write] -> Cmd err Int64 insert_Node_NodeNgrams_NodeNgrams_W :: [Node_NodeNgrams_NodeNgrams_Write] -> Cmd err Int64
......
...@@ -84,18 +84,18 @@ updateUserDB us = mkCmd $ \c -> runUpdate_ c (updateUserQuery us) ...@@ -84,18 +84,18 @@ updateUserDB us = mkCmd $ \c -> runUpdate_ c (updateUserQuery us)
toUserWrite :: NewUser HashPassword -> UserWrite toUserWrite :: NewUser HashPassword -> UserWrite
toUserWrite (NewUser u m (Auth.PasswordHash p)) = toUserWrite (NewUser u m (Auth.PasswordHash p)) =
UserDB (Nothing) (sqlStrictText p) UserDB (Nothing) (sqlStrictText p)
(Nothing) (pgBool True) (sqlStrictText u) (Nothing) (sqlBool True) (sqlStrictText u)
(sqlStrictText "first_name") (sqlStrictText "first_name")
(sqlStrictText "last_name") (sqlStrictText "last_name")
(sqlStrictText m) (sqlStrictText m)
(pgBool True) (sqlBool True)
(pgBool True) Nothing (sqlBool True) Nothing
------------------------------------------------------------------ ------------------------------------------------------------------
getUsersWith :: Username -> Cmd err [UserLight] getUsersWith :: Username -> Cmd err [UserLight]
getUsersWith u = map toUserLight <$> runOpaQuery (selectUsersLightWith u) getUsersWith u = map toUserLight <$> runOpaQuery (selectUsersLightWith u)
selectUsersLightWith :: Username -> Query UserRead selectUsersLightWith :: Username -> Select UserRead
selectUsersLightWith u = proc () -> do selectUsersLightWith u = proc () -> do
row <- queryUserTable -< () row <- queryUserTable -< ()
restrict -< user_username row .== sqlStrictText u restrict -< user_username row .== sqlStrictText u
...@@ -105,14 +105,14 @@ selectUsersLightWith u = proc () -> do ...@@ -105,14 +105,14 @@ selectUsersLightWith u = proc () -> do
getUsersWithId :: Int -> Cmd err [UserLight] getUsersWithId :: Int -> Cmd err [UserLight]
getUsersWithId i = map toUserLight <$> runOpaQuery (selectUsersLightWithId i) getUsersWithId i = map toUserLight <$> runOpaQuery (selectUsersLightWithId i)
where where
selectUsersLightWithId :: Int -> Query UserRead selectUsersLightWithId :: Int -> Select UserRead
selectUsersLightWithId i' = proc () -> do selectUsersLightWithId i' = proc () -> do
row <- queryUserTable -< () row <- queryUserTable -< ()
restrict -< user_id row .== sqlInt4 i' restrict -< user_id row .== sqlInt4 i'
returnA -< row returnA -< row
queryUserTable :: Query UserRead queryUserTable :: Select UserRead
queryUserTable = selectTable userTable queryUserTable = selectTable userTable
---------------------------------------------------------------------- ----------------------------------------------------------------------
...@@ -120,7 +120,7 @@ getUserHyperdata :: Int -> Cmd err [HyperdataUser] ...@@ -120,7 +120,7 @@ getUserHyperdata :: Int -> Cmd err [HyperdataUser]
getUserHyperdata i = do getUserHyperdata i = do
runOpaQuery (selectUserHyperdataWithId i) runOpaQuery (selectUserHyperdataWithId i)
where where
selectUserHyperdataWithId :: Int -> Query (Column PGJsonb) selectUserHyperdataWithId :: Int -> Select (Column SqlJsonb)
selectUserHyperdataWithId i' = proc () -> do selectUserHyperdataWithId i' = proc () -> do
row <- queryNodeTable -< () row <- queryNodeTable -< ()
restrict -< row^.node_id .== (sqlInt4 i') restrict -< row^.node_id .== (sqlInt4 i')
...@@ -166,5 +166,5 @@ insertNewUsers newUsers = do ...@@ -166,5 +166,5 @@ insertNewUsers newUsers = do
insertUsers $ map toUserWrite users' insertUsers $ map toUserWrite users'
---------------------------------------------------------------------- ----------------------------------------------------------------------
instance DefaultFromField PGTimestamptz (Maybe UTCTime) where instance DefaultFromField SqlTimestamptz (Maybe UTCTime) where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
...@@ -30,7 +30,7 @@ import Gargantext.Database.Query.Table.User (queryUserTable, UserPoly(..)) ...@@ -30,7 +30,7 @@ import Gargantext.Database.Query.Table.User (queryUserTable, UserPoly(..))
import Gargantext.Database.Schema.Node (NodePoly(..), NodeRead) import Gargantext.Database.Schema.Node (NodePoly(..), NodeRead)
import Gargantext.Database.Schema.Node (queryNodeTable) import Gargantext.Database.Schema.Node (queryNodeTable)
import Gargantext.Prelude import Gargantext.Prelude
import Opaleye (restrict, (.==), Query) import Opaleye (restrict, (.==), Select)
import Opaleye.SqlTypes (sqlStrictText, sqlInt4) import Opaleye.SqlTypes (sqlStrictText, sqlInt4)
...@@ -115,7 +115,7 @@ mkRoot user = do ...@@ -115,7 +115,7 @@ mkRoot user = do
_ -> pure rs _ -> pure rs
pure rs pure rs
selectRoot :: User -> Query NodeRead selectRoot :: User -> Select NodeRead
selectRoot (UserName username) = proc () -> do selectRoot (UserName username) = proc () -> do
row <- queryNodeTable -< () row <- queryNodeTable -< ()
users <- queryUserTable -< () users <- queryUserTable -< ()
......
...@@ -46,17 +46,17 @@ data NgramsPoly id terms n = NgramsDB { _ngrams_id :: !id ...@@ -46,17 +46,17 @@ data NgramsPoly id terms n = NgramsDB { _ngrams_id :: !id
, _ngrams_n :: !n , _ngrams_n :: !n
} deriving (Show) } deriving (Show)
type NgramsWrite = NgramsPoly (Maybe (Column PGInt4)) type NgramsWrite = NgramsPoly (Maybe (Column SqlInt4))
(Column PGText) (Column SqlText)
(Column PGInt4) (Column SqlInt4)
type NgramsRead = NgramsPoly (Column PGInt4) type NgramsRead = NgramsPoly (Column SqlInt4)
(Column PGText) (Column SqlText)
(Column PGInt4) (Column SqlInt4)
type NgramsReadNull = NgramsPoly (Column (Nullable PGInt4)) type NgramsReadNull = NgramsPoly (Column (Nullable SqlInt4))
(Column (Nullable PGText)) (Column (Nullable SqlText))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
type NgramsDB = NgramsPoly Int Text Int type NgramsDB = NgramsPoly Int Text Int
...@@ -119,14 +119,14 @@ instance ToParamSchema NgramsType where ...@@ -119,14 +119,14 @@ instance ToParamSchema NgramsType where
toParamSchema _ = toParamSchema (Proxy :: Proxy TODO) toParamSchema _ = toParamSchema (Proxy :: Proxy TODO)
instance DefaultFromField (Nullable PGInt4) NgramsTypeId instance DefaultFromField (Nullable SqlInt4) NgramsTypeId
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
pgNgramsType :: NgramsType -> Column PGInt4 pgNgramsType :: NgramsType -> Column SqlInt4
pgNgramsType = pgNgramsTypeId . ngramsTypeId pgNgramsType = pgNgramsTypeId . ngramsTypeId
pgNgramsTypeId :: NgramsTypeId -> Column PGInt4 pgNgramsTypeId :: NgramsTypeId -> Column SqlInt4
pgNgramsTypeId (NgramsTypeId n) = sqlInt4 n pgNgramsTypeId (NgramsTypeId n) = sqlInt4 n
ngramsTypeId :: NgramsType -> NgramsTypeId ngramsTypeId :: NgramsType -> NgramsTypeId
......
...@@ -51,29 +51,29 @@ data PosTag = PosTag { unPosTag :: !Text } ...@@ -51,29 +51,29 @@ data PosTag = PosTag { unPosTag :: !Text }
type NgramsPostagDB = NgramsPostagPoly (Maybe Int) Int Int (Maybe Text) Int Int Int type NgramsPostagDB = NgramsPostagPoly (Maybe Int) Int Int (Maybe Text) Int Int Int
------------------------------------------------------------------------ ------------------------------------------------------------------------
type NgramsPosTagWrite = NgramsPostagPoly (Maybe (Column PGInt4)) type NgramsPosTagWrite = NgramsPostagPoly (Maybe (Column SqlInt4))
(Column PGInt4) (Column SqlInt4)
(Column PGInt4) (Column SqlInt4)
(Maybe (Column PGText)) (Maybe (Column SqlText))
(Column PGInt4) (Column SqlInt4)
(Column PGInt4) (Column SqlInt4)
(Maybe (Column PGInt4)) (Maybe (Column SqlInt4))
type NgramsPosTagRead = NgramsPostagPoly (Column PGInt4) type NgramsPosTagRead = NgramsPostagPoly (Column SqlInt4)
(Column PGInt4) (Column SqlInt4)
(Column PGInt4) (Column SqlInt4)
(Column PGText) (Column SqlText)
(Column PGInt4) (Column SqlInt4)
(Column PGInt4) (Column SqlInt4)
(Column PGInt4) (Column SqlInt4)
type NgramsPosTagReadNull = NgramsPostagPoly (Column (Nullable PGInt4)) type NgramsPosTagReadNull = NgramsPostagPoly (Column (Nullable SqlInt4))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
(Column (Nullable PGText)) (Column (Nullable SqlText))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
makeLenses ''NgramsPostagPoly makeLenses ''NgramsPostagPoly
instance PGS.ToRow NgramsPostagDB where instance PGS.ToRow NgramsPostagDB where
......
...@@ -72,68 +72,68 @@ nodeTable = Table "nodes" (pNode Node { _node_id = optionalTableField "i ...@@ -72,68 +72,68 @@ nodeTable = Table "nodes" (pNode Node { _node_id = optionalTableField "i
queryNodeTable :: Query NodeRead queryNodeTable :: Query NodeRead
queryNodeTable = selectTable nodeTable queryNodeTable = selectTable nodeTable
------------------------------------------------------------------------ ------------------------------------------------------------------------
type NodeWrite = NodePoly (Maybe (Column PGInt4) ) type NodeWrite = NodePoly (Maybe (Column SqlInt4) )
(Maybe (Column PGText) ) (Maybe (Column SqlText) )
(Column PGInt4) (Column SqlInt4)
(Column PGInt4) (Column SqlInt4)
(Maybe (Column PGInt4) ) (Maybe (Column SqlInt4) )
(Column PGText) (Column SqlText)
(Maybe (Column PGTimestamptz)) (Maybe (Column SqlTimestamptz))
(Column PGJsonb) (Column SqlJsonb)
type NodeRead = NodePoly (Column PGInt4 ) type NodeRead = NodePoly (Column SqlInt4 )
(Column PGText ) (Column SqlText )
(Column PGInt4 ) (Column SqlInt4 )
(Column PGInt4 ) (Column SqlInt4 )
(Column PGInt4 ) (Column SqlInt4 )
(Column PGText ) (Column SqlText )
(Column PGTimestamptz ) (Column SqlTimestamptz )
(Column PGJsonb ) (Column SqlJsonb )
type NodeReadNull = NodePoly (Column (Nullable PGInt4)) type NodeReadNull = NodePoly (Column (Nullable SqlInt4))
(Column (Nullable PGText)) (Column (Nullable SqlText))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
(Column (Nullable PGText)) (Column (Nullable SqlText))
(Column (Nullable PGTimestamptz)) (Column (Nullable SqlTimestamptz))
(Column (Nullable PGJsonb)) (Column (Nullable SqlJsonb))
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | Node(Read|Write)Search is slower than Node(Write|Read) use it -- | Node(Read|Write)Search is slower than Node(Write|Read) use it
-- for full text search only -- for full text search only
type NodeSearchWrite = type NodeSearchWrite =
NodePolySearch NodePolySearch
(Maybe (Column PGInt4) ) (Maybe (Column SqlInt4) )
(Column PGInt4 ) (Column SqlInt4 )
(Column PGInt4 ) (Column SqlInt4 )
(Column (Nullable PGInt4) ) (Column (Nullable SqlInt4) )
(Column PGText ) (Column SqlText )
(Maybe (Column PGTimestamptz)) (Maybe (Column SqlTimestamptz))
(Column PGJsonb ) (Column SqlJsonb )
(Maybe (Column PGTSVector) ) (Maybe (Column SqlTSVector) )
type NodeSearchRead = type NodeSearchRead =
NodePolySearch NodePolySearch
(Column PGInt4 ) (Column SqlInt4 )
(Column PGInt4 ) (Column SqlInt4 )
(Column PGInt4 ) (Column SqlInt4 )
(Column (Nullable PGInt4 )) (Column (Nullable SqlInt4 ))
(Column PGText ) (Column SqlText )
(Column PGTimestamptz ) (Column SqlTimestamptz )
(Column PGJsonb ) (Column SqlJsonb )
(Column PGTSVector ) (Column SqlTSVector )
type NodeSearchReadNull = type NodeSearchReadNull =
NodePolySearch NodePolySearch
(Column (Nullable PGInt4) ) (Column (Nullable SqlInt4) )
(Column (Nullable PGInt4) ) (Column (Nullable SqlInt4) )
(Column (Nullable PGInt4) ) (Column (Nullable SqlInt4) )
(Column (Nullable PGInt4) ) (Column (Nullable SqlInt4) )
(Column (Nullable PGText) ) (Column (Nullable SqlText) )
(Column (Nullable PGTimestamptz)) (Column (Nullable SqlTimestamptz))
(Column (Nullable PGJsonb) ) (Column (Nullable SqlJsonb) )
(Column (Nullable PGTSVector) ) (Column (Nullable SqlTSVector) )
data NodePolySearch id data NodePolySearch id
......
...@@ -47,36 +47,36 @@ data NodeNgramsPoly id ...@@ -47,36 +47,36 @@ data NodeNgramsPoly id
} deriving (Show, Eq, Ord) } deriving (Show, Eq, Ord)
{- {-
type NodeNgramsWrite = NodeNgramsPoly (Maybe (Column (PGInt4))) type NodeNgramsWrite = NodeNgramsPoly (Maybe (Column (SqlInt4)))
(Column (PGInt4)) (Column (SqlInt4))
(Maybe (Column (PGInt4))) (Maybe (Column (SqlInt4)))
(Column (PGInt4)) (Column (SqlInt4))
(Maybe (Column (PGInt4))) (Maybe (Column (SqlInt4)))
(Maybe (Column (PGInt4))) (Maybe (Column (SqlInt4)))
(Maybe (Column (PGInt4))) (Maybe (Column (SqlInt4)))
(Maybe (Column (PGInt4))) (Maybe (Column (SqlInt4)))
(Maybe (Column (PGFloat8))) (Maybe (Column (SqlFloat8)))
type NodeNodeRead = NodeNgramsPoly (Column PGInt4) type NodeNodeRead = NodeNgramsPoly (Column SqlInt4)
(Column PGInt4) (Column SqlInt4)
(Column PGInt4) (Column SqlInt4)
(Column PGInt4) (Column SqlInt4)
(Column PGInt4) (Column SqlInt4)
(Column PGInt4) (Column SqlInt4)
(Column PGInt4) (Column SqlInt4)
(Column PGInt4) (Column SqlInt4)
(Column PGFloat8) (Column SqlFloat8)
type NodeNgramsReadNull = NodeNgramsPoly (Column (Nullable PGInt4)) type NodeNgramsReadNull = NodeNgramsPoly (Column (Nullable SqlInt4))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
(Column (Nullable PGFloat8)) (Column (Nullable SqlFloat8))
-} -}
type NodeNgramsId = Int type NodeNgramsId = Int
type NgramsId = Int type NgramsId = Int
......
...@@ -32,20 +32,20 @@ data NodeNodePoly node1_id node2_id score cat ...@@ -32,20 +32,20 @@ data NodeNodePoly node1_id node2_id score cat
, _nn_category :: !cat , _nn_category :: !cat
} deriving (Show) } deriving (Show)
type NodeNodeWrite = NodeNodePoly (Column (PGInt4)) type NodeNodeWrite = NodeNodePoly (Column (SqlInt4))
(Column (PGInt4)) (Column (SqlInt4))
(Maybe (Column (PGFloat8))) (Maybe (Column (SqlFloat8)))
(Maybe (Column (PGInt4))) (Maybe (Column (SqlInt4)))
type NodeNodeRead = NodeNodePoly (Column (PGInt4)) type NodeNodeRead = NodeNodePoly (Column (SqlInt4))
(Column (PGInt4)) (Column (SqlInt4))
(Column (PGFloat8)) (Column (SqlFloat8))
(Column (PGInt4)) (Column (SqlInt4))
type NodeNodeReadNull = NodeNodePoly (Column (Nullable PGInt4)) type NodeNodeReadNull = NodeNodePoly (Column (Nullable SqlInt4))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
(Column (Nullable PGFloat8)) (Column (Nullable SqlFloat8))
(Column (Nullable PGInt4)) (Column (Nullable SqlInt4))
type NodeNode = NodeNodePoly NodeId NodeId (Maybe Double) (Maybe Int) type NodeNode = NodeNodePoly NodeId NodeId (Maybe Double) (Maybe Int)
...@@ -63,18 +63,18 @@ nodeNodeTable = ...@@ -63,18 +63,18 @@ nodeNodeTable =
} }
) )
instance DefaultFromField (Nullable PGInt4) Int where instance DefaultFromField (Nullable SqlInt4) Int where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance DefaultFromField (Nullable PGFloat8) Int where instance DefaultFromField (Nullable SqlFloat8) Int where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance DefaultFromField (Nullable PGFloat8) Double where instance DefaultFromField (Nullable SqlFloat8) Double where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance DefaultFromField PGFloat8 (Maybe Double) where instance DefaultFromField SqlFloat8 (Maybe Double) where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance DefaultFromField PGInt4 (Maybe Int) where instance DefaultFromField SqlInt4 (Maybe Int) where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
...@@ -32,25 +32,25 @@ data NodeNodeNgramsPoly n1 n2 ngrams_id ngt w ...@@ -32,25 +32,25 @@ data NodeNodeNgramsPoly n1 n2 ngrams_id ngt w
} deriving (Show) } deriving (Show)
type NodeNodeNgramsWrite = type NodeNodeNgramsWrite =
NodeNodeNgramsPoly (Column PGInt4 ) NodeNodeNgramsPoly (Column SqlInt4 )
(Column PGInt4 ) (Column SqlInt4 )
(Column PGInt4 ) (Column SqlInt4 )
(Column PGInt4 ) (Column SqlInt4 )
(Column PGFloat8) (Column SqlFloat8)
type NodeNodeNgramsRead = type NodeNodeNgramsRead =
NodeNodeNgramsPoly (Column PGInt4 ) NodeNodeNgramsPoly (Column SqlInt4 )
(Column PGInt4 ) (Column SqlInt4 )
(Column PGInt4 ) (Column SqlInt4 )
(Column PGInt4 ) (Column SqlInt4 )
(Column PGFloat8) (Column SqlFloat8)
type NodeNodeNgramsReadNull = type NodeNodeNgramsReadNull =
NodeNodeNgramsPoly (Column (Nullable PGInt4 )) NodeNodeNgramsPoly (Column (Nullable SqlInt4 ))
(Column (Nullable PGInt4 )) (Column (Nullable SqlInt4 ))
(Column (Nullable PGInt4 )) (Column (Nullable SqlInt4 ))
(Column (Nullable PGInt4 )) (Column (Nullable SqlInt4 ))
(Column (Nullable PGFloat8)) (Column (Nullable SqlFloat8))
type NodeNodeNgrams = type NodeNodeNgrams =
NodeNodeNgramsPoly CorpusId DocId NgramsId NgramsTypeId Double NodeNodeNgramsPoly CorpusId DocId NgramsId NgramsTypeId Double
......
...@@ -30,19 +30,19 @@ data NodeNodeNgrams2Poly node_id nodengrams_id w ...@@ -30,19 +30,19 @@ data NodeNodeNgrams2Poly node_id nodengrams_id w
} deriving (Show) } deriving (Show)
type NodeNodeNgrams2Write = type NodeNodeNgrams2Write =
NodeNodeNgrams2Poly (Column PGInt4 ) NodeNodeNgrams2Poly (Column SqlInt4 )
(Column PGInt4 ) (Column SqlInt4 )
(Column PGFloat8) (Column SqlFloat8)
type NodeNodeNgrams2Read = type NodeNodeNgrams2Read =
NodeNodeNgrams2Poly (Column PGInt4 ) NodeNodeNgrams2Poly (Column SqlInt4 )
(Column PGInt4 ) (Column SqlInt4 )
(Column PGFloat8) (Column SqlFloat8)
type NodeNodeNgrams2ReadNull = type NodeNodeNgrams2ReadNull =
NodeNodeNgrams2Poly (Column (Nullable PGInt4 )) NodeNodeNgrams2Poly (Column (Nullable SqlInt4 ))
(Column (Nullable PGInt4 )) (Column (Nullable SqlInt4 ))
(Column (Nullable PGFloat8)) (Column (Nullable SqlFloat8))
type NodeNodeNgrams2 = type NodeNodeNgrams2 =
NodeNodeNgrams2Poly DocId NodeNgramsId Double NodeNodeNgrams2Poly DocId NodeNgramsId Double
......
...@@ -45,17 +45,17 @@ data Node_NodeNgrams_NodeNgrams_Poly node_id nng1_id nng2_id weight = ...@@ -45,17 +45,17 @@ data Node_NodeNgrams_NodeNgrams_Poly node_id nng1_id nng2_id weight =
type Node_NodeNgrams_NodeNgrams_Write = type Node_NodeNgrams_NodeNgrams_Write =
Node_NodeNgrams_NodeNgrams_Poly Node_NodeNgrams_NodeNgrams_Poly
(Column PGInt4 ) (Column SqlInt4 )
(Maybe (Column PGInt4 )) (Maybe (Column SqlInt4 ))
(Column PGInt4 ) (Column SqlInt4 )
(Maybe (Column PGFloat8)) (Maybe (Column SqlFloat8))
type Node_NodeNgrams_NodeNgrams_Read = type Node_NodeNgrams_NodeNgrams_Read =
Node_NodeNgrams_NodeNgrams_Poly Node_NodeNgrams_NodeNgrams_Poly
(Column PGInt4 ) (Column SqlInt4 )
(Column PGInt4 ) (Column SqlInt4 )
(Column PGInt4 ) (Column SqlInt4 )
(Column PGFloat8) (Column SqlFloat8)
type ListNgramsId = Int type ListNgramsId = Int
...@@ -79,9 +79,9 @@ node_NodeNgrams_NodeNgrams_Table = ...@@ -79,9 +79,9 @@ node_NodeNgrams_NodeNgrams_Table =
} }
) )
instance DefaultFromField PGInt4 (Maybe Int) where instance DefaultFromField SqlInt4 (Maybe Int) where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
instance DefaultFromField PGFloat8 (Maybe Double) where instance DefaultFromField SqlFloat8 (Maybe Double) where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
...@@ -37,21 +37,21 @@ data RepoDbPoly version patches ...@@ -37,21 +37,21 @@ data RepoDbPoly version patches
} deriving (Show) } deriving (Show)
type RepoDbWrite type RepoDbWrite
= RepoDbPoly (Column PGInt4) = RepoDbPoly (Column SqlInt4)
(Column PGJsonb) (Column SqlJsonb)
type RepoDbRead type RepoDbRead
= RepoDbPoly (Column PGInt4) = RepoDbPoly (Column SqlInt4)
(Column PGJsonb) (Column SqlJsonb)
type RepoDbNgrams = RepoDbPoly Int NgramsStatePatch type RepoDbNgrams = RepoDbPoly Int NgramsStatePatch
$(makeAdaptorAndInstance "pRepoDbNgrams" ''RepoDbPoly) $(makeAdaptorAndInstance "pRepoDbNgrams" ''RepoDbPoly)
makeLenses ''RepoDbPoly makeLenses ''RepoDbPoly
instance DefaultFromField PGJsonb instance DefaultFromField SqlJsonb
(PatchMap NgramsType (PatchMap NgramsType
(PatchMap NodeId NgramsTablePatch)) (PatchMap NodeId NgramsTablePatch))
where where
defaultFromField = fieldQueryRunnerColumn defaultFromField = fromPGSFromField
repoTable :: Table RepoDbWrite RepoDbRead repoTable :: Table RepoDbWrite RepoDbRead
repoTable = Table "nodes_ngrams_repo" repoTable = Table "nodes_ngrams_repo"
......
...@@ -25,6 +25,7 @@ module Gargantext.Database.Schema.Prelude ...@@ -25,6 +25,7 @@ module Gargantext.Database.Schema.Prelude
, module GHC.Generics , module GHC.Generics
, module Gargantext.Core.Utils.Prefix , module Gargantext.Core.Utils.Prefix
, module Opaleye , module Opaleye
, module Opaleye.Internal.Table
, module Opaleye.Internal.QueryArr , module Opaleye.Internal.QueryArr
, module Test.QuickCheck.Arbitrary , module Test.QuickCheck.Arbitrary
) )
...@@ -37,8 +38,9 @@ import Data.Profunctor.Product.TH (makeAdaptorAndInstance) ...@@ -37,8 +38,9 @@ import Data.Profunctor.Product.TH (makeAdaptorAndInstance)
import Data.Swagger hiding (required, in_) import Data.Swagger hiding (required, in_)
import GHC.Generics (Generic) import GHC.Generics (Generic)
import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger) import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger)
import Opaleye hiding (FromField, readOnly) import Opaleye hiding (FromField)
import Opaleye.Internal.QueryArr (Query) import Opaleye.Internal.QueryArr (Query)
import Opaleye.Internal.Table (Table(..))
import Test.QuickCheck.Arbitrary hiding (vector) import Test.QuickCheck.Arbitrary hiding (vector)
import Database.PostgreSQL.Simple.FromField (FromField, fromField) import Database.PostgreSQL.Simple.FromField (FromField, fromField)
......
...@@ -38,7 +38,7 @@ import Data.Aeson.TH (deriveJSON) ...@@ -38,7 +38,7 @@ import Data.Aeson.TH (deriveJSON)
import Control.Lens.TH (makeLensesWith, abbreviatedFields) import Control.Lens.TH (makeLensesWith, abbreviatedFields)
import Data.Profunctor.Product.TH (makeAdaptorAndInstance) import Data.Profunctor.Product.TH (makeAdaptorAndInstance)
import Opaleye hiding (FromField) import Opaleye hiding (FromField)
import Opaleye.Internal.Table (Table(..))
------------------------------------------------------------------------ ------------------------------------------------------------------------
data UserLight = UserLight { userLight_id :: !Int data UserLight = UserLight { userLight_id :: !Int
, userLight_username :: !Text , userLight_username :: !Text
...@@ -72,26 +72,26 @@ data UserPoly id pass llogin suser ...@@ -72,26 +72,26 @@ data UserPoly id pass llogin suser
} deriving (Show, Generic) } deriving (Show, Generic)
type UserWrite = UserPoly (Maybe (Column PGInt4)) (Column PGText) type UserWrite = UserPoly (Maybe (Column SqlInt4)) (Column SqlText)
(Maybe (Column PGTimestamptz)) (Column PGBool) (Maybe (Column SqlTimestamptz)) (Column SqlBool)
(Column PGText) (Column PGText) (Column SqlText) (Column SqlText)
(Column PGText) (Column PGText) (Column SqlText) (Column SqlText)
(Column PGBool) (Column PGBool) (Column SqlBool) (Column SqlBool)
(Maybe (Column PGTimestamptz)) (Maybe (Column SqlTimestamptz))
type UserRead = UserPoly (Column PGInt4) (Column PGText) type UserRead = UserPoly (Column SqlInt4) (Column SqlText)
(Column PGTimestamptz) (Column PGBool) (Column SqlTimestamptz) (Column SqlBool)
(Column PGText) (Column PGText) (Column SqlText) (Column SqlText)
(Column PGText) (Column PGText) (Column SqlText) (Column SqlText)
(Column PGBool) (Column PGBool) (Column SqlBool) (Column SqlBool)
(Column PGTimestamptz) (Column SqlTimestamptz)
type UserReadNull = UserPoly (Column (Nullable PGInt4)) (Column (Nullable PGText)) type UserReadNull = UserPoly (Column (Nullable SqlInt4)) (Column (Nullable SqlText))
(Column (Nullable PGTimestamptz)) (Column (Nullable PGBool)) (Column (Nullable SqlTimestamptz)) (Column (Nullable SqlBool))
(Column (Nullable PGText)) (Column (Nullable PGText)) (Column (Nullable SqlText)) (Column (Nullable SqlText))
(Column (Nullable PGText)) (Column (Nullable PGText)) (Column (Nullable SqlText)) (Column (Nullable SqlText))
(Column (Nullable PGBool)) (Column (Nullable PGBool)) (Column (Nullable SqlBool)) (Column (Nullable SqlBool))
(Column (Nullable PGTimestamptz)) (Column (Nullable SqlTimestamptz))
type UserDB = UserPoly Int Text (Maybe UTCTime) Bool Text Text Text Text Bool Bool UTCTime type UserDB = UserPoly Int Text (Maybe UTCTime) Bool Text Text Text Text Bool Bool UTCTime
......
...@@ -6,9 +6,7 @@ skip-ghc-check: true ...@@ -6,9 +6,7 @@ skip-ghc-check: true
packages: packages:
- . - .
#- 'deps/gargantext-graph' #- 'deps/gargantext-graph'
#- 'deps/patches-map' #- 'deps/haskell-opaleye'
#- 'deps/accelerate'
#- 'deps/accelerate-utility'
docker: docker:
enable: false enable: false
...@@ -63,7 +61,7 @@ extra-deps: ...@@ -63,7 +61,7 @@ extra-deps:
# Databases libs # Databases libs
- git: https://github.com/delanoe/haskell-opaleye.git - git: https://github.com/delanoe/haskell-opaleye.git
commit: d3ab7acd5ede737478763630035aa880f7e34444 commit: 756cb90f4ce725463d957bc899d764e0ed73738c
- git: https://github.com/delanoe/hsparql.git - git: https://github.com/delanoe/hsparql.git
commit: 2acbbc55ac9bbd4bf1a713c586b8b8e8b82892eb commit: 2acbbc55ac9bbd4bf1a713c586b8b8e8b82892eb
- git: https://github.com/robstewart57/rdf4h.git - git: https://github.com/robstewart57/rdf4h.git
......
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