Skip to content

Add missing :date column type #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 7, 2023

Conversation

joeljuca
Copy link
Contributor

@joeljuca joeljuca commented May 5, 2023

I'm still new to Ecto adapters so I'm not 100% confident this is the right way to do it, but I noticed that :date fields are not correctly mapped to the equivalent SQLite data type, so here's a PR trying to fix it.

@joeljuca
Copy link
Contributor Author

joeljuca commented May 5, 2023

Breaking all tests might be just a fun way to start contributing to the project. 😂

I'm updating my branch with the latest patch and check these failures.

@joeljuca joeljuca marked this pull request as draft May 5, 2023 16:43
@joeljuca joeljuca force-pushed the field-type-date branch from 16336d7 to 3d185b9 Compare May 5, 2023 16:48
@joeljuca joeljuca marked this pull request as ready for review May 5, 2023 16:54
Comment on lines 192 to 194
test "on %DateTime{} structs", %{datetime: datetime} do
{:ok, "2011-01-09"} = Codec.date_encode(datetime, :iso8601)
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if date_encode() should support %DateTime{} structs, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should go check what the postgres adapter does to support this. I think we can truncate and be fine, but that seems like it may cause confusion down the road rather than blow up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it specific to Date structs then. We can expand it in the future if there's a real use case to accept DateTime structs as values in :date fields.

@warmwaffles warmwaffles merged commit a476817 into elixir-sqlite:main May 7, 2023
@joeljuca joeljuca deleted the field-type-date branch May 7, 2023 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants