coryodaniel / arbor

Ecto elixir adjacency list and tree traversal. Supports Ecto versions 2 and 3.
MIT License
239 stars 26 forks source link

Code Formatter and Ecto 3 support #21

Closed chingan-tsc closed 5 years ago

chingan-tsc commented 5 years ago

I added a .formatter.exs file on the root level and ran Elixir mix format on the codebase. Additionally Ecto 3 has the breaking change as below:

[Ecto.Schema.Metadata] The source key no longer returns a tuple of the schema_prefix and the table/collection name. It now returns just the table/collection string. You can now access the schema_prefix via the prefix key.

Therefore I added a check on lib/tree.ex on the return type of struct_fields[:__meta__].source and assign accordingly. My original idea is to check the Ecto version (using Application.spec(:ecto, :vsn)) on lib/tree.ex instead but I couldn't get the test cases to pass as on the test cases Ecto wasn't really "loaded".

Would appreciate any comments on the PR.

coryodaniel commented 5 years ago

I like checking the type of the return value. Thanks for this and adding the formatter. I can cut a release this weekend.

coryodaniel commented 5 years ago

I got a chance to publish a release today. Arbor v 1.1.0