diff --git a/hive/indexer/votes.py b/hive/indexer/votes.py
index 85492eb2a7b68b457e1aebe2819624125bee3d58..312b0820cc2afe5260dd2b04b1131d0c0c583219 100644
--- a/hive/indexer/votes.py
+++ b/hive/indexer/votes.py
@@ -106,11 +106,12 @@ class Votes:
                 ON CONFLICT ON CONSTRAINT hive_votes_ux1 DO
                 UPDATE
                   SET
-                    weight = (CASE (SELECT hp.is_paidout FROM hive_posts hp WHERE hp.id = EXCLUDED.id) WHEN true THEN hive_votes.weight ELSE EXCLUDED.weight END),
-                    rshares = (CASE (SELECT hp.is_paidout FROM hive_posts hp WHERE hp.id = EXCLUDED.id) WHEN true THEN hive_votes.rshares ELSE EXCLUDED.rshares END),
+                    weight = (CASE (SELECT hp.is_paidout FROM hive_posts hp WHERE hp.id = EXCLUDED.post_id) WHEN true THEN hive_votes.weight ELSE EXCLUDED.weight END),
+                    rshares = (CASE (SELECT hp.is_paidout FROM hive_posts hp WHERE hp.id = EXCLUDED.post_id) WHEN true THEN hive_votes.rshares ELSE EXCLUDED.rshares END),
                     vote_percent = EXCLUDED.vote_percent,
                     last_update = EXCLUDED.last_update,
                     num_changes = hive_votes.num_changes + 1
+                  WHERE hive_votes.voter_id = EXCLUDED.voter_id and hive_votes.author_id = EXCLUDED.author_id and hive_votes.permlink_id = EXCLUDED.permlink_id;
                 """
 
             values = []
diff --git a/tests/tests_api b/tests/tests_api
index 779f69cf2171b2dd6259cb6fc300cd3bea737edc..619f51ed6c85a016621b12fa1264c12c7d3d3156 160000
--- a/tests/tests_api
+++ b/tests/tests_api
@@ -1 +1 @@
-Subproject commit 779f69cf2171b2dd6259cb6fc300cd3bea737edc
+Subproject commit 619f51ed6c85a016621b12fa1264c12c7d3d3156