fix(oracle): skip SQL pagination clauses for Oracle 11g compatibility
Oracle 11g does not support FETCH FIRST / LIMIT syntax. Skip appending pagination clauses at SQL level and rely on JDBC setMaxRows for row limiting, which already works across all Oracle versions.
This commit is contained in:
parent
025a4fdcce
commit
619573a69d
|
|
@ -191,6 +191,10 @@ pub fn build_paginated_query_sql(options: PaginatedQuerySqlOptions) -> QuerySqlB
|
|||
return ok(format!("{statement} LIMIT {safe_limit} OFFSET {safe_offset};"));
|
||||
}
|
||||
|
||||
if options.database_type == Some(DatabaseType::Oracle) {
|
||||
return ok(format!("{statement};"));
|
||||
}
|
||||
|
||||
if options.database_type.is_some_and(uses_fetch_first) {
|
||||
return ok(add_fetch_first_limit(&statement, safe_limit, safe_offset));
|
||||
}
|
||||
|
|
@ -784,7 +788,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn uses_fetch_first_pagination_for_oracle() {
|
||||
fn oracle_pagination_skips_sql_clause() {
|
||||
let result = build_paginated_query_sql(PaginatedQuerySqlOptions {
|
||||
original_sql: "SELECT id FROM users".to_string(),
|
||||
database_type: Some(DatabaseType::Oracle),
|
||||
|
|
@ -792,7 +796,7 @@ mod tests {
|
|||
offset: 0,
|
||||
});
|
||||
|
||||
assert_eq!(result.sql.unwrap(), "SELECT id FROM users FETCH FIRST 100 ROWS ONLY;");
|
||||
assert_eq!(result.sql.unwrap(), "SELECT id FROM users;");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -110,6 +110,10 @@ pub fn build_table_data_select_sql(options: TableDataSelectSqlOptions) -> String
|
|||
);
|
||||
}
|
||||
|
||||
if database_type == Some(DatabaseType::Oracle) {
|
||||
return format!("SELECT {select_columns} FROM {table_alias}{where_clause}{order}");
|
||||
}
|
||||
|
||||
if database_type.is_some_and(uses_fetch_first) {
|
||||
let offset = options
|
||||
.offset
|
||||
|
|
@ -865,7 +869,7 @@ mod tests {
|
|||
where_input: None,
|
||||
include_row_id: true,
|
||||
}),
|
||||
"SELECT ROWIDTOCHAR(t.ROWID) AS \"__DBX_ROWID\", t.* FROM \"DBXTEST\".\"DBX_LOAD_TABLE_006\" t ORDER BY t.ROWID ASC FETCH FIRST 100 ROWS ONLY"
|
||||
"SELECT ROWIDTOCHAR(t.ROWID) AS \"__DBX_ROWID\", t.* FROM \"DBXTEST\".\"DBX_LOAD_TABLE_006\" t ORDER BY t.ROWID ASC"
|
||||
);
|
||||
assert_eq!(
|
||||
build_table_data_select_sql(TableDataSelectSqlOptions {
|
||||
|
|
|
|||
Loading…
Reference in New Issue