rikbruil / Doctrine-Specification

Doctrine Specification pattern for building queries dynamically and with re-usable classes for composition.
MIT License
50 stars 7 forks source link

Add countMatching() #15

Open holtkamp opened 7 years ago

holtkamp commented 7 years ago

This allows simple counting functionality which return a single scalar result:

return (int) $this->countMatching($specification)->getSingleScalarResult();
coveralls commented 7 years ago

Coverage Status

Coverage decreased (-3.8%) to 95.804% when pulling b4e550703586bc3535117132a388f3a2cd18b3dd on holtkamp:patch-2 into 4a53c7ac1c6c332a0eabf61376281ee968691cbb on rikbruil:master.

holtkamp commented 7 years ago

@rikbruil sorry for the lack of any tests. I had a look at existing tests / specifications, but this is quite complex for me at this point... No idea on how the added functionality should be tested...

Instead of a complete SELECT e FROM entity only a SELECT count(e) FROM entity is generated... hope the idea is clear.

rikbruil commented 7 years ago

I will take a look at making the coverage better

holtkamp commented 7 years ago

@rikbruil hey Rik, I am cleaning up "custom" code and I encountered this pending PR, would/could you consider merging it?

holtkamp commented 4 years ago

Small reminder here as well

holtkamp commented 3 years ago

Hi @rikbruil, are you still using this library? Still very powerful I would say...

rikbruil commented 3 years ago

@holtkamp Hey Menno, sorry for the lack of responses here... I keep reading the notifications on my phone and then later forget them when I'm behind a keyboard again.

Yeah my employer is still using this in production, although personally I don't work that often with this library anymore since I'm rarely touching Doctrine lately. That's also why I've been a bit hesitant merging changes lately, since I'm not personally using it and can't directly see the impact of a merge on our production environment (unless the added code is covered well with tests).

I remember I looked into the coverage for this PR before, but I don't remember having a fix for it. I will take another look in the evening and get back to you here. Also, if you are still using this library a lot perhaps I could consider making you a maintainer as well? (if that's possible, I'm not sure on this).

Because I would hate for my late responses to block you if you are trying to use this library in production as well.

holtkamp commented 3 years ago

@rikbruil no problemo and I fully understand.

Yes I use the library a lot and love the charm of it. So I am flattered for being asked as a maintainer. Stuff like static analysis and using GitHub Actions to trigger them would be nice to have and things I might be able to contribute....