bitwalker / timex_ecto

An adapter for using Timex DateTimes with Ecto
MIT License
162 stars 68 forks source link

Incompatibility with Timex 3.6.1 #83

Closed dfalling closed 5 years ago

dfalling commented 5 years ago

The patch update from 3.6.0 to 3.6.1 of Timex is incompatible with timex_ecto. I get a number of these failures in my branch:

 ** (FunctionClauseError) no function clause matching in Timex.DateTime.Helpers.construct_microseconds/1

     The following arguments were given to Timex.DateTime.Helpers.construct_microseconds/1:

         # 1
         0

     Attempted function clauses (showing 1 out of 1):

         def construct_microseconds({us, p}) when is_integer(us) and is_integer(p)

     code: assert Trips.list_trips() == [trip]
     stacktrace:
       (timex) lib/datetime/helpers.ex:72: Timex.DateTime.Helpers.construct_microseconds/1
       (timex_ecto) lib/types/datetime.ex:122: Timex.Ecto.DateTime.load/1
       (ecto) lib/ecto/type.ex:661: Ecto.Type.process_loaders/3
       (ecto) lib/ecto/schema.ex:1491: Ecto.Schema.load!/5
       (ecto) lib/ecto/schema.ex:1443: Ecto.Schema.safe_load_zip/4
       (ecto) lib/ecto/schema.ex:1444: Ecto.Schema.safe_load_zip/4
       (ecto) lib/ecto/schema.ex:1431: Ecto.Schema.__safe_load__/6
       (ecto) lib/ecto/repo/queryable.ex:287: Ecto.Repo.Queryable.process_source/6
       (ecto) lib/ecto/repo/queryable.ex:175: 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
       (ecto) lib/ecto/adapters/sql.ex:426: Ecto.Adapters.SQL.execute_and_cache/7
       (ecto) lib/ecto/repo/queryable.ex:133: Ecto.Repo.Queryable.execute/5
       (ecto) lib/ecto/repo/queryable.ex:37: Ecto.Repo.Queryable.all/4
       test/ido_api/trips/trips_test.exs:60: (test)

Is there a known workaround, or do I need to hold off on updating Timex for now?

riverrun commented 5 years ago

The issue seems to be that after this commit, the construct_microseconds/1 function only takes a two-tuple as input (before, it used to also take an integer). This function is currently being used (and currently expecting an integer as input) in the following files:

timex_ecto/lib/helpers.ex timex_ecto/lib/types/datetimetz.ex timex_ecto/lib/types/datetime.ex timex_ecto/lib/types/timestamptz.ex

bitwalker commented 5 years ago

Fixed in master, and soon to be 3.4.0 release