Subject: | Odd SQL logic (bug?) in Rose::DBx::Garden::Catalyst |
I'm running the example from the SYNOPSIS of perldoc
Rose::DBx::Garden::Catalyst,
# create a Catalyst app
Show quoted text
> catalyst.pl MyApp
# create a Rose::DBx::Garden::Catalyst script
Show quoted text > cat mk_cat_garden.pl
use Rose::DBx::Garden::Catalyst;
use MyDB; # isa Rose::DB
my $garden = Rose::DBx::Garden::Catalyst->new(
catalyst_prefix => 'MyApp',
garden_prefix => 'MyRDBO',
db => MyDB->new,
tt => 1, # make Template
Toolkit files
);
$garden->plant('MyApp/lib');
# run your script
Show quoted text > perl mk_cat_garden.pl
# update your MyApp.pm file:
__PACKAGE__->setup();
Class::C3::initialize(); # add this line
# start your Catalyst dev server
Show quoted text > cd MyApp
> perl script/myapp_server.pl
# enjoy the fruits at http://localhost:3000/rdgc
For http://localhost:3000/rdgc/sdr/transcript/list, I'm seeing the
following error:
[error] Couldn't render template "undef error - Could not load
MyRDBO::Sdr::Style with key id = '1' - No such MyRDBO::Sdr::Style where
default_style = 0 at
/usr/local/share/perl/5.8.8/CatalystX/CRUD/Object.pm line 120
"
Here's the creation SQL for the relevant tables:
CREATE TABLE transcript (
id SERIAL NOT NULL UNIQUE,
...
style_id INTEGER NOT NULL,
FOREIGN KEY (style_id) REFERENCES style (id),
...
PRIMARY KEY (student_id, label)
);
CREATE TABLE style (
id SERIAL NOT NULL UNIQUE,
name VARCHAR NOT NULL PRIMARY KEY,
description VARCHAR NOT NULL UNIQUE,
css VARCHAR NOT NULL UNIQUE,
default_style BOOLEAN NOT NULL DEFAULT 'FALSE',
enabled BOOLEAN NOT NULL DEFAULT 'TRUE',
creator_id INTEGER NOT NULL,
FOREIGN KEY (creator_id) REFERENCES user_account (id),
created TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX style_default_style_uidx ON style(default_style)
WHERE default_style = 'TRUE';
Here's the SQL I see in the logs:
2009-06-12 19:19:29.719 MDT [679] ed 127.0.0.1(52142) sdr LOG: execute
dbdpg_p674_4: SELECT id, name, description, css, default_style, enabled,
creator_id, created FROM style WHERE default_style = $1
2009-06-12 19:19:29.719 MDT [679] ed 127.0.0.1(52142) sdr DETAIL:
parameters: $1 = 'f'
$ perl -v
This is perl, v5.8.8 built for x86_64-linux-gnu-thread-multi
$ uname -a
Linux davy 2.6.24-19-generic #1 SMP Wed Jun 18 14:15:37 UTC 2008 x86_64
GNU/Linux
I suspect it's getting confused due to the unique index with the WHERE
clause.