Diesel 2.0.0 has been officially released. It is said that the development cycle of this version is as long as 3 years and contains more than 1700 commits.
Diesel is a secure and scalable
Rust ORM framework and query building tool. Diesel avoids runtime errors and provides the best performance.
2.0 adds many new features and rewrites most of the internals. Since this is a new major version, it also contains many breaking changes, see the migration guide for specific handling.
Update highlights
- fully type-checked
GROUP BY
- Support for table aliases
- Support for defining select clauses by corresponding types
- support
UNION
/INTERSECT
Inquire
In addition, Diesel 2.0.0 fixes several issues in the type level SQL representation, which now correctly handles the following cases:
- mixed nesting
LEFT JOINS
andINNER JOINS
- pass
AND
,OR
Nullable expressions mixed with similar operator chaining
supportGROUP BY
clause
Diesel 2.0 adds support forGROUP BY
Clause support for select queries.
Example
users::table.inner_join(posts::table)
.group_by(users::id)
.select((users::name, count(posts::id)))
Support for table aliases
The following query demonstrates this functionality:
// Define new table alias for the existing `users` table
let users1 = diesel::alias!(schema::users as user1);
// Use the corresponding alias inside any existing query
users::table
.inner_join(users1.on(users::id).eq(users1.field(users::id))))
.select((users::id, users::name, users1.field(users::name)))
.order_by(users1.field(users::id))
supportUNION
/INTERSECT
Inquire
This feature easily chains together multiple queries as long as they return fields of the same type.
users.select(user_name.nullable())
.union(animals.select(animal_name).filter(animal_name.is_not_null()))
Release Note | Changelog
#Diesel #officially #released #Rust #ORM #framework #News Fast Delivery