is($link7->url, undef, 'Link 7 url');
is($link7->title, 'gtitle', 'Link 7 title');
-my $rs = $schema->resultset('Artist');
-$rs->delete;
+# populate with literals
+{
+ my $rs = $schema->resultset('Link');
+ $rs->delete;
-# test _execute_array_empty (insert_bulk with all literal sql)
+ # test _execute_array_empty (insert_bulk with all literal sql)
-$rs->populate([
+ $rs->populate([
(+{
- name => \"'DT'",
- rank => \500,
- charfield => \"'mtfnpy'",
+ url => \"'cpan.org'",
+ title => \"'The ''best of'' cpan'",
}) x 5
-]);
+ ]);
-is((grep {
- $_->name eq 'DT' &&
- $_->rank == 500 &&
- $_->charfield eq 'mtfnpy'
-} $rs->all), 5, 'populate with all literal SQL');
+ is((grep {
+ $_->url eq 'cpan.org' &&
+ $_->title eq "The 'best of' cpan",
+ } $rs->all), 5, 'populate with all literal SQL');
-$rs->delete;
+ $rs->delete;
-# test mixed binds with literal sql
+ # test mixed binds with literal sql
-$rs->populate([
+ $rs->populate([
(+{
- name => \"'DT'",
- rank => 500,
- charfield => \"'mtfnpy'",
+ url => \"'cpan.org'",
+ title => "The 'best of' cpan",
}) x 5
-]);
-
-is((grep {
- $_->name eq 'DT' &&
- $_->rank == 500 &&
- $_->charfield eq 'mtfnpy'
-} $rs->all), 5, 'populate with all literal SQL');
+ ]);
-$rs->delete;
+ is((grep {
+ $_->url eq 'cpan.org' &&
+ $_->title eq "The 'best of' cpan",
+ } $rs->all), 5, 'populate with all literal SQL');
-###
+ $rs->delete;
+}
+my $rs = $schema->resultset('Artist');
+$rs->delete;
throws_ok {
$rs->populate([
{
{
title => 'Some CD3',
year => '1997',
- artist => { artistid=> ++$aid, name => 'Fred BloggsC'},
+ artist => { artistid=> ++$aid, name => 'Fred BloggsE'},
},
{
title => 'Some CD4',
year => '1997',
- artist => { artistid=> ++$aid, name => 'Fred BloggsD'},
+ artist => { artistid=> ++$aid, name => 'Fred BloggsF'},
},
];
isa_ok($cdA, 'DBICTest::CD', 'Created CD');
isa_ok($cdA->artist, 'DBICTest::Artist', 'Set Artist');
- is($cdA->artist->name, 'Fred BloggsC', 'Set Artist to FredC');
+ is($cdA->artist->name, 'Fred BloggsE', 'Set Artist to FredE');
isa_ok($cdB, 'DBICTest::CD', 'Created CD');
isa_ok($cdB->artist, 'DBICTest::Artist', 'Set Artist');
- is($cdB->artist->name, 'Fred BloggsD', 'Set Artist to FredD');
+ is($cdB->artist->name, 'Fred BloggsF', 'Set Artist to FredF');
ok($cdB->artist->artistid == $aid, "Got Expected Artist ID");
}
]
});
- $rs->update({ name => 'Test _cond_for_update_delete' });
+ $rs->update({ rank => 6134 });
my $art;
$art = $schema->resultset("Artist")->find(1);
- is($art->name, 'Test _cond_for_update_delete', 'updated first artist name');
+ is($art->rank, 6134, 'updated first artist rank');
$art = $schema->resultset("Artist")->find(2);
- is($art->name, 'Test _cond_for_update_delete', 'updated second artist name');
+ is($art->rank, 6134, 'updated second artist rank');
}
# test source_name
use strict;
-use warnings;
+use warnings;
use Test::More;
use lib qw(t/lib);
my $schema = DBICTest->init_schema();
-plan tests => 4;
my $artist = $schema->resultset('Artist')->find(1);
my $artist_cds = $artist->search_related('cds');
-my $cover_band = $artist->copy;
+my $cover_band = $artist->copy ({name => $artist->name . '_cover' });
my $cover_cds = $cover_band->search_related('cds');
cmp_ok($cover_band->id, '!=', $artist->id, 'ok got new column id...');
cmp_ok($cover_cds->search_related('tags')->count, '==',
$artist_cds->search_related('tags')->count , 'duplicated count ok');
+done_testing;
},
);
__PACKAGE__->set_primary_key('artistid');
+__PACKAGE__->add_unique_constraint(['name']);
__PACKAGE__->add_unique_constraint(artist => ['artistid']); # do not remove, part of a test
+
__PACKAGE__->mk_classdata('field_name_for', {
artistid => 'primary key',
name => 'artist name',
--
-- Created by SQL::Translator::Producer::SQLite
--- Created on Thu Jun 3 11:52:50 2010
+-- Created on Sat Oct 16 16:17:01 2010
--
--
CREATE INDEX artist_name_hookidx ON artist (name);
+CREATE UNIQUE INDEX artist_name ON artist (name);
+
--
-- Table: bindtype_test
--
CREATE INDEX tags_idx_cd ON tags (cd);
+CREATE UNIQUE INDEX tagid_cd ON tags (tagid, cd);
+
+CREATE UNIQUE INDEX tagid_cd_tag ON tags (tagid, cd, tag);
+
+CREATE UNIQUE INDEX tags_tagid_tag ON tags (tagid, tag);
+
+CREATE UNIQUE INDEX tags_tagid_tag_cd ON tags (tagid, tag, cd);
+
--
-- Table: cd_to_producer
--
->schema
->populate('Artist', [
[ qw/artistid name/ ],
- [ $id, "Children of the Grave"],
+ [ $id, "Children of the Grave $id"],
]);
ok my $result = $replicated->schema->resultset('Artist')->find($id)