From: Peter Rabbitson Date: Sat, 27 Jun 2009 12:08:35 +0000 (+0000) Subject: Bump author SQLT dependency for early developer testing X-Git-Tag: v0.08108~53 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=eb0bc670a8a144695c757cddab22920abaede088;p=dbsrgits%2FDBIx-Class.git Bump author SQLT dependency for early developer testing Regenerate SQLite schema with new parser/sqlt Use throw_exception in lieu of plain die when possible --- diff --git a/Makefile.PL b/Makefile.PL index 3713df1..310f12c 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -59,7 +59,7 @@ resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/db my %force_requires_if_author = ( 'Test::Pod::Coverage' => 1.04, - 'SQL::Translator' => 0.09004, + 'SQL::Translator' => 0.09007, # CDBI-compat related 'DBIx::ContextualFetch' => 0, diff --git a/lib/SQL/Translator/Parser/DBIx/Class.pm b/lib/SQL/Translator/Parser/DBIx/Class.pm index d786185..0966562 100644 --- a/lib/SQL/Translator/Parser/DBIx/Class.pm +++ b/lib/SQL/Translator/Parser/DBIx/Class.pm @@ -36,10 +36,10 @@ sub parse { $dbicschema ||= $args->{'package'}; my $limit_sources = $args->{'sources'}; - die 'No DBIx::Class::Schema' unless ($dbicschema); + croak 'No DBIx::Class::Schema' unless ($dbicschema); if (!ref $dbicschema) { eval "use $dbicschema;"; - die "Can't load $dbicschema ($@)" if($@); + croak "Can't load $dbicschema ($@)" if($@); } my $schema = $tr->schema; @@ -51,7 +51,8 @@ sub parse { my @monikers = sort $dbicschema->sources; if ($limit_sources) { my $ref = ref $limit_sources || ''; - die "'sources' parameter must be an array or hash ref" unless $ref eq 'ARRAY' || ref eq 'HASH'; + $dbicschema->throw_exception ("'sources' parameter must be an array or hash ref") + unless( $ref eq 'ARRAY' || ref eq 'HASH' ); # limit monikers to those specified in my $sources; @@ -107,7 +108,8 @@ sub parse { if ($colinfo{is_nullable}) { $colinfo{default} = '' unless exists $colinfo{default}; } - my $f = $table->add_field(%colinfo) || die $table->error; + my $f = $table->add_field(%colinfo) + || $dbicschema->throw_exception ($table->error); } $table->primary_key($source->primary_columns); @@ -268,7 +270,7 @@ sub parse { name => $view_name, fields => [ $source->columns ], $source->view_definition ? ( 'sql' => $source->view_definition ) : () - ) || die $schema->error; + ) || $dbicschema->throw_exception ($schema->error); $source->_invoke_sqlt_deploy_hook($view); } diff --git a/t/lib/sqlite.sql b/t/lib/sqlite.sql index 441c811..f109493 100644 --- a/t/lib/sqlite.sql +++ b/t/lib/sqlite.sql @@ -1,6 +1,6 @@ -- -- Created by SQL::Translator::Producer::SQLite --- Created on Thu May 28 10:10:00 2009 +-- Created on Sat Jun 27 14:02:39 2009 -- @@ -17,41 +17,6 @@ CREATE TABLE artist ( ); -- --- Table: artist_undirected_map --- -CREATE TABLE artist_undirected_map ( - id1 integer NOT NULL, - id2 integer NOT NULL, - PRIMARY KEY (id1, id2) -); - -CREATE INDEX artist_undirected_map_idx_id1_ ON artist_undirected_map (id1); - -CREATE INDEX artist_undirected_map_idx_id2_ ON artist_undirected_map (id2); - --- --- Table: cd_artwork --- -CREATE TABLE cd_artwork ( - cd_id INTEGER PRIMARY KEY NOT NULL -); - -CREATE INDEX cd_artwork_idx_cd_id_cd_artwor ON cd_artwork (cd_id); - --- --- Table: artwork_to_artist --- -CREATE TABLE artwork_to_artist ( - artwork_cd_id integer NOT NULL, - artist_id integer NOT NULL, - PRIMARY KEY (artwork_cd_id, artist_id) -); - -CREATE INDEX artwork_to_artist_idx_artist_id_artwork_to_arti ON artwork_to_artist (artist_id); - -CREATE INDEX artwork_to_artist_idx_artwork_cd_id_artwork_to_ ON artwork_to_artist (artwork_cd_id); - --- -- Table: bindtype_test -- CREATE TABLE bindtype_test ( @@ -62,63 +27,6 @@ CREATE TABLE bindtype_test ( ); -- --- Table: bookmark --- -CREATE TABLE bookmark ( - id INTEGER PRIMARY KEY NOT NULL, - link integer NOT NULL -); - -CREATE INDEX bookmark_idx_link_bookmark ON bookmark (link); - --- --- Table: books --- -CREATE TABLE books ( - id INTEGER PRIMARY KEY NOT NULL, - source varchar(100) NOT NULL, - owner integer NOT NULL, - title varchar(100) NOT NULL, - price integer -); - -CREATE INDEX books_idx_owner_books ON books (owner); - --- --- Table: cd --- -CREATE TABLE cd ( - cdid INTEGER PRIMARY KEY NOT NULL, - artist integer NOT NULL, - title varchar(100) NOT NULL, - year varchar(100) NOT NULL, - genreid integer, - single_track integer -); - -CREATE INDEX cd_idx_artist_cd ON cd (artist); - -CREATE INDEX cd_idx_genreid_cd ON cd (genreid); - -CREATE INDEX cd_idx_single_track_cd ON cd (single_track); - -CREATE UNIQUE INDEX cd_artist_title_cd ON cd (artist, title); - --- --- Table: cd_to_producer --- -CREATE TABLE cd_to_producer ( - cd integer NOT NULL, - producer integer NOT NULL, - attribute integer, - PRIMARY KEY (cd, producer) -); - -CREATE INDEX cd_to_producer_idx_cd_cd_to_pr ON cd_to_producer (cd); - -CREATE INDEX cd_to_producer_idx_producer_cd ON cd_to_producer (producer); - --- -- Table: collection -- CREATE TABLE collection ( @@ -127,19 +35,6 @@ CREATE TABLE collection ( ); -- --- Table: collection_object --- -CREATE TABLE collection_object ( - collection integer NOT NULL, - object integer NOT NULL, - PRIMARY KEY (collection, object) -); - -CREATE INDEX collection_object_idx_collection_collection_obj ON collection_object (collection); - -CREATE INDEX collection_object_idx_object_c ON collection_object (object); - --- -- Table: employee -- CREATE TABLE employee ( @@ -180,16 +75,6 @@ CREATE TABLE file_columns ( ); -- --- Table: forceforeign --- -CREATE TABLE forceforeign ( - artist INTEGER PRIMARY KEY NOT NULL, - cd integer NOT NULL -); - -CREATE INDEX forceforeign_idx_artist_forcef ON forceforeign (artist); - --- -- Table: fourkeys -- CREATE TABLE fourkeys ( @@ -203,25 +88,6 @@ CREATE TABLE fourkeys ( ); -- --- Table: fourkeys_to_twokeys --- -CREATE TABLE fourkeys_to_twokeys ( - f_foo integer NOT NULL, - f_bar integer NOT NULL, - f_hello integer NOT NULL, - f_goodbye integer NOT NULL, - t_artist integer NOT NULL, - t_cd integer NOT NULL, - autopilot character NOT NULL, - pilot_sequence integer, - PRIMARY KEY (f_foo, f_bar, f_hello, f_goodbye, t_artist, t_cd) -); - -CREATE INDEX fourkeys_to_twokeys_idx_f_foo_f_bar_f_hello_f_goodbye_ ON fourkeys_to_twokeys (f_foo, f_bar, f_hello, f_goodbye); - -CREATE INDEX fourkeys_to_twokeys_idx_t_artist_t_cd_fourkeys_to ON fourkeys_to_twokeys (t_artist, t_cd); - --- -- Table: genre -- CREATE TABLE genre ( @@ -229,29 +95,7 @@ CREATE TABLE genre ( name varchar(100) NOT NULL ); -CREATE UNIQUE INDEX genre_name_genre ON genre (name); - --- --- Table: images --- -CREATE TABLE images ( - id INTEGER PRIMARY KEY NOT NULL, - artwork_id integer NOT NULL, - name varchar(100) NOT NULL, - data blob -); - -CREATE INDEX images_idx_artwork_id_images ON images (artwork_id); - --- --- Table: liner_notes --- -CREATE TABLE liner_notes ( - liner_id INTEGER PRIMARY KEY NOT NULL, - notes varchar(100) NOT NULL -); - -CREATE INDEX liner_notes_idx_liner_id_liner ON liner_notes (liner_id); +CREATE UNIQUE INDEX genre_name ON genre (name); -- -- Table: link @@ -263,27 +107,6 @@ CREATE TABLE link ( ); -- --- Table: lyric_versions --- -CREATE TABLE lyric_versions ( - id INTEGER PRIMARY KEY NOT NULL, - lyric_id integer NOT NULL, - text varchar(100) NOT NULL -); - -CREATE INDEX lyric_versions_idx_lyric_id_ly ON lyric_versions (lyric_id); - --- --- Table: lyrics --- -CREATE TABLE lyrics ( - lyric_id INTEGER PRIMARY KEY NOT NULL, - track_id integer NOT NULL -); - -CREATE INDEX lyrics_idx_track_id_lyrics ON lyrics (track_id); - --- -- Table: noprimarykey -- CREATE TABLE noprimarykey ( @@ -292,7 +115,7 @@ CREATE TABLE noprimarykey ( baz integer NOT NULL ); -CREATE UNIQUE INDEX foo_bar_noprimarykey ON noprimarykey (foo, bar); +CREATE UNIQUE INDEX foo_bar ON noprimarykey (foo, bar); -- -- Table: onekey @@ -319,7 +142,7 @@ CREATE TABLE producer ( name varchar(100) NOT NULL ); -CREATE UNIQUE INDEX prod_name_producer ON producer (name); +CREATE UNIQUE INDEX prod_name ON producer (name); -- -- Table: self_ref @@ -330,19 +153,6 @@ CREATE TABLE self_ref ( ); -- --- Table: self_ref_alias --- -CREATE TABLE self_ref_alias ( - self_ref integer NOT NULL, - alias integer NOT NULL, - PRIMARY KEY (self_ref, alias) -); - -CREATE INDEX self_ref_alias_idx_alias_self_ ON self_ref_alias (alias); - -CREATE INDEX self_ref_alias_idx_self_ref_se ON self_ref_alias (self_ref); - --- -- Table: sequence_test -- CREATE TABLE sequence_test ( @@ -362,15 +172,99 @@ CREATE TABLE serialized ( ); -- --- Table: tags +-- Table: treelike -- -CREATE TABLE tags ( - tagid INTEGER PRIMARY KEY NOT NULL, - cd integer NOT NULL, - tag varchar(100) NOT NULL +CREATE TABLE treelike ( + id INTEGER PRIMARY KEY NOT NULL, + parent integer, + name varchar(100) NOT NULL +); + +CREATE INDEX treelike_idx_parent ON treelike (parent); + +-- +-- Table: twokeytreelike +-- +CREATE TABLE twokeytreelike ( + id1 integer NOT NULL, + id2 integer NOT NULL, + parent1 integer NOT NULL, + parent2 integer NOT NULL, + name varchar(100) NOT NULL, + PRIMARY KEY (id1, id2) +); + +CREATE INDEX twokeytreelike_idx_parent1_parent2 ON twokeytreelike (parent1, parent2); + +CREATE UNIQUE INDEX tktlnameunique ON twokeytreelike (name); + +-- +-- Table: typed_object +-- +CREATE TABLE typed_object ( + objectid INTEGER PRIMARY KEY NOT NULL, + type varchar(100) NOT NULL, + value varchar(100) NOT NULL +); + +-- +-- Table: artist_undirected_map +-- +CREATE TABLE artist_undirected_map ( + id1 integer NOT NULL, + id2 integer NOT NULL, + PRIMARY KEY (id1, id2) +); + +CREATE INDEX artist_undirected_map_idx_id1 ON artist_undirected_map (id1); + +CREATE INDEX artist_undirected_map_idx_id2 ON artist_undirected_map (id2); + +-- +-- Table: bookmark +-- +CREATE TABLE bookmark ( + id INTEGER PRIMARY KEY NOT NULL, + link integer NOT NULL +); + +CREATE INDEX bookmark_idx_link ON bookmark (link); + +-- +-- Table: books +-- +CREATE TABLE books ( + id INTEGER PRIMARY KEY NOT NULL, + source varchar(100) NOT NULL, + owner integer NOT NULL, + title varchar(100) NOT NULL, + price integer +); + +CREATE INDEX books_idx_owner ON books (owner); + +-- +-- Table: forceforeign +-- +CREATE TABLE forceforeign ( + artist INTEGER PRIMARY KEY NOT NULL, + cd integer NOT NULL +); + +CREATE INDEX forceforeign_idx_artist ON forceforeign (artist); + +-- +-- Table: self_ref_alias +-- +CREATE TABLE self_ref_alias ( + self_ref integer NOT NULL, + alias integer NOT NULL, + PRIMARY KEY (self_ref, alias) ); -CREATE INDEX tags_idx_cd_tags ON tags (cd); +CREATE INDEX self_ref_alias_idx_alias ON self_ref_alias (alias); + +CREATE INDEX self_ref_alias_idx_self_ref ON self_ref_alias (self_ref); -- -- Table: track @@ -384,38 +278,121 @@ CREATE TABLE track ( last_updated_at datetime ); -CREATE INDEX track_idx_cd_track ON track (cd); +CREATE INDEX track_idx_cd ON track (cd); -CREATE UNIQUE INDEX track_cd_position_track ON track (cd, position); +CREATE UNIQUE INDEX track_cd_position ON track (cd, position); -CREATE UNIQUE INDEX track_cd_title_track ON track (cd, title); +CREATE UNIQUE INDEX track_cd_title ON track (cd, title); -- --- Table: treelike +-- Table: cd -- -CREATE TABLE treelike ( +CREATE TABLE cd ( + cdid INTEGER PRIMARY KEY NOT NULL, + artist integer NOT NULL, + title varchar(100) NOT NULL, + year varchar(100) NOT NULL, + genreid integer, + single_track integer +); + +CREATE INDEX cd_idx_artist ON cd (artist); + +CREATE INDEX cd_idx_genreid ON cd (genreid); + +CREATE INDEX cd_idx_single_track ON cd (single_track); + +CREATE UNIQUE INDEX cd_artist_title ON cd (artist, title); + +-- +-- Table: collection_object +-- +CREATE TABLE collection_object ( + collection integer NOT NULL, + object integer NOT NULL, + PRIMARY KEY (collection, object) +); + +CREATE INDEX collection_object_idx_collection ON collection_object (collection); + +CREATE INDEX collection_object_idx_object ON collection_object (object); + +-- +-- Table: lyrics +-- +CREATE TABLE lyrics ( + lyric_id INTEGER PRIMARY KEY NOT NULL, + track_id integer NOT NULL +); + +CREATE INDEX lyrics_idx_track_id ON lyrics (track_id); + +-- +-- Table: cd_artwork +-- +CREATE TABLE cd_artwork ( + cd_id INTEGER PRIMARY KEY NOT NULL +); + +CREATE INDEX cd_artwork_idx_cd_id ON cd_artwork (cd_id); + +-- +-- Table: liner_notes +-- +CREATE TABLE liner_notes ( + liner_id INTEGER PRIMARY KEY NOT NULL, + notes varchar(100) NOT NULL +); + +CREATE INDEX liner_notes_idx_liner_id ON liner_notes (liner_id); + +-- +-- Table: lyric_versions +-- +CREATE TABLE lyric_versions ( id INTEGER PRIMARY KEY NOT NULL, - parent integer, - name varchar(100) NOT NULL + lyric_id integer NOT NULL, + text varchar(100) NOT NULL ); -CREATE INDEX treelike_idx_parent_treelike ON treelike (parent); +CREATE INDEX lyric_versions_idx_lyric_id ON lyric_versions (lyric_id); -- --- Table: twokeytreelike +-- Table: tags -- -CREATE TABLE twokeytreelike ( - id1 integer NOT NULL, - id2 integer NOT NULL, - parent1 integer NOT NULL, - parent2 integer NOT NULL, - name varchar(100) NOT NULL, - PRIMARY KEY (id1, id2) +CREATE TABLE tags ( + tagid INTEGER PRIMARY KEY NOT NULL, + cd integer NOT NULL, + tag varchar(100) NOT NULL +); + +CREATE INDEX tags_idx_cd ON tags (cd); + +-- +-- Table: cd_to_producer +-- +CREATE TABLE cd_to_producer ( + cd integer NOT NULL, + producer integer NOT NULL, + attribute integer, + PRIMARY KEY (cd, producer) ); -CREATE INDEX twokeytreelike_idx_parent1_parent2_twokeytre ON twokeytreelike (parent1, parent2); +CREATE INDEX cd_to_producer_idx_cd ON cd_to_producer (cd); + +CREATE INDEX cd_to_producer_idx_producer ON cd_to_producer (producer); + +-- +-- Table: images +-- +CREATE TABLE images ( + id INTEGER PRIMARY KEY NOT NULL, + artwork_id integer NOT NULL, + name varchar(100) NOT NULL, + data blob +); -CREATE UNIQUE INDEX tktlnameunique_twokeytreelike ON twokeytreelike (name); +CREATE INDEX images_idx_artwork_id ON images (artwork_id); -- -- Table: twokeys @@ -426,17 +403,40 @@ CREATE TABLE twokeys ( PRIMARY KEY (artist, cd) ); -CREATE INDEX twokeys_idx_artist_twokeys ON twokeys (artist); +CREATE INDEX twokeys_idx_artist ON twokeys (artist); -- --- Table: typed_object +-- Table: artwork_to_artist -- -CREATE TABLE typed_object ( - objectid INTEGER PRIMARY KEY NOT NULL, - type varchar(100) NOT NULL, - value varchar(100) NOT NULL +CREATE TABLE artwork_to_artist ( + artwork_cd_id integer NOT NULL, + artist_id integer NOT NULL, + PRIMARY KEY (artwork_cd_id, artist_id) ); +CREATE INDEX artwork_to_artist_idx_artist_id ON artwork_to_artist (artist_id); + +CREATE INDEX artwork_to_artist_idx_artwork_cd_id ON artwork_to_artist (artwork_cd_id); + +-- +-- Table: fourkeys_to_twokeys +-- +CREATE TABLE fourkeys_to_twokeys ( + f_foo integer NOT NULL, + f_bar integer NOT NULL, + f_hello integer NOT NULL, + f_goodbye integer NOT NULL, + t_artist integer NOT NULL, + t_cd integer NOT NULL, + autopilot character NOT NULL, + pilot_sequence integer, + PRIMARY KEY (f_foo, f_bar, f_hello, f_goodbye, t_artist, t_cd) +); + +CREATE INDEX fourkeys_to_twokeys_idx_f_foo_f_bar_f_hello_f_goodbye ON fourkeys_to_twokeys (f_foo, f_bar, f_hello, f_goodbye); + +CREATE INDEX fourkeys_to_twokeys_idx_t_artist_t_cd ON fourkeys_to_twokeys (t_artist, t_cd); + -- -- View: year2000cds --