From 3487566eaf0ab337bb8bafb3425f7a9b14bcd209 Mon Sep 17 00:00:00 2001 From: Yordis Prieto Date: Sat, 26 Sep 2026 17:11:34 -0400 Subject: [PATCH] fix(plugin-cassandra): browse tables without an OFFSET, which CQL does not have Signed-off-by: Yordis Prieto --- CHANGELOG.md | 1 + ...luginMetadataRegistry+RegistryDefaults.swift | 10 ++++++++-- .../Models/PaginationCapabilityTests.swift | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bf1e29e1..3826ce28e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -130,6 +130,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Syntax error on opening a Cassandra or ScyllaDB table, from an `OFFSET` that CQL does not have. - Pre-connect script failures sometimes reported without the script's own error message. - Failed MongoDB statements, including writes the server rejected, reported as successful with an empty result. - Save reporting success after leaving out an edit it could not write, such as a new MongoDB document left empty. (#3132) diff --git a/TablePro/Core/Plugins/PluginMetadataRegistry+RegistryDefaults.swift b/TablePro/Core/Plugins/PluginMetadataRegistry+RegistryDefaults.swift index 82a5c078a..c3806102f 100644 --- a/TablePro/Core/Plugins/PluginMetadataRegistry+RegistryDefaults.swift +++ b/TablePro/Core/Plugins/PluginMetadataRegistry+RegistryDefaults.swift @@ -807,7 +807,10 @@ extension PluginMetadataRegistry { supportsDropIndex: false, supportsModifyPrimaryKey: false, supportsOpportunisticTLS: false, - supportsClientKeyPassphrase: true + supportsClientKeyPassphrase: true, + pagination: .leadingRowsOnly( + maximumRows: SettingsValidationRules.defaultPageSizeRange.upperBound + ) ), schema: PluginMetadataSnapshot.SchemaInfo( defaultSchemaName: "public", @@ -870,7 +873,10 @@ extension PluginMetadataRegistry { supportsDropIndex: false, supportsModifyPrimaryKey: false, supportsOpportunisticTLS: false, - supportsClientKeyPassphrase: true + supportsClientKeyPassphrase: true, + pagination: .leadingRowsOnly( + maximumRows: SettingsValidationRules.defaultPageSizeRange.upperBound + ) ), schema: PluginMetadataSnapshot.SchemaInfo( defaultSchemaName: "public", diff --git a/TableProTests/Models/PaginationCapabilityTests.swift b/TableProTests/Models/PaginationCapabilityTests.swift index de12a8443..7637e2f9f 100644 --- a/TableProTests/Models/PaginationCapabilityTests.swift +++ b/TableProTests/Models/PaginationCapabilityTests.swift @@ -35,6 +35,23 @@ struct PaginationCapabilityTests { #expect(PaginationCapability.of(.postgresql) == .offset) } + @Test("Cassandra and ScyllaDB never seek, because CQL has no OFFSET") + func cassandraAndScyllaDBHaveNoSeeking() { + #expect(!PaginationCapability.of(.cassandra).allowsSeeking) + #expect(!PaginationCapability.of(.scylladb).allowsSeeking) + } + + @Test("A Cassandra or ScyllaDB browse states a LIMIT and never an OFFSET") + func cassandraAndScyllaDBBrowseNeverOffsets() { + for databaseType in [DatabaseType.cassandra, .scylladb] { + let builder = TableQueryBuilder(databaseType: databaseType, pagination: .of(databaseType)) + let query = builder.buildBaseQuery(tableName: "users", schemaName: "shop", limit: 1_000, offset: 0) + + #expect(query == #"SELECT * FROM "shop"."users" LIMIT 1000"#) + #expect(!query.contains("OFFSET")) + } + } + @Test("A leading-rows table query states a clamped LIMIT and never an OFFSET") func builderNeverOffsets() { let builder = TableQueryBuilder(databaseType: .cloudflareR2SQL, pagination: leadingRows)