property values as maps closes #53 #56
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: local-it/mitgliederverwaltung#56
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "property_values"
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?
boolean type does not work for any reason.
WIP: property values as mapsto WIP: property values as maps closes #53Excellent work :) I think we can even build SQL expressions for individual property values in maps stored as json.
@ -11,2 +11,3 @@"property_type_id" => pt.id,"value" => nil"value" => %{"type" => String.to_existing_atom(pt.type),We could make this more convenient by storing
PropertyType.typeas an atom or an enum :)https://hexdocs.pm/ash/Ash.Type.Atom.html
https://hexdocs.pm/ash/Ash.Type.Enum.html
@ -36,2 +40,3 @@<% type = Enum.find(@property_types, &(&1.id == f_property[:property_type_id].value)) %><.input field={f_property[:value]} label={type && type.name} /><.inputs_for :let={value_form} field={f_property[:value]}><.input field={value_form[:value]} label={type && type.name} />Adding a
type="checkbox"parameter for boolean properties should make booleans correctly show up in the update form here.@ -0,0 +1,19 @@#!/bin/bashYou can embed this script as a task in the Justfile: https://github.com/casey/just/?tab=readme-ov-file#shebang-recipes
d085d80f74to83d6b1173d74f980414ato780efc3e91780efc3e91to6a22efce1aWorks like a charm, just had some minor comments but I'd say this is ready to merge :)
@ -40,0 +49,4 @@#!/usr/bin/env bashset -euo pipefail# Pick migrations either from the given commit or untracked filesif [ -n "{{commit_hash}}" ]; thenVery nice 👌
@ -0,0 +1,34 @@defmodule Mv.Membership.Email do@constraints [match: ~r/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/,For things like this, we can also integrate validations from ecto, with some duct-tape: By creating an ad-hoc ecto changeset and applying Ecto's
validate_emailfunction.I don't think it's worth it to do this right now, but we should be aware of the opportunity to do this in the future, as Ecto's validations seem more battle-tested and feature-rich to me.
@ -0,0 +11,4 @@constraints: @constraints@impl truedef cast_input(value, _) when is_binary(value) doWhy does this function get a binary value, is json stored as binary data in the DB? This is confusing to me because you use String functions with
valuebelow 🤔valueis a string: https://hexdocs.pm/elixir/main/binaries-strings-and-charlists.html@ -0,0 +16,4 @@cond do@constraints[:min_length] && String.length(value) < @constraints[:min_length] ->:errorCurrently, this approach always shows an "is invalid" error message when validation fails. I think we should merge this as-is and move on as it's a minor detail, but in the future we could see if we can leverage ash's validations to provide more detailed error messages.
6a22efce1ato859f5f4497WIP: property values as maps closes #53to property values as maps closes #53