Announcing Diesel — A Safe, Extensible ORM and Query Builder for Rust

What Does it Look Like?

let versions = Version::belonging_to(krate)
.select(id)
.order(num.desc())
.limit(5);
let downloads = try!(version_downloads
.filter(date.gt(now - 90.days()))
.filter(version_id.eq(any(versions)))
.order(date)
.load(&conn))
.collect::<Vec<VersionDownload>>();
SELECT version_downloads.* FROM version_downloads
WHERE date > NOW() - '90 days'::interval
AND version_id = ANY(SELECT id FROM versions
WHERE crate_id = 1
ORDER BY num DESC
LIMIT 5)
ORDER BY date;

What Makes Diesel Different?

Truly Type Safe

  • Reading a column into the wrong type (e.g. `VarChar` into `i32` or a nullable column into anything other than an `Option`)
  • Referencing a column that isn’t on the table you’re querying
  • Treating the right side of a left join as non-nullable
  • Mixing aggregate and non-aggregate expressions in the same select statement
  • And much more. We have a ton of tests to ensure these fail to compile!

Designed for Performance

Extensible at its Core

What’s in Version 0.1?

What’s next?

--

--

--

Creator of Diesel. Rails committer. Maintainer of Active Record. Host of @_yakshave. Former host of @_bikeshed.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sean Griffin

Sean Griffin

Creator of Diesel. Rails committer. Maintainer of Active Record. Host of @_yakshave. Former host of @_bikeshed.

More from Medium

Daily Native Dev: Rust & Sentry story

Part #1: Memory management in WASM

Cheerp 2.7: compile C++ to WebAssembly + JavaScript

Creating Rails Api Using Existing MySql Database