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

Not able to update custom attribute with listValues existing in assets #565

Open
bfis108137 opened this issue Feb 11, 2021 · 3 comments
Open

Comments

@bfis108137
Copy link

When I go to edit the listValues in a custom attribute (of tags/select type) that is in use on an asset it won't let me. It returns error

@bfis108137
Copy link
Author

I found the issue but still I think it's a bug. If you have the item as null on an asset it can't be edited. I am just going to fix this on my end. I will let you guys decide.

@woyuen
Copy link
Member

woyuen commented Feb 16, 2021

Hi @bfis108137, thanks for your feedback.

Indeed, a custom attribute with tags/select type will only allow values specified within listValues. That's by design and that's normal an error is returned.

The problem with null you mention probably comes from this line

const [{ count: nbAssets }] = await Asset.query().count().whereJsonNotSubsetOf(key, listValues)
where we check if the new listValues include all current usage.

An exception should probably be made for null. A fix adding it internally automatically to the list could be:

const [{ count: nbAssets }] = await Asset.query().count().whereJsonNotSubsetOf(key, _.uniqBy(listValues.concat(null)))

Would that fix your issue ?

@bfis108137
Copy link
Author

What I am saying is that I was able to save a null value to the tags custom attribute and once I wanted to add to the list I was not able to due to the null value. Personally allowing to change the list when there are null values seems acceptable but a null exception is also an idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants