alembic 3.4.0
https://hex.pm/packages/alembic/3.4.0
Changelog
Enhancements
-
Alembic.Document.from_ecto_changeset/2
converts theerrors
inecto_changeset
toAlembic.Error.t
in a singleAlembic.Document.t
. Bypasses a bug inJaSerializer
where it assumes all fields that don’t end in_id
are attribute names, which leads to association names (as opposed to their foreign key) being put under/data/attributes
.Alembic.Document.from_ecto_changeset
reflects on theEcto.Changeset.t
data
struct module to get the__schema__/1
information from theEcto.Schema.t
. It also assumes that if the field maps to no known attribute, association or foreign key, then the error should not have anAlembic.Source.t
instead of defaulting to/data/attributes
. -
Alembic.Pagination.Page.count
calculates the number of pages given the pagesize
and thetotal_size
of resources to be paginated. -
Alembic.Pagination.Page.first
returns theAlembic.Pagination.Page.t
for thefirst
forAlembic.Pagination.t
given any page and the page count. -
Alembic.Pagination.Page.last
is the last page forAlembic.Pagination.t
given any page and the page count. -
Alembic.Pagination.Page.next
is the next page after the currentpage
. Ifpage
number
matchescount
, then it must be the last page and so next will benil
. -
Alembic.Paginaton.Page.previous
is the previous page to the currentpage
. If thepage
number
is1
, then it is the first page, and the previous page isnil
. -
Alembic.Pagination.Page.to_pagination
takes the currentpage
and thetotal_size
of resources to paginated and produces theAlembic.Pagination
withfirst
,last
,next
, andprevious
around thatpage
. Ifpage
number
is greater than the calculated page count{:error, Alembic.Document.t}
is returned instead of{:ok, Alembic.Pagination.t}
. -
Alembic.FromJson.integer_from_json
-
Alembic.FromJson.integer_to_positive_integer
takes an integer and returns it if positive, otherwise returns errorDocument
if0
or below. -
Alembic.Pagination.Page.from_params
parses param format with quoted integer page number and size or JSON format with integer page number and size. -
Allow pagination opt-out with
%{“page” => nil}
.Alembic.Pagination.Page.from_params(%{“page” => nil})
will return{:ok, :all}
while no“page”
param will return{:ok, nil}
. - Use IntelliJ Elixir formatter for make the formatting consistent
-
Support
many_to_many
associations inAlembic.ToEctoSchema.to_ecto_schema/2
-
Alembic.ToEctoSchema.to_ecto_schema/2
doctest
s
Bug Fixes
-
Allow
next
andprevious
to benil
inPagination.t
@type
since they were already allowed to benil
in use for the last and first page, respectively. -
Alembic.Pagination.Page
number
ispos_integer
becausenon_neg_integer
allows 0, but that’s not valid becausenumber
is 1-based, not 0-based.
Read next Elixir for the Little Things