Implemented size, addSelect and memberOf DQL functions
yaffol opened this issue · 5 comments
Hi, this is a great project - thanks for all the hard work in making it!
I'm using it in production, and found a need to add support for DQL member of, size and addSelect functions. So I forked and implemented those.
Before submitting a PR I wanted to check that these are features of interest, and that the way they've been implemented is OK.
The comparison order (left/right operator) is effectively flipped for a member of comparison (generating 'value MEMBER OF dqlalias.field' rather than for example 'dqlalias.field LIKE value'). I've implemented the check for this in a slightly hacky way within the Filter/Comparison class. I'd be open to suggestions as to how to do it better, but didn't want to refactor the base Comparison class without reaching out first.
Again, thanks for this great project, and hopefully these features may be of use to some other people - they are certainly making my life easier!
I realised that the easiest way to review this was as a pull request, probably! So I've submitted #164
Now you can using select
and addSelect
in specification:
$spec = Spec::andX(
Spec::select('field_name1'),
Spec::addSelect('field_name2')
)
Also you can use Doctrine functions in specification:
$spec = Spec::gt(Spec::SIZE('my_field'), 0);