A safe, extensible ORM and Query Builder for Rust
APACHE-2.0 License
Bot releases are visible (Hide)
Published by weiznich about 5 years ago
diesel_derives
and diesel_migrations
are updated to syn 1.0Published by weiznich over 5 years ago
In contrast to the last release most changes in this release are minor or internal. We've added support for newer versions of some dependency crates (libsqlite-sys, uuid, ipnetwork).
Diesel CLI got a command line flag to check if a generated schema matches the already existing one. This is useful for CI setups to check there if the committed generated schema file matches the committed migrations.
We've added support for the diesel_mange_updated_at('table_name')
SQL function on SQLite. This function handles the setup of an trigger that automatically updates the updated_at
column on update operations.
Additionally several helpers were added to support the deserialisation of tuples and composite types on PostgreSQL.
As always, a full list of changes can be found it in the changelog
Thank you to everyone who helped make this release happen through bug reports, and discussion on Gitter. While we don't have a way to collect stats on that form of contribution, it's greatly appreciated.
In addition to the Diesel core team, 29 people contributed code to this release. A huge thank you to:
Published by sgrif about 6 years ago
This is a small bugfix release, addressing an issue with MySQL 8.0. The
behavior of the C API in libmysqlclient changed in this version of
MySQL, causing problems when a connection pool was used with Diesel.
If you are not using MySQL, or are on a version older than 8.0, this
release does not affect you.
Published by sgrif over 6 years ago
This release contains two major bugfixes. This release fixes the behavior of unsigned types on MySQL, and a compile time issue caused by the use of #[sql_name]
in sql_function!
with no return type. This release only affects users who are using unsigned types on MySQL, or who had code which failed to compile with 1.3.1.
Published by sgrif over 6 years ago
This release includes a couple of major changes to how Diesel projects are developed. In the past, we've had 2 ways to generate schema.rs
. A procedural macro called infer_schema!
, and a CLI command diesel print-schema
. We've recommended using the CLI command for a long time, but infer_schema!
was still useful for early prototypes.
At the beginning of a project, your database schema changes much more frequently. It's extremely annoying to have to remember to run a second command after running your migrations.
Diesel CLI 1.3 now supports a configuration file to customize its behavior. One of the new capabilities this provides is the ability to automatically regenerate schema.rs
whenever you run or revert a migration. This means you no longer have to remember to run diesel print-schema
when things change.
Because of this, we are deprecating diesel_infer_schema
. 1.3 will be the final release of that crate. However, diesel_infer_schema
1.3 will continue to work with diesel
until at least Diesel 2.0. You can see all of the capabilities of the new configuration file at http://diesel.rs/guides/configuring-diesel-cli.
This release also includes a complete redesign of the sql_function!
macro. The new syntax is significantly closer to normal Rust. For example, what used to be written as:
sql_function! {
lower, lower_t, (x: Text) -> Text,
"Here are the docs for `lower`
It's awkward to make multiline"
}
Can now be written as:
sql_function! {
/// Here are the docs for `lower`
/// It's just a normal doc comment.
fn lower(x: Text) -> Text;
}
The new form also supports much more than the old one, including aggregate functions, function renaming, and generic functions. Things like MAX
could previously not be expressed with sql_function!
. However, now the definition looks like this:
sql_function! {
#[aggregate]
fn max<ST: SqlOrd + IntoNullable>(expr: ST) -> ST::Nullable;
}
Finally, the redesigned sql_function!
supports user defined functions on SQLite. SQLite differs from other databases, in that custom functions aren't defined in SQL. Instead you give it a C function pointer to use for the body. With Diesel, you can just give us any Rust closure that takes appropriate argument types, and we'll handle gluing that to SQLite for you.
You can find examples for all of this in the docs for sql_function!
.
In addition to the headline features, this release includes a ton of quality of life changes including expanded support for locking clauses, more global support for mathematic operators, and more. As always, for a full list of changes you can find it in [the changelog].
[the changelog]: https://github.com/diesel-rs/diesel/blob/v1.3.0/CHANGELOG.md
Thank you to everyone who helped make this release happen through bug reports, and discussion on Gitter. While we don't have a way to collect stats on that form of contribution, it's greatly appreciated.
In addition to the Diesel core team, 12 people contributed code to this release. A huge thank you to:
Published by sgrif over 6 years ago
This release contains several long awaited features.
We've re-introduced the ability to use bind params with the sql
function, in a way which is harder to mis-use. This functionality was present prior to 1.0, but was removed when sql_function
was added over concerns about its use with the rest of the query builder. Recent developments have proved those concerns to be valid, but this new API fills that niche. Thanks to @notryanb for taking the lead on this feature.
We've also added the ability to insert from a select statement (e.g. queries in the form of INSERT INTO table (...) SELECT ...
. This is a feature request that has come up repeatedly since release, and we're happy to finally bring it to you. We've also added alternate forms of our insert API which feel better when used with select statements. You can find the full details in the CHANGELOG.
Finally, we've rewritten our custom dervies from scratch to take advantage of new diagnostic tools in recent versions of nightly Rust. If you turn on the unstable
feature of Diesel on a nightly compiler, you'll find that you get dramatically improved error messages from our derives. For the best error messages, you should also set RUSTFLAGS="--cfg procmacro2_semver_exempt"
.
Additionally, as of this release, Diesel is now powered by the blockchain. Because it's 2018 and that's how it works now I guess. See the CHANGELOG for full details.
In addition to the headline features, there were a ton of features that we don't have time to mention here. As always, for a full list of changes you can find a full list in the CHANGELOG.
Thank you to everyone who helped make this release happen through bug reports, and discussion on Gitter. While we don't have a way to collect stats on that form of contribution...
In addition to the Diesel core team, 14 people contributed code to this release. A huge thank you to:
Published by sgrif almost 7 years ago
This release fixes a minor issue with our r2d2 support. In 1.1 we recommend that people access r2d2
via diesel::r2d2
. However, r2d2
has a type called Error
, which was shadowed by our own type called Error
in that same module, making it inaccessible. This release adds an alias PoolError
to point at r2d2::Error
.
Thanks to YetAnotherMinion for working on this release.
Published by sgrif almost 7 years ago
The primary focus of this release was improving the ergonomics of adding support for new types in Diesel.
For implementing new SQL types, we've added #[derive(SqlType)]
which implements many traits that you need to implement for every SQL type. See the documentation for HasSqlType
for details on this derive.
For implementing new mappings, we've added #[derive(FromSqlRow)]
and #[derive(AsExpression)]
. These derives will replace the majority of the boilerplate that was previously required when supporting new types. Adding support for new types in Diesel 1.1 should only require implementing FromSql
and ToSql
. The derives will handle the rest.
We've also provided FromSql
impls for *const str
and *const [u8]
. Due to the design of FromSql
, we can't provide impls for &str
and &[u8]
without a breaking change. However many impls just need to parse a string or some bytes, and don't need the allocation that would come from String
or Vec<u8>
. This will require unsafe code to use, but should make certain implementations more efficient.
Finally, we've restructured how our serialize/deserialize modules are structured, and provided type aliases to make implementations of FromSql
and ToSql
more consise.
r2d2_diesel
is Now Part of DieselFinally, this release merges r2d2_diesel
into Diesel itself. The main benefit of doing this is that we can implement Connection
for PooledConnection
, removing the need for explicit &*
when using r2d2. This should also help to prevent version mismatches when changing Diesel versions.
To use the new r2d2 support, remove r2d2
and r2d2_diesel
from your Cargo.toml. Add the r2d2
to your enabled features on diesel
. Replace extern crate r2d2
with pub use diesel::r2d2
. Replace any r2d2_diesel::
with diesel::r2d2::
.
In addition to the headline features, there were dozens of smaller additions which should make using Diesel even better! As always, you can check the CHANGELOG for a full list of changes in this release.
In addition to the Diesel core team, 8 people contributed to this release. A huge thank you to:
Published by sgrif almost 7 years ago
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 toIt'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:
Published by sgrif almost 7 years ago
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.
Published by sgrif almost 7 years ago
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.
Published by sgrif almost 7 years ago
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!
Published by sgrif about 7 years ago
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:
Published by sgrif about 7 years ago
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.
Published by sgrif about 7 years ago
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:
Published by sgrif over 7 years ago
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.
Published by sgrif over 7 years ago
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.
Published by sgrif over 7 years ago
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.
Published by sgrif over 7 years ago
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:
Published by sgrif over 7 years ago
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: