[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-585] Create a coding standards document Created: 13/May/10 Updated: 11/Feb/13 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.0 |
| Security Level: | All |
| Type: | Task | Priority: | Major |
| Reporter: | Roman S. Borschel | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
We need a new coding standards document for Doctrine 2. |
| Comments |
| Comment by Benjamin Morel [ 29/Jan/13 ] |
|
Has there been any work on a coding standards document yet? |
| Comment by Marco Pivetta [ 29/Jan/13 ] |
|
Benjamin Morel Guilherme Blanco may have a CS ruleset, but it's not ready yet. Perfect timing btw, we really need to automate this to avoid having all these useless CS fix comments in pull requests |
| Comment by Benjamin Morel [ 29/Jan/13 ] |
|
Ok, I'll post my document here once ready, and Guilherme Blanco will be able to compare it with his ruleset! |
| Comment by Benjamin Morel [ 30/Jan/13 ] |
|
Here is a first draft: https://gist.github.com/4676670 Please comment! |
| Comment by Benjamin Morel [ 11/Feb/13 ] |
|
Guilherme Blanco, if you don't have time to compare your ruleset with my draft, maybe you could publish your current ruleset so that others can have a look? |
[DDC-536] Remove the _ prefix from private and protected members Created: 23/Apr/10 Updated: 19/Nov/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.0 |
| Security Level: | All |
| Type: | Task | Priority: | Major |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
The reasoning is simple: The prefix "_" is usually either used for easier distinction of instance variables from other, i.e. local variables, instead of always using "this." (often seen in C#), or it is used to signal that a member is not meant to be accessed from outside of the class when the language does not have visibility modifiers (PHP4). Since you always have to use "$this->" in PHP5+ when accessing instance members and there are visibility modifiers, the "_" is largely superfluous and just makes the verbose OO code even more verbose. Maybe the following find/replace steps will do the job almost completely: "private $_" => "private $" "protected $_" => "protected $" "$this->_" => "$this->" |
| Comments |
| Comment by Benjamin Eberlei [ 27/Apr/10 ] |
|
i just found a possible BC issue with this. EntityRepository is allowed to be extended by us, it has several variables that are underscore prefixed. How to proceed in this case? |
| Comment by Roman S. Borschel [ 27/Apr/10 ] |
|
I know but its not really a problem I think. We should just decide whether we make them private in the first place and provide getters instead (which would have avoided this problem in the first place). |
| Comment by Roman S. Borschel [ 27/Apr/10 ] |
|
Leaving the prefixes on the repository class only is also an option... but I dont think thats necessary. |
| Comment by Benjamin Eberlei [ 27/Apr/10 ] |
|
can we commit getters for Beta 1 then? We could give everyone a period until Beta 2 to fix their code and then make the change. EntityRepository is the only class that is meant to be userland extendable to my knowledge, so this should be the only problem to adress |
| Comment by Roman S. Borschel [ 27/Apr/10 ] |
|
Yes, you can add getters and commit right away if you want. Plus adding a note on the upgrade document that direct access of these properties is deprecated. |
| Comment by Roman S. Borschel [ 27/Apr/10 ] |
|
Persisters will be also extensible some day in userland but they need more polish for that, I've already started with it |
| Comment by Johnny Peck [ 19/Nov/10 ] |
|
Is this still planned? Searching the code base finds this is not being implemented. It would be a good idea to implement the change sooner than later if it will be done at all. Also, +1 for the change. It makes complete sense. |
[DDC-530] Create tests and documentation for possibilities of mixing inheritance mapping strategies Created: 19/Apr/10 Updated: 19/Apr/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-BETA1 |
| Fix Version/s: | 2.0 |
| Security Level: | All |
| Type: | Task | Priority: | Minor |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
It is (theoretically) possible to use different inheritance mapping strategies in the same class hierarchy as long as the different subtrees that use different mapping strategies do not have a common ancestor entity. We should add some tests for that and mention it in the docs about inheritance mapping in a new subsection "Mixing Inheritance Mapping Strategies". |
[DDC-473] Inadequate description for @MappedSuperclass in Annotations Reference Created: 25/Mar/10 Updated: 26/Aug/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Documentation |
| Affects Version/s: | 2.0-ALPHA4 |
| Fix Version/s: | 2.0 |
| Security Level: | All |
| Type: | Improvement | Priority: | Minor |
| Reporter: | David Abdemoulaie | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
This doesn't adequately communicate how to use it. It took me several minutes of failing before I downloaded the PDF and did a search for @MappedSuperclass to find an example of how it's used. Specifically the following were unclear:
|
| Comments |
| Comment by David Abdemoulaie [ 25/Mar/10 ] |
|
Apparently it's also incompatible with several other tag as well. I thought it made sense to try the following and see if the @InheritanceType and @Discriminator___ tags would apply to the children classes: /**
* @MappedSuperclass
* @InheritanceType("SINGLE_TABLE")
* @DiscriminatorColumn(name="type", type="string")
* @DiscriminatorMap({"User" = "User", "Group" = "Group"})
*/
abstract class Principal
But apparently this flags D2 to treat it as an Entity anyway, resulting in the following error: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'sentact5.principal' |
| Comment by Benjamin Eberlei [ 28/Mar/10 ] |
|
I updated the documentation, the question is if we should check for the mapped superclass attribute and throw exceptions if other entity level annotations are specified. |
| Comment by Roman S. Borschel [ 15/Apr/10 ] |
|
A mapped superclass has not many restrictions and these are mentioned in the docs (i.e. only unidirectional associations), what David mentions above should work, if it doesnt its a bug, I think |
| Comment by Roman S. Borschel [ 15/Apr/10 ] |
|
David, @"Is this defined on the superclass or on the children classes?" It doesnt matter. A @MappedSuperclass can be anywhere in an inheritance hierarchy and it always does the same thing, inherit its mapping information to subclasses (but its not itself an entity). The docs say: Mapped superclasses, just as regular, non-mapped classes, can appear in the middle of an otherwise mapped inheritance hierarchy (through Single Table Inheritance or Class Table Inheritance).
as well as Entities support inheritance, polymorphic associations, and polymorphic queries. Both abstract and concrete classes can be entities. Entities may extend non-entity classes as well as entity classes, and non-entity classes may extend entity classes.
So entities, mapped superclasses and plain non-mapped classes can appear mixed in an inheritance hierarchy. Nevertheless all the classes in a hierarchy that are entities must use 1 inheritance strategy, you can not mix inheritance mapping strategies in a single class hierarchy. @"If it's defined on the child classes, does it take parameters? The name of the super class?" No, it doesnt. The docs dont mention any parameters either which is correct. @"It was not at all apparent to me that it was mutually exclusive with the @Entity tag" OK, that needs to be made clearer in the docs then. |
[DDC-1698] Inconsistent proxy file name & namespace result in __PHP_Incomplete_Class when unserializing entities Created: 13/Mar/12 Updated: 06/Jan/13 |
|
| Status: | Reopened |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.2, 2.2.1 |
| Fix Version/s: | 2.2.2 |
| Security Level: | All |
| Type: | Documentation | Priority: | Major |
| Reporter: | Benjamin Morel | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Irrelevant |
||
| Description |
|
Starting with Doctrine 2.2, the Proxy classes have inconsistent naming with their file name, which raises problems with class autoloading. Application\Proxy\__CG__\Application\Model\User This class is located in the following file: Application/Proxy/__CG__ApplicationModelUser.php But whe we serialize such an entity, then unserialize it in another session, the framework autoloader expects the class to be located in: Application/Proxy/__CG__/Application/Model/User.php But it is not. I'm not sure whether this is an intended behavior, but I would assume this is a bug. |
| Comments |
| Comment by Benjamin Morel [ 13/Mar/12 ] |
|
It looks like there is an even broader problem with the new _CG_ prefix; the PSR-0 standard for autoloading states that the underscores should be handled this way: \namespace\package\Class_Name => {...}/namespace/package/Class/Name.php
Which means that in the above example, it could even expect the file to be located in: Application/Proxy///CG///Application/Model/User.php ... which is far away from the actual location. |
| Comment by Benjamin Eberlei [ 14/Mar/12 ] |
|
Proxy classes do not follow PSR-0. For the case unserializing objects we should provide an extra autoloader i guess. See here how symfony does it https://github.com/doctrine/DoctrineBundle/blob/master/DoctrineBundle.php#L57 |
| Comment by Benjamin Eberlei [ 14/Mar/12 ] |
|
See https://github.com/doctrine/doctrine2/commit/9b4d60897dfc7e9b165712428539e694ec596c80 and https://github.com/doctrine/orm-documentation/commit/01381fae1ff3d4944086c7cfe46721925bf6ca15 |
| Comment by Benjamin Morel [ 14/Mar/12 ] |
|
Thanks for the quick fix, Benjamin. You mentioned in the doc that the proxies are not PSR-0 compliant "for implementation reasons"; as this was working fine before 2.2, could you please explain what requirement prevents Doctrine from keeping the previous naming convention? |
| Comment by Benjamin Eberlei [ 29/Mar/12 ] |
|
In 2.1 the proxies are not PSR-0 compatible themselves, however their class naming is simpler. In 2.2 we changed proxy names so that you can derive the original name of the proxy by searching for the _CG_ flag. This flag obviously contains the __ chars that some PSR autoloaders detect as directory seperators. I agree this is an unfortunate decision, but it was done this way. I do think however that we can automatically register the proxy atuoloader (if not yet done) in EntityManager#create(). This would hide this fact from developers automatically. |
| Comment by Benjamin Morel [ 29/Oct/12 ] |
|
@Benjamin Eberlei |
| Comment by Benjamin Eberlei [ 06/Jan/13 ] |
|
Benjamin Morel Not at the moment, seems too dangerous for me since it might produce race conditions. This should really be done in the bootstrap of the system. We need to document this though. |
| Comment by Benjamin Morel [ 06/Jan/13 ] |
|
Ok, thanks for your answer! |
[DDC-2089] Modify OneToMany to allow unidirectional associations without the need of a JoinTable Created: 19/Oct/12 Updated: 16/Dec/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.x |
| Fix Version/s: | 2.4, 3.0 |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Enea Bette | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | onetomany, persister, unidirectional | ||
| Environment: |
Debian Wheezy, Mysql 5.1, Apache2, PHP 5.4 |
||
| Description |
|
As I sayd in the title, it would be nice if the ORM layer could permit to map a 1:n association in the db as an unidirectional OneToMany in the classes, without using a JoinTable in the database. Is it possible? |
| Comments |
| Comment by Enea Bette [ 16/Dec/12 ] |
|
A little up... for inspiration from JPA |
[DDC-1624] Locking CTI doesnt work on SQL Server Created: 29/Jan/12 Updated: 20/Sep/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.2 |
| Fix Version/s: | 2.4 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
The WITH Keyowrd is appended to the whole FROM .. JOIN .. block instead of behind the FROM block. |
[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-1599] OnFlush event in transaction Created: 14/Jan/12 Updated: 20/Sep/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | 2.4 |
| Type: | Improvement | Priority: | Major |
| Reporter: | Gediminas Morkevicius | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Description |
|
Is there any particular reason why onFlush event is not triggered when the transaction is allready open? https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/UnitOfWork.php#L290 It would help a lot developing listeners since this event is the mostly used one and since theres preFlush now it seems a logical solution if onFlush would be a start of transaction in general |
| Comments |
| Comment by Benjamin Eberlei [ 14/Jan/12 ] |
|
onFluish is not the start of a transaction. It has nothing to do with this. |
| Comment by Marco Pivetta [ 31/Mar/12 ] |
|
Is a third event needed? Or is this to be marked as "won't fix"? |
| Comment by Benjamin Eberlei [ 31/Mar/12 ] |
|
Maybe onBeginTransaction, onCommit and onRollback. However since you can start transactions manually using $em->beginTransaction(), the Flush events are somehwat independent of transactions anyways. |
| Comment by Gediminas Morkevicius [ 31/Mar/12 ] |
|
Well, user can start transaction anytime, but the fact is that if we think ORM we do not know nothing about the database. we just persist and flush objects. Yes I think these would be very useful, from how I see it, if you use event listeners, is: loadClassMetadata: you can apply extra mapping onFlush: you can modify entity changesets, or persist recalculate new ones, without triggering the database, since it is not used to begin the database modifications yet. onBeginTransaction: could use the database modifications keeping in sync the entity changesets. the thing about this event is that usually in behavioral way atomic updates are required. for example nestedset tree sync lft rgt columns, sortable sync the sort index, materialized path, all these requires atomic updates, and the best place is the start of transaction. onCommit: could be useful to execute right before commit, finalizing database modifications could be done. onRollback: this one is really something, since if you go far, there might be something like files uploaded during the entity processing, and you may want to remove them if transaction fails. |
| Comment by Guilherme Blanco [ 21/May/12 ] |
|
This situation was barely documented here: http://www.doctrine-project.org/jira/browse/DDC-1443 We need a better Transaction API that completely fixes the computation of changesets and also allow more fine grained control over Entities and their corresponding information. I'd postpone this one until 3.0. |
[DDC-1590] Fix Inheritance in Code-Generation Created: 09/Jan/12 Updated: 10/Dec/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.4 |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 3 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Comments |
| Comment by Lukas Domnick [ 10/Dec/12 ] |
|
(I have no Link Privileges, but this one # |
[DDC-1852] Doctrine\ORM\Tools\SchemaValidator should check validity of lifecycle callbacks Created: 04/Jun/12 Updated: 20/Sep/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | 2.4, 2.x, Git Master |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Marco Pivetta | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
The schema validator should analyze mapped lifecycle callbacks and: a) if some lifecycle callbacks were defined, but no @HasLifecycleCallbacks annotation/mapping was set, warn the user |
| Comments |
| Comment by Marco Pivetta [ 04/Jun/12 ] |
|
Existing PR at https://github.com/doctrine/doctrine2/pull/361 |
[DDC-1840] Create ParameterCollection indexed and implement it on AbstractQuery and QueryBuilder Created: 26/May/12 Updated: 20/Sep/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.4 |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Guilherme Blanco | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Currently, method setParameters in AbstractQuery and QueryBuilder only appends new parameters to the list. It should actually override the existing ones. |
| Comments |
| Comment by Benjamin Eberlei [ 27/May/12 ] |
|
Not a bug |
[DDC-2208] CASE WHEN ... WHEN doesn't work Created: 19/Dec/12 Updated: 08/Jan/13 |
|
| Status: | Reopened |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL |
| Affects Version/s: | 2.3.1 |
| Fix Version/s: | 2.4 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Miha Vrhovnik | Assignee: | Fabio B. Silva |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Having the following part in select DQL throws an exception.
SUM(CASE
WHEN c.startDate <= :start THEN c.endDate - :start
WHEN c.endDate >= :end THEN :end - c.startDate
ELSE 0
END)
exception: [Syntax Error] line 0, col 124: Error: Expected Doctrine\ORM\Query\Lexer::T_ELSE, got '-' It seems that it's failing inside the second THEN This one also seems to fail:
SUM(CASE
WHEN c.startDate <= :start THEN (c.endDate - :start)
WHEN c.endDate >= :end THEN (:end - c.startDate)
ELSE 0
END)
exception:
[Syntax Error] line 0, col 60: Error: Unexpected '('
Another one:
SUM(CASE
WHEN c.startDate <= :start THEN c.endDate - :start
WHEN c.endDate >= :end THEN :end - c.startDate
ELSE 0
END) = :result FROM ...
exception: [Syntax Error] line 0, col 60: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got '=' |
| Comments |
| Comment by Miha Vrhovnik [ 20/Dec/12 ] |
|
I've added two more cases where the parsing fails. Do you want a separate tickets for that? |
| Comment by Fabio B. Silva [ 20/Dec/12 ] |
|
Don't worry, I'll spend some time over this... |
| Comment by Miha Vrhovnik [ 20/Dec/12 ] |
|
The 3rd case seems work just fine as a part of a HAVING clause. |
| Comment by Miha Vrhovnik [ 08/Jan/13 ] |
|
Fabio I have two more...
->addSelect('CASE
WHEN po.quantity IS NULL THEN NULL
ELSE po.quantity -
COALESCE(0, (
SELECT COUNT(rd.product) FROM xxxx rd
WHERE (rd.startDate <= :end) AND (rd.endDate >= :start) AND
rd.product = c.product)))
END
AS po.quantity
')
:edit replaced with real query |
| Comment by Miha Vrhovnik [ 08/Jan/13 ] |
|
addon: well the subquery part can be full query with joins .... |
[DDC-1738] Allow multiple Generators per class Created: 29/Mar/12 Updated: 20/Sep/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | Git Master |
| Fix Version/s: | 2.4 |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Guilherme Blanco | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
We should be able to support multiple generators per class. Currently we only support 1 generator per class. |
[DDC-1723] Custom ID Generators Created: 22/Mar/12 Updated: 20/Sep/12 |
|
| Status: | Open |
| 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: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Allow specify custom id generators, pull request is GH-206 https://github.com/doctrine/doctrine2/pull/206 |
[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-2390] Remove Parser and SQLWalker dependency on Query Created: 04/Apr/13 Updated: 04/Apr/13 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.4 |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Query is too powerful to be available in Parser and SQLWalker, because it may lead to accessing data that changes on subsequent runs of a query that is cached. Idea is to introduce a MetadataBag that contains only the values that are allowed to be accessed. |
[DDC-2052] Custom tree walkers are not allowed to add new components to the query Created: 02/Oct/12 Updated: 14/May/13 |
|
| Status: | Reopened |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL |
| Affects Version/s: | 2.3 |
| Fix Version/s: | 2.4 |
| Type: | Improvement | Priority: | Major |
| Reporter: | Łukasz Cybula | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | dql | ||
| Description |
|
Custom tree walkers have freedom in modifying the AST but when you try to add a new query component (i.e. new join in walkSelectStatement() ) to the AST then the SqlWalker throws an exception because it does not has the new component in its _queryComponents array. I see two possible ways to resolve this: |
| Comments |
| Comment by Benjamin Eberlei [ 06/Oct/12 ] |
|
Ok this is much more complicated to allow then i thought. The problem is that the QueryComponents are passed by value, as an array, not by reference. That prevents changing them because this change wouldn't be visible in the output walker. I can add a method to allow this in the OutputWalker for now, but generally this requires a bigger refactoring on the Query Components. |
| Comment by Benjamin Eberlei [ 06/Oct/12 ] |
|
Added setQueryComponent() in SQL Walker to allow modification in output walker. |
| Comment by Łukasz Cybula [ 08/Oct/12 ] |
|
I'm afraid that this doesn't solve the initial problem at all. I'll try to describe it in more details to show what I mean. Suppose we have two doctrine extensions each of which contain its own tree walker. Each of these tree walkers need to modify AST and add new component to it (joined with some component already existing in the query). The first problem is that each tree walker has its own queryComponents array which is not passed between them, although they not necessary need to use queryComponents - they could use only AST. The second, bigger problem is that the Parser class does not know anything about modifications of queryComponents in tree walkers and cannot pass modified version to the OutputWalker. The goal of submitting this issue was to allow adding new components to the query in tree walkers which is not achievable by your fix. I think it may be the first step in the right direction. Maybe TreeWalkerAdapter should have public method getQueryComponents() which would be used by the Parser to pass modified queryComponents between different tree walkers and finally to the OutputWalker ? This would not break backward compatibility and solve this issue. What do you think about it? |
| Comment by Łukasz Cybula [ 08/Oct/12 ] |
|
I've tried to implement the solution mentioned in previous comment but it's also not so clean and easy as I thought. Each tree walker (including TreeWalkerChain) would have to implement getQueryComponents() and setQueryComponent($alias, array $component) methods. The same with SqlWalker, so the TreeWalker interface should have these methods, which would break BC in some way (walkers that do not inherit from SqlWalker or TreeWalkerAdapter will fail to compile). So maybe my first solution (PR #464) is not so bad for now? In the future queryComponents could be replaced by a special object or could be passed by a reference to allow modifications. |
| Comment by Benjamin Eberlei [ 09/May/13 ] |
|
Marked as improvement as its not a bug. A solution might probably implement an object holding all the QueryComponent, implementing ArrayAccess. So that way the state can be shared. |
| Comment by Marco Pivetta [ 14/May/13 ] |
|
Just hit this while developing an ast walker... Will look into it too since I need it more than soon. |
| Comment by Marco Pivetta [ 14/May/13 ] |
|
As a VERY UGLY workaround, I used a static variable and a custom sql walker in combination with my AST walker. namespace Comcom\Versioning\ORM\Query; use Doctrine\ORM\Query\SqlWalker; class WorkaroundSqlWalker extends SqlWalker { public function __construct($query, $parserResult, array $queryComponents) { parent::__construct($query, $parserResult, $queryComponents); foreach (VersionWalker::$additionalAliases as $alias => $value) { $this->setQueryComponent($alias, $value); } } } |
[DDC-2452] Additional `WITH` condition in joins between JTI roots cause invalid SQL to be produced Created: 16/May/13 Updated: 16/May/13 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL, ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | 2.4 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Marco Pivetta | Assignee: | Marco Pivetta |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | dql, sql-walker | ||
| Environment: |
irrelevant |
||
| Description |
|
Given a simple Joined Table Inheritance like following: /** * @Entity @Table(name="foo") @InheritanceType("JOINED") * @DiscriminatorColumn(name="discr", type="string") * @DiscriminatorMap({"foo" = "DDC2452Foo", "bar" = "DDC2452Bar"}) */ class DDC2452Foo { /** @Id @Column(type="integer") @GeneratedValue */ public $id; } /** @Entity @Table(name="bar") */ class DDC2452Bar extends DDC2452Foo { } Following DQL SELECT foo1 FROM DDC2452Foo foo1 JOIN DDC2452Foo foo2 WITH 1=1 Will produce broken SQL: SELECT
f0_.id AS id0, f0_.discr AS discr1
FROM
foo f0_
LEFT JOIN bar b1_
ON f0_.id = b1_.id
LEFT JOIN foo f2_
LEFT JOIN bar b3_
ON f2_.id = b3_.id
ON (1 = 1)
(please note the duplicate `ON` in the SQL) That is caused because of the SQL walker producing the JTI filter with already the `ON` clause in it. That happens because the JTI join conditions are added in https://github.com/doctrine/doctrine2/blob/2.4.0-BETA2/lib/Doctrine/ORM/Query/SqlWalker.php#L823-L825 (`walkRangeVariableDeclaration`), while the additional defined `WITH` conditions are considered in `walkJoinAssociationDeclaration` later on. Added a test case and fix at https://github.com/doctrine/doctrine2/pull/668 |
[DDC-1283] Possible issue with PersistentCollection#getDelete/InsertDiff() Created: 21/Jul/11 Updated: 20/Sep/12 |
|
| Status: | Reopened |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.1 |
| Fix Version/s: | 2.4 |
| Security Level: | All |
| Type: | Improvement | Priority: | Minor |
| Reporter: | Glen Ainscow | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Using the following code, when you go from (1, 2) to (1), (2) is deleted as expected. However, if you go from (1, 2) to (2), (1) and (2) are deleted and (2) is then inserted. Is this the desired behaviour? (i.e. 2 extra queries) $bracket->getTournamentLocations()->takeSnapshot();
$col = $bracket->getTournamentLocations()->unwrap();
$col->clear();
foreach ($form->getValue('tournamentLocations') as $id) {
$col->add($em->getReference('Tournaments_Model_TournamentLocation', $id));
}
$bracket->getTournamentLocations()->setDirty(true);
|
| Comments |
| Comment by Benjamin Eberlei [ 26/Jul/11 ] |
|
First, you are using internal API therefore you are on your own anyways. This is marked as improvment now, the functionality works, it may just be inefficient. |
| Comment by Guilherme Blanco [ 09/Dec/11 ] |
|
Hi, I'm marking issue as invalid because you're conceptually wrong. Correct code would be you to regenerate the collection (a new ArrayCollection) and just assign it to setTournamentLocations($newCollection); Does this explanation is enough for you? Cheers, |
| Comment by Glen Ainscow [ 23/Dec/11 ] |
|
Hi Guilherme, If I do this: $locations = new ArrayCollection();
foreach ($form->getValue('tournamentLocations') as $id) {
$locations->add($em->getReference('Tournaments_Model_TournamentLocation', $id));
}
$bracket->setTournamentLocations($locations);
... then all the records are deleted, before adding the new records. This is inefficient and causes extra, unnecessary write operations. Can't Doctrine perform diffs when persisting the collection, so that only the necessary deletes and inserts are executed? |
| Comment by Guilherme Blanco [ 13/Jan/12 ] |
|
We could add it, but I don't think it worth the effort. I'd rather consider that it's not possible to be done at the moment, but I need much more investigation for that. This will be something that I'll probably only do when I look at this issue again with a lot of time (which is really hard to happen). If you have some spare time, feel free to make some attempts. |
[DDC-2203] add EntityManager->getFilters()->isEnabled('filterName'') Created: 17/Dec/12 Updated: 01/Apr/13 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | 2.4 |
| Security Level: | All |
| Type: | Improvement | Priority: | Minor |
| Reporter: | Enea Bette | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Comments |
| Comment by Paweł Nowak [ 10/Jan/13 ] |
|
My pull request (https://github.com/doctrine/doctrine2/pull/548) contains an implementation of the method. Note that no exception is thrown if you query for the state of a non-existing filter - in such a case, false is returned as for disabled filters. |
[DDC-222] Create unit tests for CLI components Created: 22/Dec/09 Updated: 30/Oct/10 |
|
| Status: | Reopened |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA3 |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Task | Priority: | Critical |
| Reporter: | Roman S. Borschel | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Comments |
| Comment by Roman S. Borschel [ 19/May/10 ] |
|
Whats the status here? Do we have any? |
| Comment by Guilherme Blanco [ 19/May/10 ] |
|
Since we moved to Symfony Console I don't think this is needed anymore. I'm closing the ticket due to this. Reopen if you have any other comment. |
| Comment by Benjamin Eberlei [ 20/May/10 ] |
|
I think we do need some basic functional tests of our Commands, they have been subject to many bugs in the past becaues they are not tested. |
| Comment by Benjamin Eberlei [ 19/Jun/10 ] |
|
Fixed another fatal error in the command due to missing namespace dependency. We need tests for all the commands, there have been dozens of issues on these things so far. This commit shows a simple approach on how testing is easily possible for symfony commands: http://github.com/doctrine/doctrine2/commit/51e6681934a7cf4448b85c5670c04045f66c6056 |
| Comment by Roman S. Borschel [ 26/Aug/10 ] |
|
Can we expect some more tests for beta4 or is it unlikely that you find the time? Should we move this further back or does someone else want to step in? |
[DDC-821] Consider adding Query-Join as another join method for DQL Created: 29/Sep/10 Updated: 29/Dec/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Marc Hodgins | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
Some ORM systems support an alternative to fetch-join queries, called a "query-join". See http://www.avaje.org/ebean/introquery_joinquery.html. A query-join accomplishes the same as a fetch-join (hydrating a larger object graph across all associations types) but executes more than one SQL query in sequence in order to hydrate the requested portions of the graph in a result set. The first query retrieves data from the base entity/table and the next queries retrieve the data for the requested associations. In some cases this approach is more efficient to a fetch-join: (1) No data duplication in the SQL result as occurs in a fetch-join on to-many associations. Instead, this data is loaded through a second query. This saves network traffic, memory and general overhead in hydrating the returned results. In the case where large TEXT data is included in result sets, the savings here may be substantial. (2) setFirstResult() and setMaxResult() are again effective (for pagination) and more importantly more efficient on these query-joins. The current DoctrineExtension solution to enable pagination on fetch-joins requires a series of queries to determine the target primary keys of the root entity of the query. The primary key lookup query requires DISTINCT or GROUP BY – which often triggers filesorts, temporary tables, etc (at least on MySQL) and greatly slows down the query. Query joins would not require this. Possible implementation example: // existing fetch-join $query = $em->createQuery('SELECT c, o FROM Customers c JOIN c.orders o'); $query->setFirstResult(10)->setMaxResult(20); // doesn't do what you'd hope it would do, no ability to use this for pagination $customersAndOrders = $query->getResult(); // array of Customer objects with Orders hydrated // proposed query-join $query = $em->createQuery('SELECT c, o FROM Customers c QUERY JOIN c.orders o'); $query->setFirstResult(10)->setMaxResult(20); // now works for pagination $customersAndOrders = $query->getResult(); // array of Customer objects with Orders hyrdated // this would execute a series of queries -- i.e. in SQL // SELECT ... FROM customers LIMIT 10, 20 // SELECT ... FROM orders WHERE customer_id IN (.....) and/or, could there be a way to trigger a "query-join" against an existing array of entities? for example $query = $em->createQuery('SELECT c FROM Customers c'); // single query to fetch customers
$customers = $query->getResult(); // array of Customer objects
$em->join($customers, 'orders'); // fetch and hydrate the 'orders' association on each Customer using a single query
Perhaps at some point in the future Doctrine/DBAL could even make use of asynchronous queries (i.e. mysqlnd supports this) to allow these query-joins to run in parallel and the result would be more efficient paginated resultsets. Thoughts/feedback? |
| Comments |
| Comment by Benjamin Eberlei [ 30/Sep/10 ] |
|
There is another approach for this using several subqueries to build an IN clause, the Paginator extension supports this: http://github.com/beberlei/DoctrineExtensions I rather go the extension approach than changing the DQL for this feature. |
| Comment by Benjamin Eberlei [ 30/Sep/10 ] |
|
I just saw your second example, that is rather cool though and gets +1 from me. I had the same idea for "not initialized proxies", i.e. $em->getUnitOfWork()->initializeProxies('Customer');
|
| Comment by Marc Hodgins [ 29/Dec/10 ] |
|
Second example is a duplicate of |
[DDC-810] Issue with detaching entities and updating when using change notification Created: 17/Sep/10 Updated: 04/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.0-BETA4 |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Jonathan H. Wage | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
More information coming soon. Attaching a test case |
| Comments |
| Comment by Benjamin Eberlei [ 20/Sep/10 ] |
|
From reading the issue i know what the bug is, indeed this sucks. |
| Comment by Roman S. Borschel [ 28/Sep/10 ] |
|
@Jon: Any more information coming? @Benjamin: Can you summarize the essence of the issue shortly? |
| Comment by Benjamin Eberlei [ 29/Sep/10 ] |
|
@Roman: The UnitOfWork (may) still be pushed as a listener into that entity, and still recieve noticies of update. Which may throw notices because the oid hashes are removed everywhere. Additionally you cant serialize the thing because you still got the UoW inside there. |
| Comment by Jonathan H. Wage [ 04/Oct/10 ] |
|
I don't have anymore information currently. The issue was relayed to me. I will try and find some more information and report back. |
| Comment by Benjamin Eberlei [ 03/Apr/11 ] |
|
There is no way to "fix" this issue, i am turning it into a feature request. There needs to be a "postDetach" event that is triggered where the developer can detach the change notification objects. |
[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-1264] Add more math related DQL funcs (trig, round, stuff?) Created: 09/Jul/11 Updated: 09/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
[DDC-1262] Have proxies copy docblocks aswell Created: 09/Jul/11 Updated: 09/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0.6, 2.1, Git Master |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Whenever a Proxy is generated it does not copy the docblocks. This means when you do something like "$refl = new ReflectionObject($proxy)" you might be in trouble. However if we add docblocks then we have to make sure that proxies do not magically appear as entities by throwing an exception in the AnnotationDriver. |
[DDC-1229] generate entity interactive dialog: id column Created: 27/Jun/11 Updated: 28/Jun/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Tools |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | David Buchmann | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
according to Stof, this bug https://github.com/sensio/SensioGeneratorBundle/issues/21 comes from the doctrine tools implementation: in the dialog, i first specified that i want a field id of type integer. the result was [Doctrine\ORM\Mapping\MappingException] Duplicate definition of column 'id' on entity 'Liip\DemoBundle\Entity\Event' in a field or discriminator column mapping. and no file was created. The dialog should tell me i can not create a field named id. (Or better ask first if i want my id column named id or something else.) It would be nice if it would write some file even if its not valid, with a warning on top. As it is, i lost all my work of specifying fields. (Luckily was just playing around) |
| Comments |
| Comment by Benjamin Eberlei [ 28/Jun/11 ] |
|
not a bug, its a feature (though a dumb one). Improvement in a next version. |
[DDC-1219] Remove dependancy on Collection interface in Domain Objects Created: 21/Jun/11 Updated: 04/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.1 |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | André R. | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Short: This issue is all about being able to use doctrine with naked domain objects without any use of doctrine classes. Seems like some of the UnitOfWork code is cable of handling other types of arrays, like: // If $actualData[$name] is not a Collection then use an ArrayCollection.
if ( ! $actualData[$name] instanceof Collection) {
$actualData[$name] = new ArrayCollection($actualData[$name]);
}
But in __cascade* functions this is not the case in all but two: if ($relatedEntities instanceof Collection) {
if ($relatedEntities instanceof PersistentCollection) {
// Unwrap so that foreach() does not initialize
2 however have: if (($relatedEntities instanceof Collection || is_array($relatedEntities))) {
if ($relatedEntities instanceof PersistentCollection) {
// Unwrap so that foreach() does not initialize
Would it be an idea to do "instanceof Traversable" instead of " instanceof Collection"? |
| Comments |
| Comment by André R. [ 21/Jun/11 ] |
|
Note: If the fist code block is always performed before the last 2 blocks then there is no issue here, just a need to make it more clear in Doc that this is possible but that you should not rely custom implementation as PersistentCollection will be injected when loaded from db. |
[DDC-1200] Derived Id Generator Created: 09/Jun/11 Updated: 09/Nov/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 3 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
For usage with the foreign key as primary key features described in |
| Comments |
| Comment by Daniel Lima [ 09/Nov/11 ] |
|
When this will be fixed? I think this is related to http://groups.google.com/group/doctrine-user/browse_thread/thread/7e1cfa9c4c99af31 |
[DDC-1178] Have access to "original" metadata in events subscribed to loadClassMetadata Created: 27/May/11 Updated: 27/May/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | 2.x |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Miha Vrhovnik | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
If you subscribe to loadClassMetadata you will usually modify the metadata for some classes. My proposal would be to add function get(Original|Raw)MappingData into interface Doctrine\ORM\Mapping\Driver\Driver which would either return raw data or data in a object specific for that Driver or null if it doesn't make sense for that driver. Please note, that when loading from e.g XmlDriver we should return simplexmlnode or dom node as loadClassMetadata should be in its own namespace and not pollute the Doctrine one. |
| Comments |
| Comment by Gediminas Morkevicius [ 27/May/11 ] |
|
Sounds logic, each driver would expect NULL or data (wrapped specifically for the driver used) |
[DDC-952] Several features to batch eager selects more efficently Created: 27/Dec/10 Updated: 04/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Sub-Tasks: |
|
| Description |
|
This ticket aggregates several strategies to optimize batching of eager selects. |
| Comments |
| Comment by Benjamin Eberlei [ 31/Dec/10 ] |
|
Requirements for batching of eager loads: 1. Since we are using an IN() query for this we can only support this feature for entities that have a single column primary key. |
| Comment by Benjamin Eberlei [ 31/Dec/10 ] |
|
Next item to think about: What if an exception or event breaks the flow and "triggerEagerLoads()" is never called? |
[DDC-947] Optmize Code-Generation Strategies Created: 24/Dec/10 Updated: 29/Mar/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
We should optimize code-generation somehow. |
| Comments |
| Comment by Benjamin Eberlei [ 29/Mar/11 ] |
|
Descheduled to 2.x |
[DDC-896] Use PDepend for Code-Generation Created: 27/Nov/10 Updated: 27/Nov/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Tools |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Our current code-generation tool has many shortcomings and due to its hard to test nature also many (known and unknown) bugs, as well as high maintenance. Since people are overusing this tool and I am sort of annoyed by how much time goes into this we should rewrite this in a two-step procedure: 1. Move code into Common so we can share it between ORM, Mongo and CouchDB. This gives us the advantage of having to maintaining less code for this stuff. |
[DDC-1450] UnitOfWork Transaction Rollback Support Created: 24/Oct/11 Updated: 20/Dec/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
The UnitOfWork does not handle the case very well where a rollback is necessary. Can this be optimized? |
| Comments |
| Comment by Guilherme Blanco [ 20/Dec/11 ] |
|
Updating fix version |
[DDC-1445] Improve error messages Created: 22/Oct/11 Updated: 20/Dec/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Error messages throughout ClassMetadata validation and UnitOfWork cycles can be significantly improved. Work is being done on: https://github.com/doctrine/doctrine2/tree/ImproveErrorMessages |
| Comments |
| Comment by Guilherme Blanco [ 20/Dec/11 ] |
|
Updating fix version |
[DDC-1415] EventListener delegate on entity basis Created: 11/Oct/11 Updated: 20/Dec/11 |
|
| Status: | Reopened |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Comments |
| Comment by Benjamin Eberlei [ 12/Dec/11 ] |
|
Removed from master, as i dont like the api at all |
| Comment by Guilherme Blanco [ 20/Dec/11 ] |
|
Updating fix version |
[DDC-1398] loading one item at a time when indexBy and EXTRA_LAZY fetch mode is used on a collection Created: 29/Sep/11 Updated: 10/Mar/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Reio Piller | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 3 |
| Labels: | None | ||
| Description |
|
collection->get($key) Atm in 2.1.2 this is loading the entire collection. It would be really handy that it would extra lazy load only one item using the association and indexBy fields and given key value (if collection is not initialized and the key havent been loaded yet ofc) Am i making sense with this? |
| Comments |
| Comment by Guilherme Blanco [ 20/Dec/11 ] |
|
Updating fix version |
| Comment by German Caseres [ 05/Mar/12 ] |
|
Is there any fix for this? i have the same problem. |
| Comment by Oleg Namaka [ 10/Mar/12 ] |
|
It makes a perfect sense here, I wish it was possible, it would give us a room for even more optimization. Any input on the issue from the developers? |
[DDC-1393] Skipping tables or columns in database driver or SchemaTool Created: 24/Sep/11 Updated: 20/Dec/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.1.1, Git Master |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
There should be a sane way to skip sources of errors in SchemaTool and the DatabaseDriver. |
| Comments |
| Comment by Benjamin Eberlei [ 24/Sep/11 ] |
|
Idea: Develop a datastructure of sorts that allows saving information about skipping tables and columns therein when reverse engeneering. |
| Comment by Guilherme Blanco [ 09/Dec/11 ] |
|
This is not possible unless you take advantage of Topological Sorting to map class dependencies like we do inside of UnitOfWork AFTER creating the ClassMetadata. The necessity of having this is mandatory because we can never skip classes that have associations to other ones though FK. |
| Comment by Guilherme Blanco [ 20/Dec/11 ] |
|
Updating fix version |
[DDC-1320] Ship Immutable date time with Doctrine Common, use in ORM - Should implement __toString() Created: 06/Aug/11 Updated: 31/Oct/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Comments |
| Comment by Benjamin Eberlei [ 31/Oct/11 ] |
|
Has to be pushed back as immutable date time cannot be implemented in userland that well. |
[DDC-1308] Add cache for transient information and invalidation for ClassMetadata Created: 31/Jul/11 Updated: 20/Dec/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Two different things have to be improved in the caching: 1. The information isTransient() has to be moved to the ClassMetadataFactory and cached there. |
| Comments |
| Comment by Guilherme Blanco [ 20/Dec/11 ] |
|
Updating fix version |
[DDC-1543] Support for Mapping Files on Traits Created: 17/Dec/11 Updated: 17/Dec/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
With PHP 5.4 and traits coming we should find a way where you can add xml and yml configurations for a trait and upon loading an entity X, it also loads the trait configuration of this entity. |
[DDC-1530] HIDDEN values cannot be used in WhereClause Created: 12/Dec/11 Updated: 25/Jan/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | Git Master |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Guilherme Blanco | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
SELECT u, u.name AS HIDDEN n FROM User u WHERE n = ?1 Is broken. Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sclr16' in 'where clause On a query like: SELECT s0_.id AS id0, s0_.a AS a1, s0_.b AS b2, s0_.c AS c3, s0_.d AS d4, s0_.e AS e5, s0_.f AS f6, s0_.g AS g7, s0_.h AS h8, s0_.i AS i9, s0_.j AS j10, s0_.k AS k11, s0_.l AS l12, s0_.m AS m13, s0_.n AS n14, s0_.o AS o15, 123456789 AS sclr16, s0_.p AS p17 FROM myEntity s0_ WHERE s0_.a = 1 AND sclr16 <= ? ORDER BY sclr16 ASC |
| Comments |
| Comment by Guilherme Blanco [ 20/Dec/11 ] |
|
Updating fix version |
| Comment by Christian Raue [ 09/Jan/12 ] |
|
It occurs even if the value is not HIDDEN. |
| Comment by Benjamin Eberlei [ 10/Jan/12 ] |
|
@Christian this sounds like a completly different error, please explain why you think this belongs here or open a new ticket. |
| Comment by Christian Raue [ 10/Jan/12 ] |
|
Benjamin: Because I get exactly the same error message regardless of using HIDDEN. So HIDDEN doesn't seem to be liable here. |
| Comment by Benjamin Eberlei [ 10/Jan/12 ] |
|
Can you paste your DQL and SQL? |
| Comment by Christian Raue [ 10/Jan/12 ] |
|
Code: $queryBuilder
->select('myEntity, 123456789 AS distance')
->where('distance <= 10')
;
DQL: SELECT myEntity, 123456789 AS distance FROM MyCompany\MyBundle\Entity\MyEntity myEntity WHERE distance <= 10 SQL: SELECT s0_.id AS id0, s0_.a AS a1, s0_.b AS b2, s0_.c AS c3, s0_.d AS d4, s0_.e AS e5, s0_.f AS f6, s0_.g AS g7, s0_.h AS h8, s0_.i AS i9, s0_.j AS j10, s0_.k AS k11, s0_.l AS l12, s0_.m AS m13, s0_.n AS n14, s0_.o AS o15, 123456789 AS sclr16, s0_.p AS p17 FROM myEntity s0_ WHERE sclr16 <= 10 |
| Comment by Benjamin Eberlei [ 11/Jan/12 ] |
|
That is expected behavior, ANSI SQL defines SELECT to be evaluated AFTER WHERE. SELECT 1234 AS foo FROM `test` HAVING foo = 1234 DQL has a HAVING clause as well, not sure it works without the group by. Please try. |
| Comment by Christian Raue [ 21/Jan/12 ] |
|
So we might just close this issue then? |
| Comment by Benjamin Eberlei [ 25/Jan/12 ] |
|
Its not a bug, just the error message is supposed to be improved (if possible) in a cheap way. |
[DDC-1729] Translate queries into graphs of value objects (instead of array hydration?) Created: 27/Mar/12 Updated: 09/Jun/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
In decoupled applications the model layer returns "data-transfer-objects" through the boundary into the controller/view layer. It would make sense to have Doctrine directly generate any data-transfer/value-object from native and dql queries. |
| Comments |
| Comment by Benjamin Eberlei [ 09/Jun/12 ] |
|
Example: $dql = "SELECT new CustomerAddressView(c.id, c.name, a.id, a.street, a.number, a.city, a.code)
FROM Customer c INNER JOIN c.address a WHERE c.id = ?1";
This supersedes DDC-1819. 1. One additional property in ResultSetMapping => $viewModelClass? |
[DDC-213] Persist order of collections Created: 15/Dec/09 Updated: 16/Oct/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.0 |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 10 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
A Collection is like a php array, an ordered map. Hence there should be the possibility to persist this order. |
| Comments |
| Comment by Christian Heinrich [ 21/May/10 ] |
|
Roman, I'd like to do this one as I have currently a use case for this. Do you have any idea of how to do this? What I'm wondering is whether it is possible to implement this without user intervention. (This would simply mean "store the entities as they were added"). But this would need another column in DB that we'd have to add within oneToMany / manyToMany relationships, but in this case one could save a serialized array holding "entityId => position" key / value pairs. Afterwards, one could easily rebuild / reorder the collection via $collection->set($entity, $order[$entity->identifier]); If you've got another thought about this, please don't hesitate to point me into the right direction! |
| Comment by Benjamin Eberlei [ 22/May/10 ] |
|
this won't be implemented until 2.1, since its a pretty complex feature. Changes are probably required in: 1. CollectionPersister - Add a new collection persister that takes the position into account You can implement this already though with some performance hit in update scenarios. If you use the ORDER BY support and implement an API around your entity that abstracts those changes and always sets a "position" field on the many entity that is supposed to be sorted. |
| Comment by Roman S. Borschel [ 22/May/10 ] |
|
I don't think we necessarily need a new collection persister. Simply adjusting the ManyToManyPersister to be able to deal with it might be sufficient. For OneToMany, that is always persisted from the "many" side, thus there is no collection persister, we would need to adjust the normal persisters. They key element for the user should be a new annotation (or corresponding xml/yaml element) @OrderColumn. By default the order should not be persistent, only when an @OrderColumn annotation is present. The name of the order column can have a default, i.e. "position". Thus this enhancement of persisting the order should be fully backwards compatible. |
| Comment by Roman S. Borschel [ 22/May/10 ] |
|
On another note, the getInsertDiff/getDeleteDiff methods of PersistentCollection should already be "ready" for this. That is, when an element in the collection changed only its position, this is already tracked as a change. However the ManyToManyPersister issues no "UPDATE" queries, it simply deletes and inserts. A position change may be more effectively persisted with an UPDATE. |
| Comment by Benjamin Eberlei [ 30/Sep/10 ] |
|
From a mailinglist entry, required check/changepoints: 1. ClassMetadata of Many-To-Many associations have to be extended to publish the required datastructure to the ORM. |
| Comment by Benjamin Eberlei [ 24/Dec/10 ] |
|
Push back to 2.x, we will have support for |
| Comment by Thomas Tourlourat - Armetiz [ 07/Feb/12 ] |
|
Hi there, Benjamin Eberlei said that : "You can implement this already", but I don't understand the "how to". Also, To get this feature without any change on Doctrine, I have remplace the PK defined by the target & mapped field identifier. The new PK is a new field with type "integer" and with auto-increment enable. It's an very bad solution, but It work before an official support. Waiting for advices, and solutions, Thomas. |
| Comment by Thomas Tourlourat - Armetiz [ 08/Feb/12 ] |
|
Answering to Benjamin Eberlei on the "7. Discuss wheather to support this for One-To-Many also with the key-column on the many side. This is much more tricky internally though.". I think that for One-To-Many relations, if user want to store the collection order, Doctrine can store the One-To-Many as Many-To-Many with a "model" limitation. What do you think about it ? |
| Comment by Nicolas [ 29/Feb/12 ] |
|
I think that it must be possible to have two keys ordering : the order isn't obligatory reversible. For exemple with user and group :
And maybe more, if you decide to add multi-order : an user show group by his rank in it, if his rank is identical, the order is make by love preference, and after by the importance given by the user (not necessary a number, if we imagine filter on them). So a default order can be choice with parametized fields and could be : @ManyToMany(targetEntity="Group") ... @JoinFields ( rank: { type: int} , preference:{type:int}, importance:{type: string, length: 40} ) @OrderByJoinFields({"rank" = "ASC", "preference"="ASC", "importance"="ASC" } ) In this case the order must be optional and would be clean if another order appears in the same scope (DQL...). And manytomany became virtual entities act as other entities except they don't appears permetting in the same time a better conception. So if the solution take in DDC-181 will become the only solution. This would a good idea to document this. Because, this seems to me a very important point. My last point is even an unique ordering field created in the join table will be a big and usefull improvement. Thank a lot for your beautiful work. |
| Comment by Thomas Tourlourat - Armetiz [ 29/Feb/12 ] |
|
In my point of view, a collection can be order in a single way only.
And it's your role to keep a consistency between members & importantMembers array. Because ManyToMany join table is the reflection of a state of an ArrayCollection. It's not a usefull feature to be able to store all of the state of an ArrayCollection, even the order of this Array. It's just a normal feature that is really missing Thomas. |
| Comment by Nicolas [ 29/Feb/12 ] |
|
I don't think: If you have three collection, you duplicate one relation 3 times and it's easy in consequence to lost the data integrity and unicity. By example :
So in my idea, the many to many relation isn't just an array collection, but should be an virtual entity. In UML or in Merise method this is a common problem to have a parametized relation. I think an orm should just implement this. |
| Comment by Thomas Tourlourat - Armetiz [ 29/Feb/12 ] |
|
Hum, |
| Comment by Thomas Tourlourat - Armetiz [ 07/Mar/12 ] |
|
I just want to add a piece of Doctrine ORM Document : "When working with collections, keep in mind that a Collection is essentially an ordered map (just like a PHP array). That is why the remove operation accepts an index/key. removeElement is a separate method that has O ( n) complexity using array_search, where n is the size of the map." |
| Comment by Thomas Tourlourat - Armetiz [ 23/Mar/12 ] |
|
Hi there, Doctrine Documentation says : "When working with collections, keep in mind that a Collection is essentially an ordered map (just like a PHP array)". But I not agree with @Nicolas. Because in his case, he's talking about Association Class : http://etutorials.org/Programming/UML/Chapter+6.+Class+Diagrams+Advanced+Concepts/Association+Class/ What do you think about it ? Thomas; |
| Comment by Thomas Tourlourat - Armetiz [ 31/Aug/12 ] |
|
Any news ? |
| Comment by Matthieu Napoli [ 16/Oct/12 ] |
|
Hi, any news on this? If I may add any info to this feature request, maybe something like JPA/Hibernate could be a good start? See http://docs.oracle.com/javaee/6/api/javax/persistence/OrderColumn.html or http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/collections.html#collections-indexed The idea in Hibernate is that you persist the order of the list in an extra column. This column is not a field of the entity however. |
[DDC-128] Consider adding EntityManager#link/unlink methods for direct association manipulation Created: 07/Nov/09 Updated: 29/Dec/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA2 |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
A problem when working with collection-valued associations is that almost all operations except add($obj) require the collection to become initialized in order for the operation to be performed properly. While this is all correct and beautiful OO-wise it may be problematic at times with regards to performance. Hence we might want to consider to provide some convenient methods along the lines of link/unlink (name suggestions?) which allow more direct, less OO collection manipulation. Such methods obviously would bypass the normal object lifecycle and the changes done through these methods will not be reflected in the in-memory objects and collections, unless the user keeps them in-synch himself. |
| Comments |
| Comment by Benjamin Eberlei [ 11/Dec/09 ] |
|
Questions
Regarding the naming, i like link/unlink. |
| Comment by Roman S. Borschel [ 17/Dec/09 ] |
|
What do you mean by "handled by UnitOfWork commit" ? Whether the SQL is "scheduled" or executed immediately? Interesting question. As far as usage is concerned, I currently imagine it as follows: // EntityManager#link($sourceObj, $field, $targetObj) $user = $em->getReference($userId); // $userId probably from request parameters $address = $em->getReference($addressId); // $addressId probably from request parameters $em->link($user, 'addresses', $address); "What happens if: an entity is linked with a collection, although they are already connected." Probably an SQL error which results in an exception from the driver. Depends on the database constraints though. "What happens if: an entity is unlinked from a collection it is not in" Probably nothing, at least not from the SQL side. An exception could be thrown from Doctrine itself if the update affected 0 rows. Thanks for these initial questions. Thats definitely food for thought. Keep it coming. |
| Comment by Roman S. Borschel [ 26/Aug/10 ] |
|
Pushed back. |
[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-298] Allow Entity to hold a collection of a single primitive type Created: 02/Feb/10 Updated: 24/Dec/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.1 |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 3 |
| Labels: | None | ||
| Description |
|
Sometimes you want to save arbitrary information for an entity using a key -> value array-structure. JPA supports this by means of the @ElementCollection annotation with allows to specify HashMaps for example. I propose a new AssocationMapping called "ElementMapping" / "ElementCollection" and annotations (options): ElementCollection + elementTable + keyType + keyLength + keyColumnDefinition + valueType + valueLength + valueColumnDefinition The key and value definitions are necessary for converting and schema generation. The implementation would make use of the PersistentCollection at all times and work as any other persistent collection just with primitive types. Restrictions for a first implementation:
Use-Case: $entity->options['foo'] = 'bar'; $entity->options['bar'] = 'baz'; This could be done for 2.0 imho, adding the necessary changes and optimizations could then be scheduled for 2.1 |
| Comments |
| Comment by Benjamin Eberlei [ 02/Feb/10 ] |
|
In this implementation Schema-Tool would generate a table: elementTable (entity_id-1, ..., entity_id-n, key, value) and using the Platform Type Generation of keyType and valueType |
| Comment by Benjamin Eberlei [ 02/Feb/10 ] |
|
Column Names should be Change-able also since there could be people who name their primary keys "key" and "value" o_O |
| Comment by Benjamin Eberlei [ 02/Feb/10 ] |
|
Ordering could be implemented on top of this using the @OrderColumn JPA implementation by adding another column to the table with a numeric order that will be "order by"'d on select time. |
| Comment by Benjamin Eberlei [ 24/Dec/10 ] |
|
Pushed back |
[DDC-763] Cascade merge on associated entities can insert too many rows through "Persistence by Reachability" Created: 23/Aug/10 Updated: 04/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Dave Keen | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
I think that the UnitOfWork needs to maintain a map of spl_object_hash($newEntity)->$managedEntity for entities that were persisted via reachability during a merge. doMerge should then only call persistNew if the original entity has not already been persisted (if it has already been persisted it should merge the managed entity from the map). The map should be maintained until a flush() or until the UnitOfWork is cleared. The reasoning is as follows. Imagine we have a simple doctor object with no associations: $doctor = new Doctor();
$em->persist($doctor);
$em->persist($doctor);
$em->flush();
After the first persist() $doctor is MANAGED so the second persist has no effect and this results in a single Doctor row. If we do the same thing using merge and persistence by reachability: $doctor = new Doctor();
$em->merge($doctor);
$em->merge($doctor);
$em->flush();
we get 2 Doctor rows being added. Obviously in this particular case we should use the return value from the first merge() as the parameter of the second merge which would give correct behaviour. However, now imagine one Doctor has many Patients and many Patients have one Doctor, all the associations have cascade merge enabled, and further assume that $d1 (Doctor id=1) is already in the database. We now attempt to create two patients and assign them to the existing doctor: $d1= new Doctor(); $d1->id = 1; // This is a DETACHED entity $p1 = new Patient(); $p2 = new Patient(); $d1->patients->add($p1); $p1->doctor = $d1; $d1->patients->add($p2); $p2->doctor = $d1; $em->merge($p1); $em->merge($p2); $em->flush(); This actually results in 4 rows being added to the 'patients' table instead of 2, I think because $p1 and $p2 are getting persisted both as the root objects and then again from the patient->doctor->patients array. Since the cascade merging happens internally we can't replace the array contents with the managed return values without walking through the object graph (in which case there is no point in using cascade merge in the first place). Maintaining a map in UnitOfWork will allow doMerge to ensure it doesn't persist the same entities twice. I'm not sure, but this might be relevant for cascade persist too. P.S. Another bug report on this can be found at http://code.google.com/p/flextrine2/issues/detail?id=32 (it basically says the same thing with different entities). |
| Comments |
| Comment by Benjamin Eberlei [ 29/Aug/10 ] |
|
@Roman A possible fix for this in my opinion is another map in UnitOfWork $mergedEntities = array(); and a patch like this: diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 242d84b..1d0d8b3 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1340,6 +1340,10 @@ class UnitOfWork implements PropertyChangedListener return; // Prevent infinite recursion } + if (isset($this->mergedEntities[$oid])) { + return $this->mergedEntities[$oid]; + } + $visited[$oid] = $entity; // mark visited $class = $this->em->getClassMetadata(get_class($entity)); @@ -1468,6 +1472,8 @@ class UnitOfWork implements PropertyChangedListener $this->cascadeMerge($entity, $managedCopy, $visited); + $this->mergedEntities[$oid] = $managedCopy; + return $managedCopy; } |
| Comment by Dave Keen [ 29/Aug/10 ] |
|
I have tested this patch with my application and it fixes the problem in all my relevant test cases apart from one. The test case that's failing is one that persists a bi-directional many to many relationship, so the associations interweave with each other (if you know what I mean). I wonder if perhaps doMerge need to continue cascading even if it finds an item in $this->mergedEntities This is the Flextrine code that fails - it results in no entries in movie_artist. This might also be related to m1 = new Movie(); m2 = new Movie(); a1 = new Artist(); a2 = new Artist(); m1.artists.addItem(a1); a1.movies.addItem(m1); m2.artists.addItem(a1); a1.movies.addItem(m2); // These translate to cascade merges on the server // Now flush |
| Comment by Dave Keen [ 29/Aug/10 ] |
|
P.S. This test passes if I translate em.persist() to $em->persist() (not cascading) on the server instead of translating it to a cascade merge; not sure if that helps |
| Comment by Roman S. Borschel [ 30/Aug/10 ] |
|
I'd really like to avoid introducing an additional instance variable just to solve this issue but I did not find the time yet to really look into it. Does someone have a unit test for this already and can attach it to the issue? |
| Comment by Roman S. Borschel [ 31/Aug/10 ] |
|
Rescheduling for RC1. |
| Comment by Dave Keen [ 13/Sep/10 ] |
|
Here is a functional test case containing three tests: testMultiMerge tests basic merging of two new entities, checking that only a single entity ends up in the database. This passes with Benjamin's patch. testMultiCascadeMerge tests the more complex case of merging a OneToMany association. This also passes with Benjamin's patch. testManyToManyPersistByReachability tests the ManyToMany case described above and this fails with Benjamin's patch, probably because doMerge doesn't cascade down entities that it has already merged and some ManyToMany associations are being ignored. Its a bit hard to be certain what is causing this as even without Benjamin's patch this test would fail due to |
| Comment by Benjamin Eberlei [ 15/Sep/10 ] |
|
@Roman i thought about this issue, its not possible without that additional map of merged entities. There is no way we can get that information from other sources. Problem is rather that the use-case probably only applies in mass-merging scenarios and client-server serialization. |
| Comment by Dave Keen [ 21/Sep/10 ] |
|
Added another failing test case - adding the same entity from different ends of a many to many bi-directional association to check that there isn't an integrity constraint violation caused by Doctrine trying to add the same row twice. |
| Comment by Dave Keen [ 21/Sep/10 ] |
|
Attached a patch for this issue. |
| Comment by Benjamin Eberlei [ 22/Sep/10 ] |
|
can you comment why all the additionall stuff is necessary compared to my patch? |
| Comment by Dave Keen [ 22/Sep/10 ] |
|
It fixes the two additional test cases - testManyToManyPersistByReachability and testManyToManyDuplicatePersistByReachability. testManyToManyPersistByReachability was failing with your original patch because there are ManyToMany cases where an entity may have already been merged, but its still necessary to add it to an association and continue to cascade. Running the following with the original patch will miss out some of the associations. $m1 = new Movie(); $m1->title = "Movie 1"; $m2 = new Movie(); $m2->title = "Movie 2"; $a1 = new Artist(); $a1->name = "Artist 1"; $a2 = new Artist(); $a2->name = "Artist 2"; $m1->artists->add($a1); $a1->movies->add($m1); $m1->artists->add($a2); $a2->movies->add($m1); $m2->artists->add($a1); $a1->movies->add($m2); $m2->artists->add($a2); $a2->movies->add($m2); $em->merge($a1); $em->merge($a2); $em->flush(); The other change in my patch is to protect against this case. It ensures that the following code doesn't add the same entity twice to a collection. $em->merge($m1); $em->merge($m2); $em->merge($a2); $em->merge($a2); $em->flush(); |
| Comment by Benjamin Eberlei [ 31/Oct/10 ] |
|
I am not sure if the issue here is rather multiple calls to merge that contain different parts of the same object-graph. There should be a very simple fix for this, call ->clear() after each merge. I am not sure if this patch drags us into a blackhole of issues with merging. |
| Comment by Dave Keen [ 31/Oct/10 ] |
|
Calling ->clear() and ->flush() after each merge is a workaround for the simple case, but unless I am misunderstanding I don't think its a solution for cases where the merging is happening automatically in cascadeMerge. I've actually encountered this issue in another project and scenario to do with creating REST APIs and merging JSON objects into entities, and applying the patch fixed it so a) I think this issue might be a more common that we first thought and b) the patch basically seems to work (plus it doesn't introduce any failing cases in the existing test suite). I can actually still find one edge case to do with cascading merging interlinked many to many associations that this doesn't fix, but I was planning to open that as a new ticket after this My feeling is that the current merge already has issues and this definitely improves it. |
| Comment by Benjamin Eberlei [ 01/Nov/10 ] |
|
It cannot happen inside a single merge, single merges use the $visited to avoid infinite recursions, each entity can only be merged once inside a single merge operation. |
| Comment by Benjamin Eberlei [ 10/Nov/10 ] |
|
Added a note into the documentation about using EntityManager#clear between merging of entities which share subgraphs and cascade merge. Handling this issue in UnitOfwork will be declared an improvement, not a bug anymore and be scheduled for later releases. The required changes to the core are to dangerous and big. |
| Comment by Dave Keen [ 11/Nov/10 ] |
|
Where in the docs is that? Just to summarize, the equivalent operation to having multiple merges and a single flush is to call merge followed by flush each time, with the whole thing surrounded by a transaction? Does this have a big impact on performance? |
| Comment by Dave Keen [ 11/Nov/10 ] |
|
Ben - even given the decision not to implement this (and I do understand your thinking, as it is a major change), is there any reason not to implement the bit that ensures that the same entity isn't added to a collection twice during a merge? I can't think of a situation where this should be allowed, and I have a use case where I get 'DUPLICATE KEY' errors if this isn't there. Please see attached patch. |
| Comment by Benjamin Eberlei [ 11/Nov/10 ] |
|
What bit of that huge patch is that? Can you extract it into another ticket if thats possible? |
| Comment by Benjamin Eberlei [ 11/Nov/10 ] |
|
I added it to "Working with Objects" and the descripton of Merge. Its not yet live on the site. Using this current workaround has a performance impact, since more SELECT statements have to be issued against the database. |
| Comment by Dave Keen [ 11/Nov/10 ] |
|
Apologies for not being clear - only the 3rd patch (multipleaddmerge.diff) is relevant to the 'DUPLICATE KEY' error I am now talking about, but I'll put it in a nother ticket if you prefer. |
| Comment by Benjamin Eberlei [ 11/Nov/10 ] |
|
please add a new ticket, patch looks good. |
| Comment by Dave Keen [ 11/Nov/10 ] |
|
Created as |
[DDC-717] Do not use files when using proxy autogeneration Created: 22/Jul/10 Updated: 04/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Jaka Jancar | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Description |
|
Proxy classes are generated in less than 1ms for me. I prefer to not have a "build" step to reducing loading time by a milisecond, so I use autogenerate. For users like me, wouldn't it be nicer if we wouldn't even have to configure a proxy dir and those files were never written (since they're not read more than once anyway)? |
| Comments |
| Comment by Jaka Jancar [ 22/Jul/10 ] |
|
This very minimal patch removes the use of these temporary files: --- library/Doctrine/ORM/Proxy/ProxyFactory.php (revision 2)
+++ library/Doctrine/ORM/Proxy/ProxyFactory.php (working copy)
@@ -78,9 +78,8 @@
$fqn = $this->_proxyNamespace . '\\' . $proxyClassName;
if ($this->_autoGenerate && ! class_exists($fqn, false)) {
- $fileName = $this->_proxyDir . DIRECTORY_SEPARATOR . $proxyClassName . '.php';
- $this->_generateProxyClass($this->_em->getClassMetadata($className), $proxyClassName, $fileName, self::$_proxyClassTemplate);
- require $fileName;
+ $file = $this->_generateProxyClass($this->_em->getClassMetadata($className), $proxyClassName, null, self::$_proxyClassTemplate);
+ eval('?>'.$file);
}
if ( ! $this->_em->getMetadataFactory()->hasMetadataFor($fqn)) {
@@ -144,6 +143,9 @@
$file = str_replace($placeholders, $replacements, $file);
+ if ($fileName === null)
+ return $file;
+
file_put_contents($fileName, $file);
}
|
| Comment by Benjamin Eberlei [ 23/Jul/10 ] |
|
The proxy dir is used for the "doctrine orm:generate-proxies" command in the case of "autogenerate= false", so you need to define it anyways. You have to use proxies, the option is not for Proxy yes/no. If you have autogenerate=false and doctrine requires a proxy for a use case but can't find it you will get a fatal error. |
| Comment by Benjamin Eberlei [ 23/Jul/10 ] |
|
I just saw the eval() keyword, ieeks |
| Comment by Jaka Jancar [ 23/Jul/10 ] |
|
eval() is no different than writing code to a file and using require(). When using runtime-generated proxies, there are no benefits (that I know of) from writing them to a file. The disadvantages are:
This is a nicer patch, which makes _generateProxyClass() return a string, just like other _generate* methods: --- library/Doctrine/ORM/Proxy/ProxyFactory.php (revision 2)
+++ library/Doctrine/ORM/Proxy/ProxyFactory.php (working copy)
@@ -78,9 +78,8 @@
$fqn = $this->_proxyNamespace . '\\' . $proxyClassName;
if ($this->_autoGenerate && ! class_exists($fqn, false)) {
- $fileName = $this->_proxyDir . DIRECTORY_SEPARATOR . $proxyClassName . '.php';
- $this->_generateProxyClass($this->_em->getClassMetadata($className), $proxyClassName, $fileName, self::$_proxyClassTemplate);
- require $fileName;
+ $code = $this->_generateProxyClass($this->_em->getClassMetadata($className), $proxyClassName);
+ eval($code);
}
if ( ! $this->_em->getMetadataFactory()->hasMetadataFor($fqn)) {
@@ -107,19 +106,19 @@
foreach ($classes as $class) {
$proxyClassName = str_replace('\\', '', $class->name) . 'Proxy';
$proxyFileName = $proxyDir . $proxyClassName . '.php';
- $this->_generateProxyClass($class, $proxyClassName, $proxyFileName, self::$_proxyClassTemplate);
+ $code = $this->_generateProxyClass($class, $proxyClassName);
+ file_put_contents($proxyFileName, "<?php\n" . $code);
}
}
/**
* Generates a proxy class file.
*
- * @param $class
- * @param $originalClassName
+ * @param ClassMetadata $class
* @param $proxyClassName
- * @param $file The path of the file to write to.
+ * @return string The code of the generated methods.
*/
- private function _generateProxyClass($class, $proxyClassName, $fileName, $file)
+ private function _generateProxyClass(ClassMetadata $class, $proxyClassName)
{
$methods = $this->_generateMethods($class);
$sleepImpl = $this->_generateSleep($class);
@@ -142,9 +141,9 @@
$methods, $sleepImpl
);
- $file = str_replace($placeholders, $replacements, $file);
+ $file = str_replace($placeholders, $replacements, self::$_proxyClassTemplate);
- file_put_contents($fileName, $file);
+ return $file;
}
/**
@@ -244,8 +243,7 @@
/** Proxy class code template */
private static $_proxyClassTemplate =
-'<?php
-
+'
namespace <namespace>;
/**
|
| Comment by Benjamin Eberlei [ 24/Jul/10 ] |
|
Scheduled usage of eval() for 2.1, if the following conditions exist: 1. Autogenerate is set to TRUE |
| Comment by Jaka Jancar [ 24/Jul/10 ] |
|
Great, this is even better. This way you can have 1) autogenerated in ram-only, 2) autogenerated in files and 3) pregenerated. And the minimal amount of config needed to get up and running is reduced, which is always nice. |
| Comment by Benjamin Eberlei [ 24/Jul/10 ] |
|
you should know though, eval is dead slow. It generates the necessary proxies on EACH request and that cannot be cached in APC. |
| Comment by Jaka Jancar [ 24/Jul/10 ] |
|
It's no slower than current autogeneration (file_put_contents+require). TBH, I don't know why anyone would want to use that over eval(), but I don't mind it being there. Pre-generation is, of course, a different thing. Seems like a valid tradeoff to offer: build/a bit of config/better perfomance vs. no build/no config/potentially slower. |
| Comment by Benjamin Eberlei [ 24/Jul/10 ] |
|
Yes, that is because file_put_contents + require is a development only strategy. The manual clearly states that autogenerate has to be false in production. |
| Comment by Roman S. Borschel [ 12/Aug/10 ] |
|
Using eval() instead of producing and requiring the file in the case of enabled auto-generation of proxy classes sounds like a good improvement for 2.1 to make proxies more transparent during deveopment and for anyone for whom performance is no issue. I'm increasing the priority as I think it is easy to implement for 2.1 and a good enhancement. |
| Comment by Karsten Dambekalns [ 09/Feb/11 ] |
|
A note on why having the proxies written to a file can be useful even with autogenerate being on: it makes it really easy to check the proxy code being generated. I use that a lot currently. The solution suggested, giving three possibilities is cool, though. |
[DDC-676] Find a way to test serialize/unserialize of all ClassMetadata properties in isolation Created: 10/Jul/10 Updated: 29/Aug/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
We should find a way, using PHPUnit Data Providers or anything else, to check the serialize/unserialize of every property in the ClassMetadata instance, since errors here can be very subtle but dangerous. |
[DDC-667] Lock Timeout Query Hint for DQL Queries Created: 04/Jul/10 Updated: 16/Sep/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-BETA2 |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
After the implementation of This will be a DQL query feature only and be available via a query hint: $query->setHint(Query::LOCK_TIMEOUT, $timeoutMs); It will be only working on Oracle. |
| Comments |
| Comment by Roman S. Borschel [ 30/Aug/10 ] |
|
If this is to be implemented for 2.0, it needs to happen for RC1, therefore rescheduling to RC1. Feel free to reschedule to 2.x if necessary. |
| Comment by Benjamin Eberlei [ 16/Sep/10 ] |
|
Only oracle supports lock timeouts and no other vendor seems to plan to support it. I move to 2.x, but i guess this would rather be an issue of user extension. |
Allow @Id on @ManyToOne fields
(DDC-117)
|
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Sub-task | Priority: | Major |
| Reporter: | Mickael Perraud | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
Ubuntu 10.04 + Oracle 11g Entreprise + PHP 5.3.2 + Doctrine2 Git (up-to-date) |
||
| Description |
|
I am playing with reverse engineering with Oracle and I have some problems: My schema: drop table PHONE_NUMBER; drop table CUSTOMER; create table CUSTOMER ( CUSTOMER_ID NUMBER(4) not null, CUSTOMER_LASTNAME VARCHAR2(50) not null, CUSTOMER_MODIFIED DATE, constraint PK_CUSTOMER primary key (CUSTOMER_ID) using index tablespace TBS_INDEX storage ( initial 100K next 100K ) ) storage ( initial 100K next 100K ) tablespace TBS_DATA; create table PHONE_NUMBER ( PHONE_NUMBER_ID NUMBER(4) not null, CUSTOMER_ID NUMBER(4) not null, PHONE_NUMBER VARCHAR2(50) not null, PHONE_NUMBERMODIFIED DATE, constraint PK_PHONE_NUMBER primary key (PHONE_NUMBER_ID, CUSTOMER_ID) using index tablespace TBS_INDEX storage ( initial 100K next 100K ) ) storage ( initial 100K next 100K ) tablespace TBS_DATA; alter table PHONE_NUMBER add constraint PHONE_NUMBER__CUSTOMER foreign key (CUSTOMER_ID) references CUSTOMER (CUSTOMER_ID); I obtain "Fatal error: Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Property "customerId" in "PhoneNumber" was already declared, but it must be declared only once'" It's because a foreign key is a component of the primary key. |
| Comments |
| Comment by Mickael Perraud [ 28/Jun/10 ] |
|
This is the continuation of http://www.doctrine-project.org/jira/browse/DDC-616. Only the schema is different. |
| Comment by Benjamin Eberlei [ 28/Jun/10 ] |
|
just for understanding this scenario: Is this a One-To-One relation and the TABLE_TEST2 "inherits" the primary key from its parent TABLE_TEST1? If yes, this construct is not yet supported by Doctrine 2, we still need to include an ID-Generator that supports this kind of schema. |
| Comment by Mickael Perraud [ 28/Jun/10 ] |
|
Change for a more understandable use case. Note that it's not my real use case and that I work on legacy database on which I can't change the structure. |
| Comment by Benjamin Eberlei [ 01/Jan/11 ] |
|
updated the issue topic to get a better grasp of what needs to be done here. |
| Comment by waldo [ 09/Jun/11 ] |
|
I have the same error with Mysql whit the same condition. |
| Comment by Benjamin Eberlei [ 28/Nov/11 ] |
|
More details on the work to be done: The relevant code is in Doctrine/ORM/Mapping/Driver/DatabaseDriver.php only. The idea is currently many-to-many tables are detected by checking that the table has foreign keys on all the primary key columns (no additional columns!) Now with the 2.1 feature of foreign key/primary key entities this is not necessarily true anymore. You can have the primary keys being foreign keys BUT have additional columns that are not part of the primary key. This has to be detected. If a foreign key-primary-key entity is found that has additional columns a ClassMetadata has to be created and the associations have to be created with the "id" => true flag in mapManyToOne(). |
| Comment by Scott Steffens [ 11/Dec/11 ] |
|
For what it's worth, I'm getting this error when I have a PK that is a single column and not a FK. PRIMARY KEY (`id`), |
[DDC-624] Partial object query that leaves out an association to avoid loading it fetches the association anyway. Created: 03/Jun/10 Updated: 11/Nov/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.0-BETA1 |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
Assuming: Customer <onetoone> Cart where Cart is the owning side. Since the association from Customer to Cart can not be lazy, it would make sense to leave out the association in a query to avoid loading the carts like this: select partial c.{id,name, ... anything except cart} from Customer c"
But this is ignored and the carts of all customers are fetched anyway. Query::HINT_FORCE_PARTIAL_LOAD is an alternative solution, however it has the disadvantage that it disables lazy-loading for all queried objects. If partial querying would honor associations this would allow more fine-grained control. |
| Comments |
| Comment by Roman S. Borschel [ 26/Aug/10 ] |
|
Might need to be pushed back to a 2.0.x / 2.x.x bugfix release. Not clear yet. |
[DDC-668] add upsert support Created: 04/Jul/10 Updated: 20/Dec/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Lukas Kahwe | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 4 |
| Labels: | None | ||
| Description |
|
Didnt find anything in the docs on this. Is D2 capable of doing an UPSERT [1] in case I am trying to persist an object that may or may not have been saved previously. Different RDBMS support different syntax for this case. Like MySQL has INSERT .. ON DUPLICATE KEY UPDATE (or even INSERT IGNORE) while the SQL standard defines a MERGE syntax which seems to be gaining support. Of course you can always fallback to a SELECT FOR UPDATE (or if you want to be hacky an INSERT which catches duplicate key violations .. but probably not a good idea since many RDBMS rollback on a failure inside a transaction). [1] http://en.wikipedia.org/wiki/Upsert See also http://opensource.atlassian.com/projects/hibernate/browse/HHH-3011 asking for MERGE support Ideally there would be a way to define on a model or model instance level if merge logic should be applied. |
| Comments |
| Comment by Robert Burkhead [ 09/Jul/10 ] |
|
Doctrine_Record defines a replace() method. In the MySQL Doctrine implementation, however, it is not the same as INSERT .. ON DUPLICATE KEY UPDATE. The replace() method implemented in Doctrine_Connection_Mysql uses the REPLACE INTO syntax, which is a DELETE and then INSERT when the key exists. This is fine, except for tables that use auto-increment fields. The delete-then-insert operation yields a new auto-incremented value, whereas INSERT .. ON DUPLICTATE KEY UPDATE would not. |
| Comment by Lukas Kahwe [ 09/Jul/10 ] |
|
MySQL (and SQLite) REPLACE is a no go. It causes way too much disc I/O and worse yet totally screws up the on disk data structures because of the deleting. |
| Comment by Benjamin Eberlei [ 31/Jul/11 ] |
|
Scheduled for 2.2 |
| Comment by Benjamin Eberlei [ 31/Jul/11 ] |
|
Evaluating this makes me sad, except MySQL support for this is rather non-existant, and the oracle merge is aiming at batch operations. |
| Comment by Benjamin Eberlei [ 22/Oct/11 ] |
|
Should this be done with 1. Select first, then insert I am leaning towards 1. |
| Comment by Guilherme Blanco [ 20/Dec/11 ] |
|
Updating fix version |
[DDC-93] It would be nice if we could have support for ValueObjects Created: 01/Nov/09 Updated: 14/Apr/13 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Avi Block | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 37 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||
| Description |
| Comments |
| Comment by Benjamin Eberlei [ 05/Nov/09 ] |
|
formated snippets nicely |
| Comment by Andrea Turso [ 09/Dec/09 ] |
|
I need this feature too. But I would suggest using the same annotation used by JPA @Embeddable +1 |
| Comment by Alan Gabriel Bem [ 17/Dec/09 ] |
|
You should also take into consideration different storage strategies of ValueObjects. Martin Fowler points out - in „PoEAA" - two approaches: Embedded Value (which is the one presented above) and Serialized LOB . |
| Comment by Avi Block [ 17/Dec/09 ] |
|
Of course technically we can similate a serialized LOB with a new Doctrine 2 type. |
| Comment by Alan Gabriel Bem [ 17/Dec/09 ] |
|
I don't like that idea - Its so not generic. VO as a pattern is important building block of domain model, which clearly indicates that VO as a feature of Doctrine2 should be tailor-made. To anyone of dev-team reading this issue: without VOs Doctrine is not yet DDD-ready, please hurry |
| Comment by Roman S. Borschel [ 18/Dec/09 ] |
|
Serialized LOB is not very useful IMHO and has lots of problems (many mentioned in PoEEA already). @Alan: I appreciate your nice reminder and I'm sure you mean it in a friendly way, but please keep in mind that noone is paid to work on this project. It all happens in free/spare time and the current state of the project already consumed at least 1 1/2 years spending many hours weekly on this project from me alone. Not to speak of the others. Thus, there is no point in demanding something or telling us to hurry. The best way to get a feature in is to provide a (good) patch that we find worth including. I started to add notes to this issue to collect all the things that need to be done for this feature. In the meantime, its not too hard/ugly to get a half-way decent embedded value yourself: /** @Entity @HasLifecycleCallbacks */
class Foo {
// annotations not shown
private $id;
private $embedded;
private $value1; // never reveal to public
private $value2; // never reveal to public
private $value3; // never reveal to public
public function getEmbedded() {
return $this->embedded;
}
public function setEmbedded($embedded) {
$this->embedded = $embedded;
}
/** @PrePersist @PreUpdate */
function _destructEmbedded() {
// destruct $embedded into $value1, $value2, $value3
}
/** @PostLoad */
function _constructEmbedded() {
// construct $embedded from $value1, $value2, $value3
}
}
Several variations of this are possible, also with an external event listener instead of callbacks but in that case you might need to use reflection to get at the values. |
| Comment by Alan Gabriel Bem [ 25/Dec/09 ] |
|
I want to share my thoughts on possible VOs collections implementations. 1. As it was mentioned earlier serialized (C)LOB is one solution. Implementation of storing/retrieving object graphs alone is quite simple, but it's complex in terms of SELECTs with conditions. I'm not taking Regexp or XPath operators into consideration as only few RDBMS support them. 2. The second solution is to break VOs graph into separate related table... or tables if we consider that VO can contain another VO(s). It's not so fast as serialized LOB but more flexible and it utilize power of RDMS, In conclusion: I can't tell which approach is superior, because each of them is valid under different circumstances. Hope this helps. @Alan: I appreciate your nice reminder and I'm sure you mean it in a friendly way [...] Of course I do. |
| Comment by Benjamin Eberlei [ 13/Mar/10 ] |
|
It would be easy to implement value objects in userland using the XML capabilities of many RDBMS: 1. Implement an Xpath function on the Dql Parser The second point can be heavily optimized when value objects are immutable with an own identiy map of value types inside the Type flyweight instance. |
| Comment by Avi Block [ 13/Mar/10 ] |
|
I more or less suggested something similar above. |
| Comment by Benjamin Eberlei [ 14/Mar/10 ] |
|
ah, my bad - i must have overseen this |
| Comment by John Kleijn [ 16/May/10 ] |
|
+1 This would be awesome. |
| Comment by Matthias Pigulla [ 09/Nov/10 ] |
|
Don't forget (especially with regard to SLOBs) that values might in turn contain references to Entities. Example: An "Order" might be an @Entity and might have a field (an array) of OrderLineItems as value. Each OrderLineItem might e. g. carry quantity or disconunt and references a Product (@Entity). So even if you don't need the traversal from Product to all the Orders it is contained in, serializing the OrderLineItems needs a way to "cut off" the object graph at the transition towards the Product but must place some kind of referral there so that upon unserialization (of the OrderLineItem list, that is, during Order load) the Product references in every OrderLineItem are at least initialized with proxies again. Don't know whether/how referential integrity (OrderLineItems <-> Products) would make sense or could be implemented here. |
| Comment by Benjamin Eberlei [ 24/Dec/10 ] |
|
Pushed back to 2.x, this feature is probably the largest feature request we have and we'd rather focus on small improvements for 2.1 |
| Comment by Nino Martincevic [ 11/Jan/11 ] |
|
Several thinks to consider/not to oversee here: 1) There are value objects with identity. I know that is not DDD-conform but only at first sight. It means they are technically entities but are treated like VOs. 2) In virtually all (business) cases a collection of VO is an Entity. How else could you reference (add or remove) single elements of that list? @Matthias: OrderLineItems is an example of actually being an Entity. |
| Comment by Ondrej Sibrina [ 03/Jun/11 ] |
|
Hi guys. I face this in my own way. Hope you won't wake up your neighbours with loud laugh. Every @Entity extends my BaseEntity object which provide kind of wrap for value with ValueBase object. So when want to get/set value from entity you call $entity->getData() where you won't get value "data" but wrapping ValueBase for value "data". Then you can get bare value by getValue(). Name of value class is in annotation and would be child of ValueBase. There's also parent class Base for EntityBase and ValueBase. In my case class Base is something like HTML element. So in the end you can use $entity->renderHtml() or $value->renderHtml() no matter if you're rendering value or @Entity. There's more features like validation, filtering and hydration value/entity from HTML forms, but it's extra. Implementation: "Base.php"
/* @MappedSuperclass */
abstract class Base {
/* there're methods like _getParent(), _getPropertyName(), etc. used in code behind */
}
"ValueBase.php" abstract class ValueBase extends Base { public function getValue() { return $this->_getParent()->{$this->_getPropertyName()}; } public function setValue($value) { $this->_getParent()->{$this->_getPropertyName()} = $value; } } "EntityBase.php" /** @MappedSuperclass */ abstract class EntityBase extends Base { public function __call($name, $arguments) { /* get property object */ $pattern = '/^get(.*)$/u'; preg_match($pattern, $name, $matches); if (isset($matches[1])) { $propertyName = lcfirst($matches[1]); return $this->get($propertyName); } /* set entity */ $pattern = '/^set(.*)$/u'; preg_match($pattern, $name, $matches); if (isset($matches[1])) { $propertyName = lcfirst($matches[1]); return $this->set($propertyName, $arguments[0]); } } public function get($propertyName) { $property = $this->_getElementProperty($propertyName); if ($property == null) throw new Exception(sprintf("There isn't property like '%s'.", $propertyName)); /* for collections and entities */ if ($property["type"] == "collection" || $property["type"] == "entity") { $element = $this->{$propertyName}; if ($element != null) { $element->_setParent($this); $element->_setPropertyName($propertyName); } elseif ($property["type"] == "entity") { $element = new $property["class"]; $element->_setParent($this); $element->_setPropertyName($propertyName); $element->_setNullEntity(); $this->{$propertyName} = $element; } return $element; } else { /* for values */ if (!isset($this->_loadedEntities[$propertyName])) { $this->_loadedEntities[$propertyName] = new $property["class"]($this, $propertyName); } return $this->_loadedEntities[$propertyName]; } } public function set($propertyName, $value) { $property = $this->_getElementProperty($propertyName); if ($property == null) throw new Exception(sprintf("There isn't property like '%s'.", $propertyName)); /* for collections and entities */ if ($property["type"] == "collection" || $property["type"] == "entity") { $this->{$propertyName} = $value; } /* for values */ else { throw new Exception(sprintf("Can't call set on value property '%s'.", $propertyName)); } return $this; } } Note that there's something i call "NullEntity". Instead of getting bare "null" you'll get @Entity child of EntityBase, where is set property nullEntity. Then there's posibility to work with null entity (for example renderHtml with empty inputs). It would be nice, if this is support by Doctrine natively, because i have some performace problems with my implementation. If it's interest in my whole code i can send you. But of course there's some security holes so i'll send it privetely. Thanks for understand and for Doctrine of course. |
| Comment by Mathias Verraes [ 13/Jul/11 ] |
|
Note that Roman's workaround presented here does not work. /** @PrePersist @PreUpdate */
function _destructEmbedded() {
// destruct $embedded into $value1, $value2, $value3
}
Doctrine tracks changes and does not perform updates when no changes are found. $embedded is not mapped, so it's not tracked and won't be taken into account by Doctrine when updating. Therefore, if $embedded is the only value that was changed, the PreUpdate event won't be triggered. The easiest thing to do is to simply destruct the VO on every mutation: public function setEmbedded($embedded) { $this->embedded = $embedded; $this->_destructEmbedded(); } The downside is that you need to remember to call the method in every setter, but apart from that, there are no side effects, it always works and it's just one line of code _constructEmbedded() keeps working as is, postLoad will always be triggered. |
| Comment by Benjamin Dulau [ 18/Dec/11 ] |
|
Hi, This feature would be awesome ! If you plan to implement this, please remember that you can have nested VOs. I have no doubts that you've already took this in consideration, but i prefer pointing this out, just in case |
| Comment by Benjamin Eberlei [ 20/Jan/12 ] |
|
work has been started, https://github.com/doctrine/doctrine2/pull/265 |
| Comment by Matthias Pigulla [ 23/Nov/12 ] |
|
Does the new "complex sql types" feature help here - I mean, could that be used to map a value object to more than one column in the database? |
| Comment by songoko songowan [ 10/Feb/13 ] |
|
@Benjamin Eberlei The request seems to be closed in the link you provided! Does that mean that this feature won't be implemented?! |
| Comment by Marco Pivetta [ 10/Feb/13 ] |
|
songoko songowan no, it just probably wasn't the correct way of implementing this |
| Comment by Daniel Pitts [ 11/Apr/13 ] |
|
I'm curious if any effort is currently being put into this. I would really love to have this feature available. |
| Comment by Marco Pivetta [ 11/Apr/13 ] |
|
Daniel Pitts this is being developed in DDC-2374 ( https://github.com/doctrine/doctrine2/pull/634 ) |
[DDC-1216] A way to mark an entity to always use result cache. Like @UseResultCache class annotation. Created: 19/Jun/11 Updated: 06/Apr/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.x |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Reio Piller | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Description |
|
So that even associations, find(), findBy() etc will be affected. Very useful for entities that are being used on every request. Is that thinkable? |
| Comments |
| Comment by Menno Holtkamp [ 06/Apr/12 ] |
|
During development, I tried to have the out-of-the-box ORM layer handle as much of the queries as possible, essentially I used the Repository functions a lot: For example, having a specific Repository extend the Doctrine EntityRepository and do something like:
public function findByName($name)
{
$criteria = array('_name' => $name);
return parent::findBy($criteria);
}
Now all functionality is developed, I am optimizing performance and I find myself having to refer my Repository to my DAO layer which uses DQL, so I can enable the DQL Result Cache...
public function findByName($name)
{
//Use the DAO so we can enable DQL ResultSet caching
return $this->_getDao()->loadByName($name);
}
It would be nice to be able to configure 'DQL Result Cache = on' on Repository level as well... |
[DDC-838] SchemaTool - ignores the attribute uniq in relations Created: 13/Oct/10 Updated: 29/Oct/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Tools |
| Affects Version/s: | 2.0-BETA4 |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Minor |
| Reporter: | gektor | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu, PHP 5.3.2, MySQL |
||
| Description |
|
Mapper <entity name="Default_Model_Test" table="test"> <id name="id" type="integer" column="id"> <generator strategy="AUTO"/> </id> <field name="blabla" column="blabla" type="boolean"/> <one-to-one field="user" target-entity="Users_Model_User"> <join-column name="users_id" referenced-column-name="id" on-delete="CASCADE" on-update="CASCADE" unique="false" /> </one-to-one> </entity> SQL CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, users_id INT DEFAULT NULL, blabla TINYINT(1) NOT NULL, UNIQUE INDEX test_users_id_uniq (users_id), PRIMARY KEY(id)) ENGINE = InnoDB; ALTER TABLE test ADD FOREIGN KEY (users_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE; Actual: Expected: |
| Comments |
| Comment by Benjamin Eberlei [ 14/Oct/10 ] |
|
Verified, i just don't understand why you are using a one-to-one relation and then "deactivate" the database constraint for this. You could easily use Many-To-One |
| Comment by gektor [ 14/Oct/10 ] |
|
You are right. It's not a bug, it's feature. |
| Comment by Benjamin Eberlei [ 29/Oct/10 ] |
|
This might still be a good improvement to allow the flexibility, but its not a bug. Updating to "Minor Improvmenet for 2.x" |
[DDC-1373] Map file with specific class Created: 13/Sep/11 Updated: 14/Feb/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | 2.1.1 |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Minor |
| Reporter: | Thomas Tourlourat - Armetiz | Assignee: | Fabio B. Silva |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Debian LAMP - PHP5.3 - Apache 2 |
||
| Description |
|
Hi there, It's a cool feature because it's allow loading on-demand. It should be great to be able to manually map XML/YAML File description to a Class, like : This feature is simple to implement, just add a new array inside AbsractFileDriver to know the mapping. AbsractFileDriver->getAllClassNames () just return value of mapping array. With this new feature, it allow developers to create a pretty folder that contains entities mapping. Armetiz. |
| Comments |
| Comment by Guilherme Blanco [ 20/Dec/11 ] |
|
Updating fix version |
[DDC-1370] preInsert, postInsert, prePersist, postPersist, preUpdate, postUpdate code and documentation of events Created: 09/Sep/11 Updated: 20/Dec/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Minor |
| Reporter: | Guilherme Blanco | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
Currently we have a set of Lifecycle events, but they seem to be misleading both in actual implementation and documentation. One good example is prePersist and postPersist, which is only fired when you're creating new entities. It should be renamed to preInsert and postInsert. But if we rename prePersist and postPersist to (pre|post)Insert, we may have a situation where you wanna cover both insert and update. |
| Comments |
| Comment by Rafael Dohms [ 09/Sep/11 ] |
|
Also, documentation for post* methods is broken at the website: "Changes in here are not relevant to the persistence in the database, but you can use this events to" It cuts off in mid-sentence. |
| Comment by Guilherme Blanco [ 09/Dec/11 ] |
|
RDohms, this paragraph was already sorted out. The actual ticket is still valid here. |
| Comment by Guilherme Blanco [ 20/Dec/11 ] |
|
Updating fix version |
[DDC-17] Ability to skip the operation from a pre-operation event handler Created: 20/Sep/09 Updated: 26/Aug/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Minor |
| Reporter: | Ismo Toijala | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
In Doctrine 1.1 it is possible to skip the operation in the event handlers in Doctrine_Record_Listener using Doctrine_Event::skipOperation. This no longer seems to be possible in Doctrine 2.0 Alpha 1, for example when handling a preRemove event to implement soft-delete behaviour. Perhaps a method could be added to \Doctrine\Common\EventArgs\LifecycleEventArgs to skip the operation, at least before the operation. Without this implementing soft-delete would require the user to update deleted_at and deleted_by himself and then save the record. It could no longer be done automatically when removing a record because the record is then removed. |
| Comments |
| Comment by Roman S. Borschel [ 20/Sep/09 ] |
|
The problem is, full support for soft-delete throughout the system is not feasible and very fragile. Simple soft-delete through skipping the delete operation is the easiest part. Then you will probably want to modify all DQL queries so that they adhere to it automatically and then there will always be still queries that do NOT go through DQL, like even internal lazy-load queries or native queries or others, which would need to be modified also. To sum it up, implementing soft-delete "inside" doctrine is absolutely not worth the effort and imho a bad idea and I'm certainly not willing to make lots of adjustments to the core that have a negative impact on performance just to make this soft-delete possible. I really recommend handling "soft" deletes yourself, the normal way, by simply abstracting entity retrieval and persistence through a DAO/repository layer. As a nice side-effect you get less magic and it still works when you swap out doctrine for another persistence provider. I am willing to add support for skipping deletes and maybe some other operations through events but I'm not willing to go any further, as explained above. |
[DDC-547] Consider allowing custom PersistentCollection implementations Created: 27/Apr/10 Updated: 24/Dec/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-BETA1 |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | New Feature | Priority: | Minor |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 6 |
| Labels: | None | ||
| Description |
|
We should consider allowing the configuration of custom PersistentCollection implementations on a per-association basis. For this, PersistentCollection needs to be designed for inheritance. |
| Comments |
| Comment by Roman S. Borschel [ 26/Aug/10 ] |
|
Rescheduled for 2.1. Might be 2.x. |
| Comment by Benjamin Eberlei [ 24/Dec/10 ] |
|
Reschedule for 2.x |
[DDC-445] Evaluate possible ways in which stored procedures can be used Created: 19/Mar/10 Updated: 24/Dec/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Minor |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
We should evaluate the current situation of stored procedure support as well as where we want to go with it / how far we want to support it, if at all. |
| Comments |
| Comment by Benjamin Eberlei [ 19/Mar/10 ] |
|
I think this relates to the usage of Custom Persisters |
[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-4] Implement support for Concrete Table Inheritance Created: 09/Sep/09 Updated: 24/Dec/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.1 |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Improvement | Priority: | Minor |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
A first implementation could probably live without support for polymorphic queries (requires SQL UNIONs to be generated). |
Add the notion of read-only entities
(DDC-209)
|
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL, ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.x |
| Security Level: | All |
| Type: | Sub-task | Priority: | Minor |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 5 |
| Labels: | None | ||
| Description |
|
Setting such a query hint to TRUE should result in all entities being retrieved by that query to be read-only for the purposes of change-tracking. Note that the entities themselves need not necessarily be read-only in general. This feature is a flush performance tweak that can be used to query for objects but not let the returned objects run through change-tracking on flush. Any other managed objects are tracked as usual so you can do a read-only query for 100 entities and persist a new entity in the same unit of work with optimal flushing performance. |
| Comments |
| Comment by Konstantin [ 26/Dec/11 ] |
|
Any news? |
| Comment by Gigi Largeanus [ 31/May/12 ] |
|
Any news on this? I think this is a must have feature. Thanks for all your work. |
[DDC-2133] Issue with Query::iterate and query mixed results Created: 09/Nov/12 Updated: 01/May/13 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.2.1 |
| Fix Version/s: | 3.0 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Oleg Namaka | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
Consider this code:
$dql = "
SELECT Page, Product.name
FROM Dlayer\\Entity\\Page Page
INNER JOIN Page.Product Product
";
$q = ($em->createQuery($dql));
foreach ($q->iterate() as $entry) {
$page = $entry[0][0];
$name = $entry[0]['name'];
}
This results with undefined index: 'name' for the second entry. First result keys are (notice just one array element with index 0):
0
array(2) {
[0] =>
int(0)
[1] =>
string(4) "name"
}
but all others are different (notice two array elements with index 0 and the other one that is incrementing):
the second one:
0
array(1) {
[0] =>
int(0)
}
1
array(1) {
[0] =>
string(4) "name"
}
the third one:
0
array(1) {
[0] =>
int(0)
}
2
array(1) {
[0] =>
string(4) "name"
}
What's wrong with this approach? Is it a bug or mixed results should not be used with the iterate method? |
| Comments |
| Comment by Benjamin Eberlei [ 12/Nov/12 ] |
|
This is a known issue that we don't have found a BC fix for and as I understand Guilherme Blanco requires considerable refactoring. |
[DDC-2316] [GH-588] ClassMetadataInfo: use reflection for creating new instance (on PHP >=5.4) Created: 23/Feb/13 Updated: 04/May/13 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 3.0 |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This issue is created automatically through a Github pull request on behalf of Majkl578: Url: https://github.com/doctrine/doctrine2/pull/588 Message: On PHP >=5.4, use proper way for instantiating classes without invoking constructor. |
| Comments |
| Comment by Benjamin Eberlei [ 04/May/13 ] |
|
Scheduling this for 3.0, when we move to php 5.4 or higher requirement |
[DDC-1995] "Query Exception: Invalid parameter number: number of bound variables does not match number of tokens" when using an "Instance Of" expression Created: 22/Aug/12 Updated: 29/Aug/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL |
| Affects Version/s: | Git Master |
| Fix Version/s: | Git Master |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Craig Marvelley | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Similar to this issue I think, but triggered when performing a query on entities modelled with Class Table Inheritance, e.g. $qb = $repository->createQueryBuilder('entity'); Seems that there isn't a corresponding entry in the parameter mapping array for this clause, which triggers the exception at line 254 of Doctrine\ORM\Query: if (count($paramMappings) != count($this->parameters)) { throw QueryException::invalidParameterNumber(); } |
| Comments |
| Comment by Craig Marvelley [ 22/Aug/12 ] |
|
Pull request with a potential fix: https://github.com/doctrine/doctrine2/pull/429 |
| Comment by Benjamin Eberlei [ 29/Aug/12 ] |
|
Assigned to Guilherme |
[DDC-1963] Remove by-ref access to changeset in lifecycle event args Created: 31/Jul/12 Updated: 31/Jul/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | Git Master |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Marco Pivetta | Assignee: | Marco Pivetta |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
UoW currently passes computed changesets to lifecycle event args byref. This has to be changed to force users to use UoW public API to modify changesets instead. |
[DDC-2061] Matching Criteria on a PersistentCollection only works on OneToMany associations Created: 08/Oct/12 Updated: 08/Oct/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | Git Master |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Terje Bråten | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | criteria, matching | ||
| Description |
|
What is needed to make it also work for ManyToMany associations? May be a better fallback would be do an ArrayCollection->matching() instead of just giving a runtime exception? Is this something that is difficult to implement? |
[DDC-2332] [UnitOfWork::doPersist()] The spl_objact_hash() generate not unique hash! Created: 05/Mar/13 Updated: 01/Apr/13 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Krisztián Ferenczi | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Symfony 2.1.8, php 5.4.7 and php 5.4.12, Windows 7 |
||
| Attachments: |
|
| Description |
|
I created fixtures and some data was inserted many times without calling the Task entity PrePersist event listener. I printed the used and generated hash and I saw a Proxies_CG_\Asitly\ProjectManagementBundle\Entity\User hash equal a Task entity hash! |
| Comments |
| Comment by Marco Pivetta [ 05/Mar/13 ] |
|
Please provide either a code example or a test case. As it stands, this issue is incomplete |
| Comment by Benjamin Eberlei [ 05/Mar/13 ] |
|
Are you calling EntityManager#clear() inbetween? Because PHP reuses the hashes. The ORM accounts for this. |
| Comment by Benjamin Eberlei [ 05/Mar/13 ] |
|
This is not a reproduce case, i don't want to execute your whole project. I want to know, what is the actual bug that you see? Can you just print a list of all the hashes? Because the hashes dont differ at the end, bu tjust somewhere in the middle. |
| Comment by Krisztián Ferenczi [ 05/Mar/13 ] |
|
I attached a hashlogs.txt file. The last Task class hash is 0000000050ab4aba0000000058e1cb12 ( line 3 129 ) This is not unique, view the line 2 760 . The Task is not being saved and the program don't call the prePersist listener. The "UnitOfWork" believe the entity has been saved because the isset($this->entityStates[$oid]) is true. But it is an other entity. |
| Comment by Krisztián Ferenczi [ 06/Mar/13 ] |
|
The EntityManager::clear() fix the problem, but this is not "good" and "beautiful" solution. Shows no sign of that conflicts were and this is causing the problem. I was looking for the problem 7 hours. |
[DDC-2237] oracle IN statement with more than 1000 values Created: 11/Jan/13 Updated: 02/Apr/13 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.2.2 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Marc Drolet | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
If I have a query with a IN statement with more tahn 1000 values I get an sql error. I've try IN with implode: |
| Comments |
| Comment by Marc Drolet [ 11/Jan/13 ] |
|
Here is the way I've implement the solution on my side: (for oracle) into Doctrine/DBAL/Statement.php, I've add this method:
/**
* Binds a parameter value to the statement.
* This is implemented this way for oracle only. Other drivers are redirected to bindValue method.
*
* The value will be bound with to the type provided (that required to be a table type).
*
* @param String $name The name or position of the parameter.
* @param Array $value The value of the parameter.
* @param String $type The name of the type to use to bind.
* @return boolean TRUE on success, FALSE on failure.
*/
public function bindList($name, Array $value, $type)
{
if ('oracle' !== $this->platform->getName())
{
$this->bindValue($name, $value, $type);
}
else
{
return $this->stmt->bindList($name, $value, $type);
}
}
into Doctrine/DBAL/Driver/Statement.php I've add:
/**
* @TODO: docs
*/
function bindList($param, Array $values, $type);
into Doctrine/DBAL/Driver/OCI8/OCI8Statement.php I've add this method:
/**
* {@inheritdoc}
*/
public function bindList($param, Array $value, $type)
{
if (!($list = oci_new_collection($this->_dbh, $type)))
{
//throw new OCI8Exception::fromErrorInfo($this->errorInfo());
}
foreach ($value as $entry)
{
$list->append($entry);
}
if (!oci_bind_by_name($this->_sth, $param, $list, -1, OCI_B_NTY))
{
//throw new OCI8Exception::fromErrorInfo($this->errorInfo());
}
}
// NOTE: we should probably add the bindList to all driver Statement object. into your code you can use it this way:
$sql = "
SELECT *
FROM test
WHERE id IN
(
SELECT *
FROM
(
CAST (: p_ids AS list_int_type)
)
)
";
$stmt = connection->prepare($sql);
$stmt->bindList(': p_ids', $ids, 'list_int_type');
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
NOTE: create or replace type list_str_type as table of varchar2(4000); |
| Comment by Benjamin Eberlei [ 01/Apr/13 ] |
|
Hey Marc Drolet thanks for the feedback and the solution, however i would like to have something generic that is working independent of the database driver. This code is very specific. Can you point me to some documentation why oci collection works with more than 1000 elements and how it works in PHP? |
| Comment by Marc Drolet [ 02/Apr/13 ] |
|
Hi Benjamin, The limitation is not from the oci driver, it's an oracle limitation. There are a couple of possible solution/implementation that can be done but the one I've provide is the one that perform better for the test I've done and from what I can found over the blogs I've read. I can't find the exact documentation of oracle. oracle doc is so poor. I don't know if there is similar limitation with other database. With the implementation I've provided, It will be possible to implement the proper solution depending on the database limitation you face otherwise it will execute the generic IN. What's bad, we need to create the type into the database. NOTE: In my case, I can not perform a sub-query, I get the my collection from a web service call. |
[DDC-2441] Incorrect SQL Query being generated Created: 09/May/13 Updated: 09/May/13 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL |
| Affects Version/s: | 2.4 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Paul Mansell | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Using Doctrine in Symfony 2.2.1 on Windows Platform |
||
| Description |
|
The following DQL : SELECT s,ba,c,mno,ss,sws,ccs,cns,cws FROM WLCoreBundle:SIM s INNER JOIN s.billingAccount ba LEFT JOIN s.connection c INNER JOIN s.status ss LEFT JOIN s.workflowStatus sws INNER JOIN c.customerStatus ccs INNER JOIN c.networkStatus cns LEFT JOIN c Produces the following SQL : SELECT * FROM (SELECT c0_.id AS id0, c0_.iccid AS iccid1, c0_.created AS created2, c0_.updated AS updated3, c0_.spreference AS spreference4, c1_.id ASid5, c1_.account_number AS account_number6, c1_.name AS name7, c1_.address1 AS address18, c1_.address2 AS address29, c1_.address3 AS address310, c1_.address4 AS address411, c1_.address5 AS address512, c1_.address6 AS address613, c1_.email_address AS email_address14, c1_.spreference AS spreference15, c2_.id AS id16, c2_.msisdn AS msisdn17, c2_.local AS local18, c2_.imsi AS imsi19, c2_.data AS data20, c2_.fax AS fax21, c2_.api AS api22, c2_.activation_date AS activation_date23, c2_.contract_end_date AS contract_end_date24, c2_.created AS created25, c2_.updated AS updated26, c2_.spreference AS spreference27, c3_.id AS id28, c3_.ident AS ident29, c3_.label AS label30, c3_.description AS description31, c4_.id AS id32, c4_.ident AS ident33, c4_.label AS label34, c4_.description AS description35, c4_.customer_label AS customer_label36, c4_.customer_description AS customer_description37, c5_.id AS id38, c5_.ident AS ident39, c5_.label AS label40, c5_.description AS description41, c6_.id AS id42, c6_.ident AS ident43, c6_.label AS label44, c6_.description AS description45, c7_.id AS id46, c7_.ident AS ident47, c7_.label AS label48, c7_.description AS description49, c7_.customer_label AS customer_label50, c7_.customer_description AS customer_description51, c8_.id AS id52, c8_.name AS name53, c8_.email_address AS email_address54, c8_.is_active AS is_active55, c8_.spreference AS spreference56, c0_.billing_account AS billing_account57, c0_.customerHierarchy AS customerHierarchy58, c0_.mno AS mno59, c0_.status AS status60, c0_.workflow_status AS workflow_status61, c1_.customer_hierarchy AS customer_hierarchy62, c1_.country AS country63, c1_.tax_rate AS tax_rate64, c1_.currency AS currency65, c1_.status AS status66, c1_.priority AS priority67, c2_.sim AS sim68, c2_.customer_status AS customer_status69, c2_.network_status AS network_status70, c2_.workflow_status AS workflow_status71, ROW_NUMBER() OVER (ORDER BY msisdn17 ASC) AS doctrine_rownum FROM core_sim c0_ WITH (NOLOCK) INNER JOIN core_billing_account c1_ ON c0_.billing_account = c1_.id LEFT JOIN core_connection c2_ ON c0_.id = c2_.sim INNER JOIN core_sim_status c3_ ON c0_.status = c3_.id LEFT JOIN core_sim_workflow_status c4_ ON c0_.workflow_status = c4_.id INNER JOIN core_connection_customer_status c5_ ON c2_.customer_status = c5_.id INNER JOIN core_connection_network_status c6_ ON c2_.network_status = c6_.id LEFT JOIN core_connection_workflow_status c7_ ON c2_.workflow_status = c7_.id INNER JOIN core_mno c8_ ON c0_.mno = c8_.id) AS doctrine_tbl WHERE doctrine_rownum BETWEEN 1 AND 10 Which returns an error : SQLSTATE[42S22]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'msisdn17'. Same query works fine in Doctrine 2.3 |
[DDC-851] Automerge of detached entities passed to doctrine Created: 31/Oct/10 Updated: 30/Dec/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-BETA4 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Daniel Alvarez Arribas | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This is a feature request. Currently it is not possible to assign a detached entity to a relationship. You have to manually "merge" it, and only then you are able to assign it to relationships of managed objects. This can become complicated to do. The way it is now, when assigning an entity to a relationship in a process using a large number of entities, the entity's state needs to be checked and the entity possibly merged - all in userland code. This adds a level of complexity and potential for errors, while it could be solved transparently and elegantly within the ORM. There are ways to implement it in userland code, too, with moderate effort (see below), but this does not change the fact that responsibility for implementing a purely technical feature is delegated to the user, who could be spending his time much better writing business code. And if the user actually implements it, it will clutter the application with non-problem-domain code. To keep things simple, I propose Doctrine be extended to simply auto-merge any detached entities passed to it. That would save the programmer the manual tracking of object states and merge() calls. This would be especially handy when using cascades, as keeping track of deep object graphs in userland code would duplicate substantial ORM functionality. In programs that work with massive amounts of data, it is practically impossible to keep all entities managed due to resource constraints (see e.g. the batch processing patterns documented in the Doctrine 2 reference at http://www.doctrine-project.org/projects/orm/2.0/docs/reference/batch-processing/en). In a situation like that, one would probably simply flush and clear the entity manager regularly. Doctrine 2 currently forces the user to manually "merge" all persistent objects he/she still holds references to and wants to assign e.g. to other newly created persistable objects. I can not think of any reason why Doctrine 2 should not be able to do it automatically. Below is another comment originally attached to the GitHub proposal, containing a userland implementation of the feature as a temporary fix, for whoever cares. Here is a userland implementation for the functionality I am proposing, though I feel it is technical clutter that belongs into the ORM. Changing doctrine to be able to auto-merge unmanaged entities would be ideal. I thought I'd share this, for use as long as Doctrine 2 does not provide equivalent functionality. The implementation assumes all entities inherit from a base class (named "YourEntityBaseClass here") and intercepts the assignment to ToOne-relationships in a __set() method provided in that base class. For ToMany-relationships we extend ArrayCollection to intercept calls to add() and set() to accomplish the same. As an alternative to defining a __set() method in a base class you could also implement the interception by changing any mutator methods you define in your entities. But that would bloat your code quickly as you define more and more relationship attributes on your entities. The following __set() method implementation relies on reflection to parse the DocBlock-Comment with the Annotation and determine whether or not the property to be set is a ToOne-relationship. public function __set($name, &$value) { $reflectionClass = new ReflectionClass($this); $property = $reflectionClass->getProperty($name); if ( self::isToOneRelationship($property) && $value !== null) { $value = self::mergeIfDetached($value); } $this->$name = $value; } The following is an implementation of mergeIfDetached(), that assumes there is a __get defined on the entity, to be able to access the protected mapped properties. public static function mergeIfDetached(YourEntityBaseClass $dataObject) { $doctrineEntityManager = DB::getDoctrineEntityManager(); if ($doctrineEntityManager->getUnitOfWork()->getEntityState($dataObject) == \Doctrine\ORM\UnitOfWork::STATE_DETACHED) { $dataObject = $doctrineEntityManager->merge($dataObject); } return $dataObject; } For your purposes, consider DB to be just a class holding a reference to the Doctrine entity manager. Here are the helper methods for the reflection: private static function isToOneRelationship(ReflectionProperty $property) { return self::matchDoctrineAnnotation($property, self::$doctrineToOneRelationshipAnnotation); } private static function matchDoctrineAnnotation(ReflectionProperty $property, $pattern) { return preg_match('/\@' . $pattern . '/', $property->getDocComment()) != 0; } Here is the drop-in-replacement class for use with ToMany-Relationships. It uses the static reloadIfDetached method defined in the entity base class: use Doctrine\Common\Collections\ArrayCollection; class Collection extends ArrayCollection { public function set($key, $value) { $value = YourEntityBaseClass::mergeIfDetached($value); parent::set($key, $value); } public function add($value) { $value = YourEntityBaseClass::mergeIfDetached($value); return parent::add($value); } } This approach keeps the amount of unnecessary code to a minimum, so that merges are not scattered throughout the problem-domain code. |
| Comments |
| Comment by Daniel Alvarez Arribas [ 29/Dec/10 ] |
|
I have to note that the code I listed above turned out to be broken. There is nothing that guarantees that a data object just merged will not become detached again after being merged on assignment, unless the object is immediately persisted afterwards. The correct solution would be to merge all data objects found through relationships for a given data object, right from the persistence manager, immediately before calling persist() on the data object. I am currently using this solution (save() saves a data object safely for use within long-running batch jobs): public static function save(DataObject $dataObject) { self::mergeRelatedDataObjectsIfDetached($dataObject); self::$doctrineEntityManager->persist($dataObject); } public static function merge(DataObject $dataObject) { return self::$doctrineEntityManager->merge($dataObject); } protected static function mergeRelatedDataObjectsIfDetached(DataObject $dataObject) { $reflectionClass = new ReflectionClass($dataObject); $properties = $reflectionClass->getProperties(); foreach ($properties as $property) { $propertyName = $property->getName(); $propertyValue = $dataObject->__get($propertyName); if (MetadataReader::isToOneRelationship($property)) { if ( $propertyValue !== null && ! $propertyValue instanceof Proxy && self::isDetached($propertyValue)) { $relatedDataObject = self::merge($propertyValue); $dataObject->__set($propertyName, $relatedDataObject); } } else { if (MetadataReader::isToManyRelationship($property)) { $relatedDataObjects = $propertyValue->toArray(); foreach ($relatedDataObjects as $index => $relatedDataObject) { if ( ! $relatedDataObject instanceof Proxy && self::isDetached($relatedDataObject)) { $relatedDataObject = self::merge($relatedDataObject); // Replace the entry in the collection with the merged copy. $propertyValue->set($index, $relatedDataObject); } } } } } } protected static function isDetached(DataObject $dataObject) { return self::$doctrineEntityManager->getUnitOfWork()->getEntityState($dataObject) == UnitOfWork::STATE_DETACHED; } I still wish there would be an automerge feature, kind of Hibernate's "update". |
| Comment by Daniel Alvarez Arribas [ 29/Dec/10 ] |
|
Wrapped the code sections into proper code blocks... |
[DDC-813] Validate Schema should complain on bi-directional relationships with mapped superclasses Created: 21/Sep/10 Updated: 29/Oct/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Tools |
| Affects Version/s: | 2.0-BETA4 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
@ManyToOne and @OneToOne on mapped superclasses have to be unidirectional. The Schema Validator should verify this. |
[DDC-803] Create subselect queries within join statements Created: 14/Sep/10 Updated: 14/Sep/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Martijn Evers | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
[DDC-785] Post-Post-Persist event Created: 02/Sep/10 Updated: 14/Jan/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-BETA4 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | arnaud-lb | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
postPersist/postUpdate events are triggered in the middle of a unitOfWork, and querying the DB in such events causes infinite loops. Doctrine attempts to flush the entity manager before running any query, which triggers flushing of entities, and postPersist/postUpdate events are triggered again. I did not checked, but the flush() before each query may be a performance problem too, if doctrine has to determine what has changed, depending on the changetracking policy. Also, it would be great if postPersist / postUpdate events were triggered after all entities have been persisted. It looks like that entities are flushed by groups of same 'type', and that events for a type are triggered once all of the elements of that group have been flushed, potentially before entities of an other type have been flushed : postPersist / postUpdate events are triggered while some other entities are still not flushed. |
| Comments |
| Comment by Benjamin Eberlei [ 03/Sep/10 ] |
|
That is documented and for perfomance reasons we cannot move the preUpdate/postUpdate/prePersist/postPersist events to other locations inside the UnitOfWork. There is an onFlush event that allows for more flexibility and is triggered before any update/insert/delete is done by the UnitOfWork. |
| Comment by arnaud-lb [ 04/Sep/10 ] |
|
Thanks. I understand that. Is there any chance of getting some onPostFlush or similar, which would be triggered like onFlush, but after all update/insert/delete ? Or just some post-something event which is allowed to issue db queries. |
| Comment by Gediminas Morkevicius [ 24/Sep/10 ] |
|
onFlush you can store your entity for furher processing and on postPersist you can check if there are no more insertions and process the entity if it needs additional query |
| Comment by Gediminas Morkevicius [ 14/Jan/11 ] |
|
I think this issue should be closed since the main reason of opening it was the possibility to execute additional queries when inserts were pending in unit of work. In current release it does not cause a flush during an additional query execution anymore. |
[DDC-779] Doctrine\ORM\Configuration should be immutable after construction of EntityManager Created: 30/Aug/10 Updated: 30/Aug/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-BETA3 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Currently the Doctrine\ORM\Configuration instance is not immutable after construction of the EM, which can lead to funny behavior when changing essential dependencies such as caches or others. |
[DDC-769] Disabling discriminator column in WHERE clause Created: 26/Aug/10 Updated: 07/Sep/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.0-BETA3 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Lars Strojny | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
Per default Doctrine 2 adds an IN(...)-part to the query when hydrating an entity where a discriminator column is defined. While this makes sense as a default behavior, it would be pretty helpful if one could disable the WHERE-clause for discriminator columns alltogether for performance optimization. |
| Comments |
| Comment by Roman S. Borschel [ 26/Aug/10 ] |
|
That would obviously produce wrong results. Maybe you can elaborate more with an example. |
| Comment by Lars Strojny [ 07/Sep/10 ] |
|
I use ENUM("foo","bar") as discriminator columns. That means, the column will contain the right values out of the box, no further result set limiting required with WHERE. |
[DDC-1270] Incorrect QueryBuilder example Created: 11/Jul/11 Updated: 11/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.1 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Documentation | Priority: | Major |
| Reporter: | Alex Bogomazov | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
In the QueryBuilder section of the documentation (http://www.doctrine-project.org/docs/orm/2.1/en/reference/query-builder.html#the-expr-class) there's an example with statements like
$qb->expr()->select('u')
But this doesn't work anymore. |
| Comments |
| Comment by Michael Ridgway [ 11/Jul/11 ] |
[DDC-1269] Unexpected behavior while using association on a non primary key field Created: 11/Jul/11 Updated: 13/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.1 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Alexandr Torchenko | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
We have association on non primary key. Something like this: Entities\Payment:
type: entity
table: payments
fields:
id:
id: true
type: integer
nullable: false
generator:
strategy: IDENTITY
[-- skipped --]
manyToOne:
order:
targetEntity: Entities\Order
inversedBy: payments
joinColumn:
name: scode
referencedColumnName: scode
Entities\Order:
type: entity
table: h_orders
fields:
id:
id: true
type: integer
unsigned: false
nullable: false
generator:
strategy: IDENTITY
scode:
type: integer
unsigned: false
nullable: false
[-- skipped --]
oneToMany:
payments:
targetEntity: Entities\Payment
mappedBy: order
When I try to fetch Order from Payment with lazy loading I receive empty Order object with null properties. If I use eager fetching Order object is valid. Another problem appears while persisting new Payment. $payment = new \Entities\Payment(); ... $order = $this->em->getRepository('\Entities\Order')->find(46320); $payment->setOrder($order); $order->addPayments($payment); $this->em->persist($payment); $this->em->flush(); I get this error: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'scode' cannot be null' in /usr/share/php/Doctrine/DBAL/Statement.php:131 I found issue which is still open and looks like mine – http://www.doctrine-project.org/jira/browse/DDC-1114. What do you think about this? |
| Comments |
| Comment by Benjamin Eberlei [ 12/Jul/11 ] |
|
Formatting, please add a second ticket for the second issue. |
| Comment by Benjamin Eberlei [ 12/Jul/11 ] |
|
I don't think its supported to use a non primary id for foreign key matching. I cant tell for sure though since i wasnt responsible to design this part of the Doctrine code. I would strongly suggest not to do this. |
| Comment by Benjamin Eberlei [ 12/Jul/11 ] |
|
Marked as improvement. The problem is we cannot detect this invalid mapping, so no exception is thrown during compilation of the mappings, |
| Comment by Benjamin Eberlei [ 12/Jul/11 ] |
|
This kind of mapping error is already acknowledged by the schema-validator console task. |
| Comment by Alexandr Torchenko [ 13/Jul/11 ] |
|
Should I create second ticket? Please confirm that I understood correctly. Should we avoid such mapping as it is considered as invalid. |
| Comment by Benjamin Eberlei [ 13/Jul/11 ] |
|
Yes, it will not work at all. You dont need to create the second ticket as that error steams from the mapping error. You will see an error message when calling ./doctrine orm:schema:validate with this mapping. |
[DDC-1263] @ManyToOne Arbitrary References Created: 09/Jul/11 Updated: 09/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Could it be possible to allow for arbitrary many to one entities through a "class + id" construct as join columns? |
[DDC-1259] Atomic creation of Proxy files Created: 08/Jul/11 Updated: 09/Jul/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
From 265e5086ea51ebcafc73f91abc64334d17e2f416 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns <karsten@typo3.org> Date: Wed, 25 May 2011 12:11:55 +0200 Subject: [PATCH 4/5] Use temporary file and rename for proxy class creation Instead of a simple file_put_contents() the proxy class code is written to a temporary file and renamed to the final filename. This allows file access even if only allowed by the directory permission. --- lib/Doctrine/ORM/Proxy/ProxyFactory.php | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/lib/Doctrine/ORM/Proxy/ProxyFactory.php b/lib/Doctrine/ORM/Proxy/ProxyFactory.php index f0cf19c..b2d42fb 100644 --- a/lib/Doctrine/ORM/Proxy/ProxyFactory.php +++ b/lib/Doctrine/ORM/Proxy/ProxyFactory.php @@ -152,7 +152,15 @@ class ProxyFactory $file = str_replace($placeholders, $replacements, $file); - file_put_contents($fileName, $file, LOCK_EX); + $temporaryFileName = $fileName . uniqid( ) . '.temp'; + $result = file_put_contents( $temporaryFileName, $file ); + + if($result === FALSE) throw new \RuntimeException('The temporary proxy class file "' . $temporaryFileName . '" could not be written.'); + $i = 0; + while(!rename( $temporaryFileName, $fileName ) && $i < 5) { + $i++; + } + if($result === FALSE) throw new \RuntimeException('The proxy class file "' . $fileName . '" could not be written.'); } /** -- 1.7.4.1 |
| Comments |
| Comment by Benjamin Eberlei [ 09/Jul/11 ] |
|
Nette Framework uses a safe stream: https://github.com/nette/nette/blob/master/Nette/Utils/SafeStream.php |
[DDC-1235] Provide fluent interfaces in stub methods Created: 28/Jun/11 Updated: 29/Oct/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Andreas Hörnicke | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Or maybe some template-files could be provided for all stubs. private static $_setMethodTemplate = '/** * <description> * * @param <variableType>$<variableName> */ public function <methodName>(<methodTypeHint>$<variableName>) { <spaces>$this-><fieldName> = $<variableName>; <spaces>return $this;</spaces> }'; |
| Comments |
| Comment by Christophe Coevoet [ 29/Oct/12 ] |
|
@beberlei this should be closed as it is the case since 2.2 |
[DDC-1217] Use the DBAL ReservedKeywordsValidator in orm:validate-schema Created: 20/Jun/11 Updated: 20/Jun/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Tools |
| Affects Version/s: | 2.0.6, Git Master |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Christophe Coevoet | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
DBAL provides a ReservedKeywordsValidator to check whether a word is reserved. But this tool is not used by the ORM when validating the schema. It would be useful to use it to avoid WTF from users getting a PDOException when creating their schema because of this. |
[DDC-1201] DQL Example about count(*) related entity is wrong Created: 10/Jun/11 Updated: 10/Oct/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Documentation |
| Affects Version/s: | 2.1.1 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Documentation | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
DQL Example about count |
| Comments |
| Comment by Aigars Gedroics [ 10/Oct/11 ] |
|
Also similar DQL in documentation URL http://www.doctrine-project.org/docs/orm/2.1/en/reference/dql-doctrine-query-language.html#pure-and-mixed-results fails parsing stage: $dql = "SELECT u, 'some scalar string', count(u.groups) AS num FROM User u JOIN u.groups g GROUP BY u.id";
with error [Doctrine\ORM\Query\QueryException] [Semantical Error] line 0, col 40 near 'localizations)': Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected. Should be "count(g.id)" instead of "count(u.groups)". |
[DDC-1197] Proxies should handle variable argument lists Created: 05/Jun/11 Updated: 05/Jun/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This is a contingency issue for https://github.com/doctrine/doctrine2/pull/60 "Fix to allow for proxy generated classes to respect methods in parent which may use func_get_args internally. Previously they would be passed nothing and thus fail. Also reduces need to build up argumentString. " |
[DDC-1164] doctrine:schema:update --force == doctrine:schema:create Created: 20/May/11 Updated: 20/May/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Geoff | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Doctrine:schema:update --force is the same as doctrine:schema:create. Under the hood, this may not be true, but they basically accomplish the same task. Schema:create should be removed, as it is redundant. Just look at django, one command to update db: ./manage.py syncdb Not saying that django gets everything correct, but the one command to synchronize the database is consistent. doctrine:schema:update should be smart enough to do all of the work, instead of relying on the redundant doctrine:schema:create. |
[DDC-1154] Proxies should take convention while loading *ToOne associations to reduce 1 extra query Created: 17/May/11 Updated: 17/May/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Guilherme Blanco | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Read the IRC log: [2:38pm] guilhermeblanco: beberlei: ping [2:38pm] guilhermeblanco: I'm curious about a feature if Doctrine supports [2:38pm] guilhermeblanco: if we do this on a proxy: [2:38pm] guilhermeblanco: $proxy->getOneToOneAssoc() [2:39pm] guilhermeblanco: shouldn't Doctrine already populate the assoc entity? [2:39pm] guilhermeblanco: it would be an inner join [2:39pm] beberlei: how would doctrine know it needs it? [2:39pm] guilhermeblanco: beberlei: it always repass the ClassMetadata to Persister [2:40pm] guilhermeblanco: so all needed item is to also pass the fieldname/assocname [2:40pm] beberlei: but how would doctrine know getOneToOneASsoc() really returns this assoc [2:40pm] beberlei: it could contain any logic [2:40pm] guilhermeblanco: it wouldn't... but as soon as we trigger __load($fieldName) [2:40pm] guilhermeblanco: we know that we could populate not only the Proxy, but also assoc [2:40pm] beberlei: by convention? [2:40pm] guilhermeblanco: ya [2:41pm] beberlei: sounds good, can you open a ticket? [2:41pm] guilhermeblanco: getUser() would trigger __load('user') [2:41pm] guilhermeblanco: sure! [2:41pm] guilhermeblanco: I'll pastie this as content... it would be awesome to have [2:41pm] guilhermeblanco: I see a lot of queries here that could be optimized |
[DDC-1143] deprecated or missing method, $cacheDriver->setManageCacheIds(true); Created: 10/May/11 Updated: 10/May/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.0.4 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Documentation | Priority: | Major |
| Reporter: | raiz | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
http://www.doctrine-project.org/docs/orm/2.0/en/reference/caching.html |
[DDC-1144] How insert a AES_ENCRYPT value in a table field Created: 10/May/11 Updated: 10/May/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0.4 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | dquintard | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Win XP, MySql5, Php5.3, ZendFramework 1.11.4 |
||
| Description |
|
Hi there, Because '"INSERT statements are not allowed in DQL, ...." i processed like this:
How can i do ? /** Best regards David |
[DDC-1137] SchemaTool#getUpdateSchemaSql() does not respect database identifier in table names Created: 05/May/11 Updated: 14/May/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM, Tools |
| Affects Version/s: | 2.0.4 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Hugh Lomas | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux 2.6.18-194.32.1.el5.centos.plus x86_64 GNU/Linux |
||
| Description |
|
Given two databases, 'foo' and 'bar', with entities in /Entities/Foo/ annotated as follows: /** * Test * * @Table(name="foo.test") * @Entity */ Create an EntityManager instance with $connectionOptions = array(
'dbname' => 'Foo',
'driver' => 'pdo_mysql',
<..etc..>
);
Use EntityManager#getClassMetaData( "Entities\\Foo Use EntityManager#getClassMetaData( "Entities\\Foo Inserting die( print_r( $fromSchema, 1 ) . print_r( $toSchema, 1 ) . print_r( $schemaDiff, 1 ) ); into Doctrine/ORM/Tools/SchemaTool.php line 632 shows $fromSchema outputs [_tables:protected] => Array
(
[test]
but $toSchema outputs [_tables:protected] => Array
(
[foo.test]
which causes $schemaDiff to output [newTables] => Array
(
[foo.test]
In summary, Doctrine/DBAL/Schema/Comparator considers foo.test a new table, because Doctrine/DBAL/Schema/AbstractSchemaManager lists its table as "test" rather than "foo.test". |
| Comments |
| Comment by Hugh Lomas [ 05/May/11 ] |
|
It seems that changing AbstractSchemaManager.php to the following corrected the issue for me, however I am not sure of any repercussions that may arise as a result, being unfamiliar with the codebase. Doctrine/DBAL/Schema/AbstractSchemaManager.php line 228 return new Table( $tableName, $columns, $indexes, $foreignKeys, false, array()); Doctrine/DBAL/Schema/AbstractSchemaManager.php line 228 return new Table( $this->_conn->getDatabase() . "." . $tableName, $columns, $indexes, $foreignKeys, false, array()); |
| Comment by Benjamin Eberlei [ 14/May/11 ] |
|
Multi databases are not supported by schema manager and schema tool yet. |
[DDC-1106] Wrong inversedBy in example Created: 07/Apr/11 Updated: 07/Apr/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Documentation | Priority: | Major |
| Reporter: | cristobal castro | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
on page http://www.doctrine-project.org/docs/orm/2.0/en/reference/working-with-objects.html |
[DDC-1038] there are tabs in the code base Created: 16/Feb/11 Updated: 16/Feb/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Task | Priority: | Major |
| Reporter: | Lukas Kahwe | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
a quick search through the ORM code base finds quite a few tabs. other doctrine projects there might also be some, though in common i only found some inside the LGPL license file. |
MsSQL-Server DateTime microseconds issue
(DDC-1028)
|
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0.1 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Sub-task | Priority: | Major |
| Reporter: | Martin Weise | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
php5.3.5; MsSQL-Server 2005; W2K8; Apache2; MS pdo_sqlsrv_ts_vc6 driver |
||
| Description |
|
To ensure that the MsSQL-Server 2005 (and maybe higher) uses the format that is specified in the MsSqlPlatform class (Y-m-d) This should be done directly after the connection has be opened. |
| Comments |
| Comment by Martin Weise [ 14/Feb/11 ] |
|
Issue created as wished from Juozas Kaziukenas. |
[DDC-1025] Please repalce 'Doctrine\XXX\YYY' with '\Doctrine\XXX\YYY' in code and document Created: 09/Feb/11 Updated: 13/Dec/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Documentation, DQL, Mapping Drivers, ORM, Tools |
| Affects Version/s: | 2.0.1 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | ben yan | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 7 |
| Labels: | None | ||
| Description |
|
It will help us use the namespace and code autocomplete in some IDE. |
| Comments |
| Comment by Matthieu Napoli [ 08/Apr/11 ] |
|
Hi, do you have any more information about this ? I'm confused because the php documentation uses the Doctrine\XXX way, and everywhere I've seen, it is used like that. Thanks |
| Comment by Karsten Dambekalns [ 11/Apr/11 ] |
|
The issue is simple and logical. When an IDE (I am using PhpStorm and it does it like this) sees a namespace in a file, upon seeing namespaces afterwards, it sees them as absolute if they have a leading backslash, or relative when it does not. This affects the resolution of classes for type navigation, code inspection, ... The same rules as for actual PHP code should be used within comments. Here is an example: namespace Foo;
class Bar {
/**
* @var Baz
*/
protected $baz;
/**
* @var \Quux
*/
protected $quux;
}
The IDE will think $baz is \Foo\Baz and $quux will be seen as being \Quux. Now if you have some reference to Doctrine here, and it was relative, the IDE would assume it's \Foo\Doctrine\... |
| Comment by Benjamin Eberlei [ 11/Apr/11 ] |
|
Well yes, but since all our code examples have no leading namespace argument this means the code is in the default namespace, making Doctrine\XXX\YY a relative namespace that is actually valid. |
| Comment by Karsten Dambekalns [ 11/Apr/11 ] |
|
Yes, but the source code docblocks are what is meant here as far as I am concerned. |
| Comment by Andrey Kolyshkin [ 13/May/11 ] |
|
Example (Entitymanager.php): namespace Doctrine\ORM; and /** * The used Configuration. * * @var Doctrine\ORM\Configuration */ private $config; Result: Should be: /** * The used Configuration. * * @var Configuration */ private $config; Or /** * The used Configuration. * * @var \Doctrine\ORM\Configuration */ private $config; |
| Comment by Miha Vrhovnik [ 27/May/11 ] |
|
Why don't you take this to the PhpStorm tracker as it surely is a bug in IDE? |
| Comment by Karsten Dambekalns [ 27/May/11 ] |
|
Miha, what makes you think it's an IDE bug? In a class in namespace Foo another class named Bar is \Foo\Bar, but \Bar is \Bar. Why is it a bug if the IDE follows the namespace resolution rules? |
| Comment by Michael Ridgway [ 11/Jul/11 ] |
|
The issue is that PHPStorm and NetBeans have different class resolution rules. I also use PHPStorm and most of Doctrine does not resolve auto-completion correctly because of this issue. I'd be willing to work on this if it would be accepted. |
| Comment by Andrew Mackrodt [ 29/Sep/11 ] |
|
I've been evaluating PhpStorm and also came across this issue; I believe the problem is due to Doctrine rather than being a bug with the IDE although it would be nice if PhpStorm would assume namespaces are absolute if they're not resolved upon an initial lookup. I created a quick c# app to append the beginning forward slash to any @var or @return attributes within Doctrine's source. It's working for me with Doctrine 2.1.2 and PhpStorm (IntelliJ): http://pastebin.com/4HxiWvJA - hopefully this will be of use for anyone else using these IDEs;. Note: the application doesn't detect multiple line annotations although the only one I'm aware of is the getAST method in Doctrine\ORM\Query.php. |
| Comment by Benjamin Eberlei [ 13/Dec/11 ] |
|
This issue is referenced in Github Pull-Request GH-215 |
| Comment by Benjamin Eberlei [ 13/Dec/11 ] |
|
This issue is referenced in Github Pull-Request GH-216 |
[DDC-1016] Example code does not reflect real code Created: 03/Feb/11 Updated: 03/Feb/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0.1 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Documentation | Priority: | Major |
| Reporter: | thoth | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Website |
||
| Description |
|
http://www.doctrine-project.org/docs/orm/2.0/en/reference/working-with-objects.html#entity-state In the switch cases all the UnitOfWork constants are invalid. Example: |
[DDC-1011] Finding out if a model is persist Created: 02/Feb/11 Updated: 02/Feb/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Documentation |
| Affects Version/s: | 2.0 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Documentation | Priority: | Major |
| Reporter: | Ronny Deter | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
To find out if a model is persist, is missing in the documentation of doctrine 2. To become the state of an model you must call the entitymanager->getUnitOfWork()->getEntityState(model) |
[DDC-998] Code example for custom AST functions incorrect Created: 23/Jan/11 Updated: 23/Jan/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Documentation | Priority: | Major |
| Reporter: | Timo A. Hummel | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
On http://www.doctrine-project.org/docs/orm/2.0/en/reference/dql-doctrine-query-language.html#adding-your-own-functions-to-the-dql-language the code example is slightly incorrect. Mistakes:
Additionally, the section should tell the user that he best has a look at lib/Doctrine/ORM/Query/AST/Functions/* to learn how to write custom functions. It also could be noted that stored procedures can be called with custom functions. |
[DDC-999] DQL always needs a FROM clause, should be changed Created: 23/Jan/11 Updated: 23/Jan/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Timo A. Hummel | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
Sometimes a developer needs to issue a query without a FROM clause. This especially occurs using the QueryBuilder, when you may or may not have a table to select from, but call a stored procedure always. Example: $query = $em>createQuery('SELECT (1+1)');
The above query fails because the lexer expects T_FROM. If you replace (1+1) with a stored procedure, this example makes more sense. One might argue about that you should use DBAL directly, but I disagree, because it always can happen that you end up in a situation like this: $qb = $em->createQueryBuilder(); $qb->select("SOMEFANCYPROCEDURE()"); if ($condition) { $qb = $qb->from("additionalTable t"); } |
[DDC-993] Cookbook: Overriding the ID Generator during a database migration Created: 19/Jan/11 Updated: 28/Oct/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Documentation |
| Affects Version/s: | 2.0 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Documentation | Priority: | Major |
| Reporter: | Timo A. Hummel | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
If you need to override the ID Generator, e.g. during a migration, you can do that in your migration script as follows: Overriding the ID generator $em->getClassMetadata('foo\bar\Entity')->setIdGenerator(new \Doctrine\ORM\Id\AssignedGenerator()); Make sure that both calls equal to the same generator type. You can now modify the @Id fields in your entities. Additionally, make sure that you set the IdGenerator after you created the database using e.g. SchemaTool->create(). |
| Comments |
| Comment by Endre Kósa [ 27/Oct/12 ] |
|
Hi, this doesn't seem to work for me. I have written a small database export / import utility. As long as I use the automatic ID generation, everything works flawlessly, but I'm trying to preserve the existing IDs. I do exactly what you've suggested in your post. It works for @OneToOne relations, but I get the following error messages when persisting entities that are parts of @ManyToOne relations: |
| Comment by Endre Kósa [ 28/Oct/12 ] |
|
Never mind. I've upgraded to Doctrine 2.3.0 and it works as expected. |
[DDC-972] MySql MyISAM support Created: 07/Jan/11 Updated: 13/Jul/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | 2.0 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | nicolas isnardi | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Environment: |
All |
||
| Description |
|
We can not set MySql Engine for MyISAM. MySqlPlatform has a _getCreateTableSQL where you can pass some options with the engine param. |
| Comments |
| Comment by Cédric Tailly [ 19/May/11 ] |
|
I have the same problem and I didn't found documentation to select the engine for a given table. I tried to understand the code by myself and made modifications of my Doctrine v2.0.5, perhaps this is not the best one but here is a beginning of a solution : ------------------------------------------------------------------------------- @ ORM\Mapping\Driver\DoctrineAnnotations.php:100 final class Table extends Annotation { public $name; public $schema; public $indexes; public $uniqueConstraints; public $engine; }@ ORM\Mapping\Driver\AnnotationDriver.php:144 $primaryTable = array( @ ORM\Tools\SchemaTool.php:133 $table = $schema->createTable($class->getQuotedTableName($this->_platform)); if ( isset($class->table["engine"]) ) ------------------------------------------------------------------------------- ...and to define for instance the MyISAM engine in annotations : /**
Because there is no foreign key on MyISAM tables, there are still problems on the schema creation/update when Doctrine executes the corresponding "alter table" SQL commands. |
| Comment by gabriel sancho [ 12/Jul/12 ] |
|
in Doctrine 2.2.2 will be Doctrine/ORM/Tools/SchemaTool.php-149- /// PATCH ------------------------------------ Doctrine/ORM/Mapping/ClassMetadataInfo.php-1719- /// PATCH ------------------------------------ Doctrine/ORM/Mapping/ClassMetadataInfo.php-1723- /// PATCH ------------------------------------ Doctrine/ORM/Mapping/Table.php-42- /// PATCH ------------------------------------ Doctrine/ORM/Mapping/Driver/AnnotationDriver.php-181- /// PATCH ------------------------------------ i found a problem in ManyToMany relations, the intermediate table will be InnoDB |
| Comment by Benjamin Eberlei [ 13/Jul/12 ] |
|
You can do all tables as MyISAM already through metadata using @Table(options= {"engine": "MyISAM"}) except Many-To-Many Join Tables. But you could create a listener to the "postSchemaGenerate" event and accept the schema instance there, modify everything accordingly. |
| Comment by Christophe Coevoet [ 13/Jul/12 ] |
|
should we add the support of the options for the @JoinTable annotation ? |
| Comment by Benjamin Eberlei [ 13/Jul/12 ] |
|
Yes, that is probably what this ticket boils down to |
[DDC-948] incorrect link from the types page to known vendor issues Created: 25/Dec/10 Updated: 25/Dec/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Documentation |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Documentation | Priority: | Major |
| Reporter: | Lukas Kahwe | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
http://www.doctrine-project.org/docs/dbal/2.0/en/reference/types.html links to http://www.doctrine-project.org/docs/dbal/2.0/en/known-vendor-issues instead of http://www.doctrine-project.org/docs/dbal/2.0/en/reference/known-vendor-issues.html Also noticed that the documentation still says "Doctrine DBAL v2.0.0-BETA4 documentation" |
| Comments |
| Comment by Lukas Kahwe [ 25/Dec/10 ] |
|
err sorry .. this is of course a DBAL doc issue not and ORM issue. |
[DDC-946] Evaluate optional use of igbinary for serialization Created: 22/Dec/10 Updated: 22/Dec/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
Igbinary is supposed to be faster and better than serialize/unserialize(). We should check if its relevant for us (metadata and query caching for example): https://github.com/phadej/igbinary |
| Comments |
| Comment by Benjamin Eberlei [ 22/Dec/10 ] |
|
http://ilia.ws/archives/211-Igbinary,-The-great-serializer.html#extended |
[DDC-930] A table cannot have more than one many to many relationship with the same table when using reverse engineer Created: 13/Dec/10 Updated: 13/Dec/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | 2.0-RC2 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Jiri Helmich | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
FreeBSD, PostgreSQL 8.4 |
||
| Description |
|
This is caused by taking the join column name as the identifier while generating a property name for annotation. The mapping driver detects that the same property is already defined and ends the convert process. A little bit smarter approach for me was to take the local table name. But this assumes a specific style of join table naming convention. Doctrine\ORM\Mapping\Driver\DatabaseDriver::loadMetadataForClass() Replace: $associationMapping['fieldName'] = Inflector::camelize(str_replace('_id', '', strtolower(current($otherFk->getColumns())))); With: $name = explode("_",$myFk->getLocalTableName()); $associationMapping['fieldName'] = Inflector::camelize(str_replace('_id', '', strtolower($name))); Maybe to switch to this behavior with an additional option? |
[DDC-923] Add note about DateTime Query Parameter Type Hint Created: 10/Dec/10 Updated: 10/Dec/10 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Documentation |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Documentation | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
[DDC-919] subselect Created: 08/Dec/10 Updated: 20/Mar/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | Documentation |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Documentation | Priority: | Major |
| Reporter: | Mungiu Dragos | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
i'd like to see more example in documentation with this subselects |
| Comments |
| Comment by Alberto [ 20/Mar/11 ] |
|
Subselect as columns or FROM clause should have mor examples. |
[DDC-1484] GH-162: ProxyFactory creates proxy's parent structure if it doesn't exist Created: 08/Nov/11 Updated: 26/Jun/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Pull-Request was automatically synchronized: https://github.com/doctrine/doctrine2/pull/162 Wheeee, nested proxies can be generated without hassle! |
| Comments |
| Comment by Benjamin Eberlei [ 13/Nov/11 ] |
|
Marked as improvement |
| Comment by Benjamin Eberlei [ 16/Jun/12 ] |
|
A related Github Pull-Request [GH-162] was opened |
| Comment by Benjamin Eberlei [ 26/Jun/12 ] |
|
A related Github Pull-Request [GH-162] was closed |
[DDC-1475] Documentation for One-To-Many, Bidirectional Association does not have YAML example Created: 07/Nov/11 Updated: 07/Nov/11 |
|
| Status: | Open |
| 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: | None | ||
| Description |
|
When you are looking for a config example for the bidirectional mapping of an one-to-many association you will just find an example with XML, but not with YAML or PHP. It would be nice if somebody could add an example or a link to the bidirectional one-to-one association, because it should be the same, right? Here the link to the example: http://www.doctrine-project.org/docs/orm/2.0/en/reference/association-mapping.html#one-to-many-bidirectional |
[DDC-1465] Fetching partial objects doesn't work if HINT_FORCE_PARTIAL_LOAD is not explicitly used Created: 02/Nov/11 Updated: 11/Nov/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL |
| Affects Version/s: | 2.1.2 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Julien Pauli | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
Using the DQL "partial" keyword is not enough to get a partial entity as a result. $q = $em->createQuery('SELECT partial r.{id,comment} FROM Entities\Rating r WHERE r.id=3');
$r = $q->getResult() /* HYDRATE_OBJECT is the default hydration mode */
Here, $r contains the full Entity, a SELECT * has been sent $q = $em->createQuery('SELECT partial r.{id,comment} FROM Entities\Rating r WHERE r.id=3');
$q->setHint(Doctrine\ORM\Query::HINT_FORCE_PARTIAL_LOAD, 1);
$r = $q->getResult() /* HYDRATE_OBJECT is the default hydration mode */
Here, $r contains only the selected fields, hence a true partial Entity |
[DDC-1459] Move DDC-331, DDC-448, DDC-493, DDC-513, DDC-698 Tests into SQLGeneration Testsuite Created: 29/Oct/11 Updated: 01/Aug/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
[DDC-1443] Subscribers reachs maximum nesting level when creating association on pre/postPersist with cascade persist Created: 20/Oct/11 Updated: 29/Oct/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Guilherme Blanco | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
Suppose a situation where: A -> B Where the OneToOne unidirectional association contains cascade persist. If I decide to save an entity B that should create an A instance, it goes into maximum nesting level no matter if I track prePersist or postPersist. |
| Comments |
| Comment by Guilherme Blanco [ 20/Oct/11 ] |
|
Failing test case |
| Comment by Guilherme Blanco [ 20/Oct/11 ] |
|
Uploading a new version, now passing successfully, but consuming the onFlush event (which should not be ideal). |
| Comment by Benjamin Eberlei [ 29/Oct/11 ] |
|
Ah yes, this never worked. The transaction stuff will fix that. You have to use scheduleForInsert() something inside prePersist. |
[DDC-1441] Metadata cannot be loaded for not registered proxy objects Created: 20/Oct/11 Updated: 05/Apr/12 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.1.2 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Aigars Gedroics | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
MySQL, Ubuntu, PHP 5.3.6 |
||
| Attachments: |
|
| Description |
|
We are using several Doctrine managers in our project with the same entity classes and different database tables. The problem appears when we are willing to merge entity with lazy associations from one manager to another. The second entity manager instance hasn't got the proxy object metadata defined yet so it fails with Doctrine\ORM\Mapping\MappingException exception "Class EntityProxy is not a valid entity or mapped super class.". If both entity managers share the proxy objects the problem can be fixed by calling $em->getProxyFactory()->getProxy('Entity', -1);
which will register the entity metadata for the proxy classname as well. Still if the proxy configuration differs, there is no fix found without changing the Doctrine ORM code. The fix inside the Doctrine would be to detect Proxy classes before loading the metadata and load the metadata for it's parent class instead. Please see the diff attached with proposed solution. Also I think this issue could arise when unserialized entity objects will be merged into the entity manager. I will try creating test case for this. |
| Comments |
| Comment by Aigars Gedroics [ 24/Nov/11 ] |
|
Test case attached. |
| Comment by Aigars Gedroics [ 05/Apr/12 ] |
|
See my pull request in https://github.com/doctrine/doctrine2/pull/332. |
[DDC-1438] Add test for DDC-1437 Created: 19/Oct/11 Updated: 19/Oct/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Add test for |
[DDC-1429] Add a method to the unit of work that merges any detached entity into UoW without calling SQL Created: 17/Oct/11 Updated: 17/Oct/11 |
|
| Status: | Open |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This is for those that know what they are doing |
[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 associatio |