FAQ
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.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedMar 31, '08 at 10:19a
activeMar 31, '08 at 10:19a
posts1
users1
websitecatalystframework.org
irc#catalyst

1 user in discussion

Alex Povolotsky: 1 post

People

Translate

site design / logo © 2021 Grokbase