Skip to content

Commit

Permalink
Close #407
Browse files Browse the repository at this point in the history
  • Loading branch information
jjrom committed May 14, 2024
1 parent e0e0f95 commit 5134ef6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/resto/core/dbfunctions/FacetsFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function storeFacets($facets, $userid, $collectionId = '*')
*
* [IMPORTANT] UPSERT with check on parentId only if $facetElement['parentId'] is set
*/
$insert = 'INSERT INTO ' . $this->dbDriver->targetSchema . '.facet (id, collection, value, type, pid, owner, description, created, counter, isleaf) SELECT $1,$2,$3,$4,$5,$6,$7,now(),$8,$9';
$insert = 'INSERT INTO ' . $this->dbDriver->targetSchema . '.facet (id, collection, value, type, pid, owner, description, created, counter, isleaf) SELECT public.normalize($1),$2,$3,$4,public.normalize($5),$6,$7,now(),$8,$9';
$upsert = 'UPDATE ' . $this->dbDriver->targetSchema . '.facet SET counter=' .(isset($facetElement['counter']) ? 'counter' : 'counter+1') . ' WHERE public.normalize(id)=public.normalize($1) AND public.normalize(collection)=public.normalize($2)' . (isset($facetElement['parentId']) ? ' AND public.normalize(pid)=public.normalize($5)' : '');
$this->dbDriver->pQuery('WITH upsert AS (' . $upsert . ' RETURNING *) ' . $insert . ' WHERE NOT EXISTS (SELECT * FROM upsert)', array(
$facetElement['id'],
Expand Down

0 comments on commit 5134ef6

Please sign in to comment.