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

Allow to configure Originator Field Options #115

Merged
merged 1 commit into from
Dec 4, 2020

Conversation

maennchen
Copy link
Contributor

No description provided.

@izelnakri
Copy link
Owner

izelnakri commented Nov 28, 2020

Hi @maennchen could you add more description and better documentation on README.md for this change specifically? I couldnt understand the change completely.

originator_type: Ecto.UUID,
originator_options: [references: :uuid]

why do we need originator_options: [references: :uuid] when originator_type is already Ecto.UUID ?

@maennchen
Copy link
Contributor Author

@izelnakri This is because my field is not called id but uuid. Therefore the belongs_to references the wrong field in the target table.

@maennchen
Copy link
Contributor Author

@izelnakri https://hexdocs.pm/ecto/Ecto.Schema.html#module-schema-attributes

@primary_key {:uuid, :binary_id, autogenerate: true}

@maennchen
Copy link
Contributor Author

@izelnakri I added an example to the README

@izelnakri
Copy link
Owner

izelnakri commented Nov 30, 2020

HI @maennchen, thanks for more information and links. As few changes as it may seem, I had to do few investigations, would like to merge this feature after deep and careful thought. So far, here are my remaining concerns:

  • We should probally call this option(originator_options) with a more explicit name, since it will allow you to change the options passed into the relationship what do you think of calling it originator_relationship_options?

  • I'm bit concerned on how the use-case scenario would play with the rest of what PaperTrail does, or whether it could fall out-of-sync. We probably need a separate test cases where we prove the use-case in code and run Versioning operations on that to verify it passes/serves this use-case well. Thus I would like to hold-off merging this change until we have wide test coverage for this scenario. This could run in our CI as a separate OS process, please have a look at .circleci/config.yml#29.

Thanks again for your suggestions & contributions so far. Looking forward to your tests ;)

@maennchen
Copy link
Contributor Author

@izelnakri

what do you think of calling it originator_relationship_options?

sure, i'll amend the PR

I'm bit concerned on how the use-case scenario would play with the rest of what PaperTrail does

The relationship itself is completely handled by ecto. If we do not touch private ecto APIs (which we're not), this does not have any direct impact on the library.

I can add a test that uses this behaviour, but I don't think that this needs more than on test that tests if the relationship is correctly resolved.

@maennchen
Copy link
Contributor Author

@izelnakri Test is added.

@izelnakri
Copy link
Owner

@maennchen reviewed and run the tests. All good merging and cutting a release now. Thanks!

@izelnakri izelnakri merged commit 1e7dd40 into izelnakri:master Dec 4, 2020
@maennchen maennchen deleted the originator_options branch December 4, 2020 07:51
mayel pushed a commit to bonfire-networks/paper_trail that referenced this pull request Jun 26, 2023
also adds better support for :binary_id UUIDs
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