[DDC-3763] Passing "false" boolean value to eq() function in query builder does not end up SQL query Created: 09/Jun/15  Updated: 09/Jun/15  Resolved: 09/Jun/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4.7
Fix Version/s: None
Security Level: All

Type: Bug Priority: Trivial
Reporter: Danijel Assignee: Marco Pivetta
Resolution: Duplicate Votes: 0
Labels: querybuilder

Issue Links:
Duplicate
duplicates DDC-3762 Passing "false" boolean value to eq()... Resolved

 Description   

$qb->andWhere($qb->expr()->eq('d.active', true));

produces:

[_dql:Doctrine\ORM\Query:private] => SELECT COUNT(r.id) FROM Game:Roll r INNER JOIN r.hand d WHERE d.userId = :userId AND d.active = 1

$qb->andWhere($qb->expr()->eq('d.active', false));

produces:

[_dql:Doctrine\ORM\Query:private] => SELECT COUNT(r.id) FROM Game:Roll r INNER JOIN r.hand d WHERE d.userId = :userId AND d.active =

and this query fails with an error:

[Syntax Error] line 0, col -1: Error: Expected Literal, got end of string.

As a workaround I am using 1 and 0 instead of "true" and "false"






[DDC-3762] Passing "false" boolean value to eq() function in query builder does not end up SQL query Created: 09/Jun/15  Updated: 09/Jun/15  Resolved: 09/Jun/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4.7
Fix Version/s: None
Security Level: All

Type: Bug Priority: Trivial
Reporter: Danijel Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: querybuilder

Issue Links:
Duplicate
is duplicated by DDC-3763 Passing "false" boolean value to eq()... Resolved

 Description   
$qb->andWhere($qb->expr()->eq('d.active', true));

produces:

   [_dql:Doctrine\ORM\Query:private] => SELECT COUNT(r.id) FROM Game:Roll r INNER JOIN r.hand d WHERE d.userId = :userId AND d.active = 1
$qb->andWhere($qb->expr()->eq('d.active', false));

produces:

   [_dql:Doctrine\ORM\Query:private] => SELECT COUNT(r.id) FROM Game:Roll r INNER JOIN r.hand d WHERE d.userId = :userId AND d.active = 

and this query fails with an error:

[Syntax Error] line 0, col -1: Error: Expected Literal, got end of string.

As a workaround I am using 1 and 0 instead of "true" and "false"



 Comments   
Comment by Marco Pivetta [ 09/Jun/15 ]

You are not using parameter binding. Expressions use string concatenation internally, so this outcome is actually expected. Instead, you should do following:

$qb->andWhere($qb->expr()->eq('a.field', ':key'));
$qb->setParameter('key', false);




[DDC-3720] Doctrine - Invalid column name 'sclr0' Created: 29/Apr/15  Updated: 25/Jun/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: None
Fix Version/s: 2.5.1
Security Level: All

Type: Task Priority: Major
Reporter: Belita Colares Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: querybuilder


 Description   

My query doesn't work when i use ->setMaxResult with orderBy SUM.

My dataBase is MSSQL SERVER 2008 R2

$query = $entity->createQueryBuilder('t')
                        ->select('SUM(t.price) AS test')
                        ->setMaxResults(10)
 ->orderBy('test', 'ASC')->getQuery()->getResult();

when i use only
'->select('t.price AS test') ->setMaxResults(10) ->orderBy('test', 'ASC');' doesn't work too

Invalid column name 'sclr0'.
but when i comment this method setMaxResult() my query works fine.

Please help-me, I sorry my english.






[DDC-3587] [GH-1313] Added programmatical support to define indexBy on root aliases. Created: 25/Feb/15  Updated: 25/Feb/15  Resolved: 25/Feb/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Guilherme Blanco
Resolution: Fixed Votes: 0
Labels: index-by, querybuilder


 Description   

