[DC-515] HYDRATE_RECORD_HIERARCHY broken with many roots Created: 22/Feb/10 Updated: 09/Jun/10 |
|
| Status: | Reopened |
| Project: | Doctrine 1 |
| Component/s: | Nested Set |
| Affects Version/s: | 1.2.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Kamil Rojewski | Assignee: | Guilherme Blanco |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
DB schema: Category: Sample data: id: '1'
When using HYDRATE_RECORD_HIERARCHY, the first top-level category is empty. Everything is assigned to the other one. Only single-root trees work properly. |
| Comments |
| Comment by Kamil Rojewski [ 17/Mar/10 ] |
|
If you look at Doctrine_Collection::toHierarchy() you'll notice that there is NO reference to root_id, therefore it treats the entire collection as 1 tree (which is false). The bug is 100% repeatable. I've made a fast walkaround ba adding a multi-tree hydrator: class MultiRootHydrator extends Doctrine_Hydrator_RecordDriver { public function hydrateResultSet($stmt) { $result = parent::hydrateResultSet($stmt); $collection = array(); foreach ($result as $item) { if (!isset($collection[$item->root_id])) $collection[$item->root_id] = new Doctrine_Collection($result->getTable()); $collection[$item->root_id]->add($item); } $result = new Doctrine_Collection($result->getTable()); foreach ($collection as $tree) { $tree = $tree->toHierarchy(); $record = $tree->getFirst(); $result->add($record, $record->root_id); } return $result; } } It should clarify the problem. |
| Comment by Jonathan H. Wage [ 08/Jun/10 ] |
|
I think it was intended that you would only convert a single tree to a hierarchy. What would the structure of the returned data be like? |
| Comment by Kamil Rojewski [ 09/Jun/10 ] |
|
A Doctrine_Collection with root nodes seems to work fine. It allows to traverse the tree for each root. |
[DC-899] Expose hardDelete method on node object when SoftDelete behavior is used Created: 22/Oct/10 Updated: 22/Oct/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Behaviors, Nested Set |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major |
| Reporter: | Fernando Varesi | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
MySQL |
||
| Description |
|
When combining SoftDelete and NestedSet behavior, there's no way of calling hardDelete method on node object. According to documentation, to peform a delete on a nested set, delete should be called in node object, which will call delete method on the object itself. |
[DC-870] NestedSet not moving children of child nodes correctly Created: 20/Sep/10 Updated: 20/Sep/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Nested Set |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Ashley Broadley | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu 10.04 x64 |
||
| Description |
|
The best way I can explain the issue is with code. Please see the below: <?php
$root = new Test();
$root->name = '1';
$root->save();
// Create root node
$tree = Doctrine::getTable('Test')->getTree();
$tree->createRoot($root);
// Create child node
$child1 = new Test();
$child1->name = '2';
$child1->save();
// Add child
$child1->getNode()->moveAsLastChildOf($root);
// Create child node
$child2 = new Test();
$child2->name = '3';
$child2->save();
// Add child2 as node of child1
$child2->getNode()->moveAsLastChildOf($child1);
// Create child node
$child3 = new Test();
$child3->name = '4';
$child3->save();
// Add child3 as node of child2
$child3->getNode()->moveAsLastChildOf($child2);
// Add another root just to be nice
$root2 = new Test();
$root2->name = '5';
$root2->save();
// Create root node
$tree->createRoot($root2);
/**
* Now we have the following tree (Each '-' indicates 1 level):
* 1
* - 2
* - - 3
* - - - 4
* 5
*/
/**
* Lets say I want to move node '3' to be a root.
* With this I assume that all of the current nodes
* children will be moved with it:
*/
$tree->createRoot(child2);
/**
* Now the (implied) tree should look like this:
* 1
* - 2
* 3
* - 4
* 5
*
* Instead, the tree actually looks like this:
* 1
* - 2
* - - - 4
* 3
* 5
*/
/**
* I will now demostrate incorrect moving back of child nodes.
*/
$child2->getNode()->moveAsLastChildOf($child1);
/**
* Now the tree should go back to looking like this:
* 1
* - 2
* - - 3
* - - - 4
* 5
*
* But the tree now looks like this:
* 1
* - 2
* - - - 4
* - - 3
* 5
*/
|
| Comments |
| Comment by Ashley Broadley [ 20/Sep/10 ] |
|
Fixing code spacing |
| Comment by Ashley Broadley [ 20/Sep/10 ] |
|
I have also noticed that moving a root node back into its original position as a child also corrupts the tree. I have added an example to the original post |
[DC-971] Tree result sets hydrators are checking for column level not field level Created: 16/Feb/11 Updated: 16/Feb/11 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Nested Set |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Miloslav "adrive" Kmet | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Tree hierarchy hydrators (Doctrine_Collection::toHierarchy and Doctrine_Array_Hierarchy_Driver::hydrateResultSet) are checking wheter the column `level` exists. The level column can be aliased, and for oracle, it is required to do so. Therefor it is better to check, whether the aliased field level exists. Patch included in pull request |
Non-Equal Nest Relations Not Working - from "Children" side
(DC-952)
|
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Behaviors, Documentation, Nested Set, Relations |
| Affects Version/s: | 1.2.3 |
| Fix Version/s: | None |
| Type: | Sub-task | Priority: | Major |
| Reporter: | Daniel Reiche | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
PHP 5.3 / symfony 1.4.9 |
||
| Description |
|
Sorry for the lengthy explanation, couldn't make it more straight forward: I have a model which is similiar to a nestet set but the tree structure needs to overlap: For Model A, every Object A1 can have multiple descendant objects A2 and in turn can be a descendant of multiple objects A0. Since I saw no way to do this with Nested-Set Relations (or Equal-Nested-Sets) I have set up my Model like this: modules: modules_required: I needed to specify the Relations on both tables, to use onDelete/onUpdate CASCADE rules. Generated Models look fine, just as intended. Now the strange part: The point is: Is there a better way to solve my problem? |
| Comments |
| Comment by Daniel Reiche [ 25/Jan/11 ] |
|
forgot to add something: I have done a debug run, to see why these queries are created, when there was no data modified that related to these tables: Doctrine seems to handle my structure internally as a Nested-Set, although I have not specified an actAs: NestedSet or relations: equal: true statement in the model definition. This is not a nested set, as each object can have virtually any other object either as parent or as a child, and additionaly, parent relations can span multiple tree-levels: results in: Object 6 has parents 2 and 4 (where 4 has parent 3 and 3 has parent 2 in turn) This spanning relations seems to cause the guessed nested set to fail. I simply wanted to create an m:n Relation using a Reference table and the fact that both m and n are of the same class should not consider doctrine. |
| Comment by Daniel Reiche [ 26/Jan/11 ] |
|
related to #DC-329: also the h2aEqualable mentioned there does not work, because it does not prevent symfony from issueing the delete queries. It prevents only the UPDATE-Queries, and thus circumvents the MySQL-Error. Nevertheless, data is still corrupted after object save, thus not useable in production. |
[DC-403] Eliminate queries produced by Doctrine_Node_NestedSet::getDescendants() when possible Created: 06/Jan/10 Updated: 16/Apr/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Nested Set |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | 1.2.0 |
| Type: | Improvement | Priority: | Major |
| Reporter: | alex | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Description |
How to reproduce
Problem is described more verbosely here – http://codeutopia.net/blog/2008/08/30/understanding-doctrines-nestedset-feature/ What behavior is expectedAn already fetched record instance is returned, without calling database and without causing query flooding. Like in propel.In propel if you are calling ....::retrieveTree($id) it returns the root What happensAn additional query is issued This is a big slip in architecture of Doctrine`s nested set implementation. |
[DC-467] Can't create root node if multiple roots and primary key have multiple columns Created: 01/Feb/10 Updated: 16/Apr/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Nested Set |
| Affects Version/s: | 1.2.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Milan Cvejic | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux, PostgreSQL |
||
| Description |
|
When trying to create new root node, the following exception is thrown. PHP Fatal error: Uncaught exception 'Doctrine_Tree_Exception' with message 'Node must have a root id set or must be persistent and have a single-valued numeric primary key in order to be created as a root node. Automatic assignment of a root id on transient/new records is no longer supported.' This only happens when hasManyRoots is true, and table have multiple columns in primary key. Example: $category = new Menu(); $treeObject = Doctrine::getTable('Menu')->getTree(); and menu table is defined as follows: $this->hasColumn('id', 'integer', 8, array( If i remove primary option from language_id column, everything works as it should. |
[DC-807] Equal nest relation uses incorrect SQL and returns incorrect data Created: 03/Aug/10 Updated: 03/Aug/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Nested Set |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Denis Chmel | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Debian |
||
| Description |
|
The equal nest relation works incorrectly twice. The SQL it produces is wrong. And even if correct the SQL it still returns wrong data. Here goes steps to reproduce. Schema.yml Profile: Fixtures: Profile: UserFriend: PHP test Output [1]=> } } As it can be seen from output, the relation "UserFriend" shows insane data:
|
| Comments |
| Comment by Denis Chmel [ 03/Aug/10 ] |
|
If this will be useful. here's the SQL it produces: SELECT It's very clear that an OR in the inner join and another OR in where are not connected, while they must be. Here's the correct part (in my opinion) ... But this only fixes the problem with 2 records in "UserFriends", but not the second ("user 4 has friendship with 4 - that's also wrong, not in the fixtures."). |
[DC-707] When inserting node as direct children of a root node, it seems the root node is not populated with new lft/rgt values... Created: 27/May/10 Updated: 07/Aug/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Nested Set |
| Affects Version/s: | 1.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Julien G | Assignee: | Jonathan H. Wage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
PHP 5.3.2 (cli) (built: Apr 12 2010 15:44:21)
MySQL
|
||
| Description |
|
Hi, When inserting node as direct children of a root node, it seems the root node is not populated with new lft/rgt values... Here is a test case, simply made of the code samples given in documentation : /* * Creating a Root Node */ $category = new Category(); $category->name = 'Root Category 1'; $category->save(); $treeObject = Doctrine_Core::getTable('Category')->getTree(); $treeObject->createRoot($category); /* * Inserting a Node */ $child1 = new Category(); $child1->name = 'Child Category 1'; $child2 = new Category(); $child2->name = 'Child Category 1'; $child1->getNode()->insertAsLastChildOf($category); $child2->getNode()->insertAsLastChildOf($category); /* * BUGGY ! */ $category->getNode()->hasChildren(); // will return false, we except true as we just instert 2 children to this root node... $category->refresh(); $category->getNode()->hasChildren(); // true... that's now ok ! |
[DC-890] public function detach break the nested set tree [patch attached] Created: 14/Oct/10 Updated: 14/Oct/10 |
|
| Status: | Open |
| Project: | Doctrine 1 |
| Component/s: | Nested Set |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Alexandre PAIXAO | Assignee: | Roman S. Borschel |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
not environment dependant |
||
| Attachments: |
|
| Description |
|
If I detach a node from the tree using $node->detach(); it set the left and right value to zero without shifting, creating a possible tree corruption. I've looked to the original commit in Trac (http://trac.doctrine-project.org/changeset/4089) and I don't think the original idea of the commit was to leave a hole. |
| Comments |
| Comment by Alexandre PAIXAO [ 14/Oct/10 ] |
|
ex: root 1 4 after detach : root 1 4 then a new one : root 1 6 |