Skip to content

Commit 5bc1f32

Browse files
author
Philip Z
committed
Stabilize continuous-page cursor fingerprints
Closes #76.
1 parent ceaee99 commit 5bc1f32

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎teaql-sql-portable/src/main/java/io/teaql/core/sql/portable/PortableSQLRepository.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,10 @@ private String queryKey(
451451
ContinuousPageFetchOptions options,
452452
String sql,
453453
Map<String, Object> parameters) {
454+
String paginationNeutralSql = sql.replaceAll(
455+
"(?i)\\bOFFSET\\s+(?:\\?|:[A-Za-z_][A-Za-z0-9_]*|\\d+)", "OFFSET ?");
454456
StringBuilder canonical = new StringBuilder(options.namespace())
455-
.append('|').append(request.getTypeName()).append('|').append(sql);
457+
.append('|').append(request.getTypeName()).append('|').append(paginationNeutralSql);
456458
new TreeMap<>(parameters).forEach((key, value) -> {
457459
if (!key.startsWith("limit") && !key.startsWith("offset")) {
458460
canonical.append('|').append(key).append('=').append(String.valueOf(value));

‎teaql-sql-portable/src/test/java/io/teaql/core/sql/portable/PortableSQLDatabaseTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ public void testContinuousPageFetchUsesSeekForTheNextIdDescendingPage() {
423423
assertTrue(firstPage.get(9).getId() > secondPage.get(0).getId());
424424
String executed = sqliteDb.queryTrace().get(0);
425425
assertTrue(executed, executed.contains("<"));
426-
assertTrue(executed, executed.matches("(?s).*OFFSET \\?.*args: .*0.*"));
426+
assertTrue(executed, executed.contains("OFFSET 0"));
427427
}
428428

429429
@Test

0 commit comments

Comments
 (0)