Packages

Unit functions for the serialization to a database of a Localize.Unit.t data type. Also includes aggregation and sum functions.

Current section

Files

Jump to
Raw

CHANGELOG.md

# Changelog

**Note** that `localize_units_sql` is supported on Elixir 1.17 and later only.

## Localize Units SQL v2.1.0

This is the changelog for Localize Units SQL v2.1.0 released on October 25th, 2026.

### Bug Fixes

* Requires `localize ~> 1.4`. Version 2.0.0 required `localize ~> 0.22`, which no Localize 1.x release satisfies, so it could not be installed alongside Localize 1.0 or later.

* `cast/1` of every type returns a cast error for a string value with trailing text, such as `"12abc"`, where it raised `WithClauseError`.

* `Localize.Unit.DDL.drop_aggregate_functions/1` drops `unit_with_usage_state_function`, which it named wrongly and so left behind. A migration generated by 2.0.0 keeps the old `down`, so rolling back the type migration fails: change `unit_state_function(agg_state cldr_unit_with_usage, ...)` in that `down` to `unit_with_usage_state_function(...)`.

* `equal?/2` of every type compares the unit name and the exact value, and the with-usage types also compare the usage, so Ecto now writes a change of unit or usage. It used to compare quantities across units as floats and ignore usage, so such a change was silently dropped.

* `cast/1` of every type casts a float value, where it raised `FunctionClauseError`. The with-usage types cast a string-keyed map that has no `"usage"`.

* `load/1` of every type returns `:error` for a value of the wrong shape, where it raised. The map types load a float value.

## Localize Units SQL v2.0.0

This is the changelog for Localize Units SQL v2.0.0 released on April 24th, 2026.

### Breaking changes

* The package has been renamed from `ex_cldr_units_sql` to `localize_units_sql`. The `Cldr.Unit.*` modules are now `Localize.Unit.*` (for example `Cldr.Unit.Ecto.Composite.Type` becomes `Localize.Unit.Ecto.Composite.Type`). Existing schema and migration references must be updated.

* Supported on Elixir 1.17 or later only.

* Requires the unified [localize](https://hex.pm/packages/localize) package in place of the `ex_cldr` family of dependencies. The CLDR backend module (e.g. `MyApp.Cldr`) and its configuration are no longer used. Configure locales through `config :localize` instead.

* `Localize.Unit` uses string unit identifiers (for example `"meter"`) and string usage values (for example `"person"`), rather than atoms. Code that previously passed `:meter` or `usage: :person` should pass `"meter"` / `usage: "person"`.

* `Localize.Unit.new/2,3` takes the value as the first argument and the unit identifier as the second. The `Cldr.Unit.new(:meter, 100)` form is no longer valid — use `Localize.Unit.new(100, "meter")`.

* The `:unit` field on the struct has been renamed to `:name`.

* `jason` is no longer a declared dependency. Postgrex defaults to `Jason` for `json`/`jsonb` columns; configure `config :postgrex, :json_library, JSON` (Elixir 1.18+) and run `mix deps.compile postgrex --force` once since Postgrex captures this setting at compile time.

### Enhancements

* The Postgres composite type names (`cldr_unit`, `cldr_unit_with_usage`) and aggregate function names are unchanged, so existing databases do not require a schema migration.