LoginSignup
2
0

More than 3 years have passed since last update.

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

Posted at

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
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0