fix(gbase): support 8a and 8s profiles
This commit is contained in:
1 parent
213162aad3
commit
cbc7f9b0db
41 files changed
+596
-50
No files matched your search
@@ -68,6 +68,11 @@ pub fn build_table_data_select_sql(options: TableDataSelectSqlOptions) -> String
|
||||
return format!("SELECT TOP {limit} {select_columns} FROM {table_alias}{where_clause}{order}");
|
||||
}
|
||||
|
||||
if database_type == Some(DatabaseType::Informix) {
|
||||
let row_limit = informix_row_limit_clause(limit, options.offset.unwrap_or(0));
|
||||
return format!("SELECT {row_limit} {select_columns} FROM {table_alias}{where_clause}{order}");
|
||||
}
|
||||
|
||||
if database_type == Some(DatabaseType::Db2) && options.offset.is_some_and(|offset| offset > 0) {
|
||||
return build_db2_table_select_page_sql(
|
||||
&table_alias,
|
||||
@@ -142,6 +147,10 @@ pub fn build_table_select_sql(options: TableSelectSqlOptions<'_>) -> String {
|
||||
return format!("SELECT TOP {limit} {select_columns} FROM {table}{order_by}");
|
||||
}
|
||||
|
||||
if database_type == Some(DatabaseType::Informix) {
|
||||
return format!("SELECT FIRST {limit} {select_columns} FROM {table}{order_by}");
|
||||
}
|
||||
|
||||
if database_type.is_some_and(uses_fetch_first) {
|
||||
return format!("SELECT {select_columns} FROM {table}{order_by} FETCH FIRST {limit} ROWS ONLY");
|
||||
}
|
||||
@@ -153,6 +162,14 @@ pub fn build_table_select_sql(options: TableSelectSqlOptions<'_>) -> String {
|
||||
format!("SELECT {select_columns} FROM {table}{order_by} LIMIT {limit};")
|
||||
}
|
||||
|
||||
fn informix_row_limit_clause(limit: usize, offset: usize) -> String {
|
||||
if offset > 0 {
|
||||
format!("SKIP {offset} FIRST {limit}")
|
||||
} else {
|
||||
format!("FIRST {limit}")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn is_oracle_row_id(database_type: Option<DatabaseType>, name: &str) -> bool {
|
||||
database_type == Some(DatabaseType::Oracle) && name.eq_ignore_ascii_case(DBX_ROWID_COLUMN)
|
||||
}
|
||||
|
||||
@@ -278,6 +278,38 @@ fn builds_table_data_where_and_schema_queries() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builds_informix_table_data_with_skip_first_pagination() {
|
||||
assert_eq!(
|
||||
build_table_data_select_sql(TableDataSelectSqlOptions {
|
||||
database_type: Some(DatabaseType::Informix),
|
||||
schema: Some("ignored".to_string()),
|
||||
table_name: "users".to_string(),
|
||||
primary_keys: vec!["id".to_string()],
|
||||
columns: vec!["id".to_string(), "name".to_string()],
|
||||
fallback_order_columns: Vec::new(),
|
||||
order_by: None,
|
||||
limit: Some(50),
|
||||
offset: Some(100),
|
||||
where_input: Some("WHERE active = 1".to_string()),
|
||||
include_row_id: false,
|
||||
}),
|
||||
"SELECT SKIP 100 FIRST 50 * FROM users WHERE (active = 1) ORDER BY id ASC"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
build_table_select_sql(TableSelectSqlOptions {
|
||||
database_type: Some(DatabaseType::Informix),
|
||||
schema: None,
|
||||
table_name: "systables",
|
||||
columns: &["tabname".to_string()],
|
||||
order_columns: &[],
|
||||
limit: 1,
|
||||
}),
|
||||
"SELECT FIRST 1 tabname FROM systables"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_table_data_order_overrides_default_key_order() {
|
||||
assert_eq!(
|
||||
|
||||
Reference in new issue
Block a user