Skip to content

implement ScalarArg for tuples #378

@aljazerzen

Description

@aljazerzen

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(())
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions