$table_name = $$table_name if ref $table_name eq 'SCALAR';
# It's possible to have multiple DBIC sources using the same table
- next if $tables{$table_name};
+ next if $tables{$moniker};
- $tables{$table_name}{source} = $source;
+ $tables{$moniker}{source} = $source;
foreach my $rel (sort $source->relationships) {
my $rel_info = $source->relationship_info($rel);
\@keys, [$source->primary_columns]);
}
- $tables{$table_name}{foreign_table_deps}{$rel_table}++
+ $tables{$moniker}{foreign_table_deps}{$rel_table}++
if $fk_constraint && @keys
# calculate dependencies: do not consider deferrable constraints and
# self-references for dependency calculations
my $schema = DBICTest->init_schema( no_connect => 1, no_deploy => 1 );
is_deeply($schema->source_tree, {
- " ( SELECT a.*, cd.cdid AS cdid, cd.title AS title, cd.year AS year\n FROM artist a\n JOIN cd ON cd.artist = a.artistid\n WHERE cd.year = ?)\n" => {},
- artist => {},
- artist_undirected_map => {
+ Artist => {},
+ ArtistSubclass => {},
+ ArtistUndirectedMap => {
artist => 1
},
- artwork_to_artist => {
+ Artwork => {
+ cd => 1
+ },
+ Artwork_to_Artist => {
artist => 1,
- cd => 1,
- cd_artwork => 1,
- genre => 1,
- track => 1
+ cd_artwork => 1
},
- bindtype_test => {},
- bookmark => {
+ BindType => {},
+ Bookmark => {
link => 1
},
- books => {
+ BooksInLibrary => {
owners => 1
},
- cd => {
- genre => 1,
- track => 1
- },
- cd_artwork => {
- cd => 1,
+ CD => {
genre => 1,
track => 1
},
- cd_to_producer => {
+ CD_to_Producer => {
cd => 1,
- genre => 1,
- producer => 1,
- track => 1
+ producer => 1
},
- collection => {},
- collection_object => {
+ Collection => {},
+ CollectionObject => {
collection => 1,
typed_object => 1
},
- dummy => {},
- employee => {
+ CustomSql => {},
+ Dummy => {},
+ Employee => {
encoded => 1
},
- encoded => {},
- event => {},
- forceforeign => {
+ Encoded => {},
+ Event => {},
+ EventTZ => {},
+ ForceForeign => {
artist => 1
},
- fourkeys => {},
- fourkeys_to_twokeys => {
- artist => 1,
- cd => 1,
+ FourKeys => {},
+ FourKeys_to_TwoKeys => {
fourkeys => 1,
- genre => 1,
- track => 1,
twokeys => 1
},
- genre => {},
- images => {
- cd => 1,
- cd_artwork => 1,
- genre => 1,
- track => 1
+ Genre => {},
+ Image => {
+ cd_artwork => 1
},
- liner_notes => {
- cd => 1,
- genre => 1,
- track => 1
+ LinerNotes => {
+ cd => 1
},
- link => {},
- lyric_versions => {
- cd => 1,
- lyrics => 1,
- track => 1
+ Link => {},
+ LyricVersion => {
+ lyrics => 1
},
- lyrics => {
- cd => 1,
+ Lyrics => {
track => 1
},
- money_test => {},
- noprimarykey => {},
- onekey => {},
- owners => {},
- producer => {},
- self_ref => {},
- self_ref_alias => {
+ Money => {},
+ NoPrimaryKey => {},
+ OneKey => {},
+ Owners => {},
+ Producer => {},
+ SelfRef => {},
+ SelfRefAlias => {
self_ref => 1
},
- sequence_test => {},
- serialized => {},
- tags => {
- cd => 1,
- genre => 1,
- track => 1
+ SequenceTest => {},
+ Serialized => {},
+ SourceNameArtists => {},
+ Tag => {
+ cd => 1
},
- timestamp_primary_key_test => {},
- track => {
+ TimestampPrimaryKey => {},
+ Track => {
cd => 1
},
- treelike => {},
- twokeys => {
+ TreeLike => {},
+ TwoKeyTreeLike => {},
+ TwoKeys => {
artist => 1,
- cd => 1,
- genre => 1,
- track => 1
+ cd => 1
},
- twokeytreelike => {},
- typed_object => {},
+ TypedObject => {}
}, 'got correct source tree');
-is_deeply($schema->source_tree({ limit_sources => ['TwoKeys'] }), {
- " ( SELECT a.*, cd.cdid AS cdid, cd.title AS title, cd.year AS year\n FROM artist a\n JOIN cd ON cd.artist = a.artistid\n WHERE cd.year = ?)\n" => {},
- artist => {},
- artist_undirected_map => {
- artist => 1
- },
- artwork_to_artist => {
- artist => 1,
- cd => 1,
- cd_artwork => 1,
- genre => 1,
- track => 1
- },
- bindtype_test => {},
- bookmark => {
- link => 1
- },
- books => {
- owners => 1
- },
- cd => {
- genre => 1,
- track => 1
- },
- cd_artwork => {
- cd => 1,
- genre => 1,
- track => 1
- },
- cd_to_producer => {
- cd => 1,
- genre => 1,
- producer => 1,
- track => 1
- },
- collection => {},
- collection_object => {
- collection => 1,
- typed_object => 1
- },
- dummy => {},
- employee => {
- encoded => 1
- },
- encoded => {},
- event => {},
- forceforeign => {
+use Devel::Dwarn;
+
+my $sans_TwoKeys = {
+ Artist => {},
+ ArtistSubclass => {},
+ ArtistUndirectedMap => {
artist => 1
},
- fourkeys => {},
- fourkeys_to_twokeys => {
- fourkeys => 1
- },
- genre => {},
- images => {
- cd => 1,
- cd_artwork => 1,
- genre => 1,
- track => 1
- },
- liner_notes => {
- cd => 1,
- genre => 1,
- track => 1
- },
- link => {},
- lyric_versions => {
- cd => 1,
- lyrics => 1,
- track => 1
- },
- lyrics => {
- cd => 1,
- track => 1
- },
- money_test => {},
- noprimarykey => {},
- onekey => {},
- owners => {},
- producer => {},
- self_ref => {},
- self_ref_alias => {
- self_ref => 1
- },
- sequence_test => {},
- serialized => {},
- tags => {
- cd => 1,
- genre => 1,
- track => 1
- },
- timestamp_primary_key_test => {},
- track => {
+ Artwork => {
cd => 1
},
- treelike => {},
- twokeytreelike => {},
- typed_object => {}
-}, 'got correct source tree with limit_sources => [ ... ]');
-
-is_deeply($schema->source_tree({ limit_sources => { TwoKeys => 1 } }), {
- " ( SELECT a.*, cd.cdid AS cdid, cd.title AS title, cd.year AS year\n FROM artist a\n JOIN cd ON cd.artist = a.artistid\n WHERE cd.year = ?)\n" => {},
- artist => {},
- artist_undirected_map => {
- artist => 1
- },
- artwork_to_artist => {
+ Artwork_to_Artist => {
artist => 1,
- cd => 1,
- cd_artwork => 1,
- genre => 1,
- track => 1
+ cd_artwork => 1
},
- bindtype_test => {},
- bookmark => {
+ BindType => {},
+ Bookmark => {
link => 1
},
- books => {
+ BooksInLibrary => {
owners => 1
},
- cd => {
- genre => 1,
- track => 1
- },
- cd_artwork => {
- cd => 1,
+ CD => {
genre => 1,
track => 1
},
- cd_to_producer => {
+ CD_to_Producer => {
cd => 1,
- genre => 1,
- producer => 1,
- track => 1
+ producer => 1
},
- collection => {},
- collection_object => {
+ Collection => {},
+ CollectionObject => {
collection => 1,
typed_object => 1
},
- dummy => {},
- employee => {
+ CustomSql => {},
+ Dummy => {},
+ Employee => {
encoded => 1
},
- encoded => {},
- event => {},
- forceforeign => {
+ Encoded => {},
+ Event => {},
+ EventTZ => {},
+ ForceForeign => {
artist => 1
},
- fourkeys => {},
- fourkeys_to_twokeys => {
+ FourKeys => {},
+ FourKeys_to_TwoKeys => {
fourkeys => 1
},
- genre => {},
- images => {
- cd => 1,
- cd_artwork => 1,
- genre => 1,
- track => 1
+ Genre => {},
+ Image => {
+ cd_artwork => 1
},
- liner_notes => {
- cd => 1,
- genre => 1,
- track => 1
+ LinerNotes => {
+ cd => 1
},
- link => {},
- lyric_versions => {
- cd => 1,
- lyrics => 1,
- track => 1
+ Link => {},
+ LyricVersion => {
+ lyrics => 1
},
- lyrics => {
- cd => 1,
+ Lyrics => {
track => 1
},
- money_test => {},
- noprimarykey => {},
- onekey => {},
- owners => {},
- producer => {},
- self_ref => {},
- self_ref_alias => {
+ Money => {},
+ NoPrimaryKey => {},
+ OneKey => {},
+ Owners => {},
+ Producer => {},
+ SelfRef => {},
+ SelfRefAlias => {
self_ref => 1
},
- sequence_test => {},
- serialized => {},
- tags => {
- cd => 1,
- genre => 1,
- track => 1
+ SequenceTest => {},
+ Serialized => {},
+ SourceNameArtists => {},
+ Tag => {
+ cd => 1
},
- timestamp_primary_key_test => {},
- track => {
+ TimestampPrimaryKey => {},
+ Track => {
cd => 1
},
- treelike => {},
- twokeytreelike => {},
- typed_object => {}
-}, 'got correct source tree with limit_sources => { ... }');
+ TreeLike => {},
+ TwoKeyTreeLike => {},
+ TypedObject => {}
+};
+
+is_deeply(
+ $schema->source_tree({ limit_sources => ['TwoKeys'] }),
+ $sans_TwoKeys,
+ 'got correct source tree with limit_sources => [ ... ]',
+);
+
+is_deeply(
+ $schema->source_tree({ limit_sources => { TwoKeys => 1 } }),
+ $sans_TwoKeys,
+ 'got correct source tree with limit_sources => { ... }',
+);
# We probably also want a "collapsed" tree