1
0
mirror of https://github.com/google/nomulus synced 2025-12-23 14:25:44 +00:00

Fix BSA batch query for all unblockables (#2544)

Typo in sql script resulting in some unblockables not loaded.

See b/361770793
This commit is contained in:
Weimin Yu
2024-09-05 15:33:26 -04:00
committed by GitHub
parent ab60ac44fd
commit 7ed7cf3340
2 changed files with 15 additions and 1 deletions

View File

@@ -109,7 +109,7 @@ public final class Queries {
tm().getEntityManager()
.createQuery(
"FROM BsaUnblockableDomain d WHERE d.label > :label OR (d.label = :label"
+ " AND d.tld > :tld) ORDER BY d.tld, d.label ")
+ " AND d.tld > :tld) ORDER BY d.label, d.tld ")
.setParameter("label", lastRead.map(d -> d.label).orElse(""))
.setParameter("tld", lastRead.map(d -> d.tld).orElse(""))
.setMaxResults(batchSize)

View File

@@ -15,9 +15,12 @@
package google.registry.bsa.persistence;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.bsa.BsaTransactions.bsaQuery;
import static google.registry.bsa.persistence.Queries.batchReadBsaLabelText;
import static google.registry.bsa.persistence.Queries.batchReadUnblockableDomains;
import static google.registry.bsa.persistence.Queries.deleteBsaLabelByLabels;
import static google.registry.bsa.persistence.Queries.queryBsaLabelByLabels;
import static google.registry.bsa.persistence.Queries.queryBsaUnblockableDomainByLabels;
@@ -295,4 +298,15 @@ class QueriesTest {
assertThat(bsaQuery(() -> queryMissedRegisteredUnblockables("tld2", fakeClock.nowUtc())))
.containsExactly(new DomainLifeSpan("label3.tld2", time2, time2.plusHours(1)));
}
@Test
void batchReadUnblockables_multiBatch() {
ImmutableList<UnblockableDomain> firstBatch = batchReadUnblockableDomains(Optional.empty(), 3);
UnblockableDomain lastInFirstBatch = getLast(firstBatch);
assertThat(lastInFirstBatch.domainName()).isEqualTo("label2.page");
assertThat(
getOnlyElement(batchReadUnblockableDomains(Optional.of(lastInFirstBatch), 3))
.domainName())
.isEqualTo("label3.app");
}
}