Skip to content

Latest commit

 

History

History
95 lines (63 loc) · 6.07 KB

CHANGELOG.md

File metadata and controls

95 lines (63 loc) · 6.07 KB

Changelog for v3.0

Highlights

This is a new major release for Ecto v3.0. Despite the major number, this is a small release with the main goal of removing the previously deprecated Ecto datetime types in favor of the Calendar types that ship as part of Elixir and updating to the latest JSON handling best practices.

Calendar types

Ecto.Date, Ecto.Time and Ecto.DateTime no longer exist. Instead developers should use Date, Time, DateTime and NaiveDateTime that ship as part of Elixir and are the preferred types since Ecto 2.1. Database adapters have also been standarized to work with Elixir types and they no longer return tuples when developers perform raw queries.

To uniformly support microseconds across all databases, the types :time, :naive_datetime, :utc_datetime will now discard any microseconds information. Ecto v3.0 introduces the types :time_usec, :naive_datetime_usec and :utc_datetime_usec as an alternative for those interested in keeping microseconds. If you want to keep microseconds in your migrations and schemas, you need to configure your repository:

config :my_app, MyApp.Repo,
  migration_timestamps: [type: :naive_datetime_usec]

And then in your schema:

@timestamps_opts [type: :naive_datetime_usec]

JSON handling

Ecto v3.0 moved the management of the JSON library to adapters. All adapters should default to Jason.

The following configuration will emit a warning:

config :ecto, :json_library, CustomJSONLib

And should be rewritten as:

# For Postgres
config :postgrex, :json_library, CustomJSONLib

# For MySQL
config :mariaex, :json_library, CustomJSONLib

If you want to rollback to Poison, you need to configure your adapter accordingly:

# For Postgres
config :postgrex, :json_library, Poison

# For MySQL
config :mariaex, :json_library, Poison

We recommend everyone to migrate to Jason. Built-in support for Poison will be removed in future Ecto 3.x releases.

v3.0.0-dev (In Progress)

Enhancements

  • [Ecto.Changeset] Put constraint name in error metadata for constraints
  • [Ecto.Changeset] Add validations/1 and constraints/1 instead of allowing direct access on the struct fields
  • [Ecto.Changeset] Add :force_update option when casting relations
  • [Ecto.Migration] Migrations now lock the migrations table in order to avoid concurrent migrations in a cluster. The type of lock can be configured via the :migration_lock repository configuration and defaults to "FOR UPDATE" or disabled if set to nil
  • [Ecto.Migration] Add migration_default_prefix
  • [Ecto.Migration] Add reversible version of remove/2 subcommand
  • [Ecto.Query] Add unsafe_fragment to queries which allow developers to send dynamically generated fragments to the database that are not checked (and therefore unsafe)
  • [Ecto.Query] Support tuples in filter expressions, allowing queries such as where: {p.foo, p.bar} > {^foo, ^bar}
  • [Ecto.Query] Support arithmetic operators in queries as a thin layer around the DB functionality
  • [Ecto.Query] Allow joins in queries to be named via :as and allow named bindings
  • [Ecto.Query] Support excluding specific join types in exclude/2
  • [Ecto.Query] Allow virtual field update in subqueries
  • [Ecto.Repo] Support :replace_all_except_primary_key as :on_conflict strategy
  • [Ecto.Repo] Support {:replace, fields} as :on_conflict strategy
  • [Ecto.Repo] Support select in queries given to update_all and delete_all

Bug fixes

  • [Ecto.Migration] Keep double underscores on autogenerated index names to be consistent with changesets
  • [Ecto.Query] Fix Ecto.Query.API.map/2 for single nil column with join
  • [mix ecto.migrations] List migrated versions even if the migration file is deleted

Deprecations

  • [Ecto.Changeset] Passing a list of binaries to cast/3 is deprecated, please pass a list of atoms instead
  • [Ecto.Multi] Ecto.Multi.run/3 now receives the repo in which the transaction is executing as the first argument to functions, and the changes so far as the second argument
  • [Ecto.Query] join/5 now expects on: expr as last argument instead of simply expr. This was done in order to properly support :as and friends
  • [Ecto.Repo] The :returning option for update_all and delete_all has been deprecated as those statements now support select clauses

Backwards incompatible changes

  • [Ecto.DateTime] Ecto.Date, Ecto.Time and Ecto.DateTime were previously deprecated and have now been removed
  • [Ecto.Multi] Ecto.Multi.run/5 now receives the repo in which the transaction is executing as the first argument to functions, and the changes so far as the second argument
  • [Ecto.Schema] :time, :naive_datetime and :utc_datetime no longer keep microseconds information. If you want to keep microseconds, use :time_usec, :naive_datetime_usec, :utc_datetime_usec

Adapter changes

  • [Ecto.Adapter] The database types time, utc_datetime and naive_datetime should translate to types with seconds precision while the database types time_usec, utc_datetime_usec and naive_datetime_usec should have microseconds precision
  • [Ecto.Adapter] The on_conflict argument for insert and insert_all no longer receives a {:replace_all, list(), atom()} tuple. Instead, it receives a {fields :: [atom()], list(), atom()} where fields is a list of atoms of the fields to be replaced
  • [Ecto.Adapter] exclusion_constraint will now have type :exclusion on the adapter metadata instead of :exclude (affects PostgreSQL only)
  • [Ecto.Adapter.Migration] A new lock_for_migration/4 callback has been added. It is implemented by default by Ecto.Adapters.SQL
  • [Ecto.Query] Tuple expressions are now supported in queries. For example, where: {p.foo, p.bar} > {p.bar, p.baz} should translate to WHERE (p.foo, p.bar) > (p.bar, p.baz) in SQL databases. Adapters should be changed to handle {:{}, meta, exprs} in the query AST

Previous versions