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
-
Added partial support for composite primary keys.
-
Added support for PostgreSQL
NULLS FIRST
andNULLS LAST
when sorting. See http://docs.diesel.rs/diesel/prelude/trait.SortExpressionMethods.html for details. -
Added support for the
timestamp with time zone
type 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 ofdotenv
requires thedotenv
feature ondiesel_codegen
, which is included by default. Usingenv!
anddotenv!
will no longer work withdiesel_codegen
. They continue to work withdiesel_codgen_syntex
, but that crate will be deprecated when Macros 1.1 is in the beta channel for Rust.
-
Structs annotated with
#[has_many]
or#[belongs_to]
now require#[derive(Associations)]
. This is to allow them to work with Macros 1.1. -
embed_migrations!
now resolves paths relative toCargo.toml
instead of the file the macro was called from. This change is required to allow this macro to work with Macros 1.1.
diesel migrations run
will now respect migration directories overridden by command line argument or environment 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)
#[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"]
.
- Updated nightly version and syntex support.
- The
Copy
constraint has been removed fromIdentifiable::Id
, andIdentifiable#id
now returns&Identifiable::Id
.
#[belongs_to]
now respects theforeign_key
option when usingdiesel_codegen
ordiesel_codegen_syntex
.
-
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 http://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 http://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 http://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 http://docs.diesel.rs/diesel/macro.AsChangeset!.html for details. -
Added support for the PostgreSQL
ALL
operator. See http://docs.diesel.rs/diesel/pg/expression/dsl/fn.all.html for details. -
Added support for
RETURNING
expressions inDELETE
statements. Implicitly these queries will useRETURNING *
.
-
Diesel now targets
nightly-2016-07-07
. Future releases will update to a newer nightly version on the date that Rust releases. -
diesel_codegen
has been split into two crates.diesel_codegen
anddiesel_codegen_syntex
. See this commit for migration information. -
Most structs that implement
Queryable
will now also need#[derive(Identifiable)]
. -
infer_schema!
on SQLite now accepts a larger range of type names -
types::VarChar
is now an alias 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
DatabaseError
has changed to hold more information. See http://docs.diesel.rs/diesel/result/enum.Error.html and http://docs.diesel.rs/diesel/result/trait.DatabaseErrorInformation.html for more information -
Structs which implement
Identifiable
can now be passed toupdate
anddelete
. This means you can now writedelete(&user).execute(&connection)
instead ofdelete(users.find(user.id)).execute(&connection)
&&[T]
can now be used in queries. This allows using slices with things like#[insertable_into]
.
- Added the
escape
method toLike
andNotLike
, to specify the escape character used in the pattern. See EscapeExpressionMethods for details.
-
diesel_codegen
anddiesel_cli
now properly rely on Diesel 0.6.0. The restriction to 0.5.0 was an oversight. -
infer_schema!
now properly excludes metadata tables on SQLite. -
infer_schema!
now properly maps types on SQLite.
-
Queries can now be boxed using the
into_boxed()
method. This is useful for conditionally modifying queries without changing the type. See BoxedDsl for more details. -
infer_schema!
is now supported for use with SQLite3. -
The maximum table size can be increased to 52 by enabling the
huge-tables
feature. This feature will substantially increase compile times. -
The
DISTINCT
keyword can now be added to queries via thedistinct()
method. -
SqliteConnection
now implementsSend
-
diesel::result::Error
now implementsSend
andSync
. This required a change in the return type ofToSql
andFromSql
to have those bounds as well. -
It is no longer possible to pass an owned value to
diesel::insert
.insert
will now give a more helpful error message when you accidentally try to pass an owned value instead of a reference.
-
#[insertable_into]
can now be used with structs that have lifetimes with names other than'a'
. -
Tables with a single column now properly return a single element tuple. E.g. if the column was of type integer, then
users::all_columns
is now(id,)
and notid
. -
infer_schema!
can now work with tables that have a primary key other thanid
.
- Removed the
no select
option for thetable!
macro. This was a niche feature that didn't fit with Diesel's philosophies. You can write a function that callsselect
for you if you need this functionality.
- Updated
diesel_codegen
to allow syntex versions up to 0.30.0.
-
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_at
column to thecurrent_timestamp
for each affected row inUPDATE
statements. -
Added support for explicit
RETURNING
expressions inINSERT
andUPDATE
queries. Implicitly these queries will still useRETURNING *
.
- Updated to work on nightly from early March
- Updated to work on nightly from late February
- 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 postgres
orcargo install diesel_cli --no-default-features --features sqlite
-
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::Time
to/fromchrono::NaiveDateTime
,chrono::NaiveDate
, andchrono::NaiveTime
. Addfeatures = ["chrono"]
to enable. -
Added a
treat_none_as_null
option tochangeset_for
. When set totrue
, a model will set a field toNull
when 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
sum
andavg
functions. -
Added the
diesel setup
,diesel database setup
, anddiesel database reset
commands to the CLI. -
Added support for SQL
IN
statements through theeq_any
method. -
Added a top level
select
function for select statements with no from clause. This is primarily intended to be used for testing Diesel itself, but it has been added to the public API as it will likely be useful for third party crates in the future.select(foo).from(bar)
might be a supported API in the future as an alternative tobar.select(foo)
. -
Added
expression::dsl::sql
as a helper function for constructingSqlLiteral
nodes. This is primarily intended to be used for testing Diesel itself, but is part of the public API as an escape hatch if our query builder DSL proves inadequate for a specific case. Use of this function in any production code is discouraged as it is inherently unsafe and avoids real type checking.
-
Moved most of our top level trait exports into a prelude module, and re-exported our CRUD functions from the top level.
diesel::query_builder::update
and friends are 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. -
Connection
is now a trait instead of a struct. The struct that was previously known asConnection
can be found atdiesel::pg::PgConnection
. -
Rename both the
#[derive(Queriable)]
attribute and theQueriable
trait to use the correct spellingQueryable
. -
load
andget_results
now 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
Queryable
andChangeset
. This change should not have much impact, as most impls will have been generated by diesel_codegen, and that API has not changed. -
The mostly internal
NativeSqlType
has been removed. It now requires a known backend.fn<T> foo() where T: NativeSqlType
is nowfn<T, DB> foo() where DB: HasSqlType<T>
Connection#query_sql
andConnection#query_sql_params
have been removed. These methods were not part of the public API, and were only meant to be used for testing Diesel itself. However, they were technically callable from any crate, so the removal has been noted here. Their usage can be replaced with bareselect
andexpression::dsl::sql
.
-
Diesel CLI will no longer output notices about
__diesel_schema_migrations
already existing. -
Relicensed under MIT/Apache dual
-
Added Diesel CLI, a tool for managing your schema. See the readme for more information.
-
Add the ability for diesel to maintain your schema for you automatically. See the migrations module for individual methods.
-
Add DebugQueryBuilder to build sql without requiring a connection.
-
Add print_sql! and debug_sql! macros to print out and return sql strings from QueryFragments.
-
#[changeset_for]
can now be used with structs containing 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.
-
#[changeset_for(table)]
now treatsOption
fields as an optional update. Previously a field withNone
for the value would insertNULL
into 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 implementsQueryable
for the right SQL type
-
#[derive(Queryable)]
now allows generic parameters on the struct. -
Table definitions can now support up to 26 columns. Because this increases our compile time by 3x,
features = ["large-tables"]
is needed to support table definitions above 16 columns.
-
Quickcheck is now an optional dependency. When
features = ["quickcheck"]
is added toCargo.toml
, you'll gainArbitrary
implementations for everything indiesel::data_types
. -
Added support for the SQL
MIN
function. -
Added support for the
Numeric
data type. Since there is no Big Decimal type in the standard library, a dumb struct has been provided which mirrors what Postgres provides, which can be converted into whatever crate you are using. -
Timestamp columns can now be used with
std::time::SystemTime
when compiled with--features unstable
-
Implemented
Send
onConnection
(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.
-
Added an
execute
method 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_result
andget_results
, which work similarly toload
andfirst
, but are intended to make code read better when working with commands likecreate
andupdate
. In the future,get_result
may also check that only a single row was affected. -
Added
insert
, which mirrors the pattern ofupdate
anddelete
.
-
Added a hidden
__Nonexhaustive
variant 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
, andfirst
now assume a single row is returned. For cases where you actually expect 0 or 1 rows to be returned, theoptional
method has been added to the result, in case having aResult<Option<T>>
is more ideomatic than checking forErr(NotFound)
.
Connection#insert
andConnection#insert_returning_count
have been deprecated in favor ofinsert
- Initial release