fix(jdbc): support Caché data grid pagination

Closes #3423
This commit is contained in:
t8y2 committed 2026-08-13 20:50:07 +08:00
1 parent 65cd4cfe28
commit fc6c5d4aa6
14 files changed
+160 -1

No files matched your search

@@ -225,7 +225,11 @@ pub fn build_table_data_select_sql(options: TableDataSelectSqlOptions) -> String
match table_pagination_strategy(database_type) {
TablePaginationStrategy::IrisTop => {
format!("SELECT TOP {limit} {select_columns} FROM {table_alias}{where_clause}{order}")
if options.use_driver_row_offset {
format!("SELECT {select_columns} FROM {table_alias}{where_clause}{order}")
} else {
format!("SELECT TOP {limit} {select_columns} FROM {table_alias}{where_clause}{order}")
}
}
TablePaginationStrategy::InformixFirst => {
let row_limit = informix_row_limit_clause(limit, options.offset.unwrap_or(0));
@@ -654,6 +658,7 @@ mod tests {
order_by: None,
limit: Some(10),
offset: None,
use_driver_row_offset: false,
where_input: None,
include_row_id: false,
}
+19
View File
@@ -621,6 +621,25 @@ fn builds_table_data_where_and_schema_queries() {
}),
"SELECT TOP 100 * FROM \"Ens\".\"AlarmResponse\""
);
assert_eq!(
build_table_data_select_sql(TableDataSelectSqlOptions {
database_type: Some(DatabaseType::Iris),
schema: Some("Ens".to_string()),
table_name: "AlarmResponse".to_string(),
table_type: None,
primary_keys: Vec::new(),
columns: Vec::new(),
fallback_order_columns: Vec::new(),
order_by: Some("\"ID\" ASC".to_string()),
limit: Some(100),
offset: Some(100),
use_driver_row_offset: true,
where_input: Some("Status = 'Open'".to_string()),
include_row_id: false,
..Default::default()
}),
"SELECT * FROM \"Ens\".\"AlarmResponse\" WHERE (Status = 'Open') ORDER BY \"ID\" ASC"
);
assert_eq!(
build_table_data_select_sql(TableDataSelectSqlOptions {
database_type: Some(DatabaseType::Iotdb),
+5
View File
@@ -61,6 +61,11 @@ pub struct TableDataSelectSqlOptions {
pub limit: Option<usize>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub offset: Option<usize>,
/// The JDBC driver advances the ResultSet before collecting the page.
/// This keeps database-specific identifier rules while avoiding SQL
/// pagination syntax that the selected driver does not support.
#[serde(default)]
pub use_driver_row_offset: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub where_input: Option<String>,
#[serde(default)]