Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
haskell-gargantext
Commits
490577df
Commit
490577df
authored
Jan 30, 2023
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] #173 Ngrams Change insert causes Database error
parent
2b05b544
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
14 deletions
+7
-14
gargantext.cabal
gargantext.cabal
+1
-1
NodeStory.hs
src/Gargantext/Core/NodeStory.hs
+6
-13
No files found.
gargantext.cabal
View file @
490577df
...
...
@@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack
name: gargantext
version: 0.0.6.9.4
version:
0.0.6.9.4
synopsis: Search, map, share
description: Please see README.md
category: Data
...
...
src/Gargantext/Core/NodeStory.hs
View file @
490577df
...
...
@@ -396,18 +396,14 @@ insertNodeArchiveHistory c nodeId version (h:hs) = do
_
<-
insertNodeArchiveHistory
c
nodeId
version
hs
pure
()
where
-- https://dba.stackexchange.com/questions/265554/how-to-check-other-table-for-value-during-insert
-- https://stackoverflow.com/questions/39224438/postgresql-insert-if-foreign-key-exists
query
::
PGS
.
Query
query
=
[
sql
|
INSERT INTO node_story_archive_history(node_id, ngrams_type_id, ngrams_id, patch, version)
SELECT node_id, ngrams_type_id, ngrams_id, patch::jsonb, version FROM (
VALUES (?, ?, ?, ?, ?)
) AS i(node_id, ngrams_type_id, ngrams_id, patch, version)
WHERE NOT EXISTS (
SELECT FROM ngrams
CROSS JOIN nodes
WHERE ngrams.id = ngrams_id
AND nodes.id = node_id
WHERE EXISTS (
SELECT * FROM nodes where nodes.id = node_id
)
|]
getNodeStory
::
PGS
.
Connection
->
NodeId
->
IO
NodeListStory
...
...
@@ -475,17 +471,14 @@ insertNodeStory c (NodeId nId) a = do
-- runInsert c $ insert ngramsType ngrams ngramsRepoElement) $ archiveStateToList _a_state
where
-- https://
dba.stackexchange.com/questions/265554/how-to-check-other-table-for-value-during-insert
-- https://
stackoverflow.com/questions/39224438/postgresql-insert-if-foreign-key-exists
query
::
PGS
.
Query
query
=
[
sql
|
INSERT INTO node_stories(node_id, ngrams_type_id, ngrams_id, ngrams_repo_element)
SELECT * FROM (
VALUES (?, ?, ?, ?)
) AS i(node_id, ngrams_type_id, ngrams_id, ngrams_repo_element)
WHERE NOT EXISTS (
SELECT FROM ngrams
CROSS JOIN nodes
WHERE ngrams.id = ngrams_id
AND nodes.id = node_id
WHERE EXISTS (
SELECT * FROM nodes where nodes.id = node_id
)
|]
-- insert ngramsType ngrams ngramsRepoElement =
-- Insert { iTable = nodeStoryTable
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment