[DDC-274] Class and namespace naming inconsistency Created: 24/Jan/10 Updated: 31/Oct/10 |
|
| Status: | In Progress |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.0-ALPHA4 |
| Fix Version/s: | 2.0-RC1 |
| Security Level: | All |
| Type: | Improvement | Priority: | Critical |
| Reporter: | Glen Ainscow | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
There are inconsistencies with some class and namespace names that include acronyms. Examples: Classes with upper-casing: Classes with proper-casing: Namespaces with upper-casing: Namespaces with proper-casing: There is more proper-casing than upper-casing. IMHO, proper-casing is better as it's easier to read "SqlException" than it is to read "SQLException" (the "E" looks like part of the acronym), and things like "CLITask" can be avoided. I discussed this a bit with Benjamin and Guilherme, and they were unsure and said that the whole team needed to reach consensus. I'm leaving the priority as "Major" because this should probably be fixed sooner rather than later to prevent compatibility breaks. |
| Comments |
| Comment by Guilherme Blanco [ 25/Jan/10 ] |
|
Increasing the severity and adding a fix version since this MUST be fixed before next release. |
| Comment by Roman S. Borschel [ 25/Jan/10 ] |
|
I find this to be of rather minor importance. You're talking of compatibility breaks, but thats only the case if we intend to start being very nitpicky about the naming in the future. We are currently not, and we wont be, so not much risk of later breakage. We have a rule of thumb already: Acronyms up to 4 characters all uppercase, otherwise normal camelcase. Now, it is often a matter of taste what is an acronym and what not and also not all acronyms have a clear casing, prime example mysql. Being too nit-picky here is just a pain in the ass and we won't reach a common consensus anyway. |
| Comment by Roman S. Borschel [ 25/Jan/10 ] |
|
Oh and we better dont start arguing about whats better to read because there is no chance of agreement. If you ask me I find SQLException better than SqlException. So here we go. Lets better not run down this path. |
| Comment by Glen Ainscow [ 25/Jan/10 ] |
|
No need to get upset, I'm only trying to help. I just thought that consistency is usually a good idea, either way. I have to disagree in that an acronym is an acronym, it's not a matter of taste, the letters either stand for something, or they don't. As for "mysql", only the SQL part is an acronym. So, MySQL or MySql. Close if you disagree. |
| Comment by Roman S. Borschel [ 25/Jan/10 ] |
|
I'm not upset. What made you think so? Maybe I should introduce a There's just no point in arguing about readability. Like I said, we do have a naming standard even if its not adhered everywhere. The standard is also not something we've made up ourselves because we try to avoid that. When we introduced namespaces, we talked about adopting either the Java or .NET naming standards. We opted for the .NET standards. And there its recommended to write acronyms with up to 4 characters all uppercase. I dont think there are too many violations of that in the code, probably Cli => CLI and some others but most of it looks ok to me. UPDATE: Maybe we can gather a list here in this ticket of violations? Cli => CLI would be one. MySql => MySQL another. "Id" is rather an abbreviation of Identifier and not an acronym, to me at least. |
| Comment by Guilherme Blanco [ 25/Jan/10 ] |
|
It's not a case of getting anyone upset... But we should fix it and keep consistency of our codebase. @romanb We should all talk and reach a common sense. |
| Comment by Roman S. Borschel [ 25/Jan/10 ] |
|
@Guilherme: We do have a naming standard since a year. You want to change the standard now? |
| Comment by Glen Ainscow [ 25/Jan/10 ] |
|
@Roman, Just a feeling I got. This issue was more about consistency (indicated in the title) than moving to proper-case naming. I think it might be up to 3 characters in .NET, HtmlElement, System.Linq, etc. Anyway, not important. I agree that Id. is an abbreviation. There are some more violations. If you decide you want to change them, let me know and I'll compile a list. |
| Comment by Roman S. Borschel [ 25/Jan/10 ] |
|
@Glen: Yes, a list would be great. I find it hard to be 100% consistent sometimes though because my taste conflicts with the rule. For example, I would prefer "Id" over "ID", especially since it comes directly after ORM "Doctrine\ORM\ID\..." would be a bit too much. But I would not like "Orm" or "Dbal" either. But I think in most cases we can clearly fix the inconsistency. Like CLI or MySQL or MSSQL (or should it be MsSQL?). Thanks for your help! We should probably create updated coding standards for Doctrine 2 also, since they differ quite some from Doctrine 1 due to the introduction of namespaces and such. I'll create a ticket for that. |
| Comment by Glen Ainscow [ 25/Jan/10 ] |
|
I'll do the list for you by tomorrow at the latest, just running out of time ATM. Id is correct, as mentioned above, so that would be fine. MsSQL is correct (Ms = Microsoft = abbreviation). |
| Comment by Glen Ainscow [ 25/Jan/10 ] |
|
Found some time ... Doctrine\Common\Cache\ApcCache -> APCCache Doctrine\DBAL\Driver\PDOMsSql -> PDOMsSQL Doctrine\ORM\Mapping\Driver\PhpDriver -> PHPDriver ... I think that's it. More than you expected? I did say: "There is more proper-casing than upper-casing." |
| Comment by Roman S. Borschel [ 25/Jan/10 ] |
|
No, not more than I expected. It's mostly SQL and CLI basically. Thanks for the list! We should try to go through that list before beta. |
| Comment by Roman S. Borschel [ 05/Mar/10 ] |
|
Methods should be adjusted accordingly also (even though they're case insensitive). I already started with that. More to come. |
| Comment by Roman S. Borschel [ 28/Mar/10 ] |
|
Most of the Cli => CLI changes seem to be complete now. |
| Comment by Roman S. Borschel [ 26/Apr/10 ] |
|
Pushing the rest of the name changes towards beta2. |
| Comment by Roman S. Borschel [ 19/May/10 ] |
|
More renamings have been done but still more to do. Pushing remaining work to beta3. |
| Comment by Roman S. Borschel [ 30/Aug/10 ] |
|
Final name changes should be done prior to going into RC1. |
| Comment by Benjamin Eberlei [ 31/Oct/10 ] |
|
there is much to be done yet, however most of it is also public API class names and might cause quite some BC breaks (i.e. DBAL Platforms and Schema Manager, Mapping Driver Names). I am not sure how to proceed here. |
| Comment by Roman S. Borschel [ 31/Oct/10 ] |
|
Since PHP is mostly case-insensitive on class and method names it shouldn't be much of an issue. |
[DDC-1285] Select by multiple ids Created: 22/Jul/11 Updated: 11/Jan/13 |
|
| Status: | In Progress |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers, ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Serge Smertin | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
How do you look at adding findByIds(array $ids) to EntityManager and UnitOfWork? This would allow fetching multiple entities from a database at one request and would be very useful for caching - there would be even some kind of IdentityMap kept in memcached or any other caching engine, that supports multiple id retrieval: i've been using such an architecture in multiple projects and it turned out to be very effective. There were two basic methods - findIdsByFilter(array $filter) and findEntitiesByIds(array $ids). The latter one had a caching proxy, replicating entities to a cache storage. If this idea proceeds - I'd be glad to cover it with more details. This topic on StackOverflow could also help: |
| Comments |
| Comment by Guilherme Blanco [ 20/Dec/11 ] |
|
Updating fix version |
[DDC-1390] Lazy loading does not work for the relationships of an entity instance, whose class inherits from another entity class Created: 22/Sep/11 Updated: 06/Jan/13 |
|
| Status: | In Progress |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.1.1 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Daniel Alvarez Arribas | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Debian Linux 6.0, MySQL 5.0.51a |
||
| Attachments: |
|
| Description |
|
Lazy loading does not work for the relationships of an instance of an entity, whose class inherits from another entity class. Assume there are two entity classes, A and B, where A inherits from B. Now let $a be an instance of A, e. g. the result of "SELECT a FROM \A WHERE a.id = 1". Outputting $a will confirm it is a valid instance of a proxy object inheriting from A. Assume that the database row corresponding to $a contains a non-null foreign key that actually links to an existing row in another table, corresponding to another entity instance of a different class. Now, $a->someRelationship will always returns null in this scenario. I assume this is unintended behaviour, because clearly, the other entity should be lazily loaded on accessing it, and there is a value in the database. The fetch annotation attribute on that relationship has not been explicitly set, so I assume it is set to the default value, which, according to the docs, should be "lazy". The loading only fails when accessing the relationships of an entity instance, whose class inherits from another entity class. For entity instances, whose classes do not inherit from another entity class, lazy loading of their relationships works as expected. I had a look at the proxy objects and verified that they are present and override the __get method with an implementation containing a call to the load() method. Still, the loading won't work for some reason. This could be related to Bug |
| Comments |
| Comment by Benjamin Eberlei [ 31/Oct/11 ] |
|
Did this get fixed with the correction of your data? |
| Comment by Daniel Alvarez Arribas [ 01/Nov/11 ] |
|
No it did not. This issue is completely unrelated to the other one. For this, I have manually implemented workarounds, fetching the associations using DQL queries. Lazy loading in the inheritance scenario above still would not work. |
| Comment by Benjamin Eberlei [ 01/Nov/11 ] |
|
So A is an entity in a hierachy A -> B, and "someRelationship" is a field on A or on B Could you post parts of the mappings (entity docblock and the relationship)? |
| Comment by Daniel Alvarez Arribas [ 06/Nov/11 ] |
|
Hey, thanks for taking care of this. I attached the entities involved in the szenario to this issue. I had problems lazy loading entities through the following associations: Run.invoiceCreatorResult as well as InvoiceCreatorResult.dataVersion In this scenario, InvoiceCreatorResult, CommissionNoteCreatorResult and ConsumerInvoiceExporterResult all inherit from Result, which in turn inherits from a mapped superclass DataObject. Run and DataVersion inherit from DataObject directly. The associations where lazy loading does not work are associations both to and from the entity classes InvoiceCreatorResult, CommissionNoteCreatorResult and ConsumerInvoiceExporterResult. |
| Comment by Benjamin Eberlei [ 18/Nov/11 ] |
Just a short Q on understanding: Why is $a a proxy of A if you select it explicitly? |
| Comment by Benjamin Eberlei [ 18/Nov/11 ] |
|
This a working test-case with a model that i believe resembles yours exactly. I also put your models into another test and ran schema validation on them, which works out without problems. From the workflow with proxies, maybe |
| Comment by Daniel Alvarez Arribas [ 18/Nov/11 ] |
|
Regarding the proxy question, I just ment the query to be an example to further illustrate the type of $a. It was redundant and unnecessary though and probably misleading. Sorry for that. I did not select anything in the actual scenario. $a is merely some object of type A. No queries are involved. |
| Comment by Daniel Alvarez Arribas [ 18/Nov/11 ] |
|
Have you been able to make the tests fail with the original data provided? If not, I could set up a test case and post it. |
| Comment by Benjamin Eberlei [ 18/Nov/11 ] |
|
No i only checked the validity of mappings with the original data. If you could setup a testcase that would be really great. |
| Comment by Daniel Alvarez Arribas [ 19/Nov/11 ] |
|
I will set up a test case and upload it. I'll see if I can do it one of the next evenings. |
| Comment by Benjamin Eberlei [ 17/Dec/11 ] |
|
I tried again, also extended DDC-1390, but it was impossible for me to reproduce this. I ran this against master, 2.1.x and 2.1.1 specifically. |
| Comment by Daniel Alvarez Arribas [ 05/Jan/13 ] |
|
Sorry, I got swamped with work. Now I am working on this dedicatedly, testing against the latest release. Will let you know once I have a testcase. |
| Comment by Benjamin Eberlei [ 06/Jan/13 ] |
|
Good to hear, thanks for the persistent work on this. |
[DDC-1621] Add support for FROM Class1 a1 JOIN Class2 a2 WITH cond queries Created: 25/Jan/12 Updated: 30/Dec/12 |
|
| Status: | In Progress |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.4 |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Alexander |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
Check feasibility of this kind of query different from FROM Class1 a1, Class2 a2 to allow arbitrary joins between classes. |
| Comments |
| Comment by Alex [ 30/Nov/12 ] |
|
Hi all! |
[DDC-2184] [GH-530] Singular form of generated methods should end with 'y' when property ends with 'ies' Created: 04/Dec/12 Updated: 06/Jan/13 |
|
| Status: | In Progress |
| Project: | Doctrine 2 - ORM |
| Component/s: | Tools |
| Affects Version/s: | 2.3 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
In Doctrine 2.3 the 'add' and 'remove' methods in oneToMany associations have another problem (in earlier versions like 2.2 this worked correct). The singular form is not correctly detected if the property ends with 'ies' like 'entries' which should be transformed to 'entry'.
Archive:
type: entity
fields:
id:
id: true
type: integer
unsigned: false
nullable: false
generator:
strategy: IDENTITY
oneToMany:
entries:
targetEntity: Entry
mappedBy: archive
This generates these methods: public function addEntrie(\Entry $entries) { ... } public function removeEntrie(\Entry $entries) { ... } Because in the EntityGenerator only the plural 's' is removed. It would be nice if an ending of 'ies' could be replaced by 'y'. So that we get these methods public function addEntry(\Entry $entries) { ... } public function removeEntry(\Entry $entries) { ... } My fork already has the changes https://github.com/naitsirch/doctrine-orm2/commit/a3adfccb4927d61da7debae46ed0fff61e4212f8 |
| Comments |
| Comment by Christian Stoller [ 04/Dec/12 ] |
|
Sorry, I accidently clicked on the button 'Request Feedback' |
| Comment by Benjamin Eberlei [ 06/Jan/13 ] |
|
Mark as improvement |
[DDC-54] Trigger postLoad events and callbacks after associations have been initialized Created: 15/Oct/09 Updated: 11/Oct/12 |
|
| Status: | In Progress |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA2 |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Roman S. Borschel | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 6 |
| Labels: | None | ||
| Description |
|
Currently the postLoad events and callbacks are triggered after the entity has been created and filled with its "primitive" state but before associations are available. The postLoad events and callbacks should be postponed so that they are triggered after associations have been initialized. |
| Comments |
| Comment by Roman S. Borschel [ 30/Aug/10 ] |
|
If this is to be included in 2.0 it needs to happen for RC1. However, it is not clear yet whether it will be done in time. |
| Comment by Benjamin Eberlei [ 23/Sep/10 ] |
|
How would you solve this Roman? I thought of adding a query hint so that the postLoad inside unit of work is not triggered and gathering all the entities that have a post load event in an array inside the object hydrator, then iterating it after taking the snapshots of all collections inside hydrateAll |
| Comment by Roman S. Borschel [ 24/Sep/10 ] |
|
@Benjamin: Not sure what you would use the query hint for but in general that is the approach I had in mind, yes. You can't get around iterating over the entities after the actual hydration. |
| Comment by Benjamin Eberlei [ 27/Sep/10 ] |
|
The query hint would do something like: //TODO: These should be invoked later, after hydration, because associations may not yet be loaded here. if (isset($class->lifecycleCallbacks[Events::postLoad]) && !isset($hints['hydrationPostLoad'])) { $class->invokeLifecycleCallbacks(Events::postLoad, $entity); } if ($this->evm->hasListeners(Events::postLoad) && !isset($hints['hydrationPostLoad'])) { $this->evm->dispatchEvent(Events::postLoad, new LifecycleEventArgs($entity, $this->em)); } another way would be to move that code out of UoW::createEntity completly and have the persisters call it when they use that method. |
| Comment by Roman S. Borschel [ 28/Sep/10 ] |
|
Leaving that code in UoW does not make sense to me, if it is moved, it needs to be moved completely. Why do you think the persisters should do it? Initially I thought collecting the affected entities during hydration and then when hydration is done iterating over them and triggering the postLoad events. |
| Comment by Benjamin Eberlei [ 28/Sep/10 ] |
|
Yes but postLoad has to be triggered for non Hydrated entities (i.e. Persister) also |
| Comment by Benjamin Eberlei [ 30/Oct/10 ] |
|
Moved back |
| Comment by Kacper Gunia [ 15/Apr/12 ] |
|
Hi Gyus, I need access to associations in postLoad or similar event, and my idea is to dispatch new event after full initialisation of object, what do You think about it? If I can help please let me know |
| Comment by Alexander Pasichnick [ 25/Sep/12 ] |
|
Now in my PostLoad access to associations is work fine. Why this issue is still in Unresolved status? |
| Comment by Łukasz Cybula [ 11/Oct/12 ] |
|
What do you (Roman and Benjamin) think about adding postHydrate event which would be called within ObjectHydrator::hydrateAllData() on every entity collected during hydration? I could prepare a patch for this. I personally think this would be better than adding a hint that changes behaviour of postLoad event. |
[DDC-1858] LIKE and IS NULL operators not supported in HAVING clause Created: 07/Jun/12 Updated: 20/Mar/13 |
|
| Status: | In Progress |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL |
| Affects Version/s: | 2.2.2 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | PETIT Yoann | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 3 |
| Labels: | None | ||
| Environment: |
Win7, Mysql |
||
| Description |
|
The LIKE and IS NULL operators are not supported in HAVING clause. Work: Don't work: |
| Comments |
| Comment by Marco Pivetta [ 08/Jun/12 ] |
|
I think this has already been fixed in latest master and 2.1.7. Could you just give it a try and eventually confirm? |
| Comment by PETIT Yoann [ 08/Jun/12 ] |
|
Already try with 2.17, 2.20 and 2.2.2. This hasn't been fixed. |
| Comment by Bdiang [ 04/Jul/12 ] |
|
I'm also having this issue (2.2.2). Is there any workaround for this? Column aliases also are not supported in HAVING clause: $qb->select('p', 'COUNT(p.field) as FieldCount')
->from('Entity', 'p')
->groupBy('p.id')
->having('FieldCount IS NULL')
Above code causes error "FieldCount is not pointing to class" and IS NULL causes "Expected =, <, <=, <>, >, >=, !=, got 'IS'" |
| Comment by Benjamin Eberlei [ 29/Aug/12 ] |
|
Its not a bug as the EBNF says that this is not possible. Guilherme Blanco Is this something we should support or not? |
| Comment by Christophe Coevoet [ 29/Aug/12 ] |
|
Another place where it is not supported is in the CASE clause. I would vote +1 for supporting it |
[DDC-2214] extra single quotation in sql when using EntityRepository::findBy Created: 26/Dec/12 Updated: 01/Apr/13 |
|
| Status: | In Progress |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.4 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | scourgen | Assignee: | Marco Pivetta |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
I'm using symfony 2.1 with mysql. I have following code:
$related =
$this->getDoctrine()->getRepository('MyWebBundle:LineRelated')
->findBy(array('line' => $lines), array('count' => 'DESC'), 20);
that generate the sql like this: SELECT * FROM line_related t0 WHERE t0.line_id IN ('6059', 126352, '5677', '6058') ORDER BY t0.count DESC LIMIT 20 please notice that the sql has extra single quotation around the number 6059,5677 and 6058. which make the sql very slow. I did a test, when using single quotation,the sql takes 300ms,when using without single quotation,the sql takes 1 ms. |
| Comments |
| Comment by Fabio B. Silva [ 26/Dec/12 ] |
|
Hi Could you please attach your entities or a failing test case ? Cheers |
| Comment by scourgen [ 27/Dec/12 ] |
|
sure LineRelated.php :
class LineRelated
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="Line", inversedBy="line_related")
* @ORM\JoinColumn(name="line_id", referencedColumnName="id",nullable=false)
*/
protected $line;
/**
* @ORM\Column(name="line_id_related", type="integer")
*/
protected $line_related;
/**
* @ORM\Column(type="smallint",nullable=false)
*/
protected $count = 0;
###### get/set etc....... #######
Line.php
class Line
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
########## blablabla #############
my action:
public function right_line_relatedAction($line = null, $title='相关线路')
{
$lines = $l->getByUser($user, array());
//anyway,$lines is an array,It has several elements,each element is an instance of LineEntity.
$related = $this->getDoctrine()->getRepository('MyWebBundle:LineRelated')->findBy(array('line' => $lines), array('count' => 'DESC'), 20);
//this findBy function generate the sql which is slow.
return $related;
}
|
| Comment by Fabio B. Silva [ 27/Dec/12 ] |
|
Hi, How did you get this query string ? Repository#findBy does not quote the values, It uses PDO:bindParam. WHERE t0.line_id IN (?, ? ,?) I tried to reproduce but in my tests the generated Query binds the parameters as "PDO::PARAM_INT". I have added a test case. Cheers |
| Comment by scourgen [ 28/Dec/12 ] |
|
reproduced :
SELECT t0.id AS id1, t0.line_id_related AS line_id_related2, t0.count AS count3, t0.line_id AS line_id4 FROM line_related t0 WHERE t0.line_id IN ('6059', 4851, '6068', 126352, '6060', '1000000') ORDER BY t0.count DESC LIMIT 20
Parameters: [['6059', 4851, '6068', 126352, '6060', '1000000']]
[Hide runnable query]
Time: 234.53 ms [ Explain query ]
let me have a look on what's going on |
| Comment by scourgen [ 28/Dec/12 ] |
|
interesting. I've dump(using ladybug_dump) the $lines,and I found out that when the element is a Proxies Object(Object(Proxies_GC_\My\WebBundle\Entity\Line)),then the id of that Object will be with quoted,when the elememt is an Real Entity,then It will be without quote. for example,in my last comment, the parameters is [['6059', 4851, '6068', 126352, '6060', '1000000']] array(6) tell me if you need more information. thanks |
| Comment by Marco Pivetta [ 28/Dec/12 ] |
|
This may be because $_identifier in proxies ( https://github.com/doctrine/doctrine2/blob/42e83a2716d19eada4f1cd49ece77d5f5229a239/lib/Doctrine/ORM/Proxy/ProxyFactory.php#L383 ) is not necessarily composed by integers. This could be fixed with |
| Comment by scourgen [ 28/Dec/12 ] |
|
thanks |
| Comment by Marco Pivetta [ 06/Jan/13 ] |
|
I see what is going on here... But this should not be a problem anyway, since they're bound anyway as "PDO::PARAM_INT", as Fabio B. Silva told you. That's only a problem with the logger showing them as string. PDO will handle the conversion before the value hits the DB as far as I know. |
| Comment by scourgen [ 07/Jan/13 ] |
|
I can understand your point,but what I don't really get is that the execute time of sql is very long,that explained the quote should be in the sql,not like what you said,that's only a problem with the logger. |
| Comment by Marco Pivetta [ 07/Jan/13 ] |
|
scourgen can you profile the difference directly in CLI? What about checking the bound parameter type? Are those values bound as INTs in your case? |
| Comment by scourgen [ 07/Jan/13 ] |
|
@ocramius I wish I could, but I was using doctrine2 with symfony2,So It looks like It will takes some time to simulating all environment and settings that could allow me to reproduced the problem. but anyway,I will have a try and tell you what happen when I found something. |
| Comment by Marco Pivetta [ 07/Jan/13 ] |
|
scourgen ok, awaiting your reply then |
| Comment by scourgen [ 07/Jan/13 ] |
|
I've spent some time on playing with native doctrine2. It took me awhile to setup everything. but I just don't get that how to retrive data with its Proxy ojbect(for example Proxies_CG_\My\WebBundle\Entity\Line). I mean the result of $this->_em->getRepository("something")->findxxx() always return an array of real object. I can't reproduced the situation(#comment-19186) that happens on symfony2+doctrine2. anyway,I can make sure the problem is real exist,Because the execute time of that slow sql from the tool bar of symfony2 is same as I executed it at mysql cli. If the sql shows up on log with quote but running at mysql without quote,the execute time won't be same(actually It will be much more faster,in my case,20x times,from 2xxms to 10ms). |
| Comment by Marco Pivetta [ 07/Jan/13 ] |
|
scourgen you can use $em->getReference($className, $identifier) (identifier being a key=>value array) to force proxies. Give it a try |
| Comment by scourgen [ 08/Jan/13 ] |
|
looks like I reproduced it.
public function testIssue()
{
$no_used= $this->_em->getRepository(__NAMESPACE__. '\DDC2214Line')->findOneById(1);
$lines=array(
//$this->_em->getRepository(__NAMESPACE__. '\DDC2214Line')->findOneById(1),
$this->_em->getReference(__NAMESPACE__. '\DDC2214Line',1),
$this->_em->getReference(__NAMESPACE__. '\DDC2214Line','2'),
$this->_em->getReference(__NAMESPACE__. '\DDC2214Line',3),
);
$logger = $this->_em->getConnection()->getConfiguration()->getSQLLogger();
$ids = array_map(function($r){
return $r->id;
}, $this->relatedList);
//$related = $this->_em->getRepository(__NAMESPACE__ . '\DDC2214LineRelated')->findBy(array('line' => $lines), array('count' => 'DESC'), 20);
$related = $this->_em->createQuery('select lr from '.__NAMESPACE__ . '\DDC2214LineRelated lr where lr.id in (:ids)')->setParameter('ids',$lines)->getResult();
$query = end($logger->queries);
//\Doctrine\Common\Util\Debug::dump($query['params']);
$this->assertCount(3, $related);
$this->assertEquals($ids, $query['params'][0]);
$this->assertEquals(\Doctrine\DBAL\Connection::PARAM_INT_ARRAY, $query['types'][0]);
}
}
I use MySql Query log to see what's really happen in database(http://dev.mysql.com/doc/refman/5.5/en/query-log.html) this is the log from table mysql.general_log 2013-01-08 12:23:44 [root] @ localhost [127.0.0.1] 59 0 Connect root@localhost on doctrine_tests 2013-01-08 12:23:44 root[root] @ localhost [127.0.0.1] 59 0 Query CREATE TABLE DDC2214Line (id INT AUTO_INCREMENT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB 2013-01-08 12:23:44 root[root] @ localhost [127.0.0.1] 59 0 Query CREATE TABLE DDC2214LineRelated (id INT AUTO_INCREMENT NOT NULL, line_id INT NOT NULL, count SMALLINT NOT NULL, line_id_related INT NOT NULL, INDEX IDX_D31307994D7B7542 (line_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB 2013-01-08 12:23:44 root[root] @ localhost [127.0.0.1] 59 0 Query ALTER TABLE DDC2214LineRelated ADD CONSTRAINT FK_D31307994D7B7542 FOREIGN KEY (line_id) REFERENCES DDC2214Line (id) 2013-01-08 12:23:44 root[root] @ localhost [127.0.0.1] 59 0 Query START TRANSACTION 2013-01-08 12:23:44 root[root] @ localhost [127.0.0.1] 59 0 Query INSERT INTO DDC2214Line (id) VALUES (null) 2013-01-08 12:23:44 root[root] @ localhost [127.0.0.1] 59 0 Query INSERT INTO DDC2214Line (id) VALUES (null) 2013-01-08 12:23:44 root[root] @ localhost [127.0.0.1] 59 0 Query INSERT INTO DDC2214Line (id) VALUES (null) 2013-01-08 12:23:44 root[root] @ localhost [127.0.0.1] 59 0 Query INSERT INTO DDC2214LineRelated (count, line_id_related, line_id) VALUES (1, 1, 1) 2013-01-08 12:23:44 root[root] @ localhost [127.0.0.1] 59 0 Query INSERT INTO DDC2214LineRelated (count, line_id_related, line_id) VALUES (2, 2, 2) 2013-01-08 12:23:44 root[root] @ localhost [127.0.0.1] 59 0 Query INSERT INTO DDC2214LineRelated (count, line_id_related, line_id) VALUES (3, 3, 3) 2013-01-08 12:23:44 root[root] @ localhost [127.0.0.1] 59 0 Query COMMIT 2013-01-08 12:23:44 root[root] @ localhost [127.0.0.1] 59 0 Query SELECT t0.id AS id1 FROM DDC2214Line t0 WHERE t0.id = 1 LIMIT 1 2013-01-08 12:23:44 root[root] @ localhost [127.0.0.1] 59 0 Query SELECT d0_.id AS id0, d0_.count AS count1, d0_.line_id_related AS line_id_related2, d0_.line_id AS line_id3 FROM DDC2214LineRelated d0_ WHERE d0_.id IN (1, '2', 3) 2013-01-08 12:23:44 root[root] @ localhost [127.0.0.1] 59 0 Quit you can see,in database level,the second parameter of last query but two has quote ( (1, '2', 3) ) |
| Comment by Benjamin Eberlei [ 25/Jan/13 ] |
|
A related Github Pull-Request [GH-247] was opened |
| Comment by Benjamin Eberlei [ 26/Jan/13 ] |
|
A related Github Pull-Request [GH-247] was closed |
[DDC-1605] No documentation about the usage of indexes with YAML and XML Created: 16/Jan/12 Updated: 08/Apr/13 |
|
| Status: | In Progress |
| Project: | Doctrine 2 - ORM |
| Component/s: | Documentation |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Documentation | Priority: | Major |
| Reporter: | Christian Stoller | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | documentation | ||
| Description |
|
I am missing documentation about how to handle indexes in YAML and XML definition files. I had to search in the code to learn how to do that. This issue is related to # EDIT:
User:
type: entity
fields:
id:
id: true
type: integer
generator:
strategy: IDENTITY
email:
type: string
length: 150
unique: true
active:
type: boolean
indexes:
indexActiveField: { name: idx_user_active, columns: [ active ] }
indexActiveField is the name of the index used by doctrine and idx_user_active is the name of the index in the database. The rest should be clear. |
| Comments |
| Comment by Christian Stoller [ 27/Sep/12 ] |
|
Hi. I got an email notification that arbuscula has changed the status to "Awaiting Feedback". Do you need any feedback from me? |
[DDC-1149] Optimize OneToMany and ManyToMany without join Created: 12/May/11 Updated: 30/Mar/13 |
|
| Status: | In Progress |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Andrey Kolyshkin | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 5 |
| Labels: | None | ||
| Attachments: |
|
| Description |
/** * @Entity * @Table(name="users") */ class User { /** * @Column * @Id */ public $user_id; /** * @Column */ public $email; /** * @OneToMany(targetEntity="Language", mappedBy="user",fetch="EAGER") */ public $languages; } /** * @Entity * @Table(name="user_languages") */ class Language { /** * @Column * @Id */ public $user_language_id; /** * @ManyToOne(targetEntity="User", inversedBy="languages") * @JoinColumn(name="user_id", referencedColumnName="user_id") */ public $user; /** * @Column */ public $user_id; } $users = $em->getRepository('User')->findAll();
Result: SELECT t0.user_id AS user_id1, t0.email AS email2 FROM users t0
SELECT t0.user_language_id AS user_language_id1, t0.user_id AS user_id2, t0.user_id AS user_id3 FROM user_languages t0 WHERE t0.user_id = ?
array(1) {
[0]=>
string(1) "1"
}
array(1) {
[0]=>
NULL
}
SELECT t0.user_language_id AS user_language_id1, t0.user_id AS user_id2, t0.user_id AS user_id3 FROM user_languages t0 WHERE t0.user_id = ?
array(1) {
[0]=>
string(1) "2"
}
array(1) {
[0]=>
NULL
}
SELECT t0.user_language_id AS user_language_id1, t0.user_id AS user_id2, t0.user_id AS user_id3 FROM user_languages t0 WHERE t0.user_id = ?
array(1) {
[0]=>
string(1) "3"
}
array(1) {
[0]=>
NULL
}
...
Need result: SELECT t0.user_id AS user_id1, t0.email AS email2 FROM users t0 SELECT u0_.user_language_id AS user_language_id0, u0_.user_id AS user_id1, u0_.user_id AS user_id2 FROM user_languages u0_ WHERE u0_.user_id IN (1, 2, 3) |
| Comments |
| Comment by Benjamin Eberlei [ 12/May/11 ] |
|
Sure you are on git master? this should be optimized already with fetch=EAGER |
| Comment by Andrey Kolyshkin [ 12/May/11 ] |
|
Attach test file I run git clone git://github.com/doctrine/doctrine2.git git clone git://github.com/doctrine/common.git git clone git://github.com/doctrine/dbal.git and run testDoctrine.php Result
SELECT t0.user_id AS user_id1 FROM users t0
SELECT t0.post_id AS post_id1, t0.user_id AS user_id2 FROM posts t0 WHERE t0.user_id = ?
array(1) {
[0]=>
string(1) "1"
}
array(1) {
[0]=>
NULL
}
SELECT t0.post_id AS post_id1, t0.user_id AS user_id2 FROM posts t0 WHERE t0.user_id = ?
array(1) {
[0]=>
string(1) "2"
}
array(1) {
[0]=>
NULL
}
SELECT t0.post_id AS post_id1, t0.user_id AS user_id2 FROM posts t0 WHERE t0.user_id = ?
array(1) {
[0]=>
string(1) "3"
}
array(1) {
[0]=>
NULL
}
|
| Comment by Guilherme Blanco [ 10/Oct/11 ] |
|
Please instead of using fetch="EAGER", please use fetch="EXTRA_LAZY". It would fix your issue. |
| Comment by Vladimir [ 25/Mar/13 ] |
|
Doctrine ORM 2.3.3 (Symfony2.2) - using LAZY or EXTRA_LAZY fetch mode there are only one query for: $users = $em->getRepository('User')->findAll();
but additional users_count queries for foreach($users as $user) $user->languages->toArray() And if use fetch EAGER - for some reason there are 2 x users_count queries , ie each query SELECT t0.post_id AS post_id1, t0.user_id AS user_id2 FROM posts t0 WHERE t0.user_id = ? with unique user_id executed twice |
[DDC-1884] leftJoin via composite key part not hydrated if joining table solely consists of identifiers Created: 20/Jun/12 Updated: 09/May/13 |
|
| Status: | In Progress |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.2.0-RC1 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Sander Coolen | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
MAMP |
||
| Description |
|
Suppose I have the following entities:
/** * @ORM\Entity * @ORM\Table(name="driver") */ class Driver { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @ORM\Column(type="string", length=255); */ private $name; /** * @ORM\OneToMany(targetEntity="DriverRide", mappedBy="driver") */ private $driverRides; } /** * @ORM\Entity * @ORM\Table(name="driver_ride") */ class DriverRide { /** * @ORM\Id * @ORM\ManyToOne(targetEntity="Driver", inversedBy="driverRides") * @ORM\JoinColumn(name="driver_id", referencedColumnName="id") */ private $driver; /** * @ORM\Id * @ORM\ManyToOne(targetEntity="Car", inversedBy="carRides") * @ORM\JoinColumn(name="car", referencedColumnName="brand") */ private $car; } /** * @ORM\Entity * @ORM\Table(name="car") */ class Car { /** * @ORM\Id * @ORM\Column(type="string", length=25) * @ORM\GeneratedValue(strategy="NONE") */ private $brand; /** * @ORM\Column(type="string", length=255); */ private $model; /** * @ORM\OneToMany(targetEntity="DriverRide", mappedBy="car") */ private $carRides; } And want to query for Cars that a Driver drove in:
$qb = $em->createQueryBuilder();
$qb->select('d, dr, c')
->from('Driver', 'd')
->leftJoin('d.driverRides', 'dr')
->leftJoin('dr.car', 'c')
->where('d.id = ?1') /* some Driver id */
->getQuery()->getArrayResult();
Expected results: Actual result: When I started doing some testing I found out I get a different result when I add a third column to the DriverRide table that isn't part of the composite primary key. When I removed the composite key and used an auto-generated id-column, everything worked as expected. Some test data you might want to use: INSERT INTO `car` (`brand`, `model`) VALUES
('BMW', '7 Series'),
('Crysler', '300'),
('Mercedes', 'C-Class'),
('Volvo', 'XC90');
INSERT INTO `driver` (`id`, `name`) VALUES
(1, 'John Doe'),
(2, 'Foo Bar');
INSERT INTO `driver_ride` (`driver_id`, `car`) VALUES
(1, 'Crysler'),
(1, 'Mercedes'),
(1, 'Volvo'),
(2, 'BMW');
|
| Comments |
| Comment by Benjamin Eberlei [ 05/Jul/12 ] |
|
Can you update to at least 2.2.1 and try again, because this fix here http://www.doctrine-project.org/jira/browse/DDC-1652 look like it could be related to your problem. |
| Comment by Sander Coolen [ 07/Jul/12 ] |
|
We're already using the 2.2.x-dev package. It does look similar to |
| Comment by Sander Coolen [ 08/Jul/12 ] |
|
Added testcase on 2.1.x (not the right one unfortunately) branch: https://github.com/doctrine/doctrine2/pull/395 BTW I was adding said testcase on master and got an error similar to |
| Comment by Benjamin Eberlei [ 09/May/13 ] |
|
I upgraded the testcase to master locally, and it seems to fail on Array hydration only now, with a notice: Exception: [PHPUnit_Framework_Error] Argument 1 passed to Doctrine\ORM\Internal\Hydration\ArrayHydrator::updateResultPointer() must be of the type array, string given, called in /home/benny/code/php/workspace/doctrine2/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php on line 196 and defined I remember fixing something similar for ObjectHydration (which works for your testcases). Will investigate more when I have time. |
[DDC-2220] Add joins to Collection Filtering API Created: 03/Jan/13 Updated: 03/Jan/13 |
|
| Status: | In Progress |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.3.1 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Oleg Namaka | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | api, collection, filtering | ||
| Description |
|
The recently added collection filtering API only goes half way in achieving a full fledged solution to filter huge collections. It still lacks joins. Look at the next two snippets:
$criteria = Criteria::create()
->where(Criteria::expr()->eq('storeId', $store->getId()))
->andWhere(Criteria::expr()->eq('Category', 20))
->orderBy(array('popularity' => 'DESC'));
return $this->BrandCategories->matching($criteria);
This piece of code works but what if there is a need to filter the BrandCategories collection by Categories with some extra criteria:
$criteria = Criteria::create()
->where(Criteria::expr()->eq('storeId', $store->getId()))
->andWhere(Criteria::expr()->eq('Category', 20))
->andWhere(Criteria::expr()->eq('Category.name', 'Electronics'))
->orderBy(array('popularity' => 'DESC'));
return $this->BrandCategories->matching($criteria);
That would not work. Ideally we should have a possibility to join other entities, the Category entity in our case here:
$criteria = Criteria::create()
->where(Criteria::expr()->eq('storeId', $store->getId()))
->andWhere(Criteria::expr()->eq('Category', 20))
->innerJoin(Criteria::expr()->field('Category', 'Category'))
->andWhere(Criteria::expr()->eq('Category.name', 'Electronics'))
->orderBy(array('popularity' => 'DESC'));
return $this->BrandCategories->matching($criteria);
What do you think about it, does it make sense to add such functionality? |
[DDC-1889] generate persisters Created: 21/Jun/12 Updated: 22/Oct/12 |
|
| Status: | In Progress |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | New Feature | Priority: | Minor |
| Reporter: | Fabio B. Silva | Assignee: | Fabio B. Silva |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
I'm not sure if this is really possible.. but to improve performance we should consider generate custom entity persisters. Now entity persister are not cached, |
| Comments |
| Comment by Benjamin Eberlei [ 21/Jun/12 ] |
|
This should be relatively easy in the first step by ust generate the RSM and SQL statements in the constructor and extending from the default persister. |
[DDC-391] Allow to specifiy custom Entity and Collection Persister classes Created: 06/Mar/10 Updated: 24/Sep/12 |
|
| Status: | In Progress |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA4 |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Minor |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 5 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
It should be allowed to overwrite the default persisters for collections and entities. This should go along the lines of Hibernate which allows to set the custom implementations like: XML: <entity persister="persisterClass" /> <OneToMany persister="persisterClass" /> Annotation /** * @Entity(persister="persisterClass") * @OneToMany(persister="persisterClass") */ |
| Comments |
| Comment by Roman S. Borschel [ 19/May/10 ] |
|
Rescheduling for beta3. |
| Comment by Roman S. Borschel [ 07/Jul/10 ] |
|
Pushing back to beta4. |
| Comment by Roman S. Borschel [ 12/Jul/10 ] |
|
Moved to 2.1 due to lack of time for any larger new features for 2.0. |
| Comment by Benjamin Eberlei [ 13/Oct/10 ] |
|
implemented this in a feature branch for now, it really doesnt touch any other runtime code so maybe we can still merge this before RC1 http://github.com/doctrine/doctrine2/tree/OverridePersisters |
| Comment by Gediminas Morkevicius [ 25/Feb/11 ] |
|
Is this forgotten? you should merge it since it does not affect any other parts of ORM, this is a great feature |
| Comment by Benjamin Eberlei [ 26/Feb/11 ] |
|
This has not been forgotten, but the Persister is due for a heavy refactoring for 2.2 probably, when we will make it use the SQL Query object that we are working on. So I cannot merge this, because the API will probably break big time. |
| Comment by Jonas Wouters [ 16/Mar/11 ] |
|
Does that mean we will not see this feature before 2.2? |
| Comment by Benjamin Eberlei [ 16/Mar/11 ] |
|
Yes, that is correct. I dont want to add it as experimental/undocumented feature because people will take it for granted and make us responsible for possible bc breaks. I will update the target version accordingly. Sorry for disappointing you, but this feature is fundamentally important at the core of the library. That means we have to get it right and not rush into it. |
| Comment by Gediminas Morkevicius [ 17/Mar/11 ] |
|
Just as I thought that first you will want to make a query builder object for all persisters. since now they use plain sql. Thanks for all your work on this |
| Comment by Adam Brodziak [ 11/Jan/12 ] |
|
I might be mistaken, but AFAICS mentioned Persister heavy refactoring did not made through to 2.2 version. Is there any plan to have it in 2.3 or at any later stage? |
| Comment by Guilherme Blanco [ 13/Jan/12 ] |
|
@Adam I refactored all Persisters optimizing their code, but I could not complete the move from SQL string generation to Doctrine\DBAL\Query. |
| Comment by Thomas Rothe [ 05/Sep/12 ] |
|
Why is it still missing in 2.3? I would require this for an extension that uses its own overridden entity persister and using a custom persister is the solution that you guys recomend for not overriding the entity manager. |
| Comment by sebastiaan stok [ 23/Sep/12 ] |
|
Any change seeing this soon? I really need this for a security feature. What is making this so hard? just adding an setEntityPersister($entityName, $object) should do the trick. Edit: OK, I'm shot I CAN NOT overwrite the entity manager as the UnitOfWork is private! |
| Comment by Stefan Kögel [ 24/Sep/12 ] |
|
Any chance you could add this quickly? I need this feature urgently to complete an extension using a custom persister. Thanks in advance. |
[DDC-2236] SUM(..) with Pagination gives incorrect result Created: 11/Jan/13 Updated: 10/Feb/13 |
|
| Status: | In Progress |
| Project: | Doctrine 2 - ORM |
| Component/s: | Tools |
| Affects Version/s: | 2.2.3 |
| Fix Version/s: | None |
| Type: | Documentation | Priority: | Minor |
| Reporter: | Oleg | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | paginator | ||
| Environment: |
Linux |
||
| Description |
|
https://github.com/whiteoctober/Pagerfanta/issues/69 <?php $pager = new Pagerfanta(new DoctrineORMAdapter($query)); $result = $pager->getCurrentPageResults(); $result = $query->getQuery()->getResult(); Sql for the above: SELECT DISTINCT id0 FROM (SELECT q0_.id AS id0, SUM(q0_.price) AS sclr36 FROM Q q0_ WHERE q0_.id IN (19, 20, 22) GROUP BY q0_.customer_id) dctrn_result LIMIT 30 OFFSET 0 Sql with fetchJoin = false (new DoctrineORMAdapter($query, false)) SELECT q0_.id AS id0, SUM(q0_.price) AS sclr36 FROM Quote q0_ WHERE q0_.id IN (19, 20, 22) GROUP BY q0_.customer_id LIMIT 30 OFFSET 0 |
| Comments |
| Comment by Alexander [ 09/Feb/13 ] |
|
Can you also test this with doctrine >= 2.3? The pagination code changed quite a lot. |
| Comment by Oleg [ 10/Feb/13 ] |
|
Looks like no change composer.json:
then cleared cache but result is same
$query = $this->getDoctrine()->getEntityManager()->getRepository('MyBundle:Invoice')
->createQueryBuilder('q')
->select('q', 'SUM(q.amount) AS amount')
->groupBy('q.customer')
;
95 Connect root@localhost on ** 95 Query SELECT DISTINCT id0 FROM (SELECT i0_.id AS id0, i0_.invoice_num AS invoice_num1, i0_.date AS date2, i0_.amount AS amount3, i0_.vat_amount AS vat_amount4, i0_.amount_paid AS amount_paid5, i0_.md5 AS md56, i0_.is_exported AS is_exported7, i0_.created AS created8, SUM(i0_.amount) AS sclr9 FROM Invoice i0_ GROUP BY i0_.customer_id) dctrn_result LIMIT 30 OFFSET 0 95 Query SELECT i0_.id AS id0, i0_.invoice_num AS invoice_num1, i0_.date AS date2, i0_.amount AS amount3, i0_.vat_amount AS vat_amount4, i0_.amount_paid AS amount_paid5, i0_.md5 AS md56, i0_.is_exported AS is_exported7, i0_.created AS created8, SUM(i0_.amount) AS sclr9, i0_.customer_id AS customer_id10 FROM Invoice i0_ WHERE i0_.id IN ('2') GROUP BY i0_.customer_id 95 Query SELECT i0_.id AS id0, i0_.invoice_num AS invoice_num1, i0_.date AS date2, i0_.amount AS amount3, i0_.vat_amount AS vat_amount4, i0_.amount_paid AS amount_paid5, i0_.md5 AS md56, i0_.is_exported AS is_exported7, i0_.created AS created8, SUM(i0_.amount) AS sclr9, i0_.customer_id AS customer_id10 FROM Invoice i0_ GROUP BY i0_.customer_id 130210 16:08:25 95 Quit But I understand why that happens, it's due to group by and pagination nature. If I do $pager = new Pagerfanta(new DoctrineORMAdapter($query, false)); I get this sql SELECT i0_.id AS id0, i0_.invoice_num AS invoice_num1, i0_.date AS date2, i0_.amount AS amount3, i0_.vat_amount AS vat_amount4, i0_.amount_paid AS amount_paid5, i0_.md5 AS md56, i0_.is_exported AS is_exported7, i0_.created AS created8, SUM(i0_.amount) AS sclr9, i0_.customer_id AS customer_id10 FROM Invoice i0_ LIMIT 30 OFFSET 0 I think it should be noted somewhere that if you do groupBy you should set fetchJoin to false? |
| Comment by Marco Pivetta [ 10/Feb/13 ] |
|
Updating to Documentation issue. |