This issue is created automatically through a Github pull request on behalf of guilhermeblanco:

Url: https://github.com/doctrine/doctrine2/pull/1313

Message:



 Comments   
Comment by Doctrine Bot [ 25/Feb/15 ]

A related Github Pull-Request [GH-1313] was assigned:
https://github.com/doctrine/doctrine2/pull/1313

Comment by Doctrine Bot [ 25/Feb/15 ]

A related Github Pull-Request [GH-1313] was merged:
https://github.com/doctrine/doctrine2/pull/1313





[DDC-3573] DateTime objects casted to string when used in aggregate functions in query results Created: 18/Feb/15  Updated: 18/Feb/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.3.4
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Ameer Antar Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: dbal, mysql, orm, querybuilder
Environment:

MySQL, possibly others



 Description   

Similar to DDC-657: http://www.doctrine-project.org/jira/browse/DDC-657

DateTime objects are converted to strings when selecting them through an aggregate function.

Example:

Update.php Column definition
    /**
     * @var \DateTime
     * @ORM\Column(name="entryDate", type="datetime")
     */
    private $entryDate;
Query Builder
		$qb = $this->getEntityManager()->createQueryBuilder();
		$qb->select('u.code, max(u.entryDate) as updateDate');
		$qb->from('Update', 'u');
		$qb->addGroupBy('u.code');

		var_dump( $qb->getQuery()->getResult() );

The result contains the date/times as strings not DateTime objects as expected. This affects the query builder. I assume it also affects DQL queries.






[DDC-3567] [GH-1303] make QueryBuilder::getAllAliases public Created: 14/Feb/15  Updated: 17/Mar/15  Resolved: 17/Mar/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: New Feature Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: alias, dql, query-builder, querybuilder


 Description   

This issue is created automatically through a Github pull request on behalf of mrkrstphr:

Url: https://github.com/doctrine/doctrine2/pull/1303

Message:

Being able to get all already defined aliases in the QueryBuilder can be helpful when dynamically joining.

Funny, the DocBlock makes it seem as if this method was already public.



 Comments   
Comment by Doctrine Bot [ 17/Mar/15 ]

A related Github Pull-Request [GH-1303] was unlabeled:
https://github.com/doctrine/doctrine2/pull/1303

Comment by Doctrine Bot [ 17/Mar/15 ]

A related Github Pull-Request [GH-1303] was merged:
https://github.com/doctrine/doctrine2/pull/1303





[DDC-3554] [GH-1295] Fix join when recreation of query from parts. Created: 01/Feb/15  Updated: 16/Feb/15  Resolved: 16/Feb/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: Git Master, 2.4.7
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: clone, join, query, querybuilder


 Description   

This issue is created automatically through a Github pull request on behalf of NoUseFreak:

Url: https://github.com/doctrine/doctrine2/pull/1295

Message:



 Comments   
Comment by Doctrine Bot [ 16/Feb/15 ]

A related Github Pull-Request [GH-1295] was closed:
https://github.com/doctrine/doctrine2/pull/1295

Comment by Doctrine Bot [ 16/Feb/15 ]

A related Github Pull-Request [GH-1295] was assigned:
https://github.com/doctrine/doctrine2/pull/1295

Comment by Doctrine Bot [ 16/Feb/15 ]

A related Github Pull-Request [GH-1295] was labeled:
https://github.com/doctrine/doctrine2/pull/1295





[DDC-3553] Create a QueryBuilder from a Query/DQL Created: 01/Feb/15  Updated: 01/Feb/15  Resolved: 01/Feb/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: None
Fix Version/s: None

Type: Documentation Priority: Major
Reporter: Dries De Peuter Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: querybuilder


 Description   

Hi,

I am searching for a way to create a QueryBuilder from an existing Query or a DQL string.

Can I currently do this?

If this is not the case. I would love to create this but I don't see how to parse the DQL into parts.



 Comments   
