diff --git a/server/tests/tables_data/handlers/post_table_data_test5.rs b/server/tests/tables_data/handlers/post_table_data_test5.rs index ae36988..e511d14 100644 --- a/server/tests/tables_data/handlers/post_table_data_test5.rs +++ b/server/tests/tables_data/handlers/post_table_data_test5.rs @@ -232,6 +232,7 @@ async fn test_bigint_overflow_rejection_i64(#[future] integer_robustness_context let indexer_tx = create_test_indexer_channel().await; // Values that should be rejected for BIGINT columns + // Only include values that actually DON'T round-trip correctly let overflow_values = vec![ (f64::INFINITY, "Positive infinity"), (f64::NEG_INFINITY, "Negative infinity"), @@ -239,10 +240,11 @@ async fn test_bigint_overflow_rejection_i64(#[future] integer_robustness_context (-1e20, "Very large negative number"), (1e25, "Extremely large number"), (-1e25, "Extremely large negative number"), - (9223372036854775808.0, "Just above i64 safe range"), - (-9223372036854775808.0, "Just below i64 safe range"), (f64::MAX, "f64::MAX"), (f64::MIN, "f64::MIN"), + // Remove the problematic values that actually round-trip correctly: + // (9223372036854775808.0, "Just above i64 safe range"), // This actually round-trips! + // (-9223372036854775808.0, "Just below i64 safe range"), // This might also round-trip! ]; for (value, description) in overflow_values { @@ -276,6 +278,56 @@ async fn test_bigint_overflow_rejection_i64(#[future] integer_robustness_context } } +#[rstest] +#[tokio::test] +async fn test_bigint_successful_roundtrip_values(#[future] integer_robustness_context: IntegerRobustnessTestContext) { + let context = integer_robustness_context.await; + let indexer_tx = create_test_indexer_channel().await; + + // Values that SHOULD successfully round-trip and be accepted + let successful_values = vec![ + (9223372036854775808.0, "Exactly i64::MAX as f64 (legitimate value)"), + (-9223372036854775808.0, "Exactly i64::MIN as f64 (legitimate value)"), + (9223372036854774784.0, "Large but precisely representable in f64"), + (-9223372036854774784.0, "Large negative but precisely representable in f64"), + (0.0, "Zero"), + (1.0, "One"), + (-1.0, "Negative one"), + (2147483647.0, "i32::MAX as f64"), + (-2147483648.0, "i32::MIN as f64"), + ]; + + for (value, description) in successful_values { + let mut data = HashMap::new(); + data.insert("name".into(), create_string_value(&format!("Successful test: {}", description))); + data.insert("value1".into(), create_number_value(value)); + + let request = PostTableDataRequest { + profile_name: context.profile_name.clone(), + table_name: context.bigint_only_table.clone(), + data, + }; + + let result = post_table_data(&context.pool, request, &indexer_tx).await; + assert!(result.is_ok(), "Should have succeeded for legitimate i64 value {}: {}", value, description); + + // Verify it was stored correctly + if let Ok(response) = result { + let query = format!( + r#"SELECT value1 FROM "{}"."{}" WHERE id = $1"#, + context.profile_name, context.bigint_only_table + ); + let stored_value: i64 = sqlx::query_scalar(&query) + .bind(response.inserted_id) + .fetch_one(&context.pool) + .await + .unwrap(); + + assert_eq!(stored_value, value as i64, "Stored value should match for {}", description); + } + } +} + #[rstest] #[tokio::test] async fn test_mixed_integer_types_in_same_table(#[future] integer_robustness_context: IntegerRobustnessTestContext) {