alembic 3.4.0
https://hex.pm/packages/alembic/3.4.0
Changelog
Enhancements
-
Alembic.Document.from_ecto_changeset/2converts theerrorsinecto_changesettoAlembic.Error.tin a singleAlembic.Document.t. Bypasses a bug inJaSerializerwhere it assumes all fields that don’t end in_idare attribute names, which leads to association names (as opposed to their foreign key) being put under/data/attributes.Alembic.Document.from_ecto_changesetreflects on theEcto.Changeset.tdatastruct module to get the__schema__/1information 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.tinstead of defaulting to/data/attributes. -
Alembic.Pagination.Page.countcalculates the number of pages given the pagesizeand thetotal_sizeof resources to be paginated. -
Alembic.Pagination.Page.firstreturns theAlembic.Pagination.Page.tfor thefirstforAlembic.Pagination.tgiven any page and the page count. -
Alembic.Pagination.Page.lastis the last page forAlembic.Pagination.tgiven any page and the page count. -
Alembic.Pagination.Page.nextis the next page after the currentpage. Ifpagenumbermatchescount, then it must be the last page and so next will benil. -
Alembic.Paginaton.Page.previousis the previous page to the currentpage. If thepagenumberis1, then it is the first page, and the previous page isnil. -
Alembic.Pagination.Page.to_paginationtakes the currentpageand thetotal_sizeof resources to paginated and produces theAlembic.Paginationwithfirst,last,next, andpreviousaround thatpage. Ifpagenumberis 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_integertakes an integer and returns it if positive, otherwise returns errorDocumentif0or below. -
Alembic.Pagination.Page.from_paramsparses 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_manyassociations inAlembic.ToEctoSchema.to_ecto_schema/2 -
Alembic.ToEctoSchema.to_ecto_schema/2doctests
Bug Fixes
-
Allow
nextandpreviousto benilinPagination.t@typesince they were already allowed to benilin use for the last and first page, respectively. -
Alembic.Pagination.Pagenumberispos_integerbecausenon_neg_integerallows 0, but that’s not valid becausenumberis 1-based, not 0-based.
Read next Elixir for the Little Things
