Skip to content

Macro fails on bytes data #57

@tsvisabo

Description

@tsvisabo

For table called my_table with id -> Integer, value-> Integer and data->BYTEA (Postgress)

the following macro seems to fail when trying to insert a record (without BYTEA it seemed to work)

Fails with: "error: "unknown type param ID: 17""

        let id : i32 = 2;
        let value : i32 = 100;
        let v: Vec<u8> = vec![0, 2, 4, 6];

        let row = sqlx::query(            r#"
        INSERT INTO transactions ( id , value, data)
        VALUES ( $1, $2 , $3)
        RETURNING id, value, signature_or_message
                "#,)
            .bind(id).bind(value).bind(v)
            .fetch_one(&mut tx)
            .await.unwrap();


        tx.commit().await.unwrap();

This works fine:


        let id : i32 = 2;
        let value : i32 = 100;
        let v: Vec<u8> = vec![0, 2, 4, 6];
        let rec = sqlx::query!(
            r#"
 INSERT INTO transactions ( id , value, signature_or_message)
 VALUES ( $1, $2 , $3)
 RETURNING id, value, signature_or_message
         "#,
            0,
            0,
            v
        )
        .fetch_one(&mut tx)
        .await
        .unwrap();

        tx.commit().await.unwrap();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions