Ticket #1219 (closed defect: fixed)

Opened 5 months ago

Last modified 3 months ago

NestedSet import data from yaml, root_id is not set correctly

Reported by: lucassus Owned by: jwage
Priority: minor Milestone:
Component: NestedSet Version: 1.0.0
Keywords: nestedset yaml fixtures import Cc:
Has Test: no Status: Pending User Response
Has Patch: no

Description (last modified by lucassus) (diff)

My model is:

class Store_Category extends Doctrine_Record
{

    public function setTableDefinition()
    {
        $this->setTableName('store.categories');

        $this->hasColumn('name', 'string', 255, array(
           'notblank' => true
        ));

        $this->hasColumn('description', 'string');

    }

    public function setUp()
    {
        $this->actAs('NestedSet', array('hasManyRoots' => true,
                                        'rootColumnName' => 'root_id'));
    }

}

My fixtures:

Store_Category:

    Store_Category_Decorations:
        name: Dekoracje na gwiazdkę
        
        children:
            Store_Category_Decorations_1:
                name: Ascetyczne mobile

            Store_Category_Decorations_2:
                name: Na choinkę, na prezent, na stół...

    Store_Category_Office:
        name: Biuro
        
        children:
            Store_Category_Office_Equipment:
                name: Wyposażenie
                
                children:
                    Store_Category_Office_Equipment_1:
                        name: Akcesoria biurowe Blomus
                        
                    Store_Category_Office_Equipment_2:
                        name: Akcesoria biurowe Zack
                        
                    Store_Category_Office_Equipment_3:
                        name: Myszki komputerowe

After import fixtures to database root_id for all records is set to '1'. I'm using postres and phpDoctrine v0.11

Change History

Changed 5 months ago by lucassus

  • description modified (diff)

Changed 5 months ago by lucassus

  • description modified (diff)

Changed 5 months ago by lucassus

  • owner changed from romanb to lucassus
  • status changed from new to assigned

Changed 5 months ago by jwage

  • owner changed from lucassus to jwage
  • status changed from assigned to new

Changed 4 months ago by guilhermeblanco

  • status changed from new to closed
  • resolution set to worksforme

This ticket seems invalid.

I tried for over 3h to reproduce the issue without success. At last, I had a real implementation running and working inside tests/Data/ImportTestCase.php. You should take a look how I implemented it.

I'm marking this ticket as works for me.

Changed 4 months ago by guilhermeblanco

BTW... maybe you have a problem with indentation in the fixture.

Changed 4 months ago by lucassus

  • status changed from closed to reopened
  • resolution worksforme deleted

Probably error occurs only on Postgres database (or others).

I think there is error in Tree_NestedSet::getMaxRootID(); In my case (postgres database) query for getting max root_id always returns null even if I have root_id with not null values. Here is patch for this case:

234c234
<         $dql = 'SELECT c.' . $column . ' FROM ' . $component . ' c WHERE '.$column.' IS NOT NULL ORDER BY c.' . $column . ' DESC LIMIT 1';
---
>         $dql = 'SELECT c.' . $column . ' FROM ' . $component . ' c ORDER BY c.' . $column . ' DESC LIMIT 1';

After this fix everything works.

Changed 4 months ago by lucassus

  • milestone changed from 0.11.1 to 1.0.0-BETA1

Changed 4 months ago by guilhermeblanco

  • mystatus changed from Pending Core Response to Pending User Response

Your patch is already applied (dunno who and when it was).

Could you please check if it's still failing and give us a feedback? If it works, close the ticket for us, please.

Thanks

Changed 4 months ago by lucassus

I'm confused.. Where I can find lastest wersion of 1.0-BETE branch?

Changed 4 months ago by guilhermeblanco

The patch is applied in 0.11 and also in 1.0 branch.

Please "svn up" your Doctrine and test it again.

Cheers,

Changed 4 months ago by jwage

  • status changed from reopened to closed
  • version changed from 0.11 to 1.0
  • resolution set to fixed
  • milestone changed from Unknown to 1.0.0-RC1

Changed 3 months ago by anonymous

  • milestone New deleted

Milestone New deleted

Note: See TracTickets for help on using tickets.