diesel v1.2.0 Release Notes

Release Date: 2018-04-06 // about 6 years ago
  • ➕ Added

    • ➕ Added SqlLiteral::bind(). This is intended to be used for binding values to small SQL fragments. Use sql_query if 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 other Insertable value.

    • Any insert query written as insert_into(table).values(values) can now be written as values.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 unstable feature. For the best errors, you should also set RUSTFLAGS="--cfg procmacro2_semver_exempt".

    • ➕ Added support for specifying ISOLATION LEVEL, DEFERRABLE, and READ ONLY on PG transactions. See [PgConnection::build_transaction] for details.

    🏗 [PgConnection::build_transaction]: http://docs.diesel.rs/diesel/pg/struct.PgConnection.html#method.build_transaction

    • ➕ Added support for BEGIN IMMEDIATE and BEGIN EXCLUSIVE on SQLite. See [SqliteConnection::immediate_transaction] and [SqliteConnection::exclusive_transaction] for details

    📄 [SqliteConnection::immediate_transaction]: http://docs.diesel.rs/diesel/sqlite/struct.SqliteConnection.html#method.immediate_transaction 📄 [SqliteConnection::exclusive_transaction]: http://docs.diesel.rs/diesel/sqlite/struct.SqliteConnection.html#method.exclusive_transaction

    • 👍 Tables with more than 56 columns are now supported by enabling the 128-column-tables feature.

    • ✂ Delete statements can now be boxed. This is useful for conditionally modifying the where clause of a delete statement. See [DeleteStatement::into_boxed] for details.

    📄 [DeleteStatement::into_boxed]: http://docs.diesel.rs/diesel/query_builder/struct.DeleteStatement.html#method.into_boxed

    • ⚡️ Update statements can now be boxed. This is useful for conditionally modifying the where clause of a update statement. See [UpdateStatement::into_boxed] for details.

    📄 [UpdateStatement::into_boxed]: http://docs.diesel.rs/diesel/query_builder/struct.UpdateStatement.html#method.into_boxed

    • ➕ Added order_by as an alias for order.

    • Added then_order_by, which appends to an ORDER BY clause 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 implement Insertable (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 now Insertable also on the struct itself, not only on references to the struct

    📄 [.single_value()]: http://docs.diesel.rs/diesel/query_dsl/trait.QueryDsl.html#method.single_value

    • ConnectionError now implements PartialEq.

    • 0️⃣ Columns generated by table! now implement Default

    • #[derive(AsChangeset)] now implements AsChangeset on the struct itself, and not only on a reference to the struct

    • ➕ Added support for deserializing Numeric into BigDecimal on SQLite. SQLite has no arbitrary precision type, so the result will still have floating point rounding issues. This is primarily to support things like avg(int_col), which we define as returning Numeric

    🔄 Changed

    • The bounds on impl ToSql for Cow<'a, T> have been loosened to no longer require that T::Owned: ToSql.

    • 0️⃣ 32-column-tables are now enabled by default.

    🗄 Deprecated

    • ne_any has been renamed to ne_all.

    • The large-tables feature has been has been renamed to 32-column-tables.

    • The huge-tables feature has been renamed to 64-column-tables.

    • ⚡️ IncompleteUpdateStatement has been removed. Use UpdateStatement instead.

    🛠 Fixed

    • diesel database setup now correctly handles database URLs containing query strings

    • diesel migration list shows 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 of migration 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.

    • exists can no longer incorrectly receive values other than select statements.

    • MysqlConnection::establish can now properly handle IPv6 addresses wrapped in square brackets.

    Jokes

    • Diesel is now powered by the blockchain because it's 2018.