fix insertOrUpdate causing conflict when sending in batch
This commit is contained in:
parent
392953f08e
commit
7d5e5eb75b
@ -28,16 +28,17 @@ object PresAnnotationDAO {
|
|||||||
annotation <- annotations
|
annotation <- annotations
|
||||||
} yield {
|
} yield {
|
||||||
DatabaseConnection.enqueue(
|
DatabaseConnection.enqueue(
|
||||||
TableQuery[PresAnnotationDbTableDef].insertOrUpdate(
|
sqlu"""
|
||||||
PresAnnotationDbModel(
|
WITH upsert AS (
|
||||||
annotationId = annotation.id,
|
UPDATE pres_annotation
|
||||||
pageId = annotation.wbId,
|
SET "annotationInfo"=${JsonUtils.mapToJson(annotation.annotationInfo).compactPrint},
|
||||||
meetingId = meetingId,
|
"lastUpdatedAt" = ${new java.sql.Timestamp(annotationUpdatedAt)}
|
||||||
userId = annotation.userId,
|
WHERE "annotationId" = ${annotation.id}
|
||||||
annotationInfo = JsonUtils.mapToJson(annotation.annotationInfo).compactPrint,
|
RETURNING *)
|
||||||
lastUpdatedAt = new java.sql.Timestamp(annotationUpdatedAt)
|
INSERT INTO pres_annotation ("annotationId", "pageId", "meetingId", "userId", "annotationInfo", "lastUpdatedAt")
|
||||||
)
|
SELECT ${annotation.id}, ${annotation.wbId}, ${meetingId}, ${annotation.userId},
|
||||||
)
|
${JsonUtils.mapToJson(annotation.annotationInfo).compactPrint}, ${new java.sql.Timestamp(annotationUpdatedAt)}
|
||||||
|
WHERE NOT EXISTS (SELECT * FROM upsert)"""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user