Typed array attributes from `ash.gen.resource`

Hey guys, can array attributes be typed in Ash via generators? When I run this:
mix ash.gen.resource MyApp.MyDomain.MyThing --attribute my_list:{array,string}:public
mix ash.gen.resource MyApp.MyDomain.MyThing --attribute my_list:{array,string}:public
I get something like this: project/lib/my_app/my_domain/my_thing.ex
attribute :my_list, :array do # where string?
public? true
end
attribute :my_list, :array do # where string?
public? true
end
I tried doing --attribute my_list:{:array,:string} but it gives me a compile error about array not being a recognized attribute modifier
5 Replies
ZachDaniel
ZachDaniel3mo ago
Yeah we probably need to add a modifier for it Please open an issue or a PR
Gonzalo Muñoz
Gonzalo MuñozOP3mo ago
Alright, thanks! I don't even know how to use the thing yet so for now it'll be just an issue, I'll owe you a PR 😄 Is it a bug report or a feature proposal?
Gonzalo Muñoz
Gonzalo MuñozOP3mo ago
GitHub
Generate typed array attributes from ash.gen.resource · Issue #2...
Code of Conduct I agree to follow this project's Code of Conduct AI Policy I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue. Is your fea...
ken-kost
ken-kost3mo ago
made something as always - not sure about the approach. I wish there was something like find and pop for lists. 🐛 the example you gave is tricky, because the attribute option is a csv and is split by comma. which makes {array,string} also split. my solution makes it be used like so: list_string:string:array:required
Gonzalo Muñoz
Gonzalo MuñozOP3mo ago
Yeah as long as it works I don't care about the syntax. I just assumed it already existed because that is the only way it didn't give me an error so I thought it was parsing the arguments ok but not doing anything about it I like th array[string] suggestion though. Sounds more idiomatic Thanks BTW 🙌

Did you find this page helpful?