All user visible changes to this project will be documented in this
file. This project adheres to Semantic
Versioning, as described for Rust libraries in RFC
#1105 We explicitly reserve the right to perform breaking changes in
minor releases to fix build breaking changes from the Rust project. For
any named minimal supported Rust version we guarantee that it is
possible to build Diesel with the default features enabled using some
set of dependencies. Those set of dependencies is not necessarily an up
to date version of the specific dependency. We check this by using the
unstable -Z minimal-version cargo flag. Increasing the
minimal supported Rust version will always be coupled at least with a
minor release.
2.3.0 2025-09-12
Added
- Added
limit()andoffset()DSL to combination clauses such asUNION - Fixed
#[derive(Identifiable)]ignoring attribute#[diesel(serialize_as)]on primary keys - Added embedded struct support for
AsChangesetvia#[diesel(embed)] - Added a
#[diesel(skip_update)]attribute for theAsChangesetderive to skip updating a field present in the struct - Support for libsqlite3-sys 0.35.0
- Add support for built-in PostgreSQL range operators and functions
- Support for postgres multirange type
- Added
diesel::r2d2::TestCustomizer, which allows users to customize theirdiesel::r2d2::Pools in a way that makes the pools suitable for use in parallel tests. - Added support for built-in PostgreSQL range operators and functions
- Added support for various built-in PostgreSQL array functions
- Added
JsonandJsonbsupport for the SQLite backend. - Added a
#[diesel::declare_sql_function]attribute macro to easily define support for multiple sql functions at once via anextern "SQL"block - Support
[print_schema] allow_tables_to_appear_in_same_query_config = "fk_related_tables"to generate separateallow_tables_to_appear_in_same_query!calls containing only tables that are related through foreign keys. (Default:"all_tables".) It is not possible to build queries using two tables that don’t appear in the sameallow_tables_to_appear_in_same_query!call, but that macro generates O(n²) rust code, so this option may be useful to reduce compilation time. (#4333) - Added
wasm32-unknown-unknowntarget support for sqlite backend. - Add support for the
CASToperator - Support
[print_schema] allow_tables_to_appear_in_same_query_config = "none"to generate noallow_tables_to_appear_in_same_query!calls. (Default:"all_tables".). (#4333) - Add
[print_schema] pg_domains_as_custom_typesparameter to generate custom types for PostgreSQL domains that matches any of the regexes in the given list. (Default:[].) This option allows an application to selectively give special meaning for the serialization/deserialization of these types, avoiding the default behavior of treating the domain as the underlying type. (#4592) - Add support for batch insert and upsert statements with returning for SQLite
- Add support for window functions and aggregate expressions.
Fixed
- Fixed diesel thinking
a.eq_any(b)was non-nullable even ifaandbwere nullable. - Generate
InstrumentationEvent::BeginTransactionfor immediate and exclusive transactions in SQLite - Use a single space instead of two spaces between
DELETE FROM. - Diesel CLI now ensures that migration versions are always unique. If it fails to generate a unique version, it will return an error. The new version format remains compatible with older Diesel versions.
- Updated
ipnetworkto allow version 0.21.
Changed
- Use distinct
DIESEL_LOGlogging filter env variable instead of the defaultRUST_LOGone (#4575) - The minimal supported Rust version is now 1.86.0
2.2.12 2025-07-11
Fixed
- Added support for libsqlite3-sys 0.35.0
- Fixed a wrong oid for the
oid[]type in the PostgreSQL backend - Worked around an issue with broken nullable detection with certain versions of libmysqlclient shipped by ubuntu
- Improved compiler errors in many more cases
2.2.11 2025-06-12
Fixed
- Disallow mixing aggregate and non-aggregate expressions in
DISTINCT ONclauses - Fixed an item referenced by a non-absolute path in
#[derive(MultiConnection)] - Improved compiler errors in some cases
- Improved the documentation for creating SqliteConnections for concurrent applications
2.2.10 2025-04-25
Fixed
- Support for libsqlite3-sys 0.35.0
- Fixed potential ambiguities in code generated by various derives
2.2.9 2025-04-04
Fixed
- Fix an issue where
diesel migration generate --diff-schemaincorrectly uses the primary key of table B as the referenced column rather than the primary key of table A when B has a foreign key pointing to table A. - Bump maximal supported libsqlite3-sys version to 0.32.0 and add
explicit feature entries for the
uuidandserde_jsonfeature. - Fixed an issue where diesel generated unnamed prepared statements
would fail with an
unanmed prepared statement not founderror with pgbouncer. - Fix an issue with converting
ipnet::Ipnetvalues with an subnet to SQL values
2.2.8 2025-03-03
Fixed
- Allow
#[diesel(check_for_backend(_))]to check fields with#[diesel(embed)]annotations - Improve custom compile error message around
CompatibleType - Fix a bug that restricted the number of allowed columns in
COPY FROMstatements to 12 - Expose some SqliteValue helper functions
- Use consistent whitespace in
ASC/DESC,DISTINCT ON, andDELETE FROMclauses
2.2.7 2025-01-31
Fixed
- Fixed diesel thinking
a.eq_any(b)was non-nullable even ifaandbwere nullable. - Generate
InstrumentationEvent::BeginTransactionfor immediate and exclusive transactions in SQLite - Minimize the amount of duplicated code generated for
diesel::debug_query - Updated
ipnetworkto allow version 0.21. - Updated
libsqlite3-systo allow version 0.31.0 - Updated
pq-systo allow version 0.7.0 - Add support for numeric operators (+-*/) in
#[diesel::auto_type] - Add support for joins to sub-jons to aliases
2.2.6 2024-12-03
Fixed
- Remove more mentions of gitter from the documentation
2.2.5 2024-11-21
Fixed
- Add a typedef for
ReturningandCountso that#[auto_type]works with such queries - Fixed an issue that allowed to pass non-boolean expressions to
.and()and.or()which would result in queries failing at runtime - Officially deprecating the gitter room
Removed
- Do not mention the gitter channel in our docs anymore
2.2.4 2024-09-03
Fixed
- Fix an issue where empty queries could trigger undefined behaviour in the sqlite backend
2.2.3 2024-08-23
Fixed
- Support for libsqlite3-sys 0.30.0
- Fixed a possible vulnerability in how Diesel handled protocol level bind parameters. See the SQL Injection isn’t Dead: Smuggling Queries at Protocol Level presentation from DEF CON for details
- Fixed an issue with a possibly ambiguous trait resolution in
#[derive(QueryableByName)]
2.2.2 2024-07-19
Fixed
- Support for libsqlite3-sys 0.29.0
- Fixed a potential panic in the sqlite cursor implementation
- Fixed support for rust numeric operators with columns of the type
Numeric - Removed the
SerializedDatabase::newfunction due to unsoundness
2.2.1 2024-06-12
Fixed
- Fixed using
#[dsl::auto_type]with functions that accept reference arguments - Fixed using
#[derive(Queryable)]with structs that use a type namedRowas field type - Fixed a regression that prevented using
mysqlclient-sys0.2.x with diesel 2.2 - Fixed connecting to postgres database using the scram-sha-256 authentication method on windows while using the bundled postgres builds
- Improved the error messages in diesel-cli for cases where a file/folder was not found
- Fixed several version detection bugs in mysqlclient-sys to use pre-generated bindings in more situations
2.2.0 2024-05-31
Added
- Support
[print_schema] except_custom_type_definitions = ["Vector"]. If acustom typematches one element on the list it’s skipped. - Added automatic usage of all sqlite
rowidaliases when no explicit primary key is defined forprint-schema - Added a
#[dsl::auto_type]attribute macro, allowing to infer type of query fragment functions - Added the same type inference on
Selectablederives, which allows skipping specifyingselect_expression_typemost of the time, in turn enabling most queries to be written using just aSelectablederive. - Added an optional
#[diesel(skip_insertion)]field attribute to theInsertablederive macro, allowing fields which map to generated columns to be skipped during insertion. - Support for connection instrumentation. This allows to inspect any query run by your application
- Logging in diesel-cli
- Support for libsqlite3-sys 0.28
- Add
sqlite-integer-primary-key-is-bigintconfiguration option, usable with SQLite 3.37 or above, allowing to useBigIntforINTEGER PRIMARY KEYcolumns in SQLite for tables without theWITHOUT ROWIDattribute (SQLite doc). - Support for multiple
print_schemaentry indiesel.toml(e.g.[print_schema.user1]), which allows generating multiple schema.rs files - Add support for
COPY TOandCOPY FROMstatements - Add support for mapping
chrono::Durationto postgresql’sINTERVALsql type - Added
serialize_database_to_bufferanddeserialize_readonly_database_from_buffermethods inSqliteConnectionto support serialization/deserialization of SQLite databases to and from byte buffers. - Added
SerializedDatabasewrapper type for a serialized database that is dynamically allocated by callingserialize_database_to_buffer. This RAII wrapper deallocates the memory when it goes out of scope withsqlite3_free.
Changed
- The minimal officially supported rustc version is now 1.78.0
- Deprecated
sql_function!in favour ofdefine_sql_function!which provides compatibility with#[dsl::auto_type] - Deserialization error messages now contain information about the field that failed to deserialize
2.1.6 2024-04-19
- Fix using
BoxableExpressionwith having clauses - Fix using numeric expressions with aliased fields
- Minor documentation fixes
2.1.5 2024-03-15
- Fix
impl SqlOrdpostgres > postgres_backend feature flag. - Allow
Queryableto be used with multiple table names. - Fix an inconsistent unit test
- Fix a clippy lint
- Fix ./bin/test feature flag calls.
- Update
libsqlite3-systo allow version 0.28 as well
2.1.4 2023-11-14
- Update
libsqlite3-systo allow version 0.27 as well
2.1.3 2023-10-05
- Increased accidently decreased limit around element count in
DISTINCT ONandORDER BYclauses again as that broke existing code
2.1.2 2023-09-25
Fixed
- Fixed another potential breaking chaneg around queries containing
DISTINCT ONandORDER BYclauses consisting of custom sql expressions (e.g..nullable()) - Fixed an issue where
#[derive(Selectable)]and#[diesel(check_for_backend)]generates invalid rust code if the struct contains lifetimes/generic types
2.1.1 2023-08-25
Fixed
- Fixed an issue in diesel-cli that lead to using unquoted table names in one of the internal queries
- Fixed a bug in
diesel print-schemathat lead to generating invalidtable!macros if both the#[sql_name]and the#[max_length]attribute are present - Fixed an issue in diesel-cli that lead to ignoring certain foreign key constraints for postgresql
- Fixed an crash while using
diesel print-schemawith really old sqlite versions - Fixed an issue where
#[diesel(check_for_backend)]ignored#[diesel(deserialize_as)]attributes - Fixed several issues with the new
#[derive(MultiConnection)]feature - Fixed some edge cases in our sqlite timestamp parsing behaviour
diesel migration generate --diff-schemanow respects table filters as setup forprint-schemaviadiesel.toml- Fixed a potential breaking change around queries containing
DISTINCT ONandORDER BYclauses consisting of custom sql expressions (e.g.diesel::dsl::sql)
Added
- Support for bigdecimal 0.4
2.1.0 2023-05-26
Changed
- The minimal officially supported rustc version is now 1.65.0
Added
- Added the
custom_type_derivesconfig option to customize the derives for SQL type definitions automatically generated by Diesel CLI. - Add a
#[derive(MultiConnection)]proc-macro that lets you easily implementdiesel::Connectionfor an enum of connections to different database backends. - Added a
--diff-schemaflag to thediesel migration generatecommand that generates a migration based on the difference between your database and the providedschema.rsfile - Add a
ON CONFLICT (...) DO UPDATE ... [WHERE ...]conditional clause support for PostgreSQL. - Add support for MySQL’s
ON DUPLICATE KEY DO UPDATEsyntax through the existing upsert functions. - Add ability to define multiple columns in a single
distinct_onfor PostgreSQL, like:.distinct_on((column_a, column_b)). - Added column size restrictions to the generated
schema.rsfile
2.0.4 2023-04-18
Fixed
- Workaround the missing name resolution in rust-analyzer. This should
fix type inference for some diesel queries. (It remains broken for
queries containing
.filter()/.inner_join()/.left_join(). These require fixes in rust-analyzer itself) - Fixed a bug that could lead to inserting null values instead of empty values for custom sqlite types
- Fixed a bug that could lead to an unexpected panic while providing
an out of bounds bind for
sql_queryin the sqlite backend - Fixed some mysql backend specific impl being behind the
mysqlinstead of themysql_backendfeature flag
Added
- Support for
libsqlite3-sys0.26
diesel_derives 2.0.2 2023-03-13
Fixed
- Fixing the fallout of a breaking change from
quoteby not using their internal API
2.0.3 2023-01-24
Fixed
- Fixed a bug with our transaction manager implementation that caused by marking transactions as broken which could be recovered.
- Fixed an issue with the combination of
BoxableExpressionand order clauses
2.0.2 2022-10-11
Fixed
- Reverted a fix from the 2.0.1 release that breaks valid
INSERT … ON CONFLICTqueries
2.0.1 2022-10-07
Fixed
- Fixed an issue with
diesel_cligenerating incompatible type names for thegenerate_missing_sql_type_definitionsfeature on PostgreSQL - Fixed an issue how
diesel_clihandles sqlite urls while checking if a given database exists - Fixed an issue with
PgConnectionbecoming unusable after hitting a database error in certain situations - Fixed an issue with diesel generating invalid SQL for certain
INSERT … ON CONFLICTqueries - Fixed
diesel_derivesgenerating code that triggers the disabled by defaultunused_qualificationslint
2.0.0 2022-08-29
Added
MysqlConnection::establishis able to initiate an SSL connection while specifying certificate roots. The database URL should contain anssl_caparameter with a path pointing to the certificate roots. See docs if desired.MysqlConnection::establishis able to initiate an SSL connection. The database URL should containssl_modeparameter with a value of the MySQL client command option--ssl-modeif desired.ConnectionandSimpleConnectiontraits are implemented for a broader range ofr2d2::PooledConnection<M>types when ther2d2feature is enabled.Added
DatabaseErrorKind::ReadOnlyTransactionto allow applications to handle errors caused by writing when only allowed to read.All expression methods can now be called on expressions of nullable types.
Added
BoxedSqlQuery. This allows users to do a variable amount of.sqlor.bindcalls without changing the underlying type.Added
.sqltoSqlQueryandUncheckedBindto allow appending SQL code to an existing query.The
MacAddrSQL type can now be used without enabling thenetwork-addressfeature.Added support for SQLite’s
UPSERT. You can use this feature above SQLite version 3.24.0.Added ability to create custom aggregate functions in SQLite.
Multiple aggregate expressions can now appear together in the same select clause. See the upgrade notes for details.
ValidGroupinghas been added to represent whether an expression is valid for a given group by clause, and whether or not it’s aggregate. It replaces the functionality ofNonAggregate. See the upgrade notes for details.It is now possible to inspect the type of values returned from the database in such a way to support constructing a dynamic value depending on this type.
Added a
without-deprecatedfeature that unconditionally disables deprecated items. Use this feature flag to verify that none of your dependencies is setting thewith-deprecatedflag internally.Added support for PostgreSQL’s
SIMILAR TOandNOT SIMILAR TO.Added
#[diesel(serialize_as)]analogous to#[diesel(deserialize_as)]. This allows customization of the serialization behaviour ofInsertableandAsChangesetstructs.Added support for
GROUP BYclausesAdded support for
UNION,UNION ALL,INTERSECT,INTERSECT ALL,EXCEPT,EXCEPT ALLclausesAdded the error position for PostgreSQL errors
Added ability to create custom collation functions in SQLite.
Added support for SQLite’s
ISandIS NOT.Add support for HAVING clauses.
Added support for SQL functions without arguments for SQLite.
Diesel CLI will now generate SQL type definitions for SQL types that are not supported by diesel out of the box. It’s possible to disable this behavior via the
generate_missing_sql_type_definitionsconfig option.Added an option to
#[derive(Insertable)]that let you insertNULLvalues instead ofDEFAULTvalues forOption<T>Added support for all the derive attributes being inside
#[diesel(...)]Added support for
RETURNINGexpressions for Sqlite via thereturning_clauses_for_sqlite_3_35featureAdded support for table aliasing via the
alias!macroAdded support for the usage of slices of references with
belonging_tofromBelongingToDslAdded support for updating individual array elements
UPDATE table SET array_column[1] = trueAdds an
ipnet-addressfeature flag, allowing support (de)serializing IP values from the database using types provided byipnet. This feature may be enabled concurrently with the previously existingnetwork-addressfeature.We’ve added support for loading values using libpq’s row-by-row mode via the new iterator interface
Adds
Timestamp,Timestamptzsupport for appropriate types fortime v0.3.9. This feature enables using thetimecrate as an alternative tochrono.
Removed
- All previously deprecated items have been removed.
- Support for
uuidversion < 0.7.0 has been removed. - Support for
bigdecimal< 0.0.13 has been removed. - Support for
pq-sys< 0.4.0 has been removed. - Support for
mysqlclient-sys< 0.2.5 has been removed. - Support for
time(0.1) types has been removed. - Support for
chrono< 0.4.19 has been removed. - The minimal supported version of libsqlite3-sys is now 0.17.2.
- The
NonNulltrait for sql types has been removed in favour of the newSqlTypetrait. no_arg_sql_function!has been deprecated without replacement. [sql_function!][sql-function-2-0-0] can now be used for functions with zero arguments. See [the migration guide][2-0-migration] for more details.- Support for
barrelbased migrations has been removed for now. We are happy to add this support back as soon asbarrelintegrates with our new migration framework. - The deprecated bash completions command
(
diesel bash-completions) has been removed. Usediesel completions <shell>instead.
Changed
The minimal officially supported rustc version is now 1.56.0
Interacting with a database requires a mutable connection.
The way the
Backendtrait handles itsRawValuetype has been changed to allow non-references. Users of this type (e.g. code written&DB::RawValueor&<DB as Backend>::RawValue>) should usebackend::RawValue<DB>instead. Implementors ofBackendshould check the relevant section of [the migration guide][guides/migration_guide.html#2-0-0-from-sql].
The type metadata for MySQL has been changed to include sign information. If you are implementing
HasSqlTypeforMysqlmanually, you may need to adjust your implementation to fully use the new unsigned variants inMysqlTypeThe
RawValuetypes for theMysqlandPostgresqlbackend where changed from[u8]to distinct opaque types. If you used the concreteRawValuetype somewhere you need to change it tomysql::MysqlValueorpg::PgValue.The
uuidv07feature was renamed touuid, due to the removal of support for older uuid versionsBoxed queries (constructed from
.into_boxed()) are nowSend.The handling of mixed aggregate values is more robust. Invalid queries such as
.select(max(id) + other_column)are now correctly rejected, and valid queries such as.select((count_star(), max(other_column)))are now correctly accepted. For more details, see the migration guide.NonAggregateis now a trait alias forValidGrouping<()>for expressions that are not aggregate. On stable this is a normal trait with a blanket impl, but it should never be implemented directly. With theunstablefeature, it will use trait aliases which prevent manual implementations.Due to language limitations, we cannot make the new trait alias by itself represent everything it used to, so in some rare cases code changes may be required. See the migration guide for details.
Various
__NonExhaustivevariants in different (error-) enums are replaced with#[non_exhaustive]. If you matched on one of those variants explicitly you need to introduce a wild card match instead.FromSql::from_sqlis changed to construct value from non nullable database values. To construct a rust value for nullable values use the newFromSql::from_nullable_sqlmethod instead.Custom sql types are now required to implement the new
SqlTypetrait. Diesel will automatically create implementations of that trait for all types having a#[derive(SqlType)]The workflow for manually implementing support custom types has changed. Implementing
FromSqlRow<ST, DB>is not required anymore, as this is now implied by implementingFromSql<ST, DB>. The requirement of implementingQueryable<ST, DB>remains unchanged. For types using#[derive(FromSqlRow)]no changes are required as the derive automatically generates the correct codeThe structure of our deserialization trait has changed. Loading values from the database requires now that the result type implements
FromSqlRow<ST, DB>. Diesel provides wild card implementations for types implementingQueryable<ST, DB>orQueryableByName<DB>so non generic code does not require any change. For generic code you likely need to replace a trait bound onQueryable<ST, DB>with a trait bound onFromSqlRow<ST, DB>and a bound toQueryableByName<DB>withFromSqlRow<Untyped, DB>.CLI flags of
only-tablesandexcept-tablesare now interpreted as regular expressions. Similarly,only_tabelsandexcept_tablesindiesel.tomlare treated as regular expressions.Now you can sort column fields by name with the
column-sortingoption. It can be set to eitherordinal_position(default) orname. This ensures stable sorting even if columns are removed and re-added.The
Queryable<ST,DB>trait was updated to be made faillible, in order to properly handle cases where you detect a data inconsistency between fields on deserialization (that e.g. was supposed to be made impossible by DBCHECKs). Thebuildfunction now returns adiesel::deserialize::Result<Self>instead of aSelf.TypeMetadata::MetadataLookupis now?Sized.Multiple implementations of
Connection<Backend=Pg>are now possible because of the newPgMetadataLookuptrait.For the
Pgbackend,TypeMetadata::MetadataLookuphas changed todyn PgMetadataLookup.Diesel’s migration framework was rewritten from the ground. Existing migrations continue to be compatible with the rewrite, but code calling into
diesel_migrationsrequires an update. See the migration guide for details.eq_any()now emits a= ANY()expression for the postgresql backend instead ofIN()ne_all()now emits a!= ALL()expression for the postgresql backend instead ofNOT IN()The sqlite backend now uses a single batch insert statement if there are now default values present in the values clause
The MySQL connection is using the CLIENT_FOUND_ROWS from now on. This means that updating rows without changing any values will return the number of matched rows (like most other SQL servers do), as opposed to the number of changed rows.
The definition of
ToSql::to_sqlandQueryFragment::walk_asthas changed to allow serializing values without copying the value itself. This is useful for database backends like sqlite where you can directly share a buffer with the database. Beside of the changed signature, existing impls of this trait should remain unchanged in almost all cases.The
PIPES_AS_CONCATsql_mode is no longer set by default. This setting requires a modification to MySQL query parsing that is not supported by certain systems (such as Vitess). If you are using MySQL and executing raw queries with the||operator, you will need to rewrite your queries or setPIPES_AS_CONCATmanually.
Fixed
Many types were incorrectly considered non-aggregate when they should not have been. All types in Diesel are now correctly only considered non-aggregate if their parts are.
Offset clauses without limit clauses resulted into invalid sql using the mysql or sqlite backend. Both do not support such clauses without a preceding limit clause. For those backend Diesel does now generate a fake limit clause in case no explicit limit clause was given. As consequence of this change generic query code may require additional trait bounds as requested from the compiler. Third party backends are required to explicitly provide
QueryFragmentimpls forLimitOffsetClause<L, O>now.Nullability requirements are now properly enforced for nested joins. Previously, only the rules for the outer-most join were considered. For example,
users.left_join(posts).left_join(comments)would allow selecting any columns fromposts. That will now fail to compile, and any selections frompostswill need to be made explicitly nullable.Diesel CLI will now look for
diesel.tomlto determine the project root before looking forCargo.toml.Any relative paths in
diesel.tomlwill now be treated as relative to the project root (the directory containing eitherdiesel.tomlorCargo.toml). They are no longer dependent on the current working directory (for all directories in the same project)The SQLite backend is now configured to interpret URIs. See the SQLite URI documentation for additional details.
We’ve refactored our type translation layer for Mysql to handle more types now.
We’ve refactored our type level representation of nullable values. This allowed us to fix multiple long standing bugs regarding the correct handling of nullable values in some corner cases (#104, #2274)
Parenthesis are now inserted around all infix operations provided by diesel’s
ExpressionMethodstraitsQueries containing a
distinct onclause check now on compile time that a compatible order clause was set.Implementations of custom SQLite SQL functions now check for panics
diesel print-schemanow generatesArray<Nullable<ST>>rather thanArray<ST>for Postgres Array types. Existence ofNULLvalues in database arrays would previously result in deserialization errors. Non-nullable arrays are now opt in (by schema patching).
Deprecated
All the diesel derive attributes that are not inside
#[diesel(...)]diesel_(prefix|postfix|infix)_operator!have been deprecated. These macros are now available without thediesel_prefix. With Rust 2018 they can be invoked asdiesel::infix_operator!instead.diesel::pg::upserthas been deprecated to support upsert queries on more than one backend. Please usediesel::upsertinstead.diesel::dsl::anyanddiesel::dsl::allare now deprecated in favour ofExpressionMethods::eq_any()andExpressionMethods::ne_all()
1.4.8 - 2021-09-20
Fixed
- Fixed a incompatibly between
dieselanddiesel_migrationswhen building both crates with cargos newresolver = "2"enabled. This change ensures compatibility with the upcomming 2021 rust edition.
1.4.7 - 2021-06-08
Fixed
- Updated
libsqlite3-systo allow version 0.22 - Updated
ipnetworkto allow version 0.18
1.4.6 - 2021-03-05
Fixed
- Fixed a use-after-free issue in the
QueryableByNameimplementation of ourSqlitebackend - Updated several dependencies
1.4.5 - 2020-06-09
Fixed
- Update several dependencies
- Fixed an issue where transactions that would fail to commit would leave the connection in a broken non-committed non-rolled-back state.
- Fix a bug that result in leaking sockets/file descriptors on failed connection attempts for postgresql
- Fix an incompatibility with newer
libmysqlclientversions - Remove some potential harmful usages of
mem::uninitialized
1.4.4 - 2020-03-22
Fixed
- Update several dependencies
- Fixed a bug with printing embeded migrations
1.4.3 - 2019-10-11
Fixed
- Updated several dependencies
- Fixed an issue where the postgresql backend exploits implementation defined behaviour
- Fixed issue where rustdoc failed to build the documentation
diesel_derivesanddiesel_migrationsare updated to syn 1.0
1.4.2 - 2019-03-19
Fixed
- Parenthesis are now inserted around all mathematical operations.
This means that
(2.into_sql() + 3) * 4will correctly evaluate to 20 as expected. Previously we would generate SQL that evaluated to 14. This could even result in runtime errors if multiple types were involved (for example,interval * (integer + 1))
1.4.1 - 2019-01-24
Fixed
- This release fixes a minor memory safety issue in SQLite. This bug would only occur in an error handling branch that should never occur in practice.
1.4.0 - 2019-01-20
Fixed
embed_migrations!will no longer emit an unused import warning- Diesel now supports uuid 0.7 by adding the new feature flag
uuidv07
Added
Diesel CLI can be configured to error if a command would result in changes to your schema file by passing
--locked-schema. This is intended for use in CI and production deploys, to ensure that the committed schema file is up to date.A helper trait has been added for implementing
ToSqlfor PG composite types. SeeWriteTuplefor details.
Added support for MySQL’s
UNSIGNED TINYINTDatabaseErrorKind::SerializationFailurehas been added, corresponding to SQLSTATE code 40001 (ASERIALIZABLEisolation level transaction failed to commit due to a read/write dependency on another transaction). This error is currently only detected on PostgreSQL.Diesel CLI can now generate completions for zsh and fish. See
diesel completions --helpfor details.#[belongs_to]can now accept types that are generic over lifetimes (for example, if one of the fields has the typeCow<'a, str>). To define an association to such a type, write#[belongs_to(parent = "User<'_>")]Nullable<Text>now supportsilikeexpression on in PostgreSQL.diesel_manage_updated_at('table_name')is now available on SQLite. This function can be called in your migrations to create a trigger which automatically sets theupdated_atcolumn, unless that column was updated in the query.
Changed
Diesel’s derives now require that
extern crate diesel;be at your crate root (e.g.src/lib.rsorsrc/main.rs)Tinyinthas been renamed toTinyIntand an alias has been created fromTinyinttoTinyInt.The minimal officially supported rustc version is now 1.31.0
1.3.3 - 2018-09-12
Fixed
- Fixed an issue that occurred with MySQL 8.0 when calling
.executeor.batch_executewith a single query that returned a result set (such as ourSELECT 1health check inr2d2).
1.3.2 - 2018-06-13
Fixed
The behavior of unsigned types in MySQL has been corrected to properly set the
is_unsignedflag.Fixed an issue with
sql_function!when#[sql_name]was used on functions with no return type.
1.3.1 - 2018-05-23
Fixed
- Fixed an issue with Diesel CLI’s use of temp files that caused errors on Windows.
1.3.0 - 2018-05-22
Added
Diesel CLI now supports a configuration file. See diesel.rs/guides/configuring-diesel-cli for details.
sql_function!now supports generic functions. See the documentation forsql_function!for more details.sql_function!now supports aggregate functions likesumandmax, by annotating them with#[aggregate]. This skips the implementation ofNonAggregatefor your function. See the documentation forsql_function!for more details.sql_function!now supports renaming the function by annotating it with#[sql_name = "SOME_FUNCTION"]. This can be used to support functions with multiple signatures such as coalesce, by defining multiple rust functions (with different names) that have the same#[sql_name].Added
sqlite-bundledfeature todiesel_clito make installing on some platforms easier.Custom SQL functions can now be used with SQLite. See the docs for details.
All functions and operators provided by Diesel can now be used with numeric operators if the SQL type supports it.
PgIntervalcan now be used with-,*, and/.Vec<T>is nowInsertable. It is no longer required to always place an&in front of.values.Added support for PG tuples. See
sql_types::Recordfor details.
- Added support for a wider range of locking clauses, including
FOR SHARE,SKIP LOCKED,NO WAIT, and more. SeeQueryDslfor details.
Changed
sql_function!has been redesigned. The syntax is nowsql_function!(fn lower(x: Text) -> Text);. The output of the new syntax is slightly different than what was generated in the past. See the documentation forsql_function!for more details.
- Diesel’s minimum supported Rust version is 1.24.0. This was already true, but it is now tested and enforced. Any future changes to our minimum supported version will be listed in this change log.
Fixed
diesel print-schemaandinfer_schema!now properly handle unsigned types in MySQL
Deprecated
diesel_infer_schemahas been deprecated.diesel print-schemais now the only way to generate database schema. Diesel CLI can be configured to automatically regenerate your schema file when migrations are run. See diesel.rs/guides/configuring-diesel-cli for details.Uses of
sql_function!in the formsql_function!(foo, foo_t, (x: Integer))have been deprecated in favor of a new design (listed above). Note: Due to a bug in Rust, you may not see a deprecation warning from usage of the old form. As always, if you’re concerned about relying on deprecated code, we recommend attempting to build your app withdefault-featuresturned off (specifically excluding thewith-deprecatedfeature).The
--whitelistand--blacklistoptions todiesel print-schemahave been deprecated and renamed--only-tablesand--exclude-tables.
1.2.2 - 2018-04-12
Changed
- Warnings are now allowed inside the crate. The way we had attempted to deprecate old feature names caused builds to break. We are still not happy with how this deprecation gets communicated, and will revisit it in the future.
1.2.1 - 2018-04-11
Changed
- Renamed
x32-column-tables,x64-column-tables, andx128-column-tablesto32-column-tables,64-column-tables, and128-column-tables. The leadingxwas due to a bug in crates.io discovered while publishing 1.2.0. The bug has since been fixed.
1.2.0 - 2018-04-06
Added
Added
SqlLiteral::bind(). This is intended to be used for binding values to small SQL fragments. Usesql_queryif you are writing full queries.Added support for
INSERT INTO table (...) SELECT ...queries. Tables, select select statements, and boxed select statements can now be used just like any otherInsertablevalue.Any insert query written as
insert_into(table).values(values)can now be written asvalues.insert_into(table). This is particularly useful when inserting from a select statement, as select statements tend to span multiple lines.Diesel’s derives can now produce improved error messages if you are using a nightly compiler, and enable the
unstablefeature. For the best errors, you should also setRUSTFLAGS="--cfg procmacro2_semver_exempt".Added support for specifying
ISOLATION LEVEL,DEFERRABLE, andREAD ONLYon PG transactions. SeePgConnection::build_transactionfor details.
- Added support for
BEGIN IMMEDIATEandBEGIN EXCLUSIVEon SQLite. SeeSqliteConnection::immediate_transactionandSqliteConnection::exclusive_transactionfor details
Tables with more than 56 columns are now supported by enabling the
128-column-tablesfeature.Delete statements can now be boxed. This is useful for conditionally modifying the where clause of a delete statement. See
DeleteStatement::into_boxedfor details.
- Update statements can now be boxed. This is useful for conditionally
modifying the where clause of a update statement. See
UpdateStatement::into_boxedfor details.
Added
order_byas an alias fororder.Added
then_order_by, which appends to anORDER BYclause rather than replacing it. This is useful with boxed queries to dynamically construct an order by clause containing an unknown number of columns.#[derive(Insertable)]can now work on structs with fields that implementInsertable(meaning one field can map to more than one column). Add#[diesel(embed)]to the field to enable this behavior.Queries that treat a subselect as a single value (e.g.
foo = (subselect)) are now supported by calling.single_value().#[derive(Insertable)]implements nowInsertablealso on the struct itself, not only on references to the struct
ConnectionErrornow implementsPartialEq.Columns generated by
table!now implementDefault#[derive(AsChangeset)]now implementsAsChangeseton the struct itself, and not only on a reference to the structAdded support for deserializing
NumericintoBigDecimalon SQLite. SQLite has no arbitrary precision type, so the result will still have floating point rounding issues. This is primarily to support things likeavg(int_col), which we define as returningNumeric
Changed
The bounds on
impl ToSql for Cow<'a, T>have been loosened to no longer require thatT::Owned: ToSql.32-column-tablesare now enabled by default.
Deprecated
ne_anyhas been renamed tone_all.The
large-tablesfeature has been has been renamed to32-column-tables.The
huge-tablesfeature has been renamed to64-column-tables.IncompleteUpdateStatementhas been removed. UseUpdateStatementinstead.
Fixed
diesel database setupnow correctly handles database URLs containing query stringsdiesel migration listshows the proper migration order when mixing old and new timestamp formats. (The migrations were always run in the correct order, this only affects the display logic ofmigration list)#[derive(Identifiable)]now correctly associates#[primary_key]with the column name, not field name.Select statements can no longer incorrectly appear in an expression context.
existscan no longer incorrectly receive values other than select statements.MysqlConnection::establishcan now properly handle IPv6 addresses wrapped in square brackets.
Jokes
- Diesel is now powered by the blockchain because it’s 2018.
1.1.2 - 2018-04-05
- No changes
1.1.1 - 2018-01-16
Added
- Added
diesel::r2d2::PoolErroras an alias forr2d2::Error. Previously this type was inaccessible due todiesel::r2d2::Error.
1.1.0 - 2018-01-15
Added
r2d2-dieselhas been merged into Diesel proper. You should no longer rely directly onr2d2-dieselorr2d2. The functionality of both is exposed fromdiesel::r2d2.r2d2::PooledConnectionnow implementsConnection. This means that you should no longer need to write&*connectionwhen usingr2d2.The
BINARYcolumn type name is now supported for SQLite.The
QueryIdtrait can now be derived.FromSqlRowcan now be derived for types which implementFromSql.AsExpressioncan now be derived for types which implementToSql.HasSqlType,NotNull, andSingleValuecan now be derived with#[derive(SqlType)]. See the docs for those traits for more information.The return type of
FromSql,FromSqlRow, andQueryableByNamecan now be written asdeserialize::Result<Self>.The return type of
ToSqlcan now be written asserialize::Result.Added support for SQLite’s
INSERT OR IGNOREand MySQL’sINSERT IGNOREvia theinsert_or_ignorefunction.minandmaxcan now be used with array expressions.Added
diesel::dsl::array, which corresponds to a PGARRAY[]literal.Added the
not_none!macro, used by implementations ofFromSqlwhich do not expectNULL.Added
result::UnexpectedNullError, anErrortype indicating that an unexpectedNULLwas received during deserialization.Added
.or_filter, which behaves identically to.filter, but usingORinstead ofAND.helper_typesnow contains a type for every method defined inexpression_methods, and every function indsl.Added
FromSqlimpls for*const strand*const [u8]everywhere thatStringandVecare supported. These impls do not allocate, and are intended for use by other impls which need to parse a string or bytes, and don’t want to allocate. These impls should never be used outside of anotherFromSqlimpl.
Deprecated
- IMPORTANT NOTE Due to several bugs in Rust,
many of the deprecations in this release may not show a warning. If you
want to ensure you are not using any deprecated items, we recommend
attempting to compile your code without the
with-deprecatedfeature by addingdefault-features = falsetoCargo.toml.
Deprecated
impl_query_id!in favor of#[derive(QueryId)]Deprecated specifying a column name as
#[column_name(foo)].#[column_name = "foo"]should be used instead.The
typesmodule has been deprecated. It has been split intosql_types,serialize, anddeserialize.query_source::Queryableandquery_source::QueryableByNamehave been deprecated. These traits have been moved todeserialize.backend::TypeMetadatahas been deprecated. It has been moved tosql_types.types::ToSqlOutputhas been deprecated. It has been renamed toserialize::Output.helper_types::Notis nowhelper_types::not
Fixed
infer_schema!generates valid code when run against a database with no tables.
1.0.0 - 2018-01-02
Added
#[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 implementsQueryableByName, rather than a single column in the query, add the annotation#[diesel(embed)]The
QueryDsltrait encompasses the majority of the traits that were previously in thequery_dslmodule.
Fixed
Executing select statements on SQLite will no longer panic when the database returns
SQLITE_BUSYtable!s which use theDatetimetype with MySQL will now compile correctly, even without thechronofeature enabled.#[derive(QueryableByName)]will now compile correctly when there is a shadowedResulttype in scope.BoxableExpressioncan now be used with types that are not'static
Changed
Connection::test_transactionnow requires that the error returned implementDebug.query_builder::insert_statement::InsertStatementis now accessed asquery_builder::InsertStatementquery_builder::insert_statement::UndecoratedInsertRecordis now accessed asquery_builder::UndecoratedInsertRecord#[derive(QueryableByName)]now requires that the table name be explicitly stated.Most of the traits in
query_dslhave been moved toquery_dsl::methods. These traits are no longer exported inprelude. This should not affect most apps, as the behavior of these traits is provided byQueryDsl. However, if you were using these traits inwhereclauses for generic code, you will need to explicitly douse diesel::query_dsl::methods::WhateverDsl. You may also need to use UFCS in these cases.If you have a type which implemented
QueryFragmentorQuery, which you intended to be able to callexecuteorloadon, you will need to manually implementRunQueryDslfor that type. The trait should be unconditionally implemented (no where clause beyond what your type requires), and the body should be empty.
Removed
All deprecated items have been removed.
LoadDslandFirstDslhave been removed. Their functionality now lives inLoadQuery.
0.99.1 - 2017-12-01
Changed
- Diesel CLI now properly restricts its
clapdependency. 0.99.0 mistakenly had no upper bound on the version.
0.99.0 - 2017-11-28
Added
The
.for_update()method has been added to select statements, allowing construction ofSELECT ... FOR UPDATE.Added
insert_into(table).default_values()as a replacement forinsert_default_values()Added
insert_into(table).values(values)as a replacement forinsert(values).into(table).Added support for MySQL’s
REPLACE INTOasreplace_into(table).Added
replace_into(table).values(values)as a replacement forinsert_or_replace(values).into(table).Added
on_conflict_do_nothingonInsertStatementas a replacement foron_conflict_do_nothingonInsertablestructs.Added
on_conflictonInsertStatementas a replacement foron_conflictonInsertablestructs.filtercan now be called on update and delete statements. This means that instead ofupdate(users.filter(...))you can writeupdate(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.TextExpressionMethodsis now implemented for expressions of typeNullable<Text>as well asText.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 thansqlfor complete queries. The main difference fromsqlis 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
Changed
The signatures of
QueryId,Column, andFromSqlRowhave 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 ajoinable!invocation for those tables.diesel_codegenshould no longer explicitly be used as a dependency. Unless you are usinginfer_schema!orembed_migrations!, you can simply remove it from yourCargo.toml. All other functionality is now provided bydieselitself.Code using
infer_schema!orinfer_table_from_schema!must now adddiesel_infer_schematoCargo.toml, and#[macro_use] extern crate diesel_infer_schematosrc/lib.rsCode using
embed_migrations!must now adddiesel_migrationstoCargo.toml, and#[macro_use] extern crate diesel_migrationstosrc/lib.rsThe
migrationsmodule has been moved out ofdieseland intodiesel_migrations
Deprecated
Deprecated
insert_default_values()in favor ofinsert_into(table).default_values()Deprecated
insert(values).into(table)in favor ofinsert_into(table).values(values).Deprecated
insert_or_replace(values).into(table)in favor ofreplace_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_joinsin favor ofallow_tables_to_appear_in_same_query!Deprecated
SqlLiteral#bind.sqlis 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. Usesql_queryif you need raw SQL with bind parameters.
Removed
IntoInsertStatementandBatchInsertStatementhave been removed. It’s unlikely that your application is using these types, butInsertStatementis now the only “insert statement” type.Citextas a type alias forTexthas been removed. Writingcitext_column.eq("foo")would perform a case-sensitive comparison. More fleshed out support will be required.
Fixed
When using MySQL and SQLite, dates which cannot be represented by
chrono(such as0000-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
strand slice can now appear on structs which deriveInsertableorAsChangeset.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
strftimefunction except for the string'now'.
0.16.0 - 2017-08-24
Added
Added helper types for inner join and left outer join
diesel::debug_queryhas been added as a replacement fordebug_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 implementDisplayandDebugto show the query in different waysdiesel::pg::PgConnection,diesel::mysql::MysqlConnection, anddiesel::sqlite::SqliteConnectionare now exported fromdiesel::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
AddandSubto 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-docsparameter: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 calledtypewill be referenced astype_in Rust.
Changed
The deprecated
debug_sql!andprint_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 invokejoinable!instead, unless you are usinginfer_schema!Changed the migration directory name format to
%Y-%m-%d-%H%M%S.betweenandnot_betweennow take two arguments, rather than a range.
Removed
debug_sql!has been deprecated in favor ofdiesel::debug_query.print_sql!has been deprecated without replacement.diesel::backend::Debughas been removed.
Fixed
Diesel now properly supports joins in the form:
grandchild.join(child.join(parent)). Previously onlyparent.join(child.join(grandchild))would compile.When encoding a
BigDecimalon PG,1.0is no longer encoded as if it were1.
0.15.2 - 2017-07-28
Fixed
BigDecimalnow properly encodes numbers starting with10000on postgres. See issue #1044 for details.
0.15.1 - 2017-07-24
- No changes to public API
0.15.0 - 2017-07-23
Added
Added support for the PG
IS DISTINCT FROMoperatorThe
ONclause of a join can now be manually specified. See the docs for details.
Changed
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.Insertableno longer treats all fields as nullable for type checking. What this means for you is that if you had an impl likeimpl AsExpression<Nullable<SqlType>, DB> for CustomTypein your code base, you can remove theNullableportion (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
0.14.1 - 2017-07-10
Changed
- The return type of
sumandavgis now always considered to beNullable, as these functions returnNULLwhen against on an empty table.
0.14.0 - 2017-07-04
Added
- Added support for joining between more than two tables. The query
builder can now be used to join between any number of tables in a single
query. See the documentation for
JoinDslfor details
Added 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_valuesfunction.
- Added
diesel_prefix_operator!which behaves identically todiesel_postfix_operator!(previouslypostfix_predicate!), but for operators likeNOTwhich use prefix notation.
Changed
infix_predicate!andinfix_expression!have been renamed todiesel_infix_operator!.postfix_predicate!andpostfix_expression!have been renamed todiesel_postfix_operator!.Trait bounds along the lines of
T: LoadDsl<Conn>, U: Queryable<T::SqlType, Conn::Backend>should be changed toT: 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.
Removed
#[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 invokejoinable!directly instead.
0.13.0 - 2017-05-15
Added
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.
- Added support for the PostgreSQL
network types
CIDRandINET.
Added support for
ILIKEin PostgreSQL.diesel migration listwill show all migrations, marking those that have been run.diesel migration pendingwill list any migrations which have not been run.Added support for numeric operations with nullable types.
Fixed
Diesel CLI now respects the
--migration-dirargument or theMIGRATION_DIRECTORYenvironment variable for all commands.Diesel CLI now properly escapes the database name.
0.12.1 - 2017-05-07
Changed
- Locked the chrono dependency to require exactly
0.3.0instead 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.
0.12.0 - 2017-03-16
Added
- Added support for the majority of PG upsert
(
INSERT ON CONFLICT). We now support specifying the constraint, as well asDO UPDATEin addition toDO NOTHING. See the module docs for details.
- Added support for the SQL concatenation operator
||. See the docs for.concatfor more details.
- Added support for the PostgreSQL
Moneytype.
Diesel CLI: Added
dbas an alias fordatabase, so you can now writediesel 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 touse diesel::types::*;.
Fixed
diesel_codegenwill 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.
Removed
WithDslandAliasedhave 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()).
0.11.4 - 2017-02-21
Fixed
- Corrected a memory safety violation when using MySQL.
0.11.3 - 2017-02-21
- No changes
0.11.2 - 2017-02-19
Changed
pq-sysandmysqlclient-syswill no longer attempt to generate bindings at compile time. Generating the bindings required a bleeding edge version of clang, which caused too many issues.
0.11.1 - 2017-02-17
Fixed
.on_conflict_do_nothing()now interacts with slices properly.MysqlConnectionnow implementsSend, which is required for connection pooling.
0.11.0 - 2017-02-16
Added
- Added support for MySQL as an additional backend. Diesel CLI will
install with MySQL support by default. To enable it for Diesel and
Diesel Codegen, add
features = ["mysql"]to Cargo.toml. See the docs for details.
- Added support for PG’s
ON CONFLICT DO NOTHINGclause. See the docs for details.
- Queries constructed using
diesel::selectnow work properly when boxed.
Arrays containing null are now supported.
infer_schema!will never infer an array that contains null, but atable!definition which specifies a type ofArray<Nullable<X>>can now be deserialized toVec<Option<T>>#[belongs_to]associations can now be self referential. This will generate the code required forbelonging_to, without generating code for performing a join.
- Added support for the
rust-lang-deprecated/timecrate on PostgreSQL. To use it, addfeatures = ["deprecated-time"]
Changed
It is no longer possible to exhaustively match against
result::ConnectionError.Updated chrono to version 0.3.
maxandminare now always nullable. The database will returnNULLwhen the table is empty.
nowcan now be used as an expression of typeTimestamptz.
Connection::transactionnow returns your error directly instead of wrapping it inTransactionError. It requires that the error implementFrom<diesel::result::Error>
- The way tuples of columns from the right side of left outer joins
interact with
.selecthas 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()))
Removed
result::TransactionErrorresult::TransactionResult
0.10.1 - 2017-02-08
Fixed
infer_table_from_schema!properly handles table names with a custom schema specified.
Changed
- Updated uuid to version 0.4.
0.10.0 - 2017-02-02
Added
- Added support for the PostgreSQL
jsonandjsonbtypes. They can be mapped to/fromserde_json::Value. Theserdefeature must be enabled to use the JSON types.
- Added the
print-schemacommand to Diesel CLI. This command will print the output of theinfer_schema!macro. For more information rundiesel help print-schema.
Changed
When possible, we will use deprecation warnings for breaking changes. Deprecated code requires the
with-deprecatedfeature, which is enabled by default.The
postgresfeature is no longer enabled by default bydieselordiesel_codegen_syntex. Addfeatures = ["postgres"]to yourCargo.toml.The
persistablemodule has been renamed toinsertable.
Fixed
#[derive(Insertable)]allows fields of typeOption<T>to be used with columns that are not null if they have a default value.
Removed
diesel_codegen_syntexis no longer supported.diesel_codegencan now be used on stable Rust.Dropped support for Rust 1.14 and earlier
0.9.1 - 2016-12-09
Fixed
Added missing impls for loading
chrono::NaiveDateTimefrom a column of typeTimestamptz#[derive(AsChangeset)]no longer assumes thatuse diesel::prelude::*has been done.debug_sql!can now properly be used with types fromchronoorstd::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 - 2016-12-08
Added
Added support for SQL
NOT INusing thene_anymethod.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 thanpublicwill be wrapped in a module with the same name as the schema. For example,schema_1.table_1would be referenced asschema_1::table_1.Added support for batch insert on SQLite. This means that you can now pass a slice or vector to
diesel::inserton all backends.
- Added a function for SQL
EXISTSexpressions. Seediesel::expression::dsl::existsfor details.
#[derive(Identifiable)]can be used with structs that have primary keys other thanid, as well as structs with composite primary keys. You can now annotate the struct with#[primary_key(nonstandard)]or#[primary_key(foo, bar)].
Changed
- All macros with the same name as traits we can derive
(e.g.
Queryable!) have been renamed toimpl_Queryable!or similar.
Fixed
#[derive(Identifiable)]now works on structs with lifetimesAttempting 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_anyorne_anywith an empty array no longer panics.eq_any(vec![])will return no rows.ne_any(vec![])will return all rows.
0.8.2 - 2016-11-22
Changed
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::*;
0.8.1 - 2016-11-01
Added
- SQLite date and time columns can be deserialized to/from strings.
Fixed
- Fixed an issue with
diesel_codegenon nightlies >= 2016-10-20
0.8.0 - 2016-10-10
Added
Added partial support for composite primary keys.
Added support for PostgreSQL
NULLS FIRSTandNULLS LASTwhen sorting. See https://docs.diesel.rs/diesel/prelude/trait.SortExpressionMethods.html for details.Added support for the
timestamp with time zonetype in PostgreSQL (referred to asdiesel::types::Timestamptz)Diesel CLI can now generate bash completion. See the readme for details.
infer_schema!andinfer_table_from_schema!can now take"env:foo"instead ofenv!("foo")and"dotenv:foo"instead ofdotenv!("foo"). The use ofdotenvrequires thedotenvfeature ondiesel_codegen, which is included by default. Usingenv!anddotenv!will no longer work withdiesel_codegen. They continue to work withdiesel_codegen_syntex, but that crate will be deprecated when Macros 1.1 is in the beta channel for Rust.
Changed
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 toCargo.tomlinstead of the file the macro was called from. This change is required to allow this macro to work with Macros 1.1.
Fixed
diesel migrations runwill now respect migration directories overridden by command line argument or environment variable- The
infer_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)
Changed
#[changeset_for(foo)]should now be written as#[derive(AsChangeset)] #[table_name="foo"]. If you were specifyingtreat_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"].
0.7.2 - 2016-08-20
- Updated nightly version and syntex support.
0.7.1 - 2016-08-11
Changed
- The
Copyconstraint has been removed fromIdentifiable::Id, andIdentifiable#idnow returns&Identifiable::Id.
Fixed
#[belongs_to]now respects theforeign_keyoption when usingdiesel_codegenordiesel_codegen_syntex.
0.7.0 - 2016-08-01
Added
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 fromdiesel_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 fromdiesel_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 fromdiesel_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 fromdiesel_codegen. See https://docs.diesel.rs/diesel/macro.AsChangeset!.html for details.Added support for the PostgreSQL
ALLoperator. See https://docs.diesel.rs/diesel/pg/expression/dsl/fn.all.html for details.Added support for
RETURNINGexpressions inDELETEstatements. Implicitly these queries will useRETURNING *.
Changed
Diesel now targets
nightly-2016-07-07. Future releases will update to a newer nightly version on the date that Rust releases.diesel_codegenhas been split into two crates.diesel_codegenanddiesel_codegen_syntex. See this commit for migration information.Most structs that implement
Queryablewill now also need#[derive(Identifiable)].infer_schema!on SQLite now accepts a larger range of type namestypes::VarCharis now an alias fortypes::Text. Most code should be unaffected by this. PG array columns are treated slightly differently, however. If you are usingvarchar[], you should switch totext[]instead.Struct fields annotated with
#[column_name="name"]should be changed to#[column_name(name)].The structure of
DatabaseErrorhas 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 informationStructs which implement
Identifiablecan now be passed toupdateanddelete. This means you can now writedelete(&user).execute(&connection)instead ofdelete(users.find(user.id)).execute(&connection)
Fixed
&&[T]can now be used in queries. This allows using slices with things like#[insertable_into].
0.6.1 2016-04-14
Added
- Added the
escapemethod toLikeandNotLike, to specify the escape character used in the pattern. See EscapeExpressionMethods for details.
Fixed
diesel_codegenanddiesel_clinow 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.
0.6.0 2016-04-12
Added
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-tablesfeature. This feature will substantially increase compile times.The
DISTINCTkeyword can now be added to queries via thedistinct()method.SqliteConnectionnow implementsSend
Changed
diesel::result::Errornow implementsSendandSync. This required a change in the return type ofToSqlandFromSqlto have those bounds as well.It is no longer possible to pass an owned value to
diesel::insert.insertwill now give a more helpful error message when you accidentally try to pass an owned value instead of a reference.
Fixed
#[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_columnsis now(id,)and notid.infer_schema!can now work with tables that have a primary key other thanid.
Removed
- Removed the
no selectoption for thetable!macro. This was a niche feature that didn’t fit with Diesel’s philosophies. You can write a function that callsselectfor you if you need this functionality.
0.5.4 2016-03-23
- Updated
diesel_codegento allow syntex versions up to 0.30.0.
0.5.3 2016-03-12
Added
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 theupdated_atcolumn to thecurrent_timestampfor each affected row inUPDATEstatements.Added support for explicit
RETURNINGexpressions inINSERTandUPDATEqueries. Implicitly these queries will still useRETURNING *.
Fixed
- Updated to work on nightly from early March
0.5.2 2016-02-27
- Updated to work on nightly from late February
0.5.1 2016-02-11
- Diesel CLI no longer has a hard dependency on SQLite and PostgreSQL.
It assumes both by default, but if you need to install on a system that
doesn’t have one or the other, you can install it with
cargo install diesel_cli --no-default-features --features postgresorcargo install diesel_cli --no-default-features --features sqlite
0.5.0 2016-02-05
Added
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 adddefault-features = false, features = ["sqlite"]todiesel_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, andtypes::Timeto/fromchrono::NaiveDateTime,chrono::NaiveDate, andchrono::NaiveTime. Addfeatures = ["chrono"]to enable.Added a
treat_none_as_nulloption tochangeset_for. When set totrue, a model will set a field toNullwhen an optional struct field isNone, instead of skipping the field entirely. The default value of the option isfalse, 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
sumandavgfunctions.Added the
diesel setup,diesel database setup, anddiesel database resetcommands to the CLI.Added support for SQL
INstatements through theeq_anymethod.Added a top level
selectfunction 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 tobar.select(foo).Added
expression::dsl::sqlas a helper function for constructingSqlLiteralnodes. 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.
Changed
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::updateand friends are nowdiesel::update, and you will get them by default if you importdiesel::*. For a less aggressive glob, you can importdiesel::prelude::*, which will only export our traits.Connectionis now a trait instead of a struct. The struct that was previously known asConnectioncan be found atdiesel::pg::PgConnection.Rename both the
#[derive(Queriable)]attribute and theQueriabletrait to use the correct spellingQueryable.loadandget_resultsnow return aVec<Model>instead of an iterator.Replaced
Connection#find(source, id)withsource.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
QueryableandChangeset. 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
NativeSqlTypehas been removed. It now requires a known backend.fn<T> foo() where T: NativeSqlTypeis nowfn<T, DB> foo() where DB: HasSqlType<T>
Removed
Connection#query_sqlandConnection#query_sql_paramshave 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 bareselectandexpression::dsl::sql.
0.4.1 2016-01-11
Changed
Diesel CLI will no longer output notices about
__diesel_schema_migrationsalready existing.Relicensed under MIT/Apache dual
0.4.0 2016-01-08
Added
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.
Fixed
#[changeset_for]can now be used with structs containing aVec. 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 thanid. Fixes #66.infer_schema!properly works with array columns. Fixes #65.
0.3.0 2015-12-04
Changed
#[changeset_for(table)]now treatsOptionfields as an optional update. Previously a field withNonefor the value would insertNULLinto the database field. It now does not update the field if the value isNone..save_changes(generated by#[changeset_for]) now returns a new struct, rather than mutatingself. The returned struct can be any type that implementsQueryablefor the right SQL type
Fixed
#[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.
Added
Quickcheck is now an optional dependency. When
features = ["quickcheck"]is added toCargo.toml, you’ll gainArbitraryimplementations for everything indiesel::data_types.Added support for the SQL
MINfunction.Added support for the
Numericdata 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::SystemTimewhen compiled with--features unstableImplemented
SendonConnection(required for R2D2 support)Added
infer_schema!andinfer_table_from_schema!. Both macros take a database URL, and will invoketable!for you automatically based on the schema.infer_schema!queries for the table names, whileinfer_table_from_schema!takes a table name as the second argument.
0.2.0 - 2015-11-30
Added
Added an
executemethod toQueryFragment, which is intended to replaceConnection#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_resultandget_results, which work similarly toloadandfirst, but are intended to make code read better when working with commands likecreateandupdate. In the future,get_resultmay also check that only a single row was affected.Added
insert, which mirrors the pattern ofupdateanddelete.
Changed
Added a hidden
__Nonexhaustivevariant toresult::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, soBox<std::error::Error>is not an option.query_one,find, andfirstnow assume a single row is returned. For cases where you actually expect 0 or 1 rows to be returned, theoptionalmethod has been added to the result, in case having aResult<Option<T>>is more idiomatic than checking forErr(NotFound).
Deprecated
Connection#insertandConnection#insert_returning_counthave been deprecated in favor ofinsert
0.1.0 - 2015-11-29
- Initial release