danielberkompas / cloak_ecto

Encrypted fields for Ecto
MIT License
197 stars 31 forks source link

Cloak.Ecto.Type does not conform to the Ecto.Type behavior #12

Closed WilHall closed 3 years ago

WilHall commented 3 years ago

The Cloak.Ecto.Type module does not conform to the Ecto.Type behavior. For example, equal/3 is not implemented.

Because of this, following the cloak_ecto usage instructions results in a custom Ecto type which does not conform to the Ecto.Type behavior. This can result in UndefinedFunctionError instances when Ecto tries to use the custom type in a way that is not implemented:

** (UndefinedFunctionError) function Application.Encrypted.Binary.equal?/2 is undefined or private

I believe either Cloak.Ecto.Type should be updated to use Ecto.Type such that the default implementations can be used as fallbacks, or the usage instructions should be updated to let consumers of use Cloak.Ecto.Binary know that they either need to use Ecto.Type or define the missing methods.

ellamosi commented 3 years ago

This pull request is related to the issue: https://github.com/danielberkompas/cloak_ecto/pull/11

Unsure of what the best solution is. But as it is now things will not work as documented with Ecto 3.5.

drewolson commented 3 years ago

This should be fixed in https://github.com/danielberkompas/cloak_ecto/commit/2238af0359a79d145b9e60013afd8aba3478c3ac

ellamosi commented 3 years ago

Great! 👏