X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F71mysql.t;h=0c099f8f72663fd7bc92e319e934ced4309162e8;hb=905e6f073b89facb367cdedecd42ddbc5d770d61;hp=836c846a6d96f0f986371787b544f2be39449c3f;hpb=6a9992417a9b274d874519fd42f1b331d5ac91e6;p=dbsrgits%2FDBIx-Class.git diff --git a/t/71mysql.t b/t/71mysql.t index 836c846..0c099f8 100644 --- a/t/71mysql.t +++ b/t/71mysql.t @@ -6,6 +6,7 @@ use Test::Exception; use lib qw(t/lib); use DBICTest; use DBI::Const::GetInfoType; +use DBIC::SqlMakerTest; my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}; @@ -14,8 +15,6 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); -plan tests => 19; - my $schema = DBICTest::Schema->connect($dsn, $user, $pass); my $dbh = $schema->storage->dbh; @@ -46,6 +45,14 @@ $dbh->do("CREATE TABLE books (id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, so #'dbi:mysql:host=localhost;database=dbic_test', 'dbic_test', ''); +# make sure sqlt_type overrides work (::Storage::DBI::mysql does this) +{ + my $schema = DBICTest::Schema->connect($dsn, $user, $pass); + + ok (!$schema->storage->_dbh, 'definitely not connected'); + is ($schema->storage->sqlt_type, 'MySQL', 'sqlt_type correct pre-connection'); +} + # This is in Core now, but it's here just to test that it doesn't break $schema->class('Artist')->load_components('PK::Auto'); @@ -153,12 +160,41 @@ SKIP: { my $type_info = $schema->storage->columns_info_for('artist'); is_deeply($type_info, $test_type_info, 'columns_info_for - column data types'); + + } my $cd = $schema->resultset ('CD')->create ({}); my $producer = $schema->resultset ('Producer')->create ({}); lives_ok { $cd->set_producers ([ $producer ]) } 'set_relationship doesnt die'; +{ + my $artist = $schema->resultset('Artist')->next; + my $cd = $schema->resultset('CD')->next; + $cd->set_from_related ('artist', $artist); + $cd->update; + + my $rs = $schema->resultset('CD')->search ({}, { prefetch => 'artist' }); + + lives_ok sub { + my $cd = $rs->next; + is ($cd->artist->name, $artist->name, 'Prefetched artist'); + }, 'join does not throw (mysql 3 test)'; + + # induce a jointype override, make sure it works even if we don't have mysql3 + local $schema->storage->sql_maker->{_default_jointype} = 'inner'; + is_same_sql_bind ( + $rs->as_query, + '( + SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track, + artist.artistid, artist.name, artist.rank, artist.charfield + FROM cd me + INNER JOIN artist artist ON artist.artistid = me.artist + )', + [], + 'overriden default join type works', + ); +} ## Can we properly deal with the null search problem? ## @@ -169,7 +205,9 @@ lives_ok { $cd->set_producers ([ $producer ]) } 'set_relationship doesnt die'; # with it (ribasushi, 2009/07/03) NULLINSEARCH: { - my $ansi_schema = DBICTest::Schema->connect ($dsn, $user, $pass, { on_connect_call => 'set_ansi_mode' }); + my $ansi_schema = DBICTest::Schema->connect ($dsn, $user, $pass, { on_connect_call => 'set_strict_mode' }); + + $ansi_schema->resultset('Artist')->create ({ name => 'last created artist' }); ok my $artist1_rs = $ansi_schema->resultset('Artist')->search({artistid=>6666}) => 'Created an artist resultset of 6666'; @@ -188,3 +226,5 @@ NULLINSEARCH: { is $artist => undef => 'Nothing Found!'; } + +done_testing;