perch-query-builder
perch-query-builder copied to clipboard
Implement `@SelectAlways()` decorator
This is related to the (closed) issue https://github.com/wesleyyoung/perch-query-builder/issues/8. This PR implements my proposal of a @SelectAlways() decorator for columns.
I found that if using, for example, an @AfterLoad() that depends on fields in the entity, it would be cleaner to use a decorator instead of manually adding addSelects for the fields (like you suggested). I originally considered to encapsulate the PerchQuerybuilder.generateQueryBuilder() with a custom function in order to add the selects, however, I don't think it is ideal to hardcode a list of fields that should be selected, thus this PR.
This implementation only force-selects the column when its class relation is in the query:
parent (in query)
child (not in query)
property (not selected)
parent (in query)
child (in query)
property (selected)