fix(vastbase): preserve schema for result inserts

This commit is contained in:
zipg authored and GitHub committed 2026-08-18 10:51:38 +08:00
1 parent fab5c75fd2
commit 50c706cc95
22 files changed
+291 -30

No files matched your search

+9 -5
View File
@@ -928,8 +928,12 @@ impl MiniMaxTextAccumulator {
Some(value.to_string())
}
fn complete(&self) -> &str {
&self.complete
fn replay_text(&self) -> &str {
if matches!(self.semantics, MiniMaxStreamSemantics::Incremental) {
&self.latest
} else {
&self.complete
}
}
}
@@ -964,7 +968,7 @@ impl MiniMaxReasoningDetailState {
fn replay_value(&self) -> serde_json::Value {
let mut detail = self.latest.clone();
if detail.get("text").is_some() {
detail["text"] = serde_json::Value::String(self.text.complete().to_string());
detail["text"] = serde_json::Value::String(self.text.replay_text().to_string());
}
detail
}
@@ -6751,7 +6755,7 @@ mod tests {
assert_eq!(normalizer.push("Hell"), None);
assert_eq!(normalizer.push("Hello world"), Some(" world".to_string()));
assert_eq!(normalizer.push(""), None);
assert_eq!(normalizer.complete(), "Hello world");
assert_eq!(normalizer.replay_text(), "Hello world");
}
#[test]
@@ -6761,7 +6765,7 @@ mod tests {
assert_eq!(normalizer.push("Hello"), Some("Hello".to_string()));
assert_eq!(normalizer.push(" world"), Some(" world".to_string()));
assert_eq!(normalizer.push("!"), Some("!".to_string()));
assert_eq!(normalizer.complete(), "Hello world!");
assert_eq!(normalizer.replay_text(), "Hello world!");
}
#[test]
+32
View File
@@ -5032,6 +5032,38 @@ mod tests {
.all(|statement| statement.contains("`gc`.`docfileinfo`") && !statement.contains('"')));
}
#[test]
fn vastbase_query_result_writes_use_resolved_search_path_schema() {
let result = prepare_data_grid_save(DataGridSaveStatementOptions {
database_type: Some(DatabaseType::Vastbase),
identifier_quote: None,
table_meta: DataGridTableMeta {
catalog: None,
database: Some("smes_dev".to_string()),
schema: Some("tenant_b".to_string()),
table_name: "TBLCUSPOSTMATERIALLOG".to_string(),
primary_keys: vec![],
columns: Some(vec![column("MONO", "varchar", true, None), column("ID", "bigint", false, None)]),
},
columns: vec!["MONO".to_string(), "ID".to_string()],
source_columns: None,
rows: vec![vec![json!("mono"), json!(461936049002042_i64)]],
dirty_rows: vec![(0, vec![(0, json!("LY-SC01-260800002"))])],
deleted_rows: vec![],
new_rows: vec![vec![json!("dbx-insert-check"), json!(461936049002043_i64)]],
});
assert_eq!(result.validation_error, None);
assert_eq!(result.execution_schema.as_deref(), Some("tenant_b"));
assert_eq!(
result.statements,
vec![
"UPDATE \"tenant_b\".\"TBLCUSPOSTMATERIALLOG\" SET \"MONO\" = 'LY-SC01-260800002' WHERE \"MONO\" = 'mono' AND \"ID\" = 461936049002042;",
"INSERT INTO \"tenant_b\".\"TBLCUSPOSTMATERIALLOG\" (\"MONO\", \"ID\") VALUES ('dbx-insert-check', 461936049002043);",
]
);
}
#[test]
fn gbase8s_save_omits_owner_for_insert_update_delete_and_rollback() {
let result = prepare_data_grid_save_for_driver_profile(
@@ -293,6 +293,7 @@ pub async fn get_columns(client: &MeilisearchClient, index: &str) -> Result<Vec<
is_primary_key: primary_key.as_deref() == Some(name.as_str()),
name,
data_type: field_type.label().to_string(),
resolved_schema: None,
is_nullable: true,
column_default: None,
is_unique: false,
+2
View File
@@ -3647,6 +3647,7 @@ pub async fn get_columns(pool: &MySqlPool, database: &str, table: &str) -> Resul
is_unique: column_key.eq_ignore_ascii_case("UNI"),
name,
data_type: column_type,
resolved_schema: None,
is_nullable: get_str_by_name(row, "IS_NULLABLE") == "YES",
column_default: get_opt_str(row, "COLUMN_DEFAULT"),
extra: get_opt_str(row, "EXTRA"),
@@ -3702,6 +3703,7 @@ pub async fn get_columns_show(pool: &MySqlPool, database: &str, table: &str) ->
Some(ColumnInfo {
name,
data_type: get_str_by_name(row, "Type"),
resolved_schema: None,
is_nullable: get_str_by_name(row, "Null").eq_ignore_ascii_case("YES"),
column_default: get_opt_str(row, "Default"),
is_primary_key: key.eq_ignore_ascii_case("PRI"),
@@ -197,6 +197,7 @@ pub async fn get_columns_show_from(
Some(ColumnInfo {
name,
data_type: get_str_by_name(row, "Type"),
resolved_schema: None,
is_nullable: get_str_by_name(row, "Null").eq_ignore_ascii_case("YES"),
column_default: get_opt_str(row, "Default"),
is_primary_key: key.eq_ignore_ascii_case("PRI"),
+4
View File
@@ -4405,6 +4405,7 @@ mod tests {
ColumnInfo {
name: name.to_string(),
data_type: data_type.to_string(),
resolved_schema: None,
is_nullable: false,
column_default: None,
is_primary_key: false,
@@ -5963,6 +5964,7 @@ mod tests {
source: Some(ColumnInfo {
name: "status".to_string(),
data_type: "text".to_string(),
resolved_schema: None,
is_nullable: true,
column_default: None,
is_primary_key: false,
@@ -8408,6 +8410,7 @@ mod tests {
let s = vec![ColumnInfo {
name: "c".into(),
data_type: "varchar(100)".into(),
resolved_schema: None,
is_nullable: true,
column_default: Some("'default'".into()),
comment: Some("new".into()),
@@ -8424,6 +8427,7 @@ mod tests {
let t = vec![ColumnInfo {
name: "c".into(),
data_type: "varchar(50)".into(),
resolved_schema: None,
is_nullable: false,
column_default: None,
comment: Some("old".into()),
+3
View File
@@ -1360,6 +1360,7 @@ mod tests {
ColumnInfo {
name: name.to_string(),
data_type: data_type.to_string(),
resolved_schema: None,
is_nullable: true,
column_default: None,
is_primary_key: false,
@@ -2234,6 +2235,7 @@ mod tests {
source: Some(ColumnInfo {
name: "large_val".to_string(),
data_type: "BIGINT".to_string(),
resolved_schema: None,
is_nullable: true,
column_default: None,
is_primary_key: false,
@@ -2250,6 +2252,7 @@ mod tests {
target: Some(ColumnInfo {
name: "large_val".to_string(),
data_type: "INT".to_string(),
resolved_schema: None,
is_nullable: true,
column_default: None,
is_primary_key: false,
+2
View File
@@ -144,6 +144,8 @@ pub struct ObjectSource {
pub struct ColumnInfo {
pub name: String,
pub data_type: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub resolved_schema: Option<String>,
pub is_nullable: bool,
pub column_default: Option<String>,
pub is_primary_key: bool,
@@ -228,6 +228,7 @@ fn column_info_serialization_roundtrip() {
let col = ColumnInfo {
name: "id".to_string(),
data_type: "int".to_string(),
resolved_schema: None,
is_nullable: false,
column_default: None,
is_primary_key: true,
@@ -274,6 +275,7 @@ fn table_columns_result_serialization_contract() {
columns: vec![ColumnInfo {
name: "id".to_string(),
data_type: "int".to_string(),
resolved_schema: None,
is_nullable: false,
column_default: None,
is_primary_key: true,
@@ -16,6 +16,7 @@ fn col(name: &str, data_type: &str) -> ColumnInfo {
ColumnInfo {
name: name.to_string(),
data_type: data_type.to_string(),
resolved_schema: None,
is_nullable: false,
column_default: None,
is_primary_key: false,
@@ -19,6 +19,7 @@ fn col(name: &str, data_type: &str) -> ColumnInfo {
ColumnInfo {
name: name.to_string(),
data_type: data_type.to_string(),
resolved_schema: None,
is_nullable: false,
column_default: None,
is_primary_key: false,
@@ -34,6 +34,7 @@ fn generate_details(tables: &[TableInfo], columns_per_table: usize) -> Vec<Table
.map(|j| ColumnInfo {
name: format!("col_{}", j),
data_type: if j % 3 == 0 { "int".to_string() } else { "varchar(64)".to_string() },
resolved_schema: None,
is_nullable: j % 2 == 0,
column_default: if j == 0 { Some("0".to_string()) } else { None },
is_primary_key: j == 0,
@@ -25,6 +25,7 @@ fn col(name: &str, data_type: &str) -> ColumnInfo {
ColumnInfo {
name: name.to_string(),
data_type: data_type.to_string(),
resolved_schema: None,
is_nullable: false,
column_default: None,
is_primary_key: false,
+1
View File
@@ -1736,6 +1736,7 @@ fn infer_document_columns(documents: &[Value]) -> Vec<ColumnInfo> {
.map(|(name, data_type)| ColumnInfo {
name,
data_type,
resolved_schema: None,
is_nullable: true,
column_default: None,
is_primary_key: false,