Replies: 1 comment
-
Conceptually there is not much here that can be abstracted away. The select clauses needs to be passed explicitly as each of them refer to a different set of columns. The join, the other filter and the order clause are dependent on the table. Both, the table and the columns are represented as distinct types, so you cannot easily substitute them. That would be like using an The only possibility I see here to improve your code is to refactor your database schema in such a way that you use the same columns for all 8 cases. You could differentiate between them by using a separate column as type. |
Beta Was this translation helpful? Give feedback.
-
Hi diesel users. I'm just beginning with rust and diesel, and I have struck an issue. The project I'm working with has a large table with lots of duplicate rows, and instead of defining a single table definition (57 columns), I've decided to make 8 separate table definitions with exactly the same structure:
This would be fine, until I've struck another problem: Now I have to query 8 tables, and I have no idea how to abstract it, so I don't have to write 8 definitions of this just to do one query on each table:
So is there a way to abstract this? Or a better approach? I'm new to Rust, and trying to learn it fast.
Beta Was this translation helpful? Give feedback.
All reactions