From: Matt S Trout Date: Wed, 19 Apr 2006 17:58:48 +0000 (+0000) Subject: Fixed up tests post-merge X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=38e481637aa7e86b0257373e334457d5c23748fb;p=dbsrgits%2FDBIx-Class-Historic.git Fixed up tests post-merge --- diff --git a/Changes b/Changes index a35712f..bfd86af 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ Revision history for DBIx::Class + - modified SQLT parser to skip dupe table names - added remove_column(s) to ResultSource/ResultSourceProxy - added add_column alias to ResultSourceProxy - added source_name to ResultSource diff --git a/TODO b/TODO index 055e5c4..4380aca 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,8 @@ +2005-04-16 by mst + - set_from_related should take undef + - ResultSource objects caching ->resultset causes interesting problems + - find why XSUB dumper kills schema in Catalyst (may be Pg only?) + 2006-04-11 by castaway - using PK::Auto should set is_auto_increment for the PK columns, so that copy() "just works" - docs of copy() should say that is_auto_increment is essential for auto_incrementing keys diff --git a/lib/SQL/Translator/Parser/DBIx/Class.pm b/lib/SQL/Translator/Parser/DBIx/Class.pm index e2a3832..d8af4d6 100644 --- a/lib/SQL/Translator/Parser/DBIx/Class.pm +++ b/lib/SQL/Translator/Parser/DBIx/Class.pm @@ -43,12 +43,17 @@ sub parse { # print Dumper($dbixschema->registered_classes); #foreach my $tableclass ($dbixschema->registered_classes) + + my %seen_tables; + foreach my $moniker ($dbixschema->sources) { #eval "use $tableclass"; #print("Can't load $tableclass"), next if($@); my $source = $dbixschema->source($moniker); + next if $seen_tables{$source->name}++; + my $table = $schema->add_table( name => $source->name, type => 'TABLE', diff --git a/maint/gen-schema.pl b/maint/gen-schema.pl index 12b3aeb..d8d2ca1 100755 --- a/maint/gen-schema.pl +++ b/maint/gen-schema.pl @@ -5,7 +5,7 @@ use warnings; use lib qw(lib t/lib); use DBICTest; -use DBICTest::HelperRels; +use DBICTest::Schema::HelperRels; my $schema = DBICTest->initialise; diff --git a/t/helperrels/26sqlt.t b/t/helperrels/26sqlt.t index 1362252..0c074cc 100644 --- a/t/helperrels/26sqlt.t +++ b/t/helperrels/26sqlt.t @@ -8,7 +8,7 @@ plan skip_all => 'SQL::Translator required' if $@; my $schema = DBICTest::Schema; -plan tests => 31; +plan tests => 33; my $translator = SQL::Translator->new( parser_args => { @@ -86,6 +86,9 @@ my @unique_constraints = ( {'display' => 'twokeytreelike name unique', 'table' => 'twokeytreelike', 'cols' => ['name'], 'needed' => 1}, + {'display' => 'employee position and group_id unique', + 'table' => 'employee', cols => ['position', 'group_id'], + 'needed' => 1}, ); my $tschema = $translator->schema(); diff --git a/t/lib/DBICTest/Schema/Employee.pm b/t/lib/DBICTest/Schema/Employee.pm index 234d073..4ebeffd 100644 --- a/t/lib/DBICTest/Schema/Employee.pm +++ b/t/lib/DBICTest/Schema/Employee.pm @@ -5,7 +5,7 @@ use base 'DBIx::Class'; __PACKAGE__->load_components(qw( Ordered PK::Auto Core )); -__PACKAGE__->table('employees'); +__PACKAGE__->table('employee'); __PACKAGE__->add_columns( employee_id => { diff --git a/t/lib/DBICTest/Setup.pm b/t/lib/DBICTest/Setup.pm index 816a64c..fb08fce 100755 --- a/t/lib/DBICTest/Setup.pm +++ b/t/lib/DBICTest/Setup.pm @@ -19,7 +19,7 @@ if ($ENV{"DBICTEST_SQLT_DEPLOY"}) { close IN; - $dbh->do($_) for split(/\n\n/, $sql); + $dbh->do($_) for split(/;\n/, $sql); } $schema->storage->dbh->do("PRAGMA synchronous = OFF"); diff --git a/t/lib/sqlite.sql b/t/lib/sqlite.sql index ae029c5..826805a 100644 --- a/t/lib/sqlite.sql +++ b/t/lib/sqlite.sql @@ -1,13 +1,13 @@ -- -- Created by SQL::Translator::Producer::SQLite --- Created on Fri Mar 24 15:47:00 2006 +-- Created on Wed Apr 19 18:32:39 2006 -- BEGIN TRANSACTION; -- --- Table: employees +-- Table: employee -- -CREATE TABLE employees ( +CREATE TABLE employee ( employee_id INTEGER PRIMARY KEY NOT NULL, position integer NOT NULL, group_id integer, @@ -23,6 +23,14 @@ CREATE TABLE serialized ( ); -- +-- Table: liner_notes +-- +CREATE TABLE liner_notes ( + liner_id INTEGER PRIMARY KEY NOT NULL, + notes varchar(100) NOT NULL +); + +-- -- Table: cd_to_producer -- CREATE TABLE cd_to_producer ( @@ -32,14 +40,6 @@ CREATE TABLE cd_to_producer ( ); -- --- Table: liner_notes --- -CREATE TABLE liner_notes ( - liner_id INTEGER PRIMARY KEY NOT NULL, - notes varchar(100) NOT NULL -); - --- -- Table: artist -- CREATE TABLE artist ( @@ -48,6 +48,18 @@ CREATE TABLE artist ( ); -- +-- 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) +); + +-- -- Table: self_ref_alias -- CREATE TABLE self_ref_alias ( @@ -132,14 +144,6 @@ CREATE TABLE artist_undirected_map ( ); -- --- Table: producer --- -CREATE TABLE producer ( - producerid INTEGER PRIMARY KEY NOT NULL, - name varchar(100) NOT NULL -); - --- -- Table: onekey -- CREATE TABLE onekey ( @@ -148,4 +152,15 @@ CREATE TABLE onekey ( cd integer NOT NULL ); +-- +-- Table: producer +-- +CREATE TABLE producer ( + producerid INTEGER PRIMARY KEY NOT NULL, + name varchar(100) NOT NULL +); + +CREATE UNIQUE INDEX position_group_employee on employee (position, group_id); +CREATE UNIQUE INDEX tktlnameunique_twokeytreelike on twokeytreelike (name); +CREATE UNIQUE INDEX artist_title_cd on cd (artist, title); COMMIT;