Sorry for resending, looks like everyone able to answer overlooked this message. I'm researching the problem without much success.

Hello!

I've experienced strange problem displaying data. Minimal test case is
fairly big, I can attach it here, but will try to extract most important
information.

Creating database (Pg)

create table parent (pid serial primary key, name varchar(64));
create table child (cid serial primary key, pid int not null references
parent(pid), name varchar(64));
create table record (rid serial primary key, cid int not null references
child(cid), message varchar(64));
insert into parent (name) values('parent');
insert into child (pid, name) values (1, 'child');
insert into record (cid, message) values (1, 'message one');
insert into record (cid, message) values (1, 'message two');

creating model and view

script/testcase_create.pl model Main DBIC::Schema Testcase::Schema
create=static dbi:Pg:dbname=testcase testcase
script/testcase_create.pl view Main TTSite

in Root controller, writing trivial

sub index : Local {
   my ( $self, $c ) = @_;
   $c->stash->{parent} = $c->model('Main::Parent')->search();
}

in index template, everything is trivial as well

[% META title = 'index' %]
<ul>
[% WHILE (p = parent.next) %]
parent [% p.name %] has [% p.children.count %] children,
  <ol>
  [% WHILE (child = p.children.next) %]
  <li> [% child.name %] has [% child.records.count %] records,
     <ul>
     [% WHILE (record = child.records.next) %]
        <li>[% record.message %]
     [% END %]
     </ul>
  [% END %]
  </ol>
[% END %]
</ul>

Output is disappointing

index

  parent parent has children,

  © 2008 Your Name Here

while we get

SELECT me.pid, me.name FROM parent me:
SELECT me.cid, me.pid, me.name FROM child me WHERE ( me.pid = ? ): '1'
SELECT me.cid, me.pid, me.name FROM child me WHERE ( me.pid = ? ): '1'

with DBIC_TRACE.

Attempt to dump (using Plugin::Dumper) p.children yields reasonable result.

What am I doing wrong?

Alex.



_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/


_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to