is_X_value functions introduced in 3705e3b28 migrated to SQLA with fixups
[dbsrgits/DBIx-Class.git] / t / storage / prefer_stringification.t
CommitLineData
b5ce6748 1use warnings;
2use strict;
3
4use Test::More;
5
6use lib qw(t/lib);
7use DBICTest;
8
9{
10 package # hideee
11 DBICTest::CrazyInt;
12
13 use overload
14 '0+' => sub { 666 },
15 '""' => sub { 999 },
16 fallback => 1,
17 ;
18}
19
20# check DBI behavior when fed a stringifiable/nummifiable value
21{
22 my $crazynum = bless {}, 'DBICTest::CrazyInt';
23 cmp_ok( $crazynum, '==', 666 );
24 cmp_ok( $crazynum, 'eq', 999 );
25
26 my $schema = DBICTest->init_schema( no_populate => 1 );
27 $schema->storage->dbh_do(sub {
28 $_[1]->do('INSERT INTO artist (name) VALUES (?)', {}, $crazynum );
29 });
30
31 is( $schema->resultset('Artist')->next->name, 999, 'DBI preferred stringified version' );
32}
33done_testing;