Skip to content

Releases: elixir-ecto/ecto

v0.12.0

22 Jun 12:01
Compare
Choose a tag to compare

This release includes major changes to Ecto schemas in order to improve UUID support.

In particular, if you were customizing your primary keys to use UUIDs, you will have to change your @primary_key configuration from:

@primary_key {:id, Ecto.UUID, read_after_writes: true}

To:

@primary_key {:id, :binary_id, autogenerate: true}

The :binary_id type means the semantics of the field are specified by the adapter/database. For all SQL databases, it means the field will be treated as Ecto.UUID. The difference is that :binary_id allows other adapters to provide their own logic for generating IDs, be it a RecordID, ObjectID and so on.

Furthermore, the autogenerate: true option is also supported by custom types, so one can write:

field :secret, Ecto.UUID, autogenerate: true

and Ecto will take care of automatically generating a secret before insertion. In this case, there is no need for setting the default in the database.

If you were not customizing your primary key, the default type for primary and foregin keys is now :id, which is synonymous to :integer, so no changes should be required in your application.

Finally, due to such improvements, :read_after_writes is deprecated. Even though the option may not be removed after all, we want to deprecate it in order to push everything to use the new syntax.

Changelog

Enhancements

  • Add put_source/2 function to Ecto.Model
  • Allow binary literal syntax in queries
  • Optimize SQL transactions by reducing the amount of messages passed around
  • Provide Ecto.Adapters.Worker which can work across adapters and provides transactional semantics
  • Support :autogenerate for custom types
  • Introduce new :id and :binary_id types that support autogeneration inside primary keys and are handled by the database

Bug fixes

  • Ensure confirmation is required if field is given but nil

Deprecations

  • :read_after_writes is deprecated in favor of :autogenerate in Ecto.Schema.field/3
  • Repo.insert/2 is deprecated in favor of Repo.insert!/2
  • Repo.update/2 is deprecated in favor of Repo.update!/2
  • Repo.delete/2 is deprecated in favor of Repo.delete!/2

Backwards incompatible changes

  • Repo.log/2 is no longer invoked. Instead Repo.log/1 is called with an Ecto.LogEntry
  • :auto_field in belongs_to/3 has been renamed to :define_field
  • :uuid type has been removed in favor of Ecto.UUID

Adapters backwards incompatible changes

  • fragment AST now tags each argument as raw or expr
  • Ecto.Adapter.insert now receives an extra argument telling which key to autogenerate. The value may be: {field :: atom, type :: :id | :binary_id, value :: term | nil} | nil. If nil, there is no key to autogenerate. If a tuple, it may have type :id or :binary_id with semantics to be specified by the adapter/database. Finally, if the value is nil, it means no value was supplied by the user and the database MUST return a new one.

v0.12.0-rc

30 May 18:22
Compare
Choose a tag to compare

This release includes major changes to Ecto schemas in order to improve UUID support.

In particular, if you were customizing your primary keys to use UUIDs, you will have to change your @primary_key configuration from:

@primary_key {:id, Ecto.UUID, read_after_writes: true}

To:

@primary_key {:id, :binary_id, autogenerate: true}

The :binary_id type means the semantics of the field are specified by the adapter/database. For all SQL databases, it means the field will be treated as Ecto.UUID. The difference is that :binary_id allows other adapters to provide their own logic for generating IDs, be it a RecordID, ObjectID and so on.

Furthermore, the autogenerate: true option is also supported by custom types, so one can write:

field :secret, Ecto.UUID, autogenerate: true

and Ecto will take care of automatically generating a secret before insertion. In this case, there is no need for setting the default in the database.

If you were not customizing your primary key, the default type for primary and foregin keys is now :id, which is synonymous to :integer, so no changes should be required in your application.

Finally, due to such improvements, :read_after_writes is deprecated. Even though the option may not be removed after all, we want to deprecate it in order to push everything to use the new syntax.

CHANGELOG

Enhancements

  • Add put_source/2 function to Ecto.Model
  • Allow binary literal syntax in queries
  • Optimize SQL transactions by reducing the amount of messages passed around
  • Provide Ecto.Adapters.Worker which can work across adapters and provides transactional semantics
  • Support :autogenerate for custom types
  • Introduce new :id and :binary_id types that support autogeneration inside primary keys and are handled by the database

Deprecations

  • :read_after_writes is deprecated in favor of :autogenerate

Backwards incompatible changes

  • Repo.log/2 is no longer invoked. Instead Repo.log/1 is called with an Ecto.LogEntry
  • :auto_field in belongs_to/3 has been renamed to :define_field
  • :uuid type has been removed in favor of Ecto.UUID

