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

Merge branch 'dev' into dev-docs-download

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