Commit e7fd07652e085dc9bfcd945bc9a7a2404aeb41fc
1 parent
b8291be0
Removed code duplicates and fixed one minor issue
Showing
1 changed file
with
4 additions
and
9 deletions
... | ... | @@ -42,20 +42,15 @@ public class PsqlLatestInsertTsRepository extends AbstractInsertRepository imple |
42 | 42 | private Boolean updateByLatestTs; |
43 | 43 | |
44 | 44 | private static final String BATCH_UPDATE = |
45 | - "UPDATE ts_kv_latest SET ts = ?, bool_v = ?, str_v = ?, long_v = ?, dbl_v = ?, json_v = cast(? AS json) WHERE entity_id = ? AND key = ?;"; | |
46 | - | |
45 | + "UPDATE ts_kv_latest SET ts = ?, bool_v = ?, str_v = ?, long_v = ?, dbl_v = ?, json_v = cast(? AS json) WHERE entity_id = ? AND key = ?"; | |
47 | 46 | |
48 | 47 | private static final String INSERT_OR_UPDATE = |
49 | 48 | "INSERT INTO ts_kv_latest (entity_id, key, ts, bool_v, str_v, long_v, dbl_v, json_v) VALUES(?, ?, ?, ?, ?, ?, ?, cast(? AS json)) " + |
50 | - "ON CONFLICT (entity_id, key) DO UPDATE SET ts = ?, bool_v = ?, str_v = ?, long_v = ?, dbl_v = ?, json_v = cast(? AS json);"; | |
51 | - | |
52 | - private static final String BATCH_UPDATE_BY_LATEST_TS = | |
53 | - "UPDATE ts_kv_latest SET ts = ?, bool_v = ?, str_v = ?, long_v = ?, dbl_v = ?, json_v = cast(? AS json) WHERE entity_id = ? AND key = ? AND ts <= ?;"; | |
49 | + "ON CONFLICT (entity_id, key) DO UPDATE SET ts = ?, bool_v = ?, str_v = ?, long_v = ?, dbl_v = ?, json_v = cast(? AS json)"; | |
54 | 50 | |
51 | + private static final String BATCH_UPDATE_BY_LATEST_TS = BATCH_UPDATE + " AND ts_kv_latest.ts <= ?"; | |
55 | 52 | |
56 | - private static final String INSERT_OR_UPDATE_BY_LATEST_TS = | |
57 | - "INSERT INTO ts_kv_latest (entity_id, key, ts, bool_v, str_v, long_v, dbl_v, json_v) VALUES(?, ?, ?, ?, ?, ?, ?, cast(? AS json)) " + | |
58 | - "ON CONFLICT (entity_id, key) DO UPDATE SET ts = ?, bool_v = ?, str_v = ?, long_v = ?, dbl_v = ?, json_v = cast(? AS json) WHERE ts_kv_latest.ts <= ?;"; | |
53 | + private static final String INSERT_OR_UPDATE_BY_LATEST_TS = INSERT_OR_UPDATE + " WHERE ts_kv_latest.ts <= ?"; | |
59 | 54 | |
60 | 55 | @Override |
61 | 56 | public void saveOrUpdate(List<TsKvLatestEntity> entities) { | ... | ... |