Giter Site home page Giter Site logo

Comments (5)

rikbruil avatar rikbruil commented on June 2, 2024 2

FYI: I think the fix for this issue has just been merged to master :)

Instead of doing $results = $repo->match($spec); you can now also do $query = $repo->getQuery($spec); which solves this issue. You can now ask for a Query object if you need it or use match if you just want results.

from doctrine-specification.

Nyholm avatar Nyholm commented on June 2, 2024

I've not considered that issue. Thank you.

I've been doing some thinking on this issue the last week but I have not come up with any good generic solution. I don't believe adding a third parameter is a good solution because I don't want to add a fourth parameter when the other feature X comes around.

I was thinking of refactor EntitySpecificationRepositoryTrait::match somehow. But does only contain a few lines of code...

$specification->modify($qb, $alias);
$query = $qb->where($specification->getFilter($qb, $alias))->getQuery();

if ($modifier !== null) {
    $modifier->modify($query);
}

I would suggest you to write your own EntitySpecificationRepository and implement your version of match there.

from doctrine-specification.

jproffitt3ge avatar jproffitt3ge commented on June 2, 2024

How I handled this problem was I created a second method "getPaginator" to
the entity repository as you suggested, which takes the same parameters as
"match". To avoid repetition I moved the query building out to a protected
"getSpecificationQuery" method.

Justin Proffitt
Lead Web Programmer
719.964.7350 voice/text
LEGAL CONFIDENTIAL: All information in this e-mail and in any attachment
contains information which is legally privileged. It is provided only for
the attention and use of the named recipient. If you are not the intended
recipient, you are not authorized to retain, disclose, copy or distribute
the message and/or any of its attachments.

On Tue, Mar 17, 2015 at 5:54 AM, Tobias Nyholm [email protected]
wrote:

I've not considered that issue. Thank you.

I've been doing some thinking on this issue the last week but I have not
come up with any good generic solution. I don't believe adding a third
parameter is a good solution because I don't want to add a fourth parameter
when the other feature X comes around.

I was thinking of refactor EntitySpecificationRepositoryTrait::match
somehow. But does only contain a few lines of code...

$specification->modify($qb, $alias);$query = $qb->where($specification->getFilter($qb, $alias))->getQuery();if ($modifier !== null) { $modifier->modify($query);}

I would suggest you to write your own EntitySpecificationRepository and
implement your version of match there.


Reply to this email directly or view it on GitHub
#85 (comment)
.

from doctrine-specification.

Nyholm avatar Nyholm commented on June 2, 2024

What if match() retured the Query instead of executing it?

from doctrine-specification.

drewclauson avatar drewclauson commented on June 2, 2024

Would it be overkill to let match() continue to execute the query but have a different function return the Query or QueryBuilder instead? (I've been using the match quite a bit in code that I plan to deploy to production but obviously refactoring to execute the query isn't that crazy.) I haven't used the Paginator but could see it being useful at some point.

from doctrine-specification.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.