7 use DBIC::SqlMakerTest;
9 { # Fake storage driver for sqlite with autocast
10 package DBICTest::SQLite::AutoCast;
12 DBIx::Class::Storage::DBI::AutoCast
13 DBIx::Class::Storage::DBI::SQLite
18 datetime => 'DateTime',
20 int => undef, # no conversion
24 return $type_map->{$_[1]};
28 my $schema = DBICTest->init_schema (storage_type => 'DBICTest::SQLite::AutoCast');
30 # 'me.id' will be cast unlike the unqualified 'id'
31 my $rs = $schema->resultset ('CD')->search ({
33 'tracks.last_updated_at' => { '!=', undef },
34 'tracks.last_updated_on' => { '<', 2009 },
35 'tracks.position' => 4,
36 }, { join => 'tracks' });
38 my $bind = [ [ cdid => 5 ], [ 'tracks.last_updated_on' => 2009 ], [ 'tracks.position' => 4 ] ];
43 SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track
45 LEFT JOIN track tracks ON tracks.cd = me.cdid
48 AND tracks.last_updated_at IS NOT NULL
49 AND tracks.last_updated_on < ?
50 AND tracks.position = ?
53 'expected sql with casting off',
56 $schema->storage->auto_cast (1);
61 SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track
63 LEFT JOIN track tracks ON tracks.cd = me.cdid
66 AND tracks.last_updated_at IS NOT NULL
67 AND tracks.last_updated_on < CAST (? AS yyy)
68 AND tracks.position = ?
71 'expected sql with casting on',