Adapters backwards incompatible changes

  • fragment AST now tags each argument as raw or expr
  • Ecto.Adapter.insert now receives an extra argument telling which key to autogenerate. The value may be: {field :: atom, type :: :id | :binary_id, value :: term | nil} | nil. If nil, there is no key to autogenerate. If a tuple, it may have type :id or :binary_id with semantics to be specified by the adapter/database. Finally, if the value is nil, it means no value was supplied by the user and the database MUST return a new one.

v0.11.3

19 May 09:15
Compare
Choose a tag to compare

Enhancements

  • Add validate_confirmation/3
  • Normalize ports for MySQL and PostgreSQL

Bug fixes

  • Ensure changes in changesets can be reset to their original value

v0.11.2

06 May 12:39
Compare
Choose a tag to compare

Bug fixes

  • Trigger validate_unique/3 if the field or any of the scopes changed
  • Do not trigger validate_unique/3 if the field or scopes contains errors
  • Ensure repo log calls can be optimized out
  • Improve error message when model types are given on migrations

v0.11.1

06 May 12:37
Compare
Choose a tag to compare

Enhancements

  • Add force_change/3 to force a change into a changeset

Bug fixes

  • put_change/3, put_new_change/3 and change/2 in Ecto.Changeset also verify the model value before storing the change

v0.11.0

04 May 09:03
Compare
Choose a tag to compare

Enhancements

  • Add Ecto.Repo.get_by/3 and Ecto.Repo.get_by!/3
  • Add to_erl/from_erl to datetime modules
  • Add :scope option to Ecto.Changeset.validate_unique/2
  • Allow distinct(query, true) query expression
  • Effectively track dirty changes in Ecto.Changeset. If the value being sent as parameter is the same as the value in the model, it won't be sent to the Repo on insert/update

Deprecations

  • Deprecate nil as parameters in Ecto.Changeset.cast/4 in favor of :empty

Backwards incompatible changes

  • The pool size now defaults to 10 with no overflow. This will affect you if you were not explicitly setting those values in your pool configuration.
  • Ecto.Model now only imports from/2 from Ecto.Query out of the box
  • Ecto.Changeset.apply/1 was removed in favor of Ecto.Changeset.apply_changes/1

v0.10.3

04 May 09:00
Compare
Choose a tag to compare

Enhancements

  • Relax poolboy dependency

v0.10.2

04 May 09:00
Compare
Choose a tag to compare

Enhancements

  • Add Ecto.DateTime.from_date/1
  • Allow adapter to be configured at the :repo level
  • Add --quiet to ecto.migrate, ecto.create and ecto.drop tasks
  • Support timestampz type for PostgreSQL

Bug fixes

  • Ensure :invalid error shows up as "is invalid" message
  • Improve support for "schema.table" queries in MySQL and PostgreSQL

v0.10.1

25 Mar 13:57
Compare
Choose a tag to compare

Enhancements

  • Add an option to set the engine when creating a table (used by MySQL and defaults to InnoDB). This ensures Ecto works out of the box with earlier MySQL versions

Bug fixes

  • No longer create database in ecto.migrate if one does not exist
  • Fix a bug where dates earlier than 2000 could not be saved in Postgres

v0.10.0

25 Mar 13:44
Compare
Choose a tag to compare

Enhancements

  • Add validate_number/3 to Ecto.Changeset
  • Add cardinality to Ecto.Association.NotLoaded
  • Allow {"source", Model} as a source in queries and associations
  • Add support for usec in Ecto.Date, Ecto.Time and Ecto.DateTime
  • Add usec: true support to Ecto.Schema.timestamps/1
  • Create database in ecto.migrate if one does not exist
  • Repo.preload/2 no longer preloads already loaded associations

Backwards incompatible changes

  • Using distict: EXPR automatically sets the given distinct expressions in order_by
  • __state__ field has been removed in favor of a __meta__ field which includes the state and the model source
  • Error messages in Ecto.Changeset now return strings instead of atoms
  • Ecto.Model.primary_key/1 now returns a keyword list of primary key fields, returning an empty list when there is no primary key. Use Ecto.Model.primary_key!/1 for the raising variant
  • Use simple representations when converting Ecto.Date, Ecto.Time and Ecto.DateTime to strings. Use to_iso8601 for the ISO specific formatting
  • @timestamps_type Your.Type was removed in favor of @timestamps_opts [type: Your.Type]