Skip Menu |

This queue is for tickets about the Maypole CPAN distribution.

Report information
The Basics
Id: 29982
Status: resolved
Priority: 0/
Queue: Maypole

People
Owner: Nobody in particular
Requestors: ben [...] decadent.org.uk
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in:
  • 2.111
  • 2.11_pre1
  • 2.11_pre2
  • 2.11_pre3
  • 2.11_pre4
  • 2.11_pre5
  • 2.12
  • 2.121
Fixed in: 2.13



Subject: Inconsistency between examples and tutorial
Date: Sun, 14 Oct 2007 17:36:10 +0100
To: bug-Maypole [...] rt.cpan.org
From: Ben Hutchings <ben [...] decadent.org.uk>
The examples are somewhat inconsistent with each other and with the tutorial. Suggested changes: --- maypole.orig/examples/fancy_example/BeerDB.pm +++ maypole/examples/fancy_example/BeerDB.pm @@ -6,11 +6,23 @@ # This is the sample application. Change this to the path to your # database. (or use mysql or something) use constant DBI_DRIVER => 'SQLite'; -use constant DATASOURCE => '/home/peter/Desktop/maypolebeer/beerdb'; +use constant DATASOURCE => $ENV{BEERDB_DATASOURCE} || 't/beerdb.db'; BeerDB->config->model('BeerDB::Base'); -BeerDB->setup("dbi:mysql:beerdb",'root', ''); +BEGIN { + my $dbi_driver = DBI_DRIVER; + if ($dbi_driver =~ /^SQLite/) { + die sprintf "SQLite datasource '%s' not found, correct the path or " + . "recreate the database by running Makefile.PL", DATASOURCE + unless -e DATASOURCE; + eval "require DBD::SQLite"; + if ($@) { + eval "require DBD::SQLite2" and $dbi_driver = 'SQLite2'; + } + } + BeerDB->setup(join ':', "dbi", $dbi_driver, DATASOURCE); +} # Give it a name. BeerDB->config->application_name('The Beer Database'); @@ -20,7 +32,7 @@ # Change this to the htdoc root for your maypole application. -my @root= ('/home/peter/Desktop/maypolebeer/templates'); +my @root= ('t/templates'); push @root,$ENV{BEERDB_TEMPLATE_ROOT} if ($ENV{BEERDB_TEMPLATE_ROOT}); BeerDB->config->template_root( [@root] ); # Specify the rows per page in search results, lists, etc : 10 is a nice round number @@ -37,7 +49,7 @@ BeerDB::Brewery->untaint_columns( printable => [qw/name notes url/] ); BeerDB::Style->untaint_columns( printable => [qw/name notes/] ); BeerDB::Beer->untaint_columns( - printable => [qw/abv name price notes/], + printable => [qw/abv name price notes url/], integer => [qw/style brewery score/], date =>[ qw/tasted/], ); @@ -47,7 +59,7 @@ # Required Fields -BeerDB->config->{brewery}{required_cols} = [qw/name url/]; +BeerDB->config->{brewery}{required_cols} = [qw/name/]; BeerDB->config->{style}{required_cols} = [qw/name/]; BeerDB->config->{beer}{required_cols} = [qw/brewery name price/]; BeerDB->config->{pub}{required_cols} = [qw/name/]; @@ -67,7 +79,7 @@ # For testing classmetadata #sub BeerDB::Beer::classdata :Exported {}; -sub BeerDB::Beer::list_columns { return qw/score name price style brewery/}; +sub BeerDB::Beer::list_columns { return qw/score name price style brewery url/}; sub BeerDB::Handpump::stringify_self { my $self = shift; --- maypole.orig/examples/fancy_example/beerdb.sql +++ maypole/examples/fancy_example/beerdb.sql @@ -1,27 +1,28 @@ CREATE TABLE style ( - id integer primary key auto_increment, + id integer not null primary key auto_increment, name varchar(60), notes text ); CREATE TABLE pub ( - id integer primary key auto_increment, + id integer not null primary key auto_increment, name varchar(60), url varchar(120), notes text ); CREATE TABLE handpump ( - id integer primary key auto_increment, + id integer not null primary key auto_increment, beer integer, pub integer ); CREATE TABLE beer ( - id integer primary key auto_increment, + id integer not null primary key auto_increment, brewery integer, style integer, name varchar(30), + url varchar(120), score integer(2), price varchar(12), abv varchar(10), @@ -30,7 +31,7 @@ ); CREATE TABLE brewery ( - id integer primary key auto_increment, + id integer not null primary key auto_increment, name varchar(30), url varchar(50), notes text --- maypole.orig/lib/Maypole/Manual/About.pod +++ maypole/lib/Maypole/Manual/About.pod @@ -119,7 +119,8 @@ score integer(2), price varchar(12), abv varchar(10), - notes text + notes text, + tasted date ); create table handpump ( --- maypole.orig/examples/beerdb.sql +++ maypole/examples/beerdb.sql @@ -1,24 +1,24 @@ CREATE TABLE style ( - id integer primary key auto_increment, + id integer not null primary key auto_increment, name varchar(60), notes text ); CREATE TABLE pub ( - id integer primary key auto_increment, + id integer not null primary key auto_increment, name varchar(60), url varchar(120), notes text ); CREATE TABLE handpump ( - id integer primary key auto_increment, + id integer not null primary key auto_increment, beer integer, pub integer ); CREATE TABLE beer ( - id integer primary key auto_increment, + id integer not null primary key auto_increment, brewery integer, style integer, name varchar(30), @@ -31,7 +31,7 @@ ); CREATE TABLE brewery ( - id integer primary key auto_increment, + id integer not null primary key auto_increment, name varchar(30), url varchar(50), notes text -- END -- (The schema should have "not null" because SQLite primary keys are allowed to be null by default.) Ben. -- Ben Hutchings Lowery's Law: If it jams, force it. If it breaks, it needed replacing anyway.
Download signature.asc
application/pgp-signature 189b

Message body not shown because it is not plain text.

Fixed in SVN revision 588
fixed in SVN revision 588
Resolved in 2.13