athena_rs 3.3.0

Database gateway API
Documentation
use athena_rs::drivers::postgresql::sqlx_driver::{describe_bind_value, describe_bind_values};
use serde_json::json;

#[test]
fn describe_bind_value_handles_uuid_like_strings_as_text() {
    let old_format_id = json!("aecd8e47-c92d-44f2-b150-abcdef123456");
    let description = describe_bind_value(&old_format_id);
    assert!(
        description.contains("(string)"),
        "UUID-like string should be described as string, got: {}",
        description
    );

    let new_format_id = json!("aAycr5gho2AKXSa022yvbsL1");
    let description = describe_bind_value(&new_format_id);
    assert!(
        description.contains("(string)"),
        "Alphanumeric ID should be described as string, got: {}",
        description
    );
}

#[test]
fn describe_bind_value_handles_various_types() {
    assert_eq!(describe_bind_value(&json!(null)), "null (null)");
    assert_eq!(describe_bind_value(&json!(true)), "true (bool)");
    assert_eq!(describe_bind_value(&json!(false)), "false (bool)");
    assert_eq!(describe_bind_value(&json!(42)), "42 (i64)");
    assert_eq!(describe_bind_value(&json!(2.5)), "2.5 (f64)");
    assert_eq!(describe_bind_value(&json!("hello")), "hello (string)");
    assert_eq!(describe_bind_value(&json!([1, 2, 3])), "array(len=3)");
    assert_eq!(
        describe_bind_value(&json!({"key": "value"})),
        "object(len=1)"
    );
}

#[test]
fn describe_bind_values_handles_mixed_id_formats() {
    let values = vec![
        json!("aecd8e47-c92d-44f2-b150-abcdef123456"),
        json!("aAycr5gho2AKXSa022yvbsL1"),
        json!("AL046ozwXS8XQOXV4BmVaPBc"),
    ];

    let descriptions = describe_bind_values(&values);

    for (i, desc) in descriptions.iter().enumerate() {
        assert!(
            desc.contains("(string)"),
            "Value {} should be described as string, got: {}",
            i,
            desc
        );
    }
}