Allow Ecto.UUID to dump values that are already 16 byte binaries #1585
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a fix for a bug I discovered while using changesets to insert binaries into
:binary_id
columns. If you try to insert a value that is already a 16 byte binary, instead of a hyphenated string, ecto raises an error such as:I got this when I selected a record with a primary key that's a
:binary_id
, and tried to insert that id into the foreign key column of another table that's also a:binary_id
. It seems currently Ecto is expecting that value to be converted to a formatted string such asXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
at some point, as if it were being submitted from a form.This PR allows it to be retrieved as a binary from one table and inserted into another table as a binary without being converted to a string first.