Labels
No labels
bug
duplicate
enhancement
help wanted
high priority
invalid
L
low priority
M
medium priority
needs refinement
question
S
UX research
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: local-it/mitgliederverwaltung#81
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/74_memberfields"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
#48
#49
#74
#50
Nice :)
d771e5b579to03da80cca503da80cca5to2ab3332941The last main rebase created this error:
https://drone.dev.local-it.cloud/local-it/mitgliederverwaltung/284/1/7
@moritz wrote in #81 (comment):
Seems like my commit
d54b226bwas a bit too eager. I've opened a MR for reverting it and will check if that fixes the issue.@ -9,6 +9,7 @@ migrate-database:reset-database:mix ash.resetMIX_ENV=test mix ash.setupWhy not use
ash.resethere as well?typo that works as well. but i change it
@ -19,1 +36,4 @@destroy :destroy doprimary? truechange Ash.Resource.Change.Builtins.cascade_destroy(:properties)I think this will run using ash's "notifiers", and as such will run outside the transaction used for the destroy itself. This means that we could end up with errors if postgres detects that a property does not have an associated member.
Also, I think the "references" block in the property's postgres configuration should take make this line obsolete because it tells postgres to cascade delete properties when a member is deleted? 🤔
I tried different approaches to get the cascade deletion working. I think in the end the postgres reference block has done the job and this is still a leftover. I will try to run it without this change.
Seems that properties are deleted using default :destroy with the reference block
@ -28,0 +87,4 @@validate fn changeset, _ ->join_date = Ash.Changeset.get_attribute(changeset, :join_date)if join_date && Date.compare(join_date, Date.utc_today()) == :gt doI'm fine with doing this using custom validations as I think "real" code is easier to read than DSLs - but I think if we wanted to, we could achieve this in a more concise way using ash's built-in compare validation, e.g.:
Not sure if I got the syntax exactly right, but I hope you get what I mean. I think this approach would work for other custom validations in this file as well, e.g. using the built-in
matchvalidation for regexes.One advantage of using the built-in validations is that they are "atomic", meaning they can run in the database directly, which can improve performance.
Thank you for the hint, I will apply it and test if it works.
Maybe not from a technical but from a user perspective: Why should it not be possible to add members already, where the membership starts maybe beginning of next month? Should we take the question to the Pilotvereine?
@ -28,0 +132,4 @@validate fn changeset, _ ->paid = Ash.Changeset.get_attribute(changeset, :paid)if not is_nil(paid) and not is_boolean(paid) doI don't think this works the way it appears: If I remove the
type="checkbox"attribute in the paid form field, and e.g. enter "not a boolean" instead of "true" or "false", I get back an "is invalid" error. This hints to me that the validate function does not get called if the input does not cast to the required attribute type. There's a hint buried in the ash docs:Should we omit that validation? Because we define "paid" as boolean and I think using
type="checkbox"should not be removed anywhere or am I wrong?Just realized that my comment was very unspecific about what to change :D I think we can omit the validation, because ash already ensures that the attribute is a boolean, because the attribute definition marks it as the type
:boolean. We should not remove thetype="checkbox", that was just what I did to be able to send invalid data to the server.@ -31,3 +217,3 @@relationships dohas_many :properties, Mv.Membership.Propertyhas_many :properties, Mv.Membership.Property, destination_attribute: :member_idAFAIK
:member_idis the defaultdestination_attribute, why is this addition needed?As mentioned above, this is also a leftover of getting the deletion to work.