2015-11-30 00:59:46 +03:00
|
|
|
# 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)
|
|
|
|
|
2016-01-13 21:20:12 +03:00
|
|
|
## Unreleased
|
|
|
|
|
2016-01-15 00:09:07 +03:00
|
|
|
### 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
|
|
|
|
Cargo.toml. You'll also want to add `default-features = false` to `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.
|
|
|
|
|
2016-01-19 00:00:07 +03:00
|
|
|
* Added support for mapping `types::Timestamp`, `types::Date`, and `types::Time`
|
|
|
|
to/from `chrono::NaiveDateTime`, `chrono::NaiveDate`, and `chrono::NaiveTime`.
|
2016-01-15 00:09:07 +03:00
|
|
|
Add `features = ["chrono"]` to enable.
|
|
|
|
|
Add a bare `select` function for select statements with no from clause
In addition to this function, I have also added a `sql` function, which
is shorthand for `SqlLiteral` (but only takes `&str`, not `String`), and
`in_time_zone` which is not part of the public API.
`sql` takes `&str`, instead of `T: Into<String>`, because the first type
parameter is always going to need to be passed, and I find
`sql::<Timestamp, _>` ugly. There's always `SqlLiteral::new` if you need
to pass a `String`, or you can just deref it to `str` and accept the
copying.
I had hoped to eliminate `query_sql_params`, but there's one test we
have that's using it which requires a where clause. I can't just hack it
and do `select(sql("1 WHERE ..."))` because it uses bind params. I'll
implement `FilterDsl` for `BareSelectStatement` at some point. I'd also
like to remove `query_sql`, as I think that `select(sql` covers it
suffciently.
I've opted to leave `in_time_zone` out of the public API, as it should
actually have the return type of `Timestamptz`, and I'm really unsure
how various infix predicates with the lhs being `Timestamp` and the rhs
being `Timestamptz` are going to interact. We might be able to get away
with just not allowing it and have it be a non-issue, similarly to
`VarChar` and `Text`, but it needs further exploration.
Fixes #97.
2016-01-17 02:06:18 +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.
|
|
|
|
|
2016-01-19 19:51:46 +03:00
|
|
|
* 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.
|
|
|
|
|
2016-01-20 21:06:43 +03:00
|
|
|
* 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.
|
|
|
|
|
2016-01-31 01:48:30 +03:00
|
|
|
* 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-01-13 21:20:12 +03:00
|
|
|
### 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.
|
|
|
|
|
2016-02-02 21:18:51 +03:00
|
|
|
* `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.
|
|
|
|
|
2016-01-25 07:49:06 +03:00
|
|
|
* Replaced `Connection#find(source, id)` with
|
|
|
|
`source.find(id).first(&connection)`.
|
|
|
|
|
2016-01-22 19:23:29 +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.
|
|
|
|
|
2016-01-24 20:08:51 +03:00
|
|
|
* 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>`
|
|
|
|
|
2016-01-18 02:29:58 +03:00
|
|
|
### 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
|
Don't output notices when running migrations
When you run just about any command via diesel_cli, you'll see this
message output to stderr.
> NOTICE: relation "__diesel_schema_migrations" already exists,
> skipping
This silences that notice when creating the table. Unfortunately the
`silence_notices` function is not necessarily idempotent, as it would
override the notice processor if a custom one was set. However, the
actual raw libpq connection is private, so we're free to do with it what
we wish.
libpq does not provide any method to get the current notice processor,
or its default. As such I've had to re-implement the same function,
based on the description at the bottom of
http://www.postgresql.org/docs/current/static/libpq-notice-processing.html
As an alternative, we could perform two queries when attempting to
create the table, but this is becoming a common need in my work on new
features, and might be a candidate for public API.
2016-01-09 19:42:11 +03:00
|
|
|
|
|
|
|
### 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
|
|
|
|
|
2016-01-09 00:48:23 +03:00
|
|
|
## [0.4.0] 2016-01-08
|
2015-12-06 21:20:51 +03:00
|
|
|
|
|
|
|
### Added
|
|
|
|
|
2016-01-09 00:48:23 +03:00
|
|
|
* Added Diesel CLI, a tool for managing your schema.
|
|
|
|
See [the readme](https://github.com/sgrif/diesel/blob/v0.4.0/README.md#database-migrations)
|
|
|
|
for more information.
|
|
|
|
|
2016-01-07 18:35:05 +03:00
|
|
|
* Add the ability for diesel to maintain your schema for you automatically. See
|
|
|
|
the [migrations](http://sgrif.github.io/diesel/diesel/migrations/index.html)
|
|
|
|
module for individual methods.
|
|
|
|
|
2015-12-06 21:20:51 +03:00
|
|
|
* 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.
|
|
|
|
|
2015-12-20 21:42:17 +03:00
|
|
|
### Fixed
|
|
|
|
|
|
|
|
* `#[changeset_for]` can now be used with structs containing a `Vec`. Fixes
|
|
|
|
[#63](https://github.com/sgrif/diesel/issues/63).
|
|
|
|
|
2015-12-24 00:13:06 +03:00
|
|
|
* No longer generate invalid SQL when an optional update field is not the first
|
|
|
|
field on a changeset. Fixes [#68](https://github.com/sgrif/diesel/issues/68).
|
|
|
|
|
2016-01-07 19:02:02 +03:00
|
|
|
* `#[changeset_for]` can now be used with structs containing only a single field
|
|
|
|
other than `id`. Fixes [#66](https://github.com/sgrif/diesel/issues/66).
|
|
|
|
|
2016-01-07 19:46:03 +03:00
|
|
|
* `infer_schema!` properly works with array columns. Fixes
|
|
|
|
[#65](https://github.com/sgrif/diesel/issues/65).
|
|
|
|
|
2015-12-05 06:05:18 +03:00
|
|
|
## [0.3.0] 2015-12-04
|
2015-12-01 01:32:42 +03:00
|
|
|
|
2015-12-04 20:13:56 +03:00
|
|
|
### 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`.
|
|
|
|
|
2015-12-05 02:11:11 +03:00
|
|
|
* `.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
|
2015-12-05 02:11:11 +03:00
|
|
|
|
2015-12-01 01:32:42 +03:00
|
|
|
### Fixed
|
|
|
|
|
2016-01-15 19:29:27 +03:00
|
|
|
* `#[derive(Queryable)]` now allows generic parameters on the struct.
|
2015-11-30 00:59:46 +03:00
|
|
|
|
2015-12-14 20:13:07 +03:00
|
|
|
* 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.
|
|
|
|
|
2015-12-01 23:09:29 +03:00
|
|
|
### 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.
|
2015-12-01 22:51:22 +03:00
|
|
|
|
2015-12-02 18:31:28 +03:00
|
|
|
* 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.
|
|
|
|
|
2015-12-02 22:13:12 +03:00
|
|
|
* 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)
|
2015-12-03 02:45:03 +03:00
|
|
|
|
2015-12-05 03:23:05 +03:00
|
|
|
* 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.
|
|
|
|
|
2015-11-30 20:29:37 +03:00
|
|
|
## [0.2.0] - 2015-11-30
|
2015-11-30 00:59:46 +03:00
|
|
|
|
2015-11-30 16:53:32 +03:00
|
|
|
### 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.
|
|
|
|
|
2015-11-30 19:22:04 +03:00
|
|
|
* 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.
|
|
|
|
|
2015-11-30 20:26:37 +03:00
|
|
|
* Added [`insert`][insert], which mirrors the pattern of `update` and `delete`.
|
|
|
|
|
2015-11-30 00:59:46 +03:00
|
|
|
### 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.
|
|
|
|
|
For `query_one` and friends, not returning records is an error condition
Through usage, it has become clear that in the overwhelming majority of
cases, you either expect N records, or exactly 1. Expecting either 0 or
1 is uncommon.
However, it's a completely valid use case, and having to match against
`Err(NotFound)` is a pain, especially if you intend to use `try!`.
Keeping that in mind, `QueryResult` now has the `optional` method, which
converts `QueryResult<T>` to `QueryResult<Option<T>>`, treating
`NotFound` as `None`. Since [`result::Error` is not exhaustively
matchable](https://github.com/sgrif/diesel/commit/5435e30f1dc28008a8bef34c889998a0b009f0c4),
I do not think we need to change the error type in this method.
Since checking for and handling `NotFound` seems like a common case,
particularly for returning a 404 response in a web server, it has been
re-exported in the root namespace.
I was going to open a PR to get feedback on this change first, but after
making it, I feel the code quality improvement in our tests (especially
the doctests, where we've removed most `.unwrap()` calls) was enough to
convince me this is the right change.
2015-11-30 03:35:46 +03:00
|
|
|
* `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)`.
|
|
|
|
|
2015-11-30 20:26:37 +03:00
|
|
|
### Deprecated
|
|
|
|
|
|
|
|
* `Connection#insert` and `Connection#insert_returning_count` have been
|
|
|
|
deprecated in favor of [`insert`][insert]
|
|
|
|
|
|
|
|
[insert]: http://sgrif.github.io/diesel/diesel/query_builder/fn.insert.html
|
|
|
|
|
2015-11-30 00:59:46 +03:00
|
|
|
## [0.1.0] - 2015-11-29
|
|
|
|
|
|
|
|
* Initial release
|