Comments (9)
I would find that useful, as I'm manually checking for that scenario in several cases at this point. An exception would be easier to handle IMHO.
from doctrine-specification.
Thank you for this suggestion. I like the idea.
If I'm not misremembering there are a way of achieving this. Does the behavior for matchOne differ from using the following?
// Will throw a NoResultException if nothing found
$oneResult = $repo->match(Spec::andX(
new MySpec(),
Spec::limit(1)
), Spec::asSingle());
from doctrine-specification.
I didn't know about that. That would do the trick, except that AsSingle
uses Query::HYDRATE_SINGLE_SCALAR
so it throws a Doctrine\ORM\NonUniqueResultException
for objects.
Changing the hydration mode would be a BC breaking change. Perhaps Spec::asSingle(AsSingle::OBJECT)
, but then the API is starting to look a bit untidy. What are your thoughts?
from doctrine-specification.
Lets introduce Spec::asSingleScalar
and rewrite Spec::asSingle
. Would that work?
Please send a PR if you want to.
from doctrine-specification.
Yes, that would work. Would you also want matchOne
as syntactic sugar for Spec::asSingle
, or just the one method?
from doctrine-specification.
Im not too sure if about introducing matchOne
on the EntitySpecificationRepositoryTrait
. I want to try to solve problems using Specifications.
from doctrine-specification.
Okay, no problem.
from doctrine-specification.
Fixed by #113
from doctrine-specification.
I've tagged version 0.6.1 which includes this feature.
from doctrine-specification.
Related Issues (20)
- Need remove not used vars in RoundDateTimeSpec
- Add createQueryBuilder() abstract method in EntitySpecificationRepositoryTrait HOT 1
- Remove AbstractJoin::getJoinType() method HOT 1
- [Syntax Error] line 0, col -1: Error: Expected Literal, got end of string. HOT 1
- Mysql substring function bug HOT 1
- Disable Style CI HOT 3
- Release 2.0.0 HOT 1
- Check single entity satisfiability HOT 8
- DATE_ADD() and DATE_SUB() platform functions does not work HOT 1
- TRIM() platform functions does not support options HOT 1
- Best practices and architectural decissions HOT 5
- Use defaultRepositoryClassName instead of the RepositoryFactory HOT 4
- Using subqueries HOT 5
- Always use a unique aliases to prevent cases in which we have auto-joining and reserved keywords as context HOT 4
- Psalm annotations HOT 5
- A bit confused about the proper use of `$context` HOT 2
- Customize JOIN HOT 1
- Auto-joins with dot notation HOT 7
- Symfony 6 HOT 1
- How to set Query::HINT? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from doctrine-specification.