Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

implement ScalarArg for tuples #378

Open
aljazerzen opened this issue Jan 31, 2025 · 0 comments
Open

implement ScalarArg for tuples #378

aljazerzen opened this issue Jan 31, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@aljazerzen
Copy link
Contributor

aljazerzen commented Jan 31, 2025

This should work:

#[tokio::test]
async fn tuples() -> anyhow::Result<()> {
    let client = Client::new(&SERVER.config);
    client.ensure_connected().await?;

    let res: Value = client
        .query_required_single("select <tuple<int64, int64>>(42, 3)", &())
        .await
        .unwrap();
    let Value::Tuple(res) = res else { panic!() };
    assert_eq!(res, vec![Value::Int64(42), Value::Int64(3)]);

    let res: (i64, i64) = client
        .query_required_single("select <tuple<int64, int64>>(42, 3)", &())
        .await
        .unwrap();
    assert_eq!(res, (42, 3));

    let arg = Value::Tuple(vec![Value::Int64(42), Value::Int64(3)]);
    let res: (i64, i64) = client
        .query_required_single("select <tuple<int64, int64>>$0", &(arg,))
        .await
        .unwrap();
    assert_eq!(res, (42, 3));

    let arg: (i64, i64) = (42, 3);
    let res: (i64, i64) = client
        .query_required_single("select <tuple<int64, int64>>$0", &(arg,))
        .await
        .unwrap();
    assert_eq!(res, (42, 3));

    Ok(())
}
@aljazerzen aljazerzen added the enhancement New feature or request label Jan 31, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant