NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io, #1584 most downloaded on crates.io
A safe, extensible ORM and Query Builder for PostgreSQL, SQLite, and MySQL
Latest stable
2.3.14
Last release 1 months ago
07 Oct 2026
Ships on a steady schedule
a new release about every 5 weeks
Nearly every release is documented
notes for 59 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
11 years old
99 releases · first in 2015
Drag across the ruler to compare, or tap a release to open it.
Nothing published for this version
1.0.0 marks stability for Diesel. While there are many more features that will be added in the future, there will be no breaking changes from this poi…
We didn't quite make it for 2017, but Diesel 1.0 is finally here! There are no changes between Diesel 1.0 and 1.0.0-rc1.
1.0.0 marks stability for Diesel. While there are many more features that will be added in the future, there will be no breaking changes from this point forward without a major version bump (which we do not anticipate happening for many years).
A lot has happened since Diesel 0.1 was released over 2 years ago. While it would be impossible to list every major change that has happened since then, here are a few highlights:
diesel print-schema replaced infer_schema! as the go-to way to
infer your database schema.It's been a great honor to watch this community grow and thrive as this library has developed. I look forward to continuing to evolve Diesel, and seeing how far it can go.
In addition to the Diesel core team, 98 people have contributed to Diesel. A huge thank you to everyone who made this and every prior release possible:
Your coding agent can read these notes before it upgrades. Set up the MCP server →
#[derive(QueryableByName)] can now handle structs that have no associated
table. If the #[table_name] annotation is left off, you must annotate each
field with #[sql_type = "Integer"]
#[derive(QueryableByName)] can now handle embedding other structs. To have a
field whose type is a struct which implements QueryableByName, rather than a
single column in the query, add the annotation #[diesel(embed)]
The QueryDsl trait encompasses the majority of the traits that were
previously in the query_dsl module.
Executing select statements on SQLite will no longer panic when the database
returns SQLITE_BUSY
table!s which use the Datetime type with MySQL will now compile correctly,
even without the chrono feature enabled.
#[derive(QueryableByName)] will now compile correctly when there is a shadowed Result type in scope.
BoxableExpression can now be used with types that are not 'static
Connection::test_transaction now requires that the error returned implement Debug.
query_builder::insert_statement::InsertStatement is now accessed as
query_builder::InsertStatement
query_builder::insert_statement::UndecoratedInsertRecord is now accessed as
query_builder::UndecoratedInsertRecord
#[derive(QueryableByName)] now requires that the table name be explicitly
stated.
Most of the traits in query_dsl have been moved to query_dsl::methods.
These traits are no longer exported in prelude. This should not affect most
apps, as the behavior of these traits is provided by QueryDsl. However, if
you were using these traits in where clauses for generic code, you will need
to explicitly do use diesel::query_dsl::methods::WhateverDsl. You may also
need to use UFCS in these cases.
If you have a type which implemented QueryFragment or Query, which you
intended to be able to call execute or load on, you will need to manually
implement RunQueryDsl for that type. The trait should be unconditionally
implemented (no where clause beyond what your type requires), and the body
should be empty.
All deprecated items have been removed.
LoadDsl and FirstDsl have been removed. Their functionality now lives in
LoadQuery.
This release contains no major code changes. There are a handful of minor bug fixes (the most notable being that SQLite no longer panics when we recei
Happy holidays!
This release contains no major code changes. There are a handful of minor bug fixes (the most notable being that SQLite no longer panics when we receive SQLITE_BUSY), but most changes are related to ensuring that our API documentation renders better.
We do not expect any further changes to the codebase of any kind (other than the version number) between this release and 1.0.0. Assuming no critical issues are found with this release candidate, the code as it exists at this point will be released as 1.0.0 on 2017-12-30.
We do not plan on having a 1.0.0.beta2, but there may be additional minor breaking changes in that release if it is needed. If there are any code chan…
This release contains 2 major changes from 0.99.0. The first is not news, we have removed all deprecated code from the codebase. However, this release also contains some major restructuring of the query_dsl module.
Traits related to the construction of queries, such as SelectDsl, FilterDsl, etc. Have been merged into a single QueryDsl trait. Traits related to the execution of queries, such as ExecuteDsl and LoadDsl have been merged into a single RunQueryDsl trait. The individual method traits still exist under the query_dsl::methods module, but they are no longer exported from prelude.
Though we promised there would be no significant changes other than documentation, during our process of documenting this module, it became clear that making this change would make discovering how to use Diesel's query builder dramatically easier. It also gives us a much more centralized place to document these logically grouped methods. While we do not expect this change to break many apps, it is significant enough to warrant an early release.
Most applications should not need to care about this change. Code which is just doing use diesel::prelude::* and calling these methods will continue to work with no changes (though error messages will be improved if you make a mistake).
However, if you had code that was implementing QueryFragment or Query, and expected to be able to call .execute, .load, or similar on it (such as the Pagination helper in crates.io), you will need to add impl<Conn> RunQueryDsl<Conn> for YourType.
If you have code that is calling query builder methods generically (e.g. if you have where T: FilterDsl<Something>, you will likely need to explicitly import things from query_dsl::methods
In addition to those changes, there are some minor improvements to #[derive(QueryableByName)] which we had planned on releasing as 0.99.2.
With this release, 0.99.x will only receive bug fixes and security patches. No new features will be backported to that branch. However, 0.99 can be considered our first "LTS" release. While we have not yet determined what exactly that means for Diesel, you can be assured that release line will continue to be supported for as long as there is demand.
We do not plan on having a 1.0.0.beta2, but there may be additional minor breaking changes in that release if it is needed. If there are any code changes between now and 1.0.0, even non-breaking ones, we will have a release candidate before the final release.
As with 0.99.0, we expect that the only significant change between this release and 1.0.0 will be documentation. We expect that the final release of 1.0.0 will be before the end of the year.
Our only blocker for a final 1.0 release continues to be documentation. There is a lot of work to do before the end of the year. We need help from the community to reach our goal of releasing this year. If you're interested in helping out, join the impl period working group channel.
However, 1.0 will have an important significant difference. Anything that is deprecated as of this release will not be present in the 1.0 release. Thi…
This release is by far the largest Diesel has ever had. It serves 2 purposes. You can consider this release to be a beta for 1.0. However, 1.0 will have an important significant difference. Anything that is deprecated as of this release will not be present in the 1.0 release. This includes functions which were newly deprecated in 0.99. We know this may introduce a migration burden for some people, so we will continue to support the 0.99 line with bug fixes as long as there is demand and it is reasonable to do so.
This release is mainly focused on ergonomics. Our main new feature is the sql_query function. This is a new API which behaves similarly to sql, but it is entirely focused on cases where you want to write the entire query yourself. The main difference from sql is that you do not need to specify the return type of the query, and values are fetched by name rather than by index. This feature is still early, and there's a lot of features still to come (specifically evolving #[derive(QueryableByName)], but we think this feature will ease a lot of pains for cases where Diesel doesn't quite do what you need.
Additionally, you can now use tuples for inserts the same as you can for updates. If you've ever wanted to insert a row with just 1 or 2 values, and been annoyed that you needed a struct that you're only using in this one place, this feature will make you happy. We'll have new guides highlighting this feature soon.
Additionally, this release comes with a ton of quality of life features. Many of these changes are focused around making it easier to introduce line breaks naturally in your code. For example, .filter is now implemented on UpdateStatement, meaning you can write update(foo).filter(bar) instead of update(foo.filter(bar)). We've also introduced new APIs for insert and PG upsert which will have similar readability improvements.
This release includes more deprecations than any release prior. In particular, insert has been deprecated, along with our entire PG upsert API. All deprecations in this release have direct replacements, which will lead to code which formats much more nicely. It should be a mostly mechanical replacement for most apps. See the CHANGELOG file for details.
With this release, we'd like to welcome several new members to the Diesel committer team. @weiznich, @notryanb, and @katrinabrock you've all done excellent work and we're very excited to officially welcome you to the team!
In addition to the Diesel core and committer teams, 10 people contributed to this release. A huge thank you to:
Our only remaining blockers from this release and 1.0 are documentation changes, and having this tested in the wild. Thank you to every one of our users for your support, and we look forward to Diesel 1.0 by the end of the year!
The .for_update() method has been added to select statements, allowing
construction of SELECT ... FOR UPDATE.
Added insert_into(table).default_values() as a replacement for
insert_default_values()
Added insert_into(table).values(values) as a replacement for
insert(values).into(table).
Added support for MySQL's REPLACE INTO as replace_into(table).
Added replace_into(table).values(values) as a replacement for
insert_or_replace(values).into(table).
Added on_conflict_do_nothing on InsertStatement as a replacement for
on_conflict_do_nothing on Insertable structs.
Added on_conflict on InsertStatement as a replacement for
on_conflict on Insertable structs.
filter can now be called on update and delete statements. This means that
instead of update(users.filter(...)) you can write
update(users).filter(...). This allows line breaks to more naturally be
introduced.
Subselects can now reference columns from the outer table. For example,
users.filter(exists(posts.filter(user_id.eq(users::id)))) will now compile.
TextExpressionMethods is now implemented for expressions of type
Nullable<Text> as well as Text.
allow_tables_to_appear_in_same_query! can now take more than 2 tables, and is the same
as invoking it separately for every combination of those tables.
Added sql_query, a new API for dropping to raw SQL that is more pleasant to
use than sql for complete queries. The main difference from sql is that
you do not need to state the return type, and data is loaded from the query by
name rather than by index.
Added a way to rename a table in the table! macro with #[sql_name="the_table_name"]
Added support for PostgreSQL's DISTINCT ON. See
.distinct_on() for more details
The signatures of QueryId, Column, and FromSqlRow have all changed to
use associated constants where appropriate.
You will now need to invoke allow_tables_to_appear_in_same_query! any time two tables
appear together in the same query, even if there is a joinable! invocation for those tables.
diesel_codegen should no longer explicitly be used as a dependency. Unless
you are using infer_schema! or embed_migrations!, you can simply remove it
from your Cargo.toml. All other functionality is now provided by diesel
itself.
Code using infer_schema! or infer_table_from_schema! must now add
diesel_infer_schema to Cargo.toml, and #[macro_use] extern crate diesel_infer_schema to src/lib.rs
Code using embed_migrations! must now add diesel_migrations to Cargo.toml,
and #[macro_use] extern crate diesel_migrations to src/lib.rs
The migrations module has been moved out of diesel and into
diesel_migrations
Deprecated insert_default_values() in favor of
insert_into(table).default_values()
Deprecated insert(values).into(table) in favor of
insert_into(table).values(values).
Deprecated insert_or_replace(values).into(table) in favor of
replace_into(table).values(values).
Deprecated .values(x.on_conflict_do_nothing()) in favor of
.values(x).on_conflict_do_nothing()
Deprecated .values(x.on_conflict(y, do_nothing())) in favor of
.values(x).on_conflict(y).do_nothing()
Deprecated .values(x.on_conflict(y, do_update().set(z))) in favor of
.values(x).on_conflict(y).do_update().set(z)
Deprecated enable_multi_table_joins in favor of
allow_tables_to_appear_in_same_query!
Deprecated SqlLiteral#bind. sql is intended for use with small fragments
of SQL, not complete queries. Writing bind parameters in raw SQL when you are
not writing the whole query is error-prone. Use sql_query if you need raw
SQL with bind parameters.
IntoInsertStatement and BatchInsertStatement have been removed. It's
unlikely that your application is using these types, but InsertStatement is
now the only "insert statement" type.
Citext as a type alias for Text has been removed. Writing
citext_column.eq("foo") would perform a case-sensitive comparison. More
fleshed out support will be required.
When using MySQL and SQLite, dates which cannot be represented by chrono
(such as 0000-00-00) will now properly return an error instead of panicking.
MySQL URLs will now properly percent decode the username and password.
References to types other than str and slice can now appear on structs which
derive Insertable or AsChangeset.
Deserializing a date/time/timestamp column into a chrono type on SQLite will
now handle any value that is in a format documented as valid for SQLite's
strftime function except for the string 'now'.
This release contains some changes to how joins work with Diesel, which we wanted to release as far in advance of 1.0 as possible. With this release,
This release contains some changes to how joins work with Diesel, which we wanted to release as far in advance of 1.0 as possible. With this release, #[belongs_to] no longer generates the code required to join between two tables. The macro joinable! must be invoked instead. However, if you are using infer_schema! or diesel print-schema, these invocations will be generated based on the foreign keys in your database.
Also included in this release is the ability to rename columns. This is most useful when your columns conflict with Rust keywords. See the changelog for details.
In addition to the Diesel core team, 11 people contributed to this release. A huge thank you to:
Added helper types for inner join and left outer join
diesel::debug_query has been added as a replacement for debug_sql!. This
function differs from the macro by allowing you to specify the backend, and
will generate the actual query which will be run. The returned value will
implement Display and Debug to show the query in different ways
diesel::pg::PgConnection, diesel::mysql::MysqlConnection, and
diesel::sqlite::SqliteConnection are now exported from diesel::prelude.
You should no longer need to import these types explicitly.
Added support for the Decimal datatype on MySQL, using the BigDecimal crate.
Added support for the Range type on postgreSQL.
Added support for the Datetime type on MySQL.
Added support for the Blob type on MySQL.
infer_schema! will now automatically detect which tables can be joined based
on the presence of foreign key constraints.
Added support for Add and Sub to timestamp types.
Added a way to rename columns in the table macro with #[sql_name="the_column_name"]
Schema inference now also generates documentation comments for tables and
columns. For infer_schema!, this is enabled by default. If you are using
Diesel's CLI tool, pass the new --with-docs parameter:
diesel print-schema --with-docs.
infer_schema! now automatically renames columns that conflict with
a Rust keyword by placing a _ at the end of the name. For example,
a column called type will be referenced as type_ in Rust.
The deprecated debug_sql! and print_sql! functions will now generate
backend specific SQL. (The specific backend they will generate for will be
arbitrarily chosen based on the backends enabled).
#[belongs_to] will no longer generate the code required to join between two
tables. You will need to explicitly invoke joinable! instead, unless you are
using infer_schema!
Changed the migration directory name format to %Y-%m-%d-%H%M%S.
between and not_between now take two arguments, rather than a range.
debug_sql! has been deprecated in favor of diesel::debug_query.
print_sql! has been deprecated without replacement.
diesel::backend::Debug has been removed.
Diesel now properly supports joins in the form:
grandchild.join(child.join(parent)). Previously only
parent.join(child.join(grandchild)) would compile.
When encoding a BigDecimal on PG, 1.0 is no longer encoded as if it were
1.
This is a minor bugfix release which addresses an issue with encoding of BigDecimal objects with PostgreSQL. Diesel would previously incorrectly encod
This is a minor bugfix release which addresses an issue with encoding of BigDecimal objects with PostgreSQL. Diesel would previously incorrectly encode certain numbers resulting in a runtime error.
BigDecimal now properly encodes numbers starting with 10000 on postgres.
See issue #1044 for details.* No changes to public API
This is a minor release containing a few quality of life features. We were originally planning to ship these with 1.0, but they're specifically needed
This is a minor release containing a few quality of life features. We were originally planning to ship these with 1.0, but they're specifically needed by some production users.
The biggest feature here is the ability to manually specify the ON clause of a join, which is separate from the associations API. You can also use this to join to tables which otherwise have no association between them (but this will also require you to invoke enable_multi_table_joins!).
In addition to the Diesel core team, 6 people contributed to this release. A huge thank you to:
Added support for the PG IS DISTINCT FROM operator
The ON clause of a join can now be manually specified. See the
docs for details.
Diesel will now automatically invoke numeric_expr! for your columns in the
common cases. You will likely need to delete any manual invocations of this
macro.
Insertable no longer treats all fields as nullable for type checking. What
this means for you is that if you had an impl like impl AsExpression<Nullable<SqlType>, DB> for CustomType in your code base, you can
remove the Nullable portion (Unless you are using it with fields that are
actually nullable)
Connections will now explicitly set the session time zone to UTC when the connection is established
This is a bugfix release addressing an issue with sum and avg. These were mistakenly treated as returning the same type as their argument. However, th
This is a bugfix release addressing an issue with sum and avg. These were mistakenly treated as returning the same type as their argument. However, these functions return NULL when run against an empty database, which could result in errors.
sum and avg is now always considered to be Nullable,
as these functions return NULL when against on an empty table.It focuses on the set of changes that we think are likely to require breaking changes.
One of the oldest issues in Diesel was that we limited the number of tables that could appear in a single query to 2. The problem was never about having more than 2 tables, but safely and correctly proving in the type system what would and could not be selected from that join.
With 0.14, that restriction has been removed. The query builder now supports joins containing an arbitrary number of tables. You may find that you need to call enable_multi_table_joins! for a few tables, but that need should go away in the future as specialization matures.
In addition to the headline feature, this release includes support for several new datatypes (including NUMERIC/DECIMAL which has been widely requested), and other small quality of life improvements. As always, you can see the CHANGELOG for the full release notes.
A recent point of discussion among the core team has been what remaining blockers we have for releasing a version 1.0. The roadmap doesn't necessarily include everything that would make us "feature complete". It focuses on the set of changes that we think are likely to require breaking changes.
We expect that this will be the last 0.x release. You can follow the milestone here. Additionally, we all agreed that the biggest blocker to a 1.0 release is improvements to our documentation. We're going to be doing a big push in the coming months to clean things up, and are looking for help from the community. You can follow that project here, or just come join us in our gitter room to talk about how you can help.
There will be a blog post with more details about this in the coming weeks.
In addition to the core team, 10 people contributed to this release. A huge thank you to:
With this release, we are also making some changes to the core team to better reflect the current active maintainers. In recognition of his fantastic work, we're pleased to welcome @Eijebong to the core team. Many early members of the team have also since moved onto other projects. To reflect that, Mike Piccolo, Matt Casper, and Sam Phippen are all being moved to the core team alumni.
JoinDsl for detailsAdded support for the PostgreSQL network types MACADDR.
Added support for the Numeric datatypes, using the BigDecimal crate.
Added a function which maps to SQL NOT. See the docs for more
details.
Added the insert_default_values function.
diesel_prefix_operator! which behaves identically to
diesel_postfix_operator! (previously postfix_predicate!), but for
operators like NOT which use prefix notation.infix_predicate! and infix_expression! have been renamed to
diesel_infix_operator!.
postfix_predicate! and postfix_expression! have been renamed to
diesel_postfix_operator!.
Trait bounds along the lines of T: LoadDsl<Conn>, U: Queryable<T::SqlType, Conn::Backend> should be changed to T: LoadQuery<Conn, U>.
Diesel now uses a migration to set up its timestamp helpers. To generate this
migration for your project, run diesel database setup.
#[has_many] has been removed. Its functionality is now provided by
#[belongs_to] on the child struct. If there is no child struct to
put #[belongs_to] on, you can invoke joinable! directly instead.This is a bugfix release addressing an issue with sum and avg. These were mistakenly treated as returning the same type as their argument. However, th
This is a bugfix release addressing an issue with sum and avg. These were mistakenly treated as returning the same type as their argument. However, these functions return NULL when run against an empty database, which could result in errors.
This release adds support for date and time types with SQLite, allows for raw SQL to use bind parameters, and updates our dependencies (notably allowi
This release adds support for date and time types with SQLite, allows for raw SQL to use bind parameters, and updates our dependencies (notably allowing serde 1.0).
As always, you can find the full release notes in the CHANGELOG
In addition to the core team, 11 people contributed to this release. A huge thank you to:
Added support for chrono types with SQLite.
Bind values can now be supplied to queries constructed using raw SQL. See the docs for more details.
CIDR and
INET.Added support for ILIKE in PostgreSQL.
diesel migration list will show all migrations, marking those that have been
run.
diesel migration pending will list any migrations which have not been run.
Added support for numeric operations with nullable types.
Diesel CLI now respects the --migration-dir argument or the
MIGRATION_DIRECTORY environment variable for all commands.
Diesel CLI now properly escapes the database name.
This restriction is required for the 0.12 line of releases to continue compiling, as the chrono project is including breaking changes in patch release…
0.3.0 instead of a semver
restriction. This restriction is required for the 0.12 line of releases to
continue compiling, as the chrono project is including breaking changes in
patch releases.The main feature of this release is support for PG's ON CONFLICT DO UPDATE, which brings our support for upsert on PG to nearly the entire range of po
The main feature of this release is support for PG's ON CONFLICT DO UPDATE, which brings our support for upsert on PG to nearly the entire range of possible syntax. Additionally, this release contains support for some new data types and operators, and several bug fixes.
Finally, the way that we handle joins has been going through a huge overhaul internally. For the most part this doesn't affect public API yet, but you may notice an increase in compile times, and more things "just working" the way you'd expect when working with joins. This work will hopefully lead to 3+ table joins in the next release.
As always, you can find the full release notes in the CHANGELOG
In addition to the core team, 11 people contributed to this release. A huge thank you to:
INSERT ON CONFLICT). We now
support specifying the constraint, as well as DO UPDATE in addition to DO NOTHING. See the module docs for details.||. See the docs for
.concat for more details.Money type.Diesel CLI: Added db as an alias for database, so you can now write diesel db setup (which is almost 40% faster!).
The table! macro now allows you to use types from crates outside of Diesel.
You can specify where types should be imported from by doing: table! { use some_modules::*; foo { columns... }. Not specifying any any modules is
equivalent to use diesel::types::*;.
diesel_codegen will provide a more useful error message when it encounters
an unsupported type that contains a space in MySQL.
#[derive(AsChangeset)] will now respect custom #[primary_key] annotations,
and avoid setting those columns.
WithDsl and Aliased have been removed. They were a feature that was
actually closer to a cross join than the names implied, and wasn't fully
thought out. The functionality they provided will return as joins are further
revamped.
The internal use macro select_column_workaround! has been removed. If you
were relying on this internal macro, you can simply delete the line that was
calling it.
Columns from the right side of a left join will now need to have .nullable()
explicitly called to be passed to .select. This allows it to compose better
with functions that don't normally take nullable columns (e.g.
lower(name).nullable()).
This release addresses a memory safety issue in our interaction with libmysqlclient. There was an undocumented assumption made by that library which w
This release addresses a memory safety issue in our interaction with libmysqlclient. There was an undocumented assumption made by that library which we were not taking into consideration, resulting in a use-after-free bug. This was resulting in a segmentation fault on some systems.
While this issue is quite serious, we are not issuing a CVE or a security advisory. The bug resulted in 4 bytes being written to a handful of values. It could not be exploited to cause a security issue.
No changes. @sgrif is bad at releasing things.
No changes. @sgrif is bad at releasing things.
This release has no code changes other than bumping the allowed version for pq-sys and mysqlclient-sys. The versions released alongside 0.11 attempted
This release has no code changes other than bumping the allowed version for pq-sys and mysqlclient-sys. The versions released alongside 0.11 attempted to generate the bindings at compile time. This required a bleeding edge version of clang, and caused too many issues for too many people. The latest versions of those two libraries include pre-generated bindings.
If you need to use bindings generated by the old version, you can
explicitly depend on that version with cargo update --precise
pq-sys and mysqlclient-sys will no longer attempt to generate bindings at
compile time. Generating the bindings required a bleeding edge version of
clang, which caused too many issues.This release is a minor bug fix release that handles two edge cases in 0.11's new behavior.
This release is a minor bug fix release that handles two edge cases in 0.11's new behavior.
.on_conflict_do_nothing() now interacts with slices properly.
MysqlConnection now implements Send, which is required for connection
pooling.
The headline features for this release are MySQL support and limited PG upsert support. MySQL support works exactly as you'd expect. Just add features
The headline features for this release are MySQL support and limited PG upsert support. MySQL support works exactly as you'd expect. Just add features = ["mysql"] to your Cargo.toml, pass a connection URL (where the scheme is mysql:// and the path is the name of the database) to MysqlConnection::establish and you're off. Keep in mind that if you're following the getting started guide, MySQL does not support the RETURNING clause, so methods like get_result and get_results won't work.
PostgreSQL upsert was a feature added in PG 9.5 and has been one of our most requested features. The full upsert API is quite complex, but we've added support for ON CONFLICT DO NOTHING, as this covered the highest percentage of use cases with the lowest amount of work. You can see examples in the docs. Support for the full upsert syntax will be coming in 0.12
In addition to the headline features, there were plenty of quality of life improvements and bug fixes. As always, you can see a full list of changes by reading the changelog.
In addition to the Diesel core team, 6 additional contributors worked on this release. A huge thank you to:
I'd also like to thank everybody who helped this release by opening issues, finding bugs, and asking/answering questions in our gitter room.
features = ["mysql"] to Cargo.toml. See the docs for details.ON CONFLICT DO NOTHING clause. See the
docs for details.diesel::select now work properly
when boxed.Arrays containing null are now supported. infer_schema! will never infer an
array that contains null, but a table! definition which specifies a type of
Array<Nullable<X>> can now be deserialized to Vec<Option<T>>
#[belongs_to] associations can now be self referential.
This will generate the code required for
belonging_to, without generating code for performing
a join.
rust-lang-deprecated/time crate on PostgreSQL. To use
it, add features = ["deprecated-time"]It is no longer possible to exhaustively match against
result::ConnectionError.
Updated chrono to version 0.3.
max and min are now always nullable. The database will
return NULL when the table is empty.
now can now be used as an expression of type Timestamptz.Connection::transaction now returns your error
directly instead of wrapping it in TransactionError. It requires that the
error implement From<diesel::result::Error>.select has changed. If you are deserializing into an option of a tuple
(instead of a tuple of options), you will need to explicitly call
.nullable(). (e.g. .select(users::name, (posts::title, posts::body).nullable()))result::TransactionErrorresult::TransactionResultThis is a minor bugfix release to address a bug in 0.10.0 involving infer_table_from_schema! specifying a table from a schema other than public. Two v
This is a minor bugfix release to address a bug in 0.10.0 involving infer_table_from_schema! specifying a table from a schema other than public. Two version bumps which were backwards compatible have also been included.
infer_table_from_schema! properly handles table names with a custom schema
specified.v0.10.0 drops support for Rust 1.14 and earlier, and adds support for Rust 1.15 (ON STABLE). diesel_codegen_syntex has been removed, and is no longer
v0.10.0 drops support for Rust 1.14 and earlier, and adds support for Rust 1.15 (ON STABLE). diesel_codegen_syntex has been removed, and is no longer supported.
Additionally, this release adds initial support for the JSON data type in PostgreSQL. There is also a new print-schema subcommand in Diesel CLI which will show you the code generated by infer_schema!(). As always, you can find a full list of what has changed in the changelog.
In addition to the Diesel core team, 7 contributors worked on this release. A huge thank you to
I'd also like to thank everybody who helped this release by opening issues, finding bugs, and asking/answering questions in our gitter room.
There were several big features that I had hoped to get done in time for this release, but my daughter inherited my troll gene and decided to come early. If you were hoping for MySQL support, blame Ruby. In the mean time, here is a picture of Ruby.
json and jsonb types. They can
be mapped to/from serde_json::Value. The serde feature must be enabled to
use the JSON types.print-schema command to Diesel CLI. This command will print the
output of the infer_schema! macro. For more information run diesel help print-schema.When possible, we will use deprecation warnings for breaking changes.
Deprecated code requires the with-deprecated feature, which is enabled by
default.
The postgres feature is no longer enabled by default by diesel or
diesel_codegen_syntex. Add features = ["postgres"] to your Cargo.toml.
The persistable module has been renamed to insertable.
#[derive(Insertable)] allows fields of type Option<T> to be used with
columns that are not null if they have a default value.diesel_codegen_syntex is no longer supported. diesel_codegen can now be
used on stable Rust.
Dropped support for Rust 1.14 and earlier
Added missing impls for loading chrono::NaiveDateTime from a column of type Timestamptz
Added missing impls for loading chrono::NaiveDateTime from a column of type
Timestamptz
#[derive(AsChangeset)] no longer assumes that use diesel::prelude::* has
been done.
debug_sql! can now properly be used with types from chrono or
std::time.
When using PostgreSQL, attempting to get the error message of a query which could not be transmitted to the server (such as a query with greater than 65535 bind parameters) will no longer panic.
0.9.0 is a fairly large release, bringing several important quality of life features. The main features of this release are:
0.9.0 is a fairly large release, bringing several important quality of life features. The main features of this release are:
This release also includes numerous bug fixes. In particular several bugs which occurred from using empty arrays have all been fixed. For full release notes, see the CHANGELOG
Added support for SQL NOT IN using the ne_any method.
The table! macro now allows custom schemas to be specified. Example:
table! {
schema_1.table_1 {
id -> Integer,
}
}
The generated module will still be called table_1.
The infer_table_from_schema! macro now allows custom schemas to be
specified. Example:
infer_table_from_schema!("dotenv:DATABASE_URL", "schema_1.table_1");
The infer_schema! optionally allows a schema name as the second argument. Any
schemas other than public will be wrapped in a module with the same name as
the schema. For example, schema_1.table_1 would be referenced as
schema_1::table_1.
Added support for batch insert on SQLite. This means that you can now pass a
slice or vector to diesel::insert on all backends.
EXISTS expressions. See
diesel::expression::dsl::exists for details.#[derive(Identifiable)] can be used with structs that have primary keys
other than id, as well as structs with composite primary keys. You can now
annotate the struct with #[primary_key(nonstandard)] or #[primary_key(foo, bar)].Queryable!) have
been renamed to impl_Queryable! or similar.#[derive(Identifiable)] now works on structs with lifetimes
Attempting to insert an empty slice will no longer panic. It does not execute any queries, but the result will indicate that we successfully inserted 0 rows.
Attempting to update a record with no changes will no longer generate invalid
SQL. The result of attempting to execute the query will still be an error, but
but it will be a Error::QueryBuilderError, rather than a database error.
This means that it will not abort the current transaction, and can be handled
by applications.
Calling eq_any or ne_any with an empty array no longer panics.
eq_any(vec![]) will return no rows. ne_any(vec![]) will return all rows.
Fixed support for nightlies later than 2016-11-07
Fixed support for nightlies later than 2016-11-07
Removed support for nightlies earlier than 2016-11-07
Calls to infer_table_from_schema! will need to be wrapped in a module if
called more than once. This change is to work around further limitations of
the Macros 1.1 system. Example:
mod infer_users {
infer_table_from_schema!("dotenv:DATABASE_URL", "users");
}
pub use self::infer_users::*;
SQLite date and time columns can be deserialized to/from strings.
diesel_codegen on nightlies >= 2016-10-20…use codegen such as serde. This did reqiure some breaking changes to their API, but it should be a straightforward migration. the CHANGELOG has migrat…
This release is primarily focused around diesel_codegen, which has been entirely rewritten to use the new Macros 1.1 framework. This means that Diesel should continue to work on all future nightlies, and will be much more compatible with other crates which use codegen such as serde. This did reqiure some breaking changes to their API, but it should be a straightforward migration. the CHANGELOG has migration instructions.
The macros 1.1 rewrite took the majority of our time, so this release is fairly light on features, but we do have a few great quality of life additions. See the CHANGELOG for details.
A huge thank you to all the contributors who worked on this release:
Added partial support for composite primary keys.
Added support for PostgreSQL NULLS FIRST and NULLS LAST when sorting.
See https://docs.diesel.rs/diesel/prelude/trait.SortExpressionMethods.html
for details.
Added support for the timestamp with time zone type in PostgreSQL (referred
to as diesel::types::Timestamptz)
Diesel CLI can now generate bash completion. See the readme for details.
infer_schema! and infer_table_from_schema! can now take "env:foo"
instead of env!("foo") and "dotenv:foo" instead of dotenv!("foo"). The
use of dotenv requires the dotenv feature on diesel_codegen, which is
included by default. Using env! and dotenv! will no longer work with
diesel_codegen. They continue to work with diesel_codegen_syntex, but that
crate will be deprecated when Macros 1.1 is in the beta channel for Rust.
Structs annotated with #[has_many] or #[belongs_to] now require
#[derive(Associations)]. This is to allow them to work with Macros 1.1.
embed_migrations! now resolves paths relative to Cargo.toml instead of the
file the macro was called from. This change is required to allow this macro to
work with Macros 1.1.
diesel migrations run will now respect migration directories overridden by
command line argument or environment variableinfer_schema! macro will no longer fetch views alongside with tables.
This was a source of trouble for people that had created views or are using
any extension that automatically creates views (e.g. PostGIS)#[changeset_for(foo)] should now be written as
#[derive(AsChangeset)] #[table_name="foo"]. If you were specifying
treat_none_as_null = "true", you should additionally have
#[changeset_options(treat_none_as_null = "true")].#[insertable_into(foo)] should now be written as
#[derive(Insertable)] #[table_name="foo"].This fix does technically constitute a breaking change to public API, but I'm doing this in a patch release as it affects a recently introduced trait…
This is a bugfix release containing two major fixes. Most importantly, the Copy constraint has been removed from Identifiable::Id. This was an oversight which ended up making it impossible to use #[changeset_for] with string IDs. This fix does technically constitute a breaking change to public API, but I'm doing this in a patch release as it affects a recently introduced trait and I consider it more of a bugfix. We're still 0.x, so semver doesn't strictly hold yet. Additionally, the macro form of #[belongs_to] supported specifying custom foriegn keys, while the procedural form did not. This has been remedied.
Copy constraint has been removed from Identifiable::Id, and
Identifiable#id now returns &Identifiable::Id.#[belongs_to] now respects the foreign_key option when using
diesel_codegen or diesel_codegen_syntex.diesel_codegen has been split into two crates. This is a breaking change which will affect 100% of our users. Please see https://github.com/diesel-rs/…
The headline feature of this version is associations. Just add #[belongs_to(User)] above your struct, and it becomes incredibly easy to manipulate larger batches of data. See http://docs.diesel.rs/diesel/associations/index.html for a full guide.
Diesel is taking a slightly different approach to what you may have seen in the past, which I'm calling "non-invasive associations". In contrast to something like Active Record or Ecto, where the association lives on the parent, the data is completely independent. The type of a user and all its posts is (User, Vec<Post>).
This release also marks the elimination of Diesel's reliance on procedural macros. They're still available as an option, and their usage is recommended. However, a lot of people have had a desire to shy away from them. For all of our code generation that does not perform IO, there is now a completely stable non-procedural macro, which has been designed to work with the custom_derive crate. See the CHANGELOG for a full list.
diesel_codegen has been split into two crates. This is a breaking change which will affect 100% of our users. Please see https://github.com/diesel-rs/diesel/commit/36b8801bf5e9594443743e6a7c62e29d3dce36b7 for more information on how to migrate.
This release has also had a contributor who has gone above and beyond to help out. I'd like to take this opportunity to announce the 4th addition to the Diesel core team, @killercup! Your contributions have been much appreciated, and your code review has been invaluable.
Thank you to everybody who contributed to this release.
On to 0.8! With this release, we are approaching the benchmarks I had set for 1.0. We will still have at least 2 more releases before the 1.0 release, but it's quickly becoming the next target. We will be publishing a roadmap soon.
The initial APIs have been added in the form of #[has_many] and
#[belongs_to]. See the module documentation for more
information.
The Insertable! macro can now be used instead of #[insertable_into] for
those wishing to avoid syntax extensions from diesel_codegen. See
https://docs.diesel.rs/diesel/macro.Insertable!.html for details.
The Queryable! macro can now be used instead of #[derive(Queryable)] for
those wishing to avoid syntax extensions from diesel_codegen. See
https://docs.diesel.rs/diesel/macro.Queryable!.html for details.
The Identifiable! macro can now be used instead of #[derive(Identifiable)] for
those wishing to avoid syntax extensions from diesel_codegen. See
https://docs.diesel.rs/diesel/macro.Identifiable!.html for details.
The AsChangeset! macro can now be used instead of #[changeset_for(table)]
for those wishing to avoid syntax extensions from diesel_codegen. See
https://docs.diesel.rs/diesel/macro.AsChangeset!.html for details.
Added support for the PostgreSQL ALL operator. See
https://docs.diesel.rs/diesel/pg/expression/dsl/fn.all.html for details.
Added support for RETURNING expressions in DELETE statements. Implicitly
these queries will use RETURNING *.
Diesel now targets nightly-2016-07-07. Future releases will update to a
newer nightly version on the date that Rust releases.
diesel_codegen has been split into two crates. diesel_codegen and
diesel_codegen_syntex. See this commit for migration
information.
Most structs that implement Queryable will now also need
#[derive(Identifiable)].
infer_schema! on SQLite now accepts a larger range of type names
types::VarChar is now an alias for types::Text. Most code should be
unaffected by this. PG array columns are treated slightly differently,
however. If you are using varchar[], you should switch to text[] instead.
Struct fields annotated with #[column_name="name"] should be changed to
#[column_name(name)].
The structure of DatabaseError has changed to hold more information. See
https://docs.diesel.rs/diesel/result/enum.Error.html and
https://docs.diesel.rs/diesel/result/trait.DatabaseErrorInformation.html for
more information
Structs which implement Identifiable can now be passed to update and
delete. This means you can now write delete(&user).execute(&connection)
instead of delete(users.find(user.id)).execute(&connection)
&&[T] can now be used in queries. This allows using slices with things like
#[insertable_into].Nothing published for this version
Added the escape method to Like and NotLike, to specify the escape character used in the pattern. See [EscapeExpressionMethods][escape] for details.
escape method to Like and NotLike, to specify the escape
character used in the pattern. See EscapeExpressionMethods for
details.diesel_codegen and diesel_cli now properly rely on Diesel 0.6.0. The
restriction to 0.5.0 was an oversight.
infer_schema! now properly excludes metadata tables on SQLite.
infer_schema! now properly maps types on SQLite.
Queries can now be boxed using the into_boxed() method. This is useful for conditionally modifying queries without changing the type. See [BoxedDsl][b
Queries can now be boxed using the into_boxed() method. This is useful for
conditionally modifying queries without changing the type. See
BoxedDsl for more details.
infer_schema! is now supported for use with SQLite3.
The maximum table size can be increased to 52 by enabling the huge-tables
feature. This feature will substantially increase compile times.
The DISTINCT keyword can now be added to queries via the distinct()
method.
SqliteConnection now implements Send
diesel::result::Error now implements Send and Sync. This required a
change in the return type of ToSql and FromSql to have those bounds as
well.
It is no longer possible to pass an owned value to diesel::insert. insert
will now give a more helpful error message when you accidentally try to pass
an owned value instead of a reference.
#[insertable_into] can now be used with structs that have lifetimes with
names other than 'a'.
Tables with a single column now properly return a single element tuple. E.g.
if the column was of type integer, then users::all_columns is now (id,)
and not id.
infer_schema! can now work with tables that have a primary key other than
id.
no select option for the table! macro. This was a niche
feature that didn't fit with Diesel's philosophies. You can write a function
that calls select for you if you need this functionality.Added helper function diesel_manage_updated_at('TABLE_NAME') to postgres upon database setup. This function sets up a trigger on the specified table t
Added helper function diesel_manage_updated_at('TABLE_NAME') to postgres
upon database setup. This function sets up a trigger on the specified table
that automatically updates the updated_at column to the current_timestamp
for each affected row in UPDATE statements.
Added support for explicit RETURNING expressions in INSERT and UPDATE
queries. Implicitly these queries will still use RETURNING *.
Added support for SQLite. Diesel still uses postgres by default. To use SQLite instead, add default-features = false, features = ["sqlite"] to your Ca
Added support for SQLite. Diesel still uses postgres by default. To use SQLite
instead, add default-features = false, features = ["sqlite"] to your
Cargo.toml. You'll also want to add default-features = false, features = ["sqlite"] to diesel_codegen.
Since SQLite is a much more limited database, it does not support our full set
of features. You can use SQLite and PostgreSQL in the same project if you
desire.
Added support for mapping types::Timestamp, types::Date, and types::Time
to/from chrono::NaiveDateTime, chrono::NaiveDate, and chrono::NaiveTime.
Add features = ["chrono"] to enable.
Added a treat_none_as_null option to changeset_for. When set to true,
a model will set a field to Null when an optional struct field is None,
instead of skipping the field entirely. The default value of the option is
false, as we think the current behavior is a much more common use case.
Added Expression#nullable(), to allow comparisons of not null columns with
nullable ones when required.
Added sum and avg functions.
Added the diesel setup, diesel database setup, and diesel database reset commands to the CLI.
Added support for SQL IN statements through the eq_any method.
Added a top level select function for select statements with no from clause.
This is primarily intended to be used for testing Diesel itself, but it has
been added to the public API as it will likely be useful for third party
crates in the future. select(foo).from(bar) might be a supported API in the
future as an alternative to bar.select(foo).
Added expression::dsl::sql as a helper function for constructing
SqlLiteral nodes. This is primarily intended to be used for testing Diesel
itself, but is part of the public API as an escape hatch if our query builder
DSL proves inadequate for a specific case. Use of this function in any
production code is discouraged as it is inherently unsafe and avoids real type
checking.
Moved most of our top level trait exports into a prelude module, and
re-exported our CRUD functions from the top level.
diesel::query_builder::update and friends are now diesel::update, and you
will get them by default if you import diesel::*. For a less aggressive
glob, you can import diesel::prelude::*, which will only export our traits.
Connection is now a trait instead of a struct. The struct that was
previously known as Connection can be found at diesel::pg::PgConnection.
Rename both the #[derive(Queriable)] attribute and the Queriable trait to
use the correct spelling Queryable.
load and get_results now return a Vec<Model> instead of an iterator.
Replaced Connection#find(source, id) with
source.find(id).first(&connection).
The debug_sql! macro now uses ` for identifier quoting, and ? for bind
parameters, which is closer to a "generic" backend. The previous behavior had
no identifier quoting, and used PG specific bind params.
Many user facing types are now generic over the backend. This includes, but is
not limited to Queryable and Changeset. This change should not have much
impact, as most impls will have been generated by diesel_codegen, and that API
has not changed.
The mostly internal NativeSqlType has been removed. It now requires a known
backend. fn<T> foo() where T: NativeSqlType is now fn<T, DB> foo() where DB: HasSqlType<T>
Connection#query_sql and Connection#query_sql_params have been removed.
These methods were not part of the public API, and were only meant to be used
for testing Diesel itself. However, they were technically callable from any
crate, so the removal has been noted here. Their usage can be replaced with
bare select and expression::dsl::sql.Diesel CLI will no longer output notices about __diesel_schema_migrations already existing.
Diesel CLI will no longer output notices about __diesel_schema_migrations
already existing.
Relicensed under MIT/Apache dual
Added Diesel CLI, a tool for managing your schema. See the readme for more information.
Added Diesel CLI, a tool for managing your schema. See the readme for more information.
Add the ability for diesel to maintain your schema for you automatically. See the migrations module for individual methods.
Add DebugQueryBuilder to build sql without requiring a connection.
Add print_sql! and debug_sql! macros to print out and return sql strings from QueryFragments.
#[changeset_for] can now be used with structs containing a Vec. Fixes
#63.
No longer generate invalid SQL when an optional update field is not the first field on a changeset. Fixes #68.
#[changeset_for] can now be used with structs containing only a single field
other than id. Fixes #66.
infer_schema! properly works with array columns. Fixes
#65.
.save_changes (generated by #[changeset_for]) now returns a new struct, rather than mutating self. The returned struct can be any type that implements
#[changeset_for(table)] now treats Option fields as an optional update.
Previously a field with None for the value would insert NULL into the
database field. It now does not update the field if the value is None.
.save_changes (generated by #[changeset_for]) now returns a new struct,
rather than mutating self. The returned struct can be any type that
implements Queryable for the right SQL type
#[derive(Queryable)] now allows generic parameters on the struct.
Table definitions can now support up to 26 columns. Because this increases our
compile time by 3x, features = ["large-tables"] is needed to support table
definitions above 16 columns.
Quickcheck is now an optional dependency. When features = ["quickcheck"] is
added to Cargo.toml, you'll gain Arbitrary implementations for everything
in diesel::data_types.
Added support for the SQL MIN function.
Added support for the Numeric data type. Since there is no Big Decimal type
in the standard library, a dumb struct has been provided which mirrors what
Postgres provides, which can be converted into whatever crate you are using.
Timestamp columns can now be used with std::time::SystemTime when compiled
with --features unstable
Implemented Send on Connection (required for R2D2 support)
Added infer_schema! and infer_table_from_schema!. Both macros take a
database URL, and will invoke table! for you automatically based on the
schema. infer_schema! queries for the table names, while
infer_table_from_schema! takes a table name as the second argument.
Connection#insert and Connection#insert_returning_count have been deprecated in favor of [insert][insert]
Added an execute method to QueryFragment, which is intended to replace
Connection#execute_returning_count. The old method still exists for use
under the hood, but has been hidden from docs and is not considered public
API.
Added get_result and get_results, which work similarly to load and
first, but are intended to make code read better when working with commands
like create and update. In the future, get_result may also check that
only a single row was affected.
Added [insert][insert], which mirrors the pattern of update and delete.
Added a hidden __Nonexhaustive variant to result::Error. This is not
intended to be something you can exhaustively match on, but I do want people
to be able to check for specific cases, so Box<std::error::Error> is
not an option.
query_one, find, and first now assume a single row is returned. For
cases where you actually expect 0 or 1 rows to be returned, the optional
method has been added to the result, in case having a Result<Option<T>> is
more idiomatic than checking for Err(NotFound).
Connection#insert and Connection#insert_returning_count have been
deprecated in favor of [insert][insert][0.2.0]: https://github.com/diesel-rs/diesel/compare/v0.1.0...v0.2.0 [0.3.0]: https://github.com/diesel-rs/diesel/compare/v0.2.0...v0.3.0 [0.4.0]: htt
One column per quarter.