Fix video update on conflict insert

This commit is contained in:
Kavin 2023-07-28 11:15:03 +01:00
parent f4040772a2
commit 88e38bd8a1
No known key found for this signature in database
GPG key ID: 6E4598CA5C92C41F

View file

@ -159,8 +159,13 @@ public class VideoHelpers {
try (StatelessSession s = DatabaseSessionFactory.createStatelessSession()) { try (StatelessSession s = DatabaseSessionFactory.createStatelessSession()) {
var tr = s.beginTransaction(); var tr = s.beginTransaction();
try { try {
s.createNativeMutationQuery("INSERT INTO videos (uploader_id,duration,is_short,thumbnail,title,uploaded,views,id) values " + s.createNativeMutationQuery(
"(:uploader_id,:duration,:is_short,:thumbnail,:title,:uploaded,:views,:id) ON CONFLICT DO NOTHING") "INSERT INTO videos (uploader_id,duration,is_short,thumbnail,title,uploaded,views,id) values " +
"(:uploader_id,:duration,:is_short,:thumbnail,:title,:uploaded,:views,:id) ON CONFLICT (id) DO UPDATE SET " +
"duration = :duration," +
"title = :title," +
"views = :views"
)
.setParameter("uploader_id", video.getChannel()) .setParameter("uploader_id", video.getChannel())
.setParameter("duration", video.getDuration()) .setParameter("duration", video.getDuration())
.setParameter("is_short", video.isShort()) .setParameter("is_short", video.isShort())