0
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

Organization

Ecto 3.17 から 3.2.2 にアップデート: use Ecto.Type

Ecto を 3.1.7 から 3.2.2 にアップデートしたところ、コンパイル時に大量の warning が出るようになってしまった。

warning: function embed_as/1 required by behaviour Ecto.Type is not implemented (in module MyApp.Ecto.SecretKey)
  lib/myapp/ecto/secret_key.ex:1: MyApp.Ecto.SecretKey (module)

warning: function equal?/2 required by behaviour Ecto.Type is not implemented (in module MyApp.Ecto.SecretKey)
  lib/myapp/ecto/secret_key.ex:1: MyApp.Ecto.SecretKey (module)

warning: function embed_as/1 required by behaviour Ecto.Type is not implemented (in module MyApp.Ecto.RandomSecretKey20)
  lib/myapp/ecto/random_secret_key.ex:42: MyApp.Ecto.RandomSecretKey20 (module)

warning: function equal?/2 required by behaviour Ecto.Type is not implemented (in module MyApp.Ecto.RandomSecretKey20)
  lib/myapp/ecto/random_secret_key.ex:42: MyApp.Ecto.RandomSecretKey20 (module)

Ecto.Type の @callback に追加された embed_as/1equal?/2 が、use Ecto.Type の導入に伴い @optional_callback から外されたのが原因のようだ。

自分のプロジェクトで @behaviour Ecto.Type をしている箇所を use Ecto.Type に置き換えれば、デフォルトの実装を提供してくれるので、上記の warning は収まる。

- @behaviour Ecto.Type
+ use Ecto.Type
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
0
Help us understand the problem. What are the problem?