fernandobatels / rsfbclient

Rust Firebird Client
MIT License
76 stars 11 forks source link

the trait `FromRow` is not implemented for .... #95

Closed AndreiTS closed 3 years ago

AndreiTS commented 3 years ago

What this error means? image

I have a custom type holding a tuple with the type of each column from the table:

type ClienteFields = (String, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<i32>, Option<i32>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<f64>, Option<f64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>, Option<i32>, Option<i32>, Option<String>, Option<f64>, Option<f64>, Option<String>, Option<String>, Option<String>, Option<String>, Option<String>);

And I'm using it like this:

` let rows = conn.query_iter("SELECT * FROM C000007", ())?;

for row in rows {
    let row_data: ClienteFields = row.unwrap();

    println!("{:?}", row_data.0);
}

`

AndreiTS commented 3 years ago

Table structure: https://pastebin.com/gcsEjvAs

fernandobatels commented 3 years ago

What this error means?

You have too many columns. Like 101. At this moment, we only implement the FromRow until 26

fernandobatels commented 3 years ago

You can use the Row struct instead and iterate over your columns.

fernandobatels commented 3 years ago

If you need a structured row, you can use the diesel. We are still working on this implementation, but you can already use for tests.

AndreiTS commented 3 years ago

You can use the Row struct instead and iterate over your columns.

Can you give me an example?

fernandobatels commented 3 years ago

You can use the Row struct instead and iterate over your columns.

Can you give me an example?

Yes. Here.

 let rows: Vec<Row> = conn.query("select test.*, 10 as extra from test", ())?;

  for row in rows {
      println!("------------------------------------");

      for col in row.cols {
          println!("{}: {:?}", col.name, col.value);
      }
  }
AndreiTS commented 3 years ago

Thanks