bitwalker / timex_ecto

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

add Timex.Ecto.TimestampWithTimezone to support :timestamptz and deprecate Timex.Ecto.Timestamps #64

Closed bitgorust closed 7 years ago

bitgorust commented 7 years ago

@bitwalker , thanks for your job!

I have met two problems when using these excellent libraries. Here are the problems and my solutions. I hope I am not wasting your time.

Timex.Ecto.TimestampWithTimezone

Since a new :datetimetz type is needed when using Timex.Ecto.DateTimeWithTimezone, which is a pain to me, I have created Timex.Ecto.TimestampWithTimezone to directly support :timestamptz in my project and it works well.

Timex.Ecto.Timestamps

I think Timex.Ecto.Timestamps which restricts inserted_at and updated_at to Timex.Ecto.DateTime is unnecessary as timestamps has all the options needed and is more flexible and convenient. Here's an example in my project:

timestamps(type: Timex.Ecto.TimestampWithTimezone,
           autogenerate: {Timex.Ecto.TimestampWithTimezone, :autogenerate, [:usec]})

Looking forward to your response. And if my job is acceptable, I am willing to work further such as adding relative test cases and documents.

bitwalker commented 7 years ago

This looks great! Can you leave Timex.Ecto.Timestamps in the project, but update any references to it in the documentation to mention that it is deprecated in favor of the approach you've laid out here? I want to give folks a deprecation cycle before removing something that is likely used in many places.

bitgorust commented 7 years ago

Thanks for your approval. I will have a try tomorrow.

bitgorust commented 7 years ago

@bitwalker lib/model.ex is back and README.md is updated. A unit test for Timex.Ecto.TimestampWithTimezone is also added. Please check if I have done all these right.

bitwalker commented 7 years ago

Thanks! This will be published in 3.2.0