diesel/CHANGELOG.md

583 lines
22 KiB
Markdown
Raw Normal View History

# Change Log
All user visible changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/), as described
for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/text/1105-api-evolution.md)
## Unreleased
### Changed
* The `postgres` feature is no longer enabled by default by `diesel` or
`diesel_codegen_syntex`. Add `features = ["postgres"]` to your `Cargo.toml`.
## [0.9.1] - 2016-12-09
### Fixed
* Added missing impls for loading `chrono::NaiveDateTime` from a column of type
`Timestamptz`
* `#[derive(AsChangeset)]` no longer assumes that `use diesel::prelude::*` has
been done.
* `debug_sql!` can now properly be used with types from `chrono` or
`std::time`.
Construct error messages properly when libpq returns `NULL` result I had originally thought that this was some weird condition that was the result of the server getting a query with more than `34464` (`i16::MAX`) bind parameters, where we got back an error but it had no message. We panic in that case, as PG is documented that all errors have a message. It turns out I was wrong for two reasons. First, the number is 65535 (`u16::MAX`), not `34464`. (This might have been something changed on the PG side in 9.6 which was released since I last looked at this). Second, we were not getting back an error with no message, we were getting a `NULL` return value from libpq. From [their docs][]: [their docs]: https://www.postgresql.org/docs/9.6/static/libpq-exec.html#LIBPQ-PQPREPARE > A null result indicates out-of-memory or inability to send the command > at all. Use PQerrorMessage to get more information about such errors. `PQerrorMessage` means the error is on the connection. The reason that we had no result was that the PG wire protocol uses a `u16` for the number of bind parameters, so there's no way for the driver to have even sent the message to the server. Once we realized the error condition that we were seeing is more general than just the bind parameter case, I've refactored the code to perform a not null check as early as possible, and hide the `*mut PGresult`. The test itself is written in a somewhat strange fashion. We're constructing a query that has 70_000 bind parameters, as this is the only case that I know of which will always cause libpq to return null. I don't care what the error message is, just that it's not an empty string. I've also written the test to explicitly match instead of unwrap and use `#[should_panic]` because I want to be sure that it *didn't* panic. Ideally we would never see `*mut PGresult` anywhere in the code, and use `Unique<PGresult>` instead. However, it is currently unstable. I had originally implemented this to use `Unique` if `feature = "unstable"` was set, but deleted it as the `#[cfg]` branches made the code harder to comprehend. The only real benefit `Unique` gives us here is clarity of intent. For the not-null and non-aliased hints to result in any optimization by the compiler would require libpq to be statically linked, and LTO to be happening at the LLVM layer, neither of which are commonly true. We know that `Send` and `Sync` are safe to implement on our new struct, because the pointer is unaliased. We can delete those impls if we switch to using `Unique` in the future, as it already implements those traits. Fixes #446.
2016-12-10 15:19:18 +03:00
* 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
2016-12-02 23:41:53 +03:00
### Added
* Added support for SQL `NOT IN` using the `ne_any` method.
* The `table!` macro now allows custom schemas to be specified. Example:
```rust
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:
```rust
infer_table_from_schema!("dotenv:DATABASE_URL", "schema_1.table_1");
```
* The `infer_schema!` optionally allows a schema name as the second argument. Any
schemas other than `public` will be wrapped in a module with the same name as
the schema. For example, `schema_1.table_1` would be referenced as
`schema_1::table_1`.
* Added support for batch insert on SQLite. This means that you can now pass a
slice or vector to [`diesel::insert`][insert] on all backends.
[insert]: http://docs.diesel.rs/diesel/fn.insert.html
* Added a function for SQL `EXISTS` expressions. See
[`diesel::expression::dsl::exists`][exists] for details.
[exists]: http://docs.diesel.rs/diesel/expression/dsl/fn.sql.html
* `#[derive(Identifiable)]` can be used with structs that have primary keys
other than `id`, as well as structs with composite primary keys. You can now
annotate the struct with `#[primary_key(nonstandard)]` or `#[primary_key(foo,
bar)]`.
### Changed
* All macros with the same name as traits we can derive (e.g. `Queryable!`) have
been renamed to `impl_Queryable!` or similar.
### Fixed
* `#[derive(Identifiable)]` now works on structs with lifetimes
* Attempting to insert an empty slice will no longer panic. It does not execute
any queries, but the result will indicate that we successfully inserted 0
rows.
* Attempting to update a record with no changes will no longer generate invalid
SQL. The result of attempting to execute the query will still be an error, but
but it will be a `Error::QueryBuilderError`, rather than a database error.
This means that it will not abort the current transaction, and can be handled
by applications.
* Calling `eq_any` or `ne_any` with an empty array no longer panics.
`eq_any(vec![])` will return no rows. `ne_any(vec![])` will return all rows.
## [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:
```rust
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_codegen` on nightlies >= 2016-10-20
## [0.8.0] - 2016-10-10
Reform types inferred by `infer_schema!` on SQLite (#277) `infer_schema!` is woefully undertested. Really our tests for it at the moment are "we use it for our test suite so the cases our suite covers work". However, even though I defined `tinyint` == `Bool`, I wanted to make sure that `TINYINT(1)` was treated as bool as well, as I wasn't certain how SQLite handles limit/precision/scale. The answer is that it doesn't, and it's way looser about allowed type names than I had thought. The process listed at https://www.sqlite.org/datatype3.html is a literal description, and any possible string is a valid type. This adds tests for every example given on that page, plus a few extras. We create a table with as many of these fields as possible, and do a trivial roundtrip to make sure that it *actually* infers something we can deserialize from, and that we're not doing anything dumb. The new logic for type inference matches pretty closely to how SQLite handles things with a few exceptions: - "boolean" or types containing "tiny" and "int" are treated as bool - smallint and bigint are separated from int - float is separated from double - varchar is separated from text - We do not accept random unrecognized type names as numeric Unresolved Questions -------------------- This actually starts to make me a bit more nervous about our semantics with SQLite. If you're just using Diesel, everything is fine. However, you can definitely insert values that would fail to deserialize with so little constraints on the backend. I'm starting to wonder if we should truly embrace SQLite's definitions and map exactly to that, allowing only the following types: - BigInt - VarChar (yes, it's the ANSI text type but we treat VarChar as the "default" string type) - Binary - Double We're omitting numeric, as there's no observable difference in SQLite between the real affinity and the numeric affinity. This would have several *major* implications. Aside from not being able to use basic things like an `i32`, it would also mean that there is no boolean type, and no dates/times/datetimes. Functions for those do exist on the SQLite side though, so some of the interactions might get super janky. That said, Diesel's goal is not to abstract away the backend. These are the semantics of the backend chosen, and maybe we should go whole hog and embrace them. I'm still unsure. In the meantime, with our current semantics, this should improve the reliability of `infer_schema!`
2016-04-17 23:42:11 +03:00
### Added
* Added partial support for composite primary keys.
2016-08-25 18:00:54 +03:00
* Added support for PostgreSQL `NULLS FIRST` and `NULLS 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 as `diesel::types::Timestamptz`)
* Diesel CLI can now generate bash completion. See [the readme][bash completion]
for details.
* `infer_schema!` and `infer_table_from_schema!` can now take `"env:foo"`
instead of `env!("foo")` and `"dotenv:foo"` instead of `dotenv!("foo")`. The
use of `dotenv` requires the `dotenv` feature on `diesel_codegen`, which is
included by default. Using `env!` and `dotenv!` will no longer work with
`diesel_codegen`. They continue to work with `diesel_codgen_syntex`, but that
crate will be deprecated when Macros 1.1 is in the beta channel for Rust.
[bash completion]: https://github.com/diesel-rs/diesel/blob/b1a0d9901f0f2a8c8d530ccba8173b57f332b891/diesel_cli/README.md#bash-completion
### 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 to `Cargo.toml` instead of the
file the macro was called from. This change is required to allow this macro to
work with Macros 1.1.
### Fixed
* `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)
### Changed
* `#[changeset_for(foo)]` should now be written as
`#[derive(AsChangeset)] #[table_name="foo"]`. If you were specifying
`treat_none_as_null = "true"`, you should additionally have
`#[changeset_options(treat_none_as_null = "true")]`.
* `#[insertable_into(foo)]` should now be written as
`#[derive(Insertable)] #[table_name="foo"]`.
## [0.7.2] - 2016-08-20
* Updated nightly version and syntex support.
## [0.7.1] - 2016-08-11
### Changed
* The `Copy` constraint has been removed from `Identifiable::Id`, and
`Identifiable#id` now returns `&Identifiable::Id`.
### Fixed
* `#[belongs_to]` now respects the `foreign_key` option when using
`diesel_codegen` or `diesel_codegen_syntex`.
Release v0.7.0 The headline feature of this version is associations. Just add `#[belongs_to(User)]` above your struct, and it becomes incredibly easy to manipulate larger batches of data. See http://docs.diesel.rs/diesel/associations/index.html for a full guide. Diesel is taking a slightly different approach to what you may have seen in the past, which I'm calling "non-invasive associations". In contrast to something like Active Record or Ecto, where the association lives on the parent, the data is completely independent. The type of a user and all its posts is `(User, Vec<Post>)`. This release also marks the elimination of Diesel's reliance on procedural macros. They're still available as an option, and their usage is recommended. However, a lot of people have had a desire to shy away from them. For all of our code generation that does not perform IO, there is now a completely stable non-procedural macro, which has been designed to work with the [custom_derive][custom-derive] crate. See [the CHANGELOG][changelog] for a full list. [custom-derive]: https://github.com/DanielKeep/rust-custom-derive [changelog]: https://github.com/diesel-rs/diesel/blob/v0.7.0/CHANGELOG.md `diesel_codegen` has been split into two crates. This is a breaking change which will affect 100% of our users. Please see https://github.com/diesel-rs/diesel/commit/36b8801bf5e9594443743e6a7c62e29d3dce36b7 for more information on how to migrate. This release has also had a contributor who has gone above and beyond to help out. I'd like to take this opportunity to announce the 4th addition to the Diesel core team, @killercup! Your contributions have been much appreciated, and your code review has been invaluable. Thank you to everybody who contributed to this release. - derekdreery - kardeiz - Michael Macias - Mike Piccolo - Pascal Hertleif - Richard Dodd - Tim Brooks On to 0.8! With this release, we are approaching the benchmarks I had set for 1.0. We will still have at least 2 more releases before the 1.0 release, but it's quickly becoming the next target. We will be publishing a roadmap soon.
2016-08-01 22:56:01 +03:00
## [0.7.0] - 2016-08-01
Provide a syntax extension free alternative to `#[insertable_into]` (#303) Provide a syntax extension free alternative to `#[insertable_into]` This provides a pure stable alternative to the `#[insertable_into]` annotation. The intention is to change the annotation to call this macro, rather than `impl Insertable` directly. However, there are some unaddressed issues for that, and I will submit that as a separate PR to attempt to keep the PR size reasonable. The tests for this are a bit messy, as the actual test body doesn't change much -- Just the struct definition. I moved the most common case out into a macro, but I opted to just leave the duplication for the remaining 4-5 cases that didn't fit, instead of trying to make it so dry it chafes. We will continue to support syntex as an option on stable, as we can provide much better error messages from a procedural macro. I would like to improve the error messages in some cases if possible though (in particular, we want to handle the case where a unit struct is passed or where a tuple struct has unannotated fields). The structure of the macro is intended to be compatible with the `custom_derive` crate. This is untested, but will be fully tested once I've moved all our annotations to stable macros. The goal is for any struct definition to be copy pasted into this macro, and the macro parses the struct body to create the proper implementation. For sufficiently large structs, we can hit the recursion limit, but there's really no way around that. People will just need to bump the limit. One case that this macro *doesn't* handle is when there are annotations on struct fields other than `#[column_name]`. I had originally planned to handle these, but I realized that the only recognized annotation that could be there on stable is `#[cfg]`, and we are *not* handling cfg attributes. We might handle that in the future, but it'd look *really* ugly. Related to #99
2016-04-25 03:35:15 +03:00
### Added
* The initial APIs have been added in the form of `#[has_many]` and
`#[belongs_to]`. See [the module documentation][associations-module] for more
information.
Provide a syntax extension free alternative to `#[insertable_into]` (#303) Provide a syntax extension free alternative to `#[insertable_into]` This provides a pure stable alternative to the `#[insertable_into]` annotation. The intention is to change the annotation to call this macro, rather than `impl Insertable` directly. However, there are some unaddressed issues for that, and I will submit that as a separate PR to attempt to keep the PR size reasonable. The tests for this are a bit messy, as the actual test body doesn't change much -- Just the struct definition. I moved the most common case out into a macro, but I opted to just leave the duplication for the remaining 4-5 cases that didn't fit, instead of trying to make it so dry it chafes. We will continue to support syntex as an option on stable, as we can provide much better error messages from a procedural macro. I would like to improve the error messages in some cases if possible though (in particular, we want to handle the case where a unit struct is passed or where a tuple struct has unannotated fields). The structure of the macro is intended to be compatible with the `custom_derive` crate. This is untested, but will be fully tested once I've moved all our annotations to stable macros. The goal is for any struct definition to be copy pasted into this macro, and the macro parses the struct body to create the proper implementation. For sufficiently large structs, we can hit the recursion limit, but there's really no way around that. People will just need to bump the limit. One case that this macro *doesn't* handle is when there are annotations on struct fields other than `#[column_name]`. I had originally planned to handle these, but I realized that the only recognized annotation that could be there on stable is `#[cfg]`, and we are *not* handling cfg attributes. We might handle that in the future, but it'd look *really* ugly. Related to #99
2016-04-25 03:35:15 +03:00
* The `Insertable!` macro can now be used instead of `#[insertable_into]` for
those wishing to avoid syntax extensions from `diesel_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 from `diesel_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 from `diesel_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 from `diesel_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 in `DELETE` statements. Implicitly
these queries will use `RETURNING *`.
Reform types inferred by `infer_schema!` on SQLite (#277) `infer_schema!` is woefully undertested. Really our tests for it at the moment are "we use it for our test suite so the cases our suite covers work". However, even though I defined `tinyint` == `Bool`, I wanted to make sure that `TINYINT(1)` was treated as bool as well, as I wasn't certain how SQLite handles limit/precision/scale. The answer is that it doesn't, and it's way looser about allowed type names than I had thought. The process listed at https://www.sqlite.org/datatype3.html is a literal description, and any possible string is a valid type. This adds tests for every example given on that page, plus a few extras. We create a table with as many of these fields as possible, and do a trivial roundtrip to make sure that it *actually* infers something we can deserialize from, and that we're not doing anything dumb. The new logic for type inference matches pretty closely to how SQLite handles things with a few exceptions: - "boolean" or types containing "tiny" and "int" are treated as bool - smallint and bigint are separated from int - float is separated from double - varchar is separated from text - We do not accept random unrecognized type names as numeric Unresolved Questions -------------------- This actually starts to make me a bit more nervous about our semantics with SQLite. If you're just using Diesel, everything is fine. However, you can definitely insert values that would fail to deserialize with so little constraints on the backend. I'm starting to wonder if we should truly embrace SQLite's definitions and map exactly to that, allowing only the following types: - BigInt - VarChar (yes, it's the ANSI text type but we treat VarChar as the "default" string type) - Binary - Double We're omitting numeric, as there's no observable difference in SQLite between the real affinity and the numeric affinity. This would have several *major* implications. Aside from not being able to use basic things like an `i32`, it would also mean that there is no boolean type, and no dates/times/datetimes. Functions for those do exist on the SQLite side though, so some of the interactions might get super janky. That said, Diesel's goal is not to abstract away the backend. These are the semantics of the backend chosen, and maybe we should go whole hog and embrace them. I'm still unsure. In the meantime, with our current semantics, this should improve the reliability of `infer_schema!`
2016-04-17 23:42:11 +03:00
### Changed
* Diesel now targets `nightly-2016-07-07`. Future releases will update to a
newer nightly version on the date that Rust releases.
* `diesel_codegen` has been split into two crates. `diesel_codegen` and
`diesel_codegen_syntex`. See [this commit][syntex-split] for migration
information.
* Most structs that implement `Queryable` will now also need
`#[derive(Identifiable)]`.
Reform types inferred by `infer_schema!` on SQLite (#277) `infer_schema!` is woefully undertested. Really our tests for it at the moment are "we use it for our test suite so the cases our suite covers work". However, even though I defined `tinyint` == `Bool`, I wanted to make sure that `TINYINT(1)` was treated as bool as well, as I wasn't certain how SQLite handles limit/precision/scale. The answer is that it doesn't, and it's way looser about allowed type names than I had thought. The process listed at https://www.sqlite.org/datatype3.html is a literal description, and any possible string is a valid type. This adds tests for every example given on that page, plus a few extras. We create a table with as many of these fields as possible, and do a trivial roundtrip to make sure that it *actually* infers something we can deserialize from, and that we're not doing anything dumb. The new logic for type inference matches pretty closely to how SQLite handles things with a few exceptions: - "boolean" or types containing "tiny" and "int" are treated as bool - smallint and bigint are separated from int - float is separated from double - varchar is separated from text - We do not accept random unrecognized type names as numeric Unresolved Questions -------------------- This actually starts to make me a bit more nervous about our semantics with SQLite. If you're just using Diesel, everything is fine. However, you can definitely insert values that would fail to deserialize with so little constraints on the backend. I'm starting to wonder if we should truly embrace SQLite's definitions and map exactly to that, allowing only the following types: - BigInt - VarChar (yes, it's the ANSI text type but we treat VarChar as the "default" string type) - Binary - Double We're omitting numeric, as there's no observable difference in SQLite between the real affinity and the numeric affinity. This would have several *major* implications. Aside from not being able to use basic things like an `i32`, it would also mean that there is no boolean type, and no dates/times/datetimes. Functions for those do exist on the SQLite side though, so some of the interactions might get super janky. That said, Diesel's goal is not to abstract away the backend. These are the semantics of the backend chosen, and maybe we should go whole hog and embrace them. I'm still unsure. In the meantime, with our current semantics, this should improve the reliability of `infer_schema!`
2016-04-17 23:42:11 +03:00
* `infer_schema!` on SQLite now accepts a larger range of type names
* `types::VarChar` is now an alias for `types::Text`. Most code should be
unaffected by this. PG array columns are treated slightly differently,
however. If you are using `varchar[]`, you should switch to `text[]` instead.
* Struct fields annotated with `#[column_name="name"]` should be changed to
`#[column_name(name)]`.
* The structure of `DatabaseError` has changed to hold more information. See
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 to `update` and
`delete`. This means you can now write `delete(&user).execute(&connection)`
instead of `delete(users.find(user.id)).execute(&connection)`
[associations-module]: http://docs.diesel.rs/diesel/associations/index.html
[syntex-split]: https://github.com/diesel-rs/diesel/commit/36b8801bf5e9594443743e6a7c62e29d3dce36b7
### 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 `escape` method to `Like` and `NotLike`, to specify the escape
character used in the pattern. See [EscapeExpressionMethods][escape] for
details.
[escape]: http://docs.diesel.rs/diesel/expression/expression_methods/escape_expression_methods/trait.EscapeExpressionMethods.html
### Fixed
* `diesel_codegen` and `diesel_cli` now properly rely on Diesel 0.6.0. The
restriction to 0.5.0 was an oversight.
2016-04-16 17:51:55 +03:00
* `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][boxed_dsl] for more details.
* `infer_schema!` is now supported for use with SQLite3.
* The maximum table size can be increased to 52 by enabling the `huge-tables`
feature. This feature will substantially increase compile times.
* The `DISTINCT` keyword can now be added to queries via the `distinct()`
method.
* `SqliteConnection` now implements `Send`
[boxed_dsl]: http://docs.diesel.rs/diesel/prelude/trait.BoxedDsl.html
### Changed
* `diesel::result::Error` now implements `Send` and `Sync`. This required a
change in the return type of `ToSql` and `FromSql` to have those bounds as
well.
* It is no longer possible to pass an owned value to `diesel::insert`. `insert`
will now give a more helpful error message when you accidentally try to pass
an owned value instead of a reference.
### 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_columns` is now `(id,)`
and not `id`.
* `infer_schema!` can now work with tables that have a primary key other than
`id`.
### Removed
* Removed the `no select` option for the `table!` macro. This was a niche
feature that didn't fit with Diesel's philosophies. You can write a function
that calls `select` for you if you need this functionality.
## [0.5.4] 2016-03-23
* Updated `diesel_codegen` to allow syntex versions up to 0.30.0.
2016-03-13 01:44:54 +03:00
## [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 the `updated_at` column to the `current_timestamp`
for each affected row in `UPDATE` statements.
* Added support for explicit `RETURNING` expressions in `INSERT` and `UPDATE`
queries. Implicitly these queries will still use `RETURNING *`.
2016-03-13 01:44:54 +03:00
### 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 postgres` or `cargo install diesel_cli
--no-default-features --features sqlite`
## [0.5.0] 2016-02-05
### Added
2016-02-03 17:02:10 +03:00
* Added support for SQLite. Diesel still uses postgres by default. To use SQLite
instead, add `default-features = false, features = ["sqlite"]` to your
2016-02-06 00:33:36 +03:00
Cargo.toml. You'll also want to add `default-features = false, features =
["sqlite"]` to `diesel_codegen`.
2016-02-03 17:02:10 +03:00
Since SQLite is a much more limited database, it does not support our full set
of features. You can use SQLite and PostgreSQL in the same project if you
desire.
* Added support for mapping `types::Timestamp`, `types::Date`, and `types::Time`
to/from `chrono::NaiveDateTime`, `chrono::NaiveDate`, and `chrono::NaiveTime`.
Add `features = ["chrono"]` to enable.
* Added a `treat_none_as_null` option to `changeset_for`. When set to `true`,
a model will set a field to `Null` when an optional struct field is `None`,
instead of skipping the field entirely. The default value of the option is
`false`, as we think the current behavior is a much more common use case.
* Added `Expression#nullable()`, to allow comparisons of not null columns with
nullable ones when required.
2016-01-30 05:27:33 +03:00
* Added `sum` and `avg` functions.
* Added the `diesel setup`, `diesel database setup`, and `diesel database
reset` commands to the CLI.
2016-02-05 23:06:44 +03:00
* Added support for SQL `IN` statements through the `eq_any` method.
2016-02-06 00:33:36 +03:00
* Added a top level `select` function for select statements with no from clause.
This is primarily intended to be used for testing Diesel itself, but it has
been added to the public API as it will likely be useful for third party
crates in the future. `select(foo).from(bar)` might be a supported API in the
future as an alternative to `bar.select(foo)`.
* Added `expression::dsl::sql` as a helper function for constructing
`SqlLiteral` nodes. This is primarily intended to be used for testing Diesel
itself, but is part of the public API as an escape hatch if our query builder
DSL proves inadequate for a specific case. Use of this function in any
production code is discouraged as it is inherently unsafe and avoids real type
checking.
### Changed
2016-02-05 23:06:44 +03:00
* Moved most of our top level trait exports into a prelude module, and
re-exported our CRUD functions from the top level.
`diesel::query_builder::update` and friends are now `diesel::update`, and you
will get them by default if you import `diesel::*`. For a less aggressive
glob, you can import `diesel::prelude::*`, which will only export our traits.
* `Connection` is now a trait instead of a struct. The struct that was
previously known as `Connection` can be found at `diesel::pg::PgConnection`.
2016-01-15 19:29:27 +03:00
* Rename both the `#[derive(Queriable)]` attribute and the `Queriable` trait to
use the correct spelling `Queryable`.
2016-02-05 23:06:44 +03:00
* `load` and `get_results` now return a `Vec<Model>` instead of an iterator.
* Replaced `Connection#find(source, id)` with
`source.find(id).first(&connection)`.
2016-02-06 00:34:45 +03:00
* 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.
Make `ToSql` and `FromSql` generic over the backend This was a mostly mechanical change, but there were several points of interest. I've done my best to audit impls which I consider generic, vs impls that are PG specific. This implies that an impl even can be considered generic. This mostly doesn't apply to SQLite, since due to the way its bind parameters are handled I don't expect that types will go through `ToSql`. `FromSql` I'm still unclear on, and that might change further. However, after reading through the `MySQL` docs for bind params, I'm reasonably confident that for string types, binary types, and numeric types which have an equivalent C primitive, they will always be represented this way. SQL standard types which I believe will generally very by backend are date/time types, and decimal. As part of this change, our blanket impl causing `FromSql` implying `FromSqlRow` becomes invalid. I won't go into too much detail here, as I've written up a pre-RFC on a solution that goes into more detail at https://internals.rust-lang.org/t/pre-rfc-sealed-traits/3108/1, and I think this issue goes away once specialization is stable (which is tracked at https://github.com/sgrif/diesel/issues/130). With this change, I believe the only remaining trait which needs to be made generic is `NativeSqlType` (though I'm legitimately unsure if we actually want to do that, due to the complications it adds with our expression heirarchy related to `Bool`, and I do not think I want `Expression` to be generic over the backend)
2016-01-24 00:28:45 +03:00
* Many user facing types are now generic over the backend. This includes, but is
not limited to `Queryable` and `Changeset`. This change should not have much
impact, as most impls will have been generated by diesel_codegen, and that API
has not changed.
* The mostly internal `NativeSqlType` has been removed. It now requires a known
backend. `fn<T> foo() where T: NativeSqlType` is now `fn<T, DB> foo() where
DB: HasSqlType<T>`
### Removed
* `Connection#query_sql` and `Connection#query_sql_params` have been removed.
These methods were not part of the public API, and were only meant to be used
for testing Diesel itself. However, they were technically callable from any
crate, so the removal has been noted here. Their usage can be replaced with
bare `select` and `expression::dsl::sql`.
2016-01-11 23:17:30 +03:00
## [0.4.1] 2016-01-11
### Changed
* Diesel CLI will no longer output notices about `__diesel_schema_migrations`
already existing.
2016-01-11 23:17:30 +03:00
* Relicensed under MIT/Apache dual
## [0.4.0] 2016-01-08
### Added
* Added Diesel CLI, a tool for managing your schema.
See [the readme](https://github.com/diesel-rs/diesel/blob/v0.4.0/README.md#database-migrations)
for more information.
* Add the ability for diesel to maintain your schema for you automatically. See
the [migrations](http://docs.diesel.rs/diesel/migrations/index.html)
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 a `Vec`. Fixes
[#63](https://github.com/diesel-rs/diesel/issues/63).
* No longer generate invalid SQL when an optional update field is not the first
field on a changeset. Fixes [#68](https://github.com/diesel-rs/diesel/issues/68).
* `#[changeset_for]` can now be used with structs containing only a single field
other than `id`. Fixes [#66](https://github.com/diesel-rs/diesel/issues/66).
* `infer_schema!` properly works with array columns. Fixes
[#65](https://github.com/diesel-rs/diesel/issues/65).
## [0.3.0] 2015-12-04
### Changed
* `#[changeset_for(table)]` now treats `Option` fields as an optional update.
Previously a field with `None` for the value would insert `NULL` into the
database field. It now does not update the field if the value is `None`.
* `.save_changes` (generated by `#[changeset_for]`) now returns a new struct,
rather than mutating `self`. The returned struct can be any type that
2016-01-15 19:29:27 +03:00
implements `Queryable` for the right SQL type
### Fixed
2016-01-15 19:29:27 +03:00
* `#[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 to `Cargo.toml`, you'll gain `Arbitrary` implementations for everything
in `diesel::data_types`.
2015-12-02 18:33:36 +03:00
* 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`
2015-12-03 02:45:47 +03:00
* Implemented `Send` on `Connection` (required for R2D2 support)
* Added `infer_schema!` and `infer_table_from_schema!`. Both macros take a
database URL, and will invoke `table!` for you automatically based on the
schema. `infer_schema!` queries for the table names, while
`infer_table_from_schema!` takes a table name as the second argument.
## [0.2.0] - 2015-11-30
### Added
* Added an `execute` method to `QueryFragment`, which is intended to replace
`Connection#execute_returning_count`. The old method still exists for use
under the hood, but has been hidden from docs and is not considered public
API.
* Added `get_result` and `get_results`, which work similarly to `load` and
`first`, but are intended to make code read better when working with commands
like `create` and `update`. In the future, `get_result` may also check that
only a single row was affected.
* Added [`insert`][insert], which mirrors the pattern of `update` and `delete`.
### Changed
* Added a hidden `__Nonexhaustive` variant to `result::Error`. This is not
intended to be something you can exhaustively match on, but I do want people
to be able to check for specific cases, so `Box<std::error::Error>` is
not an option.
* `query_one`, `find`, and `first` now assume a single row is returned. For
cases where you actually expect 0 or 1 rows to be returned, the `optional`
method has been added to the result, in case having a `Result<Option<T>>` is
more ideomatic than checking for `Err(NotFound)`.
### Deprecated
* `Connection#insert` and `Connection#insert_returning_count` have been
deprecated in favor of [`insert`][insert]
## 0.1.0 - 2015-11-29
* Initial release
[0.2.0]: https://github.com/diesel-rs/diesel/compare/v0.1.0...v0.2.0
[0.3.0]: https://github.com/diesel-rs/diesel/compare/v0.2.0...v0.3.0
[0.4.0]: https://github.com/diesel-rs/diesel/compare/v0.3.0...v0.4.0
[0.4.1]: https://github.com/diesel-rs/diesel/compare/v0.4.0...v0.4.1
[0.5.0]: https://github.com/diesel-rs/diesel/compare/v0.4.1...v0.5.0
[0.5.1]: https://github.com/diesel-rs/diesel/compare/v0.5.0...v0.5.1
[0.5.2]: https://github.com/diesel-rs/diesel/compare/v0.5.1...v0.5.2
[0.5.3]: https://github.com/diesel-rs/diesel/compare/v0.5.2...v0.5.3
[0.5.4]: https://github.com/diesel-rs/diesel/compare/v0.5.3...v0.5.4
[0.6.0]: https://github.com/diesel-rs/diesel/compare/v0.5.4...v0.6.0
[0.6.1]: https://github.com/diesel-rs/diesel/compare/v0.6.0...v0.6.1
[0.7.0]: https://github.com/diesel-rs/diesel/compare/v0.6.1...v0.7.0
[0.7.1]: https://github.com/diesel-rs/diesel/compare/v0.7.0...v0.7.1
[0.7.2]: https://github.com/diesel-rs/diesel/compare/v0.7.1...v0.7.2
[0.8.0]: https://github.com/diesel-rs/diesel/compare/v0.7.2...v0.8.0
[0.8.1]: https://github.com/diesel-rs/diesel/compare/v0.8.0...v0.8.1
[0.8.2]: https://github.com/diesel-rs/diesel/compare/v0.8.1...v0.8.2
[0.9.0]: https://github.com/diesel-rs/diesel/compare/v0.8.2...v0.9.0
[0.9.1]: https://github.com/diesel-rs/diesel/compare/v0.9.0...v0.9.1