Skip to content
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

How to use custom Ecto type for item_id #235

Open
mayel opened this issue Aug 31, 2024 · 2 comments
Open

How to use custom Ecto type for item_id #235

mayel opened this issue Aug 31, 2024 · 2 comments

Comments

@mayel
Copy link
Contributor

mayel commented Aug 31, 2024

Hi, thanks for merging my recent PR :)
It's great that we can configure the type of ID used for item_id, but an issue for us is that it doesn't seem to work for types that aren't built-in to Ecto (such as Needle.ULID from https://www.hex.pm/packages/needle_ulid). What would be a good approach to make this possible (without simply adding such libraries as an optional dependency)?

@mayel mayel changed the title How to use custom Ecto Type for item_id How to use custom Ecto type for item_id Aug 31, 2024
@izelnakri
Copy link
Owner

izelnakri commented Sep 12, 2024

Hi @mayel ,

I've never come across this issue before. What kind of error do you get? Perhaps we can simulate the scenario in a test and then create a solution/PR for this edge case scenario.

mayel added a commit to bonfire-networks/paper_trail that referenced this issue Sep 13, 2024
@mayel
Copy link
Contributor Author

mayel commented Sep 13, 2024

Here's a basic reproduction which results in the following compilation error: https://github.com/bonfire-networks/paper_trail/tree/custom-type-repro/example

== Compilation error in file lib/version.ex ==
** (ArgumentError) unknown type Needle.ULID for field :item_id
    (ecto 3.12.3) lib/ecto/schema.ex:2491: Ecto.Schema.check_field_type!/4
    (ecto 3.12.3) lib/ecto/schema.ex:2053: Ecto.Schema.__field__/4
    lib/version.ex:18: (module)

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

No branches or pull requests

2 participants