我有这段代码:
case Timex.Timezone.get(data) do
{:error, _} = error ->
error
data ->
{:ok, data}
end
将保存在数据库中的时区放入结构中。
好吧,当运行通过 Ecto 查询获取一些数据的迁移时,我收到此错误:
** (ArgumentError) argument error
(stdlib) :ets.lookup(:tzdata_current_release, :release_version)
lib/tzdata/release_reader.ex:47: Tzdata.ReleaseReader.current_release_from_table/0
lib/tzdata/release_reader.ex:14: Tzdata.ReleaseReader.simple_lookup/1
lib/tzdata/release_reader.ex:7: Tzdata.ReleaseReader.zone_and_link_list/0
lib/tzdata.ex:40: Tzdata.zone_exists?/1
lib/timezone/timezone.ex:152: Timex.Timezone.name_of/1
lib/timezone/timezone.ex:180: Timex.Timezone.get/2
lib/common/ecto/timezone.ex:27: Common.Ecto.Timezone.load/1
(ecto) lib/ecto/type.ex:661: Ecto.Type.process_loaders/3
(ecto) lib/ecto/schema.ex:1490: Ecto.Schema.load!/5
(ecto) lib/ecto/schema.ex:1442: Ecto.Schema.safe_load_zip/4
(ecto) lib/ecto/schema.ex:1443: Ecto.Schema.safe_load_zip/4
(ecto) lib/ecto/schema.ex:1430: Ecto.Schema.__safe_load__/6
(ecto) lib/ecto/repo/queryable.ex:282: Ecto.Repo.Queryable.process_source/6
(ecto) lib/ecto/repo/queryable.ex:170: Ecto.Repo.Queryable.preprocess/5
(postgrex) lib/postgrex/query.ex:77: DBConnection.Query.Postgrex.Query.decode_map/3
(postgrex) lib/postgrex/query.ex:64: DBConnection.Query.Postgrex.Query.decode/3
(db_connection) lib/db_connection.ex:1019: DBConnection.decode/6
(ecto) lib/ecto/adapters/postgres/connection.ex:73: Ecto.Adapters.Postgres.Connection.prepare_execute/5
(ecto) lib/ecto/adapters/sql.ex:256: Ecto.Adapters.SQL.sql_call/6
在堆栈跟踪中有该代码并执行一些检查可以验证这确实是触发错误的调用,尽管这样做:
iex(1)> Timex.Timezone.get("America/Los_Angeles")
#<TimezoneInfo(America/Los_Angeles - PDT (-07:00:00))>
在iex -S mix
作品中。