lunar icon indicating copy to clipboard operation
lunar copied to clipboard

You cannot safely search for a Collection

Open webpatser opened this issue 1 year ago • 2 comments

  • Lunar version: 1.0-dev
  • Laravel Version: 10.0.43
  • PHP Version: 8.3.2
  • Database Driver & Version: MariaDB

Expected Behaviour:

When I am building up a Collection Structure via an import script. I want to search on exact names and filter on parent_id to get the exact first hit so I can build up the collection tree.

Actual Behaviour:

Since the names are hidden in the attributes field and no handle or some identifiable name is stored directly in the table, you can only search for the name via Scout. But in the database index you cannot filter on parent_id. Also it not always gives the correct result; if you Collection name has spaces in it, the search results are based on a word level. You cannot set it to match the whole string.

I also now have to cache the Parent CollectionIDs in the import script. I rather lookup it fresh so I know I have the correct one, but that's not possible.

Steps To Reproduce:

https://docs-v1.lunarphp.io/core/reference/collections.html#collections-1

I would love to see a name and handle in the Collection table. Just like in all other models. And use attributes for translations and other metadata.

webpatser avatar Jan 31 '24 09:01 webpatser

Could you not use a where clause on the json column? https://laravel.com/docs/10.x/queries#json-where-clauses

Or if you have the parent_id you could just get the collection by it's ID, unless I'm missing something there.

alecritson avatar Jan 31 '24 10:01 alecritson

We have discussed this previously, so this is a good reminder. We wanted to pull out the name attributes (and maybe handle, if required) into dedicated fields.

glennjacobs avatar Jan 31 '24 11:01 glennjacobs

Closing as we already have this planned for the 1.0.0 beta release.

glennjacobs avatar May 20 '24 12:05 glennjacobs