Comment by Marco Pivetta [ 01/Feb/15 ]

.

Not an issue

Note that the QueryBuilder just assembles strings: there is currently no way to transform DQL into a query builder, as the operation is not bijective.

Comment by Dries De Peuter [ 01/Feb/15 ]

I understand. Is their any way you would suggest allowing a DQL to be altered/extended.





[DDC-3508] andWhere('... OR...') syntax ignores a newly added field Created: 16/Jan/15  Updated: 23/Jan/15  Resolved: 23/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Julien Villetorte Assignee: Guilherme Blanco
Resolution: Invalid Votes: 0
Labels: dql, querybuilder
Environment:

CentOS



 Description   

Doctrine v2.3.6

All caches cleared before reporting.

After adding a new field on an already existing entity (field "question" on a "News" entity), this field is ignored when using the addWhere('.... OR ...') syntax, while it's working using a $qb->expr()->orX() syntax:

Not working (missing "question" column in SELECT of the generated SQL, and objects hydrated with a question's value of null) :

$qb = $this->createQueryBuilder('n');

$qb
    ->where('n.state = :state')
    ->andWhere('n.startAt <= :now')
    ->andWhere('n.endAt >= :now OR n.endAt is NULL') // Ignores the question field, don't know why
    ->setParameter('state', News::ACTIVE)
    ->setParameter('now', new \DateTime())
    ->orderBy('n.createdAt', 'DESC');

This syntax works:

$qb = $this->createQueryBuilder('n');

$qb
    ->where('n.state = :state')
    ->andWhere('n.startAt <= :now')
    ->andWhere($qb->expr()->orX(
        $qb->expr()->gte('n.endAt', ':now'),
        $qb->expr()->isNull('n.endAt')
    ))
    ->setParameter('state', News::ACTIVE)
    ->setParameter('now', new \DateTime())
    ->orderBy('n.createdAt', 'DESC');

Notes:

  • If I add an extra ->addSelect('n.question'), the field shows up twice in the generated SQL.
  • If I remove the orderBy statement or the "OR n.endAt is NULL" part, the field shows up in the SQL.
  • The generated DQL of both queries is exactly the same:
    SELECT n FROM [...]\Entity\News n WHERE n.state = :state AND n.startAt <= :now AND (n.endAt >= :now OR n.endAt IS NULL) ORDER BY n.createdAt DESC
    


 Comments   
Comment by Marco Pivetta [ 23/Jan/15 ]

Julien Villetorte why was this marked as invalid? Was it already fixed in 2.4?





[DDC-3454] [GH-1224] Updated setParameters function for not replace all parameters Created: 17/Dec/14  Updated: 13/Jan/15  Resolved: 13/Jan/15

Status: Closed
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Guilherme Blanco
Resolution: Won't Fix Votes: 0
Labels: dql, query, querybuilder


 Description   

This issue is created automatically through a Github pull request on behalf of uthopiko:

Url: https://github.com/doctrine/doctrine2/pull/1224

Message:

When you create QueryBuilder and you bind some parameters, if you use setParameters function after bind other parameters, previous parameters are removed(https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/QueryBuilder.php#L558). This would not be a problem if it was the same behaviour with the attribute $_parameterMappings (in ParserResult), but it's not the case, given that it keeps the number of parameters introduced, throwing an exception(https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Query.php#L293). To prevent this, I've made it initialize the setParameters with the existing ones.



 Comments   
Comment by Doctrine Bot [ 17/Dec/14 ]

A related Github Pull-Request [GH-1224] was assigned:
https://github.com/doctrine/doctrine2/pull/1224

Comment by Doctrine Bot [ 13/Jan/15 ]

A related Github Pull-Request [GH-1224] was closed:
https://github.com/doctrine/doctrine2/pull/1224





[DDC-3414] Joining on a table with inheritance produces badly formed ON clause Created: 26/Nov/14  Updated: 24/Jan/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.5, 2.4.6
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Lewis Wright Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 1
Labels: inheritance, joins, orm, querybuilder


 Description   

When I join on a table that uses class table inheritance, Doctrine automatically joins on the parent table, but it does it before the ON clause.

So for example, writing this DQL:

SELECT uc, c FROM MyModel\Customer c LEFT JOIN MyModel\Customer uc WITH uc.customer = c

produces:

SELECT 
 # Snipped
FROM 
  customer c0_ 
  LEFT JOIN user_customer u2_ 
  INNER JOIN base_user b1_ ON u2_.id = b1_.id ON (u2_.customer_id = c0_.id)

This syntax for the ON clause looks wrong, and fails in SQLite, so I can only assume it's the result of a bug?



 Comments   
Comment by Marco Pivetta [ 26/Nov/14 ]

Please compare the DQL you wrote by hand with the one generated by the QueryBuilder

Comment by Lewis Wright [ 26/Nov/14 ]

The issue appears not to be with just the query builder, but with the DQL version too (see the updated bug report). Would it help if I made a bare-bones doctrine application demoing the problem?

Actually, what would probably be more helpful is if I added a test to the test suite for this bug. I'll see what I can do.

Comment by Marco Pivetta [ 26/Nov/14 ]

We'd need a functional test to add to the test suite, not a demo app. Sending a pull-request with a failing test case will expose the problem immediately.

Comment by Lewis Wright [ 26/Nov/14 ]

Apologies, I should have read the contribute readme first before submitting the ticket. I've created a pull request here with the failing SQLite tests:

https://github.com/doctrine/doctrine2/pull/1194

I did put this ticket number as the PR subject, but the bot seems to have created another issue here:
http://www.doctrine-project.org/jira/browse/DDC-3415

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1194] was labeled:
https://github.com/doctrine/doctrine2/pull/1194





[DDC-3355] [GH-1164] [QueryBuilder] Remove unused method parameters to run on HHVM/PHP7 Created: 17/Oct/14  Updated: 19/Oct/14  Resolved: 19/Oct/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.3.5, 2.4.6
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: hhvm, querybuilder


 Description   

This issue is created automatically through a Github pull request on behalf of AlphaStream:

Url: https://github.com/doctrine/doctrine2/pull/1164

Message:

PHP5 treats the left part of an assignment to a method parameter as an independent local variable, while HHVM/PHP7 treats it as a reference to the method parameter. This leads to the value of the parameter being changed, which, in turn, causes func_get_args() to return not what is expected.

This commit is a part of the effort to make Symfony run flawlessly on HHVM. This issue causes a bunch of Symfony tests to fail on HHVM.

The master is currently broken, so the best thing I could do was to make sure the number of test failures remained the same after the change.

If possible, please merge this to version 2.2 used by Symfony 2.4.



 Comments   
Comment by Doctrine Bot [ 19/Oct/14 ]

A related Github Pull-Request [GH-1164] was closed:
https://github.com/doctrine/doctrine2/pull/1164





[DDC-3327] [GH-1149] Update Composite.php for HHVM compatibility Created: 26/Sep/14  Updated: 13/Jan/15  Resolved: 13/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: Git Master, 2.4.7
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Won't Fix Votes: 0
Labels: infinite-recursion, querybuilder, segfault


 Description   

This issue is created automatically through a Github pull request on behalf of zhil:

Url: https://github.com/doctrine/doctrine2/pull/1149

Message:

Not sure, why this issue is not founded in unittests, but I got HHVM crushed with message
```
Fatal error: Stack overflow in ...../vendor/doctrine/orm/lib/Doctrine/ORM/Query/Expr/Composite.php on line 58
```
The same issue is being reported here
https://github.com/facebook/hhvm/issues/1747

@LinuxDoku proposed quick patch, which works great for me and its in this PR.

Just in case, if you wonder what trigger this error - here is my repository function, which trigger it
```
public function findOpenTeamTimeEntry($user)
{
$r = $this->createQueryBuilder("t")
->join("t.owner","u")
->where("t.dateEnd IS NULL")
->andWhere("u.id = :user_id")
>setParameter(":user_id",$user>getId())
->getQuery()
->getResult();
if(is_array($r) && count($r))

{ return $r[0]; }

else

{ return false; }

}
```



 Comments   
Comment by Doctrine Bot [ 13/Jan/15 ]

A related Github Pull-Request [GH-1149] was assigned:
https://github.com/doctrine/doctrine2/pull/1149

Comment by Doctrine Bot [ 13/Jan/15 ]

A related Github Pull-Request [GH-1149] was closed:
https://github.com/doctrine/doctrine2/pull/1149

Comment by Marco Pivetta [ 13/Jan/15 ]

Assigning an object to itself can obviously cause infinite recursion: checking for infinite recursion loops throughout the project is not feasible and unpractical.

This is more an abuse of the API rather than an actual bug.





[DDC-3246] [GH-1103] Update Expr.php Created: 09/Aug/14  Updated: 21/Oct/14  Resolved: 21/Oct/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Minor
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Won't Fix Votes: 0
Labels: dql, querybuilder


 Description   

This issue is created automatically through a Github pull request on behalf of romanto:

Url: https://github.com/doctrine/doctrine2/pull/1103

Message:

adding NOT EXISTS statement



 Comments   
Comment by Doctrine Bot [ 18/Aug/14 ]

A related Github Pull-Request [GH-1103] was assigned:
https://github.com/doctrine/doctrine2/pull/1103

Comment by Doctrine Bot [ 21/Oct/14 ]

A related Github Pull-Request [GH-1103] was closed:
https://github.com/doctrine/doctrine2/pull/1103





[DDC-3108] Criteria cannot reference a joined tables' fields when used with an ORM QueryBuilder Created: 30/Apr/14  Updated: 17/Jan/15  Resolved: 17/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL, ORM
Affects Version/s: 2.4.2
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Major
Reporter: Chris Rog Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: criteria, dql, orm, querybuilder

Issue Links:
Reference
is referenced by DDC-3436 [GH-1212] [DDC-3108] Fix regression w... Resolved

 Description   

This regression was introduced in 2.4.2 with the addition of the "rootAlias" stuff. Basically, the hard-coded addition of the rootAlias + "." prevents any Criteria object from referencing any field that isn't on the first table selected.

Example:
// Assume $repo is a valid EntityRepository and $value is some scalar value.
$qb = $repo->createQueryBuilder('T1')->join('T1.field', 'T2');

$criteria = new Comparison('T2.field2', Comparison::EQ, $value);

$qb->addCriteria($criteria);
$dql = $qb->getDQL();

$dql is now (roughly) equal to:
SELECT T1 FROM <entityclass> T1 JOIN T1.field T2 WHERE T1.T2.field2 = <value>

Evaluating this causes QueryExceptions to be thrown; usually something along the lines of "Expected Doctrine\ORM\Query\Lexer::<token>, got '.'"

There's a similar issue involving ordering by a related field for the same reason.



 Comments   
Comment by Marco Pivetta [ 17/Jan/15 ]

Fixed in DDC-3436





[DDC-3034] QueryBuilder invalid number of bound params Created: 17/Mar/14  Updated: 17/Mar/14  Resolved: 17/Mar/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4.2
Fix Version/s: None
Security Level: All

Type: Bug Priority: Minor
Reporter: Mike Zukowsky Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: orm, querybuilder
Environment:

PHP 5.4.16, Zend Framework 2.2.5, Doctrine ORM Module 0.8.0



 Description   
    /**
     * @param int  $companyId
     * @param bool $includeDeleted
     * @return \Doctrine\ORM\QueryBuilder
     */
    public function findCompanySubjects($companyId, $includeDeleted = false)
    {
        $qb=$this->createQueryBuilder('t')
            ->addSelect('owner')
            ->innerJoin('t.owner', 'owner')
            ->innerJoin('owner.company', 'company')
            ->andWhere('t.deleted = :deleted')
            ->andWhere('company.id = :id')
            ->orderBy('t.name', 'asc')

            ->setParameter('deleted', $includeDeleted)
            ->setParameter('id', $companyId)
        ;

        return $qb;
    }

Code above does not work for me. I'm still getting an error "Invalid parameter number: number of bound variables does not match number of tokens". However, bound parameters does work with raw DQL and the Query object.



 Comments   
Comment by Marco Pivetta [ 17/Mar/14 ]

Mike Zukowsky what is the complete DQL that is produced for that query? And does it work with a DQL query written directly (rather than the QB)?

Comment by Mike Zukowsky [ 17/Mar/14 ]

Raw DQL is:

SELECT t, owner FROM Domain\Entity\Subject t INNER JOIN t.owner owner INNER JOIN owner.company company WHERE t.deleted = :deleted AND company.id = :id ORDER BY t.name asc

And yes, it does work with a DQL query written directly:

        // $qb from above

        $query=$qb->getQuery()->setParameters(array(
            'deleted' => $includeDeleted,
            'id'      => $companyId
        ));

        debug($query->getArrayResult()); // returns a list of subjects
Comment by Marco Pivetta [ 17/Mar/14 ]

You are returning the QB in your reported code - I'm pretty sure that some interaction with it is going on at a later point in time.

Could you provide the code that is causing the problem? Otherwise, this doesn't look like a bug to me.





[DDC-2923] Query expressions ALL/ANY/SOME don't seem to work Created: 17/Jan/14  Updated: 09/Feb/14  Resolved: 09/Feb/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL, ORM
Affects Version/s: 2.3.4
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Kees Schepers Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: dql, orm, querybuilder
Environment:

Doctrine 2.3 from a Symfony 2.4 application running on a Ubuntu 12.04 machine onder Apache / PHP.



 Description   

It seems that the query expressions ALL() / ANY() / SOME() don't work (anymore). See my testcase and the error on my stackoverflow question:

http://stackoverflow.com/questions/21184374/doctrine-any-all-some-doesnt-work

The exception is thrown in the Query/Parser.php (line: 3040) since the functions are not mapped in the parser class as string functions.

What goes wrong?



 Comments   
Comment by Marco Pivetta [ 20/Jan/14 ]

Tests seem to cover this use case at https://github.com/doctrine/doctrine2/blob/a83f5df47c463cd64a2525274c97812e04a8eca5/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php#L418-L426 - try using plain DQL instead of the query builder first - may be a problem with the QB

Comment by Steve Müller [ 20/Jan/14 ]

Kees Schepers You use the expression wrong. ALL/ANY/SOME expression needs another expression to compare against. Something like:

SELECT * FROM foo WHERE ALL(SELECT bar.id FROM bar WHERE bar.id > 100)

is not valid SQL.

What you want is something like:

SELECT * FROM foo WHERE foo.id > ALL(SELECT bar.id FROM bar WHERE bar.id > 100)

I hope you get what I mean, I don't know exactly what you supposed your query to do but I hope you get the point. This is not a Doctrine bug.

See here for an example with the query builder: https://github.com/doctrine/doctrine2/blob/a83f5df47c463cd64a2525274c97812e04a8eca5/tests/Doctrine/Tests/ORM/QueryBuilderTest.php#L716-L729

Comment by Benjamin Eberlei [ 09/Feb/14 ]

Not an issue, the `andWhere($expr->all())` usage is wrong.





[DDC-2322] [GH-592] Added ability to specify INDEX BY when creating a QueryBuilder from a Repository Created: 27/Feb/13  Updated: 01/May/14  Resolved: 12/Mar/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.2, 2.3, Git Master
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Minor
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: QueryBuilder, Repository


 Description   

This issue is created automatically through a Github pull request on behalf of cmenning:

Url: https://github.com/doctrine/doctrine2/pull/592

Message:

This is a handy shortcut when using indexed results.



 Comments   
Comment by Benjamin Eberlei [ 12/Mar/13 ]

A related Github Pull-Request [GH-592] was closed
https://github.com/doctrine/doctrine2/pull/592

Comment by Craig Menning [ 12/Mar/13 ]

I disagree with the reasoning behind closing this request. In DoctrineBundle,

getDoctrine()->getEntityManager()

has been deprecated, which leaves you to use

getDoctrine()->getRepository($class)->createQueryBuilder();

Adding ->from() at that point is redundant since it's already been specified inside the createQueryBuilder() call. It seems wasteful to not allow a passthru of the $indexBy argument during the initial call when it's already supported by the from() called inside createQueryBuilder().

Comment by Marco Pivetta [ 12/Mar/13 ]

The repository is already (probably) doing too much. A simpler approach with:

$qb = $em->createQueryBuilder()->select('e')->from($repo->getClassName(), 'e', 'e.stuff')

Is no big deal in my opinion.

Comment by Doctrine Bot [ 01/May/14 ]

A related Github Pull-Request [GH-592] was closed:
https://github.com/doctrine/dbal/pull/592





[DDC-2140] [GH-512] Added addParameters() to Query and QueryBuilder Created: 13/Nov/12  Updated: 08/Feb/14

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3, Git Master
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Minor
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: Query,, QueryBuilder
Environment:

OS X 10.8.2, PHP 5.3.18, Nginx 1.2.4 (php through FPM)



 Description   

This issue is created automatically through a Github pull request on behalf of jappie:

Url: https://github.com/doctrine/doctrine2/pull/512

Message:

This method behaves like setParameters() before version 2.3:
It will add new parameters to the collection, and override any existing positions/names.

It can take a Doctrine\Common\Collections\ArrayCollection with Doctrine\ORM\Query\Parameter objects, as well as a plain array with key/value pairs, as argument.

This will greatly ease the upgrade to Doctrine 2.3, because you only need to perform a project-wide replace of setParameters with addParameters, in stead of going into your code and determine if calls to setParameters are ok or need refactoring.

I've also added unit-tests to maintain integrity.



 Comments   
Comment by Benjamin Eberlei [ 20/Nov/12 ]

A related Github Pull-Request [GH-512] was closed
https://github.com/doctrine/doctrine2/pull/512

Comment by Jasper N. Brouwer [ 20/Nov/12 ]

I don't feel strong need to have such an API.
If you want to keep track and merge collection of parameters, all you have to do is create an array (or an ArrayCollection), manipulate the instance and then setParameters at the end.
Unless you give me a stronger argument, this code won't be in. Closing for now.

Hi Guilherme,

I agree that such a method makes less sense in Query, because when you write a DQL string all parameters are known at once. But when using the QueryBuilder you might need different parameters in different cases, so addParameters() becomes useful there.

I guess it's just a convenience method, like IMHO setParameter() is. (You could just do $qb->getParameters()->add())

The main reason for adding the method was, like I said, upgrading to Doctrine 2.3. I've already upgraded all my projects to Doctrine 2.3, so the method is less useful for me now. But it took me a full day to refactor my repositories, because there is no safe way to automate the process. A simple search-and-replace setParameters() to addParameters() would have taken me 5 minutes

I'm content with your decision.
If others find addParameters() useful, I hope they let us know.

Comment by Doctrine Bot [ 08/Feb/14 ]

A related Github Pull-Request [GH-512] was closed:
https://github.com/doctrine/dbal/pull/512





Generated at Sun Jul 05 00:25:10 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.