Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /proc/self/root/usr/share/doc/perl-DBIx-Class/t/storage/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/usr/share/doc/perl-DBIx-Class/t/storage/prefer_stringification.t
use warnings;
use strict;

use Test::More;

use lib qw(t/lib);
use DBICTest;

{
  package # hideee
    DBICTest::CrazyInt;

  use overload
    '0+' => sub { 666 },
    '""' => sub { 999 },
    fallback => 1,
  ;
}

# check DBI behavior when fed a stringifiable/nummifiable value
{
  my $crazynum = bless {}, 'DBICTest::CrazyInt';
  cmp_ok( $crazynum, '==', 666 );
  cmp_ok( $crazynum, 'eq', 999 );

  my $schema = DBICTest->init_schema( no_populate => 1 );
  $schema->storage->dbh_do(sub {
    $_[1]->do('INSERT INTO artist (name) VALUES (?)', {}, $crazynum );
  });

  is( $schema->resultset('Artist')->next->name, 999, 'DBI preferred stringified version' );
}
done_testing;

Hry