3

I am new to Rust and working with the Actix-Web "advanced" GraphiQL example which uses Juniper and MySQL. I am running into an issue when my model reaches 13 columns it throws an error. This works until I add the 13th column.

#[graphql(description = "List of all (View) Items LIKE")]
fn items_view_like(context: &Context, item_number: String) -> FieldResult<Vec<ItemView>> {
    let mut conn = context.dbpool.get().unwrap();
    let items_view = conn
        .prep_exec("select item_number, description, extended_description, item_type, bulk_type, item_product_group, billing_category, stock_unit, price_unit, purchasing_unit, manufacturing_unit, purchase_price, category from v_items WHERE item_number LIKE :item_number", params! {"item_number" => item_number})
        .map(|result| {
            result
                .map(|x| x.unwrap())
                .map(|row| {
                    let (item_number, description, extended_description, item_type, bulk_type, item_product_group, billing_category, stock_unit, price_unit, purchasing_unit, manufacturing_unit, purchase_price, category) = from_row(row);
                    ItemView {
                        item_number,
                        description,
                        extended_description,
                        item_type, 
                        bulk_type,
                        item_product_group,
                        billing_category, 
                        stock_unit,
                        price_unit,
                        purchasing_unit,
                        manufacturing_unit,
                        purchase_price,
                        category

                    }
                })
                .collect()
        })
        .unwrap();
    Ok(items_view)
}

Error:

error[E0277]: the trait bound `(_, _, _, _, _, _, _, _, _, _, _, _, _): FromValue` is not satisfied
   --> src\schemas\root.rs:116:227
    |
116 | ...price, category) = from_row(row);
    |                       ^^^^^^^^ the trait `FromValue` is not implemented for `(_, _, _, _, _, _, _, _, _, _, _, _, _)`

From what I have been able to find there is a limit if 12 columns for the from_row method, what is the correct way I would handle larger queries?

Any help would be appreciated for this noob. Thanks again.

xXPhenom22Xx
  • 1,265
  • 5
  • 29
  • 63

1 Answers1

0

The problem is that from_row is defined for a maximum of 12 columns. See documentation here:

Trait to convert Row into a tuple of FromValue implementors up to arity 12.

Take a look at Row::take for alternative strategies.

wordragon
  • 1,297
  • 9
  • 16