last error remaining

This commit is contained in:
Priec
2025-09-18 18:53:55 +02:00
parent 1f6dc3cd75
commit 49277cfdd4
6 changed files with 278 additions and 241 deletions

View File

@@ -3,6 +3,7 @@
use crate::common::setup_isolated_db;
use server::table_script::handlers::post_table_script::post_table_script; // Fixed import
use common::proto::komp_ac::table_script::PostTableScriptRequest;
use common::proto::komp_ac::table_definition::ColumnDefinition;
use rstest::*;
use serde_json::json;
use sqlx::PgPool;
@@ -12,15 +13,10 @@ async fn create_test_table(
pool: &PgPool,
schema_id: i64,
table_name: &str,
columns: Vec<(&str, &str)>,
columns: Vec<ColumnDefinition>,
) -> i64 {
let column_definitions: Vec<String> = columns
.iter()
.map(|(name, type_def)| format!("\"{}\" {}", name, type_def))
.collect();
let columns_json = json!(column_definitions);
let indexes_json = json!([]);
let columns_json = serde_json::to_value(columns).unwrap();
let indexes_json = serde_json::json!([]);
sqlx::query_scalar!(
r#"INSERT INTO table_definitions (schema_id, table_name, columns, indexes)
@@ -97,7 +93,9 @@ async fn test_steel_decimal_literal_operations(
let pool = setup_isolated_db().await;
let schema_id = get_default_schema_id(&pool).await;
let columns = vec![("result", "NUMERIC(30, 15)")];
let columns: Vec<ColumnDefinition> = vec![
ColumnDefinition { name: "result".to_string(), field_type: "NUMERIC(30, 15)".to_string() }
];
let table_id = create_test_table(&pool, schema_id, "literal_test", columns).await;
let script = format!(r#"({} "{}" "{}")"#, operation, value1, value2);
@@ -133,9 +131,9 @@ async fn test_steel_decimal_column_operations(
let pool = setup_isolated_db().await;
let schema_id = get_default_schema_id(&pool).await;
let columns = vec![
("test_value", column_type),
("result", "NUMERIC(30, 15)"),
let columns: Vec<ColumnDefinition> = vec![
ColumnDefinition { name: "test_value".to_string(), field_type: column_type.to_string() },
ColumnDefinition { name: "result".to_string(), field_type: "NUMERIC(30, 15)".to_string() },
];
let table_id = create_test_table(&pool, schema_id, "column_test", columns).await;
@@ -179,12 +177,12 @@ async fn test_complex_financial_calculation(
let schema_id = get_default_schema_id(&pool).await;
// Create a realistic financial calculation table
let columns = vec![
("principal", "NUMERIC(16, 2)"), // Principal amount
("annual_rate", "NUMERIC(6, 5)"), // Interest rate
("years", "INTEGER"), // Time period
("compounding_periods", "INTEGER"), // Compounding frequency
("compound_interest", "NUMERIC(20, 8)"), // Result
let columns: Vec<ColumnDefinition> = vec![
ColumnDefinition { name: "principal".to_string(), field_type: "NUMERIC(16, 2)".to_string() }, // Principal amount
ColumnDefinition { name: "annual_rate".to_string(), field_type: "NUMERIC(6, 5)".to_string() }, // Interest rate
ColumnDefinition { name: "years".to_string(), field_type: "INTEGER".to_string() }, // Time period
ColumnDefinition { name: "compounding_periods".to_string(), field_type: "INTEGER".to_string() }, // Compounding frequency
ColumnDefinition { name: "compound_interest".to_string(), field_type: "NUMERIC(20, 8)".to_string() }, // Result
];
let table_id = create_test_table(&pool, schema_id, "financial_calc", columns).await;
@@ -217,11 +215,11 @@ async fn test_scientific_precision_calculations() {
let pool = setup_isolated_db().await;
let schema_id = get_default_schema_id(&pool).await;
let columns = vec![
("measurement_a", "NUMERIC(25, 15)"),
("measurement_b", "NUMERIC(25, 15)"),
("coefficient", "NUMERIC(10, 8)"),
("scientific_result", "NUMERIC(30, 18)"),
let columns: Vec<ColumnDefinition> = vec![
ColumnDefinition { name: "measurement_a".to_string(), field_type: "NUMERIC(25, 15)".to_string() },
ColumnDefinition { name: "measurement_b".to_string(), field_type: "NUMERIC(25, 15)".to_string() },
ColumnDefinition { name: "coefficient".to_string(), field_type: "NUMERIC(10, 8)".to_string() },
ColumnDefinition { name: "scientific_result".to_string(), field_type: "NUMERIC(30, 18)".to_string() },
];
let table_id = create_test_table(&pool, schema_id, "scientific_data", columns).await;
@@ -259,9 +257,9 @@ async fn test_precision_boundary_conditions(
let pool = setup_isolated_db().await;
let schema_id = get_default_schema_id(&pool).await;
let columns = vec![
("boundary_value", numeric_type),
("result", "NUMERIC(30, 15)"),
let columns: Vec<ColumnDefinition> = vec![
ColumnDefinition { name: "boundary_value".to_string(), field_type: numeric_type.to_string() },
ColumnDefinition { name: "result".to_string(), field_type: "NUMERIC(30, 15)".to_string() },
];
let table_id = create_test_table(&pool, schema_id, "boundary_test", columns).await;
@@ -284,11 +282,11 @@ async fn test_mixed_integer_and_numeric_operations() {
let pool = setup_isolated_db().await;
let schema_id = get_default_schema_id(&pool).await;
let columns = vec![
("integer_quantity", "INTEGER"),
("numeric_price", "NUMERIC(10, 4)"),
("numeric_tax_rate", "NUMERIC(5, 4)"),
("total_with_tax", "NUMERIC(15, 4)"),
let columns: Vec<ColumnDefinition> = vec![
ColumnDefinition { name: "integer_quantity".to_string(), field_type: "INTEGER".to_string() },
ColumnDefinition { name: "numeric_price".to_string(), field_type: "NUMERIC(10, 4)".to_string() },
ColumnDefinition { name: "numeric_tax_rate".to_string(), field_type: "NUMERIC(5, 4)".to_string() },
ColumnDefinition { name: "total_with_tax".to_string(), field_type: "NUMERIC(15, 4)".to_string() },
];
let table_id = create_test_table(&pool, schema_id, "mixed_types_calc", columns).await;
@@ -325,9 +323,9 @@ async fn test_mathematical_edge_cases(
let pool = setup_isolated_db().await;
let schema_id = get_default_schema_id(&pool).await;
let columns = vec![
("test_value", "NUMERIC(15, 6)"),
("result", "NUMERIC(20, 8)"),
let columns: Vec<ColumnDefinition> = vec![
ColumnDefinition { name: "test_value".to_string(), field_type: "NUMERIC(15, 6)".to_string() },
ColumnDefinition { name: "result".to_string(), field_type: "NUMERIC(20, 8)".to_string() },
];
let table_id = create_test_table(&pool, schema_id, "edge_case_test", columns).await;
@@ -381,10 +379,10 @@ async fn test_comparison_operations_with_valid_types() {
let pool = setup_isolated_db().await;
let schema_id = get_default_schema_id(&pool).await;
let columns = vec![
("value_a", "NUMERIC(10, 2)"),
("value_b", "INTEGER"),
("comparison_result", "BOOLEAN"),
let columns: Vec<ColumnDefinition> = vec![
ColumnDefinition { name: "value_a".to_string(), field_type: "NUMERIC(10, 2)".to_string() },
ColumnDefinition { name: "value_b".to_string(), field_type: "INTEGER".to_string() },
ColumnDefinition { name: "comparison_result".to_string(), field_type: "BOOLEAN".to_string() },
];
let table_id = create_test_table(&pool, schema_id, "comparison_test", columns).await;
@@ -419,11 +417,11 @@ async fn test_nested_mathematical_expressions() {
let pool = setup_isolated_db().await;
let schema_id = get_default_schema_id(&pool).await;
let columns = vec![
("x", "NUMERIC(15, 8)"),
("y", "NUMERIC(15, 8)"),
("z", "INTEGER"),
("nested_result", "NUMERIC(25, 12)"),
let columns: Vec<ColumnDefinition> = vec![
ColumnDefinition { name: "x".to_string(), field_type: "NUMERIC(15, 8)".to_string() },
ColumnDefinition { name: "y".to_string(), field_type: "NUMERIC(15, 8)".to_string() },
ColumnDefinition { name: "z".to_string(), field_type: "INTEGER".to_string() },
ColumnDefinition { name: "nested_result".to_string(), field_type: "NUMERIC(25, 12)".to_string() },
];
let table_id = create_test_table(&pool, schema_id, "nested_calc", columns).await;