Replies: 4 comments 9 replies
-
|
Thank you for such a detailed summary! One question: do we have a sense of how/if it affects query performance? |
Beta Was this translation helpful? Give feedback.
-
|
With diesel: Previously: |
Beta Was this translation helpful? Give feedback.
-
Tackling the
|
Beta Was this translation helpful? Give feedback.
-
|
We moved to diesel, after using it for a few months, it shows its limitations and the DSL complexity adds non-zero developer overhead. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Experience through #928 as a start and continuation of #921
What is diesel?
dieselordiesel-rshas been one of the long standing ORM tools in the rust ecosystem for SQL database. It allows to derive a schema from an existing database with a standalone tool, and from there on reference that schema via strongly typed queries.tl;dr
The code is cleaner, the enforcement at the type level is helpful to catch errors early, but at the cost of an additional syntax to learn and interpretation of the error messages is required. After spending a few days with it, writing queries become natural, with autocompletion.
For me personally, there is a clear upside, it's not as significant as initially anticipated though.
🔼 Upsides
The upsides of diesel cover a few features:
The history of diesel is well supported.
🚧 Outstanding
Currently a few intermediate types are created when querying. diesel has a few ways of allowing the mapping of complex types. These should have compounding effects, but have not been implemented yet.
🕳️ Practical Pitfalls
Error Complexity
Particularly around selecting more complex types in join_left and join statements, the a mismatch of
.select((schema::foo::bar, schema::foo::baz))or usingschema::foo::all_columnsany mismatch between the schema and the provided column-selectors will generate type-mismatch-errors that are hard to diagnose. They oftentimes are so large, that they end up in external files.Incomprehensible issues with some features
Using
will always result in one of the wall-sized error messages mentioned in the previous section. Unfortunately I have not found a way to make this work in
left_joinorjoinqueries, other than flattening the struct manually or falling back to(schema::foo::bar, schema::foo::baz)specification.CustomType::as_select()was not working despite triple checking columns and ordering correctness, as well as trimming the complexity down. :hType resolution
Using rust
1.85oftentimes multiple variants of a function exist and require to use fully qualifying syntax, i.e.schema::foo::table.select(Foo::as_select())often needs to be expressed asSelectDsl::select(schema::foo::table, Foo::as_select()), since there is an ambiguity withQueryDsl::select.At other times, avoiding sub-queries rather than nested queries is a better and easier to understand approach. The error messages also become easier.
Beta Was this translation helpful? Give feedback.
All reactions