I’m happy to announce the release of Diesel 2.4.0, a ORM and query builder for Rust. This release contains the development of the last 14 months, including the contributions of 76 people.

Headline features include:

  • Support for database views
  • Improved support for enums
  • Support for batch update statements
  • A distinct backend for MariaDB
  • Extended support for SQLite functionality, including hooks, pragmas and BLOB’s
  • Support for using Diesel (SQLite) in a no-std environment
  • Migrations written in Rust
  • Support for diesel-async in #[derive(MultiConnection)]

See the announcement blog post about details to each feature: https://diesel.rs/news/2_4_0_release/

I would like to use this possibility to thank all contributors and sponsors that made this release possible. A special thank goes to Luca for his large contributors to the release, to Prototype Found for funding the development of the Database View support and to RustFoundation for funding the general maintenance.

Nevertheless, the Diesel project is always looking for support. You can help by:

  • Contributing Code, Documentation, or Guides.
  • Answering questions in our discussion forum
  • Reporting bugs in our issue tracker
  • Helping to triage issues in our issue tracker
  • Sponsoring the maintainers.
  • Filling out this survey about about the current state and future developments of Diesel (EDIT: lemmy seems to break that link, please use that one from the blog post instead)

Feel free to answer questions about the release or Diesel in general, I will try to answer them in the next days.

  • TheAgeOfSuperboredom@lemmy.ca
    link
    fedilink
    arrow-up
    3
    ·
    9 days ago

    I really want to like Diesel but I always struggle with factoring out common query fragments. There seems to be a lot of things you just need to know to wrangle the types. I don’t think much is necessarily undocumented, but I find it hard to find the doc and understand how it all fits together.

    Still, I’m being stubborn and using it in a personal project because it is challenging me!

    • weiznich@programming.devOP
      link
      fedilink
      arrow-up
      3
      ·
      8 days ago

      For factoring out common query parts have a look at the composing applications guide: http://diesel.rs/guides/composing-applications/

      The tools you usually want to use there are the auto_type macro, BoxableExpression (for dynamic fragments, but also as trait bound) an the HasQuery macro to share common base queries.

      There are a few more details in this (https://blog.weiznich.de/rustweek_2025.html#/title-slide) set of slices from last years RustWeek workshop

      • TheAgeOfSuperboredom@lemmy.ca
        link
        fedilink
        arrow-up
        1
        ·
        8 days ago

        Thanks!

        I think part of it is also that I just have to get more familiar with Diesel, but also get over wanting to solve things without Boxing. I do like a good puzzle sometimes :)

        I also didn’t see that you posted the original link. Thanks for all your hard work and for being so active in all the communities Diesel is discussed!

        • weiznich@programming.devOP
          link
          fedilink
          arrow-up
          2
          ·
          7 days ago

          At least #[auto_type] and using BoxableExpression as trait bound doesn’t need any boxing at all.

          That written, as others already pointed out: Boxing and dyn dispatch are sometimes the right solution. You also should keep in mind that in most cases the performance penalty of the allocation or the indirect function call is not significant compared to say a network roundtrip or an io operation. The only situation with Diesel queries where I found that allocations matter are for hot loops of trivial queries on an in memory SQLite database connection. There it costs you around 50% of performance. Otherwise you won’t notice much difference.

          • TheAgeOfSuperboredom@lemmy.ca
            link
            fedilink
            arrow-up
            1
            ·
            7 days ago

            Oh for sure! I’m not opposed to allocations. It’s just me being stubborn and getting myself stuck on wanting to see if there is a solution without it. It mostly happens on my personal projects where I can afford to get distracted for hours.

        • ExperimentalGuy@programming.dev
          link
          fedilink
          arrow-up
          4
          ·
          8 days ago

          I get the want to not use boxes but, in my experience, I got over that by realizing that using boxes is basically just using malloc in C. Once I realized how often we malloc in C, I slowly was able to get over the Box bump. Also there’s some really cool features like dyn types and the type erasure pattern which I only learned a few months ago. It makes a lot of more complicated rust cpdebases make sense once I figured that out.

          • TheAgeOfSuperboredom@lemmy.ca
            link
            fedilink
            arrow-up
            2
            ·
            7 days ago

            I also like to approach this by looking at other languages where most things live on the heap anyway. There’s lots of great software written in dynamic GC’d languages, so I treat that as a sort of upper bound in my Rust code.

            I mostly allow myself to get distracted by this sort of thing in my personal projects where I have the luxury of not having to complete anything. 😁

  • onlinepersona@programming.dev
    link
    fedilink
    English
    arrow-up
    2
    ·
    7 days ago

    Awesome. I hope Diesel becomes the Django ORM of Rust. The other solutions in Rust are such an incredible pain to deal with, it puts me off writing Rust applications with databases sometimes.