@@ -25,16 +25,16 @@ const { PURGE_DAY_RANGE } = require('../../util/constants');
2525// Check if provided UUIDs (array) were used by purged entities.
2626
2727const _getPurgedOrDeletedUuids = ( all , uuids ) => all ( sql `
28- SELECT "entityUuid" AS uuid FROM purged_entities WHERE "entityUuid" = ANY (ARRAY[${ sql . array ( uuids , 'text ' ) } ])
28+ SELECT "entityUuid" AS uuid FROM purged_entities WHERE "entityUuid" = ANY (ARRAY[${ sql . array ( uuids , 'uuid ' ) } ])
2929 UNION
30- SELECT uuid FROM entities WHERE "deletedAt" IS NOT NULL AND uuid = ANY (ARRAY[${ sql . array ( uuids , 'text ' ) } ])` )
30+ SELECT uuid FROM entities WHERE "deletedAt" IS NOT NULL AND uuid = ANY (ARRAY[${ sql . array ( uuids , 'uuid ' ) } ])` )
3131 . then ( all . map ( r => r . uuid ) ) ;
3232
3333const _isPurgedOrDeletedUuid = ( oneFirst , uuid ) => oneFirst ( sql `
3434 SELECT
35- EXISTS ( SELECT 1 FROM purged_entities WHERE "entityUuid" = ${ uuid } )
35+ EXISTS ( SELECT 1 FROM purged_entities WHERE "entityUuid" = ${ uuid } ::uuid )
3636 OR
37- EXISTS ( SELECT 1 FROM entities WHERE uuid = ${ uuid } AND "deletedAt" IS NOT NULL )
37+ EXISTS ( SELECT 1 FROM entities WHERE uuid = ${ uuid } ::uuid AND "deletedAt" IS NOT NULL )
3838 ` ) ;
3939/////////////////////////////////////////////////////////////////////////////////
4040// ENTITY DEF SOURCES
@@ -113,7 +113,7 @@ const createNew = (dataset, partial, subDef, sourceId, userAgentIn) => async ({
113113 return one ( sql `
114114with def as (${ _defInsert ( nextval , true , creatorId , userAgent , partial , 1 , sourceId ) } ),
115115ins as (insert into entities (id, "datasetId", "uuid", "createdAt", "creatorId")
116- select def."entityId", ${ dataset . id } , ${ partial . uuid } , def."createdAt", ${ creatorId } from def
116+ select def."entityId", ${ dataset . id } , ${ partial . uuid } ::uuid , def."createdAt", ${ creatorId } from def
117117 returning entities.*)
118118select ins.*, def.id as "entityDefId" from ins, def;` )
119119 . then ( ( { entityDefId, ...entityData } ) =>
@@ -197,7 +197,7 @@ const createVersion = (dataset, partial, subDef, version, sourceId, baseVersion,
197197 with def as (${ _defInsert ( partial . id , false , creatorId , userAgent , partial , version , sourceId , baseVersion , conflictingPropJson ) } ),
198198 upd as (update entity_defs set current=false where entity_defs."entityId" = ${ partial . id } AND current IS TRUE),
199199 entities as (update entities set "updatedAt"=clock_timestamp(), conflict=${ partial . conflict ?? sql `NULL` }
200- where "uuid"=${ partial . uuid }
200+ where "uuid"=${ partial . uuid } ::uuid
201201 returning *)
202202 select ${ _unjoiner . fields } from def as entity_defs
203203 join entities on entity_defs."entityId" = entities.id
@@ -677,7 +677,7 @@ const _holdSubmission = (event, submissionId, submissionDefId, entityUuid, branc
677677 await Entities . logBacklogEvent ( 'hold' , event , submissionId , submissionDefId ) ;
678678 await run ( sql `
679679 INSERT INTO entity_submission_backlog ("auditId", "submissionId", "submissionDefId", "entityUuid", "branchId", "branchBaseVersion", "loggedAt")
680- VALUES (${ event . id } , ${ submissionId } , ${ submissionDefId } , ${ entityUuid } , ${ branchId } , ${ branchBaseVersion } , CLOCK_TIMESTAMP())
680+ VALUES (${ event . id } , ${ submissionId } , ${ submissionDefId } , ${ entityUuid } ::uuid , ${ branchId } , ${ branchBaseVersion } , CLOCK_TIMESTAMP())
681681 ` ) ;
682682} ;
683683
@@ -691,7 +691,7 @@ const _getNextHeldSubmissionInBranch = (entityUuid, branchId, branchBaseVersion)
691691 ( branchId == null )
692692 ? maybeOne ( sql `
693693 SELECT * FROM entity_submission_backlog
694- WHERE "entityUuid" = ${ entityUuid } AND "branchBaseVersion" = 1` )
694+ WHERE "entityUuid" = ${ entityUuid } ::uuid AND "branchBaseVersion" = 1` )
695695 : maybeOne ( sql `
696696 SELECT * FROM entity_submission_backlog
697697 WHERE "branchId"=${ branchId } AND "branchBaseVersion" = ${ branchBaseVersion } ` ) ) ;
@@ -868,7 +868,7 @@ INNER JOIN entities ON entities.id = entity_defs."entityId"
868868LEFT JOIN actors ON entities."creatorId"=actors.id
869869${ options . skiptoken ? sql `
870870 INNER JOIN
871- ( SELECT id, "createdAt" FROM entities WHERE "uuid" = ${ options . skiptoken . uuid } ) AS cursor
871+ ( SELECT id, "createdAt" FROM entities WHERE "uuid" = ${ options . skiptoken . uuid } ::uuid ) AS cursor
872872 ON entities."createdAt" <= cursor."createdAt" AND entities.id < cursor.id
873873 ` : sql `` }
874874WHERE
@@ -903,7 +903,7 @@ CROSS JOIN
903903 JOIN entity_defs ON entity_defs."entityId" = entities.id
904904 ${ options . skiptoken ? sql `
905905 INNER JOIN
906- ( SELECT id, "createdAt" FROM entities WHERE "uuid" = ${ options . skiptoken . uuid } ) AS cursor
906+ ( SELECT id, "createdAt" FROM entities WHERE "uuid" = ${ options . skiptoken . uuid } ::uuid ) AS cursor
907907 ON entities."createdAt" <= cursor."createdAt" AND entities.id < cursor.id
908908 ` : sql `` }
909909 WHERE "datasetId" = ${ datasetId }
@@ -958,7 +958,7 @@ const _trashedFilter = (force, projectId, datasetName, entityUuid) => {
958958 const idFilters = [ sql `TRUE` ] ;
959959 if ( projectId ) idFilters . push ( sql `datasets."projectId" = ${ projectId } ` ) ;
960960 if ( datasetName ) idFilters . push ( sql `datasets."name" = ${ datasetName } ` ) ;
961- if ( entityUuid ) idFilters . push ( sql `entities."uuid" = ${ entityUuid } ` ) ;
961+ if ( entityUuid ) idFilters . push ( sql `entities."uuid" = ${ entityUuid } ::uuid ` ) ;
962962
963963 const idFilter = sql . join ( idFilters , sql ` AND ` ) ;
964964
@@ -984,7 +984,7 @@ const purge = (force = false, projectId = null, datasetName = null, entityUuid =
984984 UPDATE audits SET notes = NULL
985985 FROM entities
986986 JOIN datasets ON entities."datasetId" = datasets.id
987- WHERE (audits.details->'entity'->>'uuid') = entities.uuid
987+ WHERE (audits.details->'entity'->>'uuid')::uuid = entities.uuid
988988 AND ${ _trashedFilter ( force , projectId , datasetName , entityUuid ) }
989989 ), purge_audit AS (
990990 INSERT INTO audits ("action", "acteeId", "loggedAt", "processed", "details")
@@ -1005,7 +1005,7 @@ const purge = (force = false, projectId = null, datasetName = null, entityUuid =
10051005 ), delete_submission_backlog AS (
10061006 DELETE FROM entity_submission_backlog
10071007 USING entities, datasets
1008- WHERE entity_submission_backlog."entityUuid"::varchar = entities.uuid
1008+ WHERE entity_submission_backlog."entityUuid"::uuid = entities.uuid
10091009 AND entities."datasetId" = datasets.id
10101010 AND ${ _trashedFilter ( force , projectId , datasetName , entityUuid ) }
10111011 ), deleted_entities AS (
@@ -1060,7 +1060,7 @@ order by actors."displayName" asc`)
10601060 . then ( map ( construct ( Actor ) ) ) ;
10611061
10621062const deleteByIds = ( uuids ) => ( { allFirst } ) => allFirst ( sql `
1063- UPDATE entities SET "deletedAt" = now() WHERE "deletedAt" IS NULL AND uuid = ANY (ARRAY[${ sql . array ( uuids , 'text ' ) } ])
1063+ UPDATE entities SET "deletedAt" = now() WHERE "deletedAt" IS NULL AND uuid = ANY (ARRAY[${ sql . array ( uuids , 'uuid ' ) } ])
10641064 RETURNING uuid
10651065` ) ;
10661066
@@ -1077,7 +1077,7 @@ deleteByIds.audit = (deletedUuids, _, dataset) => (log) => {
10771077deleteByIds . audit . withResult = true ;
10781078
10791079const restoreByIds = ( uuids ) => ( { allFirst } ) => allFirst ( sql `
1080- UPDATE entities SET "deletedAt" = null WHERE "deletedAt" IS NOT NULL AND uuid = ANY (ARRAY[${ sql . array ( uuids , 'text ' ) } ])
1080+ UPDATE entities SET "deletedAt" = null WHERE "deletedAt" IS NOT NULL AND uuid = ANY (ARRAY[${ sql . array ( uuids , 'uuid ' ) } ])
10811081 RETURNING uuid
10821082` ) ;
10831083
0 commit comments