xtea service: fix bulk query returning duplicates

Some rows have backfilled times that are duplicates, causing the join to
join multiple rows. Assume ids only increment and fetch the row with the
highest id instead, and join on id.
This commit is contained in:
Adam
2019-05-25 18:02:56 -04:00
parent bc649d3d7b
commit 4f82be9691

View File

@@ -184,9 +184,9 @@ public class XteaService
try (Connection con = sql2o.open())
{
return con.createQuery(
"select t1.region, t1.time, t2.rev, t2.key1, t2.key2, t2.key3, t2.key4 from " +
"(select region,max(time) as time from xtea group by region) t1 " +
"join xtea t2 on t1.region = t2.region and t1.time = t2.time")
"select t1.region, t2.time, t2.rev, t2.key1, t2.key2, t2.key3, t2.key4 from " +
"(select region,max(id) as id from xtea group by region) t1 " +
"join xtea t2 on t1.id = t2.id")
.executeAndFetch(XteaEntry.class);
}
}