diesel v0.99.0 Release Notes

Release Date: 2017-11-28 // over 6 years ago
  • ➕ Added

    • ⚡️ The .for_update() method has been added to select statements, allowing construction of SELECT ... FOR UPDATE.

    • 0️⃣ Added insert_into(table).default_values() as a replacement for insert_default_values()

    • ➕ Added insert_into(table).values(values) as a replacement for insert(values).into(table).

    • ➕ Added support for MySQL's REPLACE INTO as replace_into(table).

    • ➕ Added replace_into(table).values(values) as a replacement for insert_or_replace(values).into(table).

    • Added on_conflict_do_nothing on InsertStatement as a replacement for on_conflict_do_nothing on Insertable structs.

    • ➕ Added on_conflict on InsertStatement as a replacement for on_conflict on Insertable structs.

    • ⚡️ filter can now be called on update and delete statements. This means that instead of update(users.filter(...)) you can write update(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.

    • TextExpressionMethods is now implemented for expressions of type Nullable<Text> as well as Text.

    • 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 than sql for complete queries. The main difference from sql is 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, and FromSqlRow have 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 a joinable! invocation for those tables.

    • diesel_codegen should no longer explicitly be used as a dependency. Unless you are using infer_schema! or embed_migrations!, you can simply remove it from your Cargo.toml. All other functionality is now provided by diesel itself.

    • Code using infer_schema! or infer_table_from_schema! must now add diesel_infer_schema to Cargo.toml, and #[macro_use] extern crate diesel_infer_schema to src/lib.rs

    • Code using embed_migrations! must now add diesel_migrations to Cargo.toml, and #[macro_use] extern crate diesel_migrations to src/lib.rs

    • 🚚 The migrations module has been moved out of diesel and into diesel_migrations

    🗄 Deprecated

    • 0️⃣ Deprecated insert_default_values() in favor of insert_into(table).default_values()

    • 🗄 Deprecated insert(values).into(table) in favor of insert_into(table).values(values).

    • Deprecated insert_or_replace(values).into(table) in favor of replace_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_joins in favor of allow_tables_to_appear_in_same_query!

    • 🗄 Deprecated SqlLiteral#bind. sql is 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. Use sql_query if you need raw SQL with bind parameters.

    ✂ Removed

    • 🚚 IntoInsertStatement and BatchInsertStatement have been removed. It's unlikely that your application is using these types, but InsertStatement is now the only "insert statement" type.

    • 🚚 Citext as a type alias for Text has been removed. Writing citext_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 as 0000-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 str and slice can now appear on structs which derive Insertable or AsChangeset.

    • 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 strftime function except for the string 'now'.