spacebat
`string_join` expression failing when first argument is not a literal list of strings
I have a resource with an attribute that is an array of strings. Calculations on these arrays seem inconsistent:
attribute :tags, {:array, :string}, allow_nil?: false
Some calculations:
calculate :num_tags, :integer, expr(length(tags))
calculate :all_tags, :string, expr(string_join(tags, ", "))
calculate :reverse_tags, {:array, :string}, expr(lazy({__MODULE__, :reverse, [tags]}))
Loading :num_tags works, but loading :all_tags raises:
(Protocol.UndefinedError) protocol Enumerable not implemented for drivers of type Ash.Query.Ref (a struct)
If I substitute a literal list of strings the expression works.
When I include the third calculation it fails to compile, undefined variable “tags”, but if I wrap it to be [expr(tags)] then it compiled but I’m back to the Protocol.UndefinedError above, and yet it works with a literal list of strings.
It looks like some calculations on compound attributes don’t work. I’m using ash 2.21.12 and ash_postgres 1.5.23.
Most Liked
zachdaniel
I’ve pushed a fix for the string_join calculation only working with literal values to both the latest 3.0 release candidate and the 2.0 branch.
We’ll need to look into the lazy separately, since I’m not quite sure how related or unrelated to this issue it is. Lets start a new GH issue or thread if you still have issues after upgrading.
Popular in Questions
Other popular topics
Latest Ash Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security










