Skip to content

Commit

Permalink
Added test scripts
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.perl.org/modules/DBD-mysql/trunk@12690 50811bd7-b8ce-0310-adc1-d9db26280581
  • Loading branch information
capttofu committed Apr 13, 2009
1 parent 775da62 commit ef87e45
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
38 changes: 38 additions & 0 deletions eg/bigint_quotes.pl
@@ -0,0 +1,38 @@
#!/usr/bin/perl

use strict;
use warnings;

use DBI;
use Data::Dumper;

my $create= <<'EOTABLE';
create table bigt1 (
id bigint unsigned not null default 0
)
EOTABLE

#my $dbh= DBI->connect('DBI:mysql:test', 'root', 'root', { mysql_bind_type_guessing => 2})
# or die "unable to connect $DBI::errstr";
my $dbh= DBI->connect('DBI:mysql:test', 'root', 'root')
or die "unable to connect $DBI::errstr";

$dbh->{mysql_bind_type_guessing}= 1;

$dbh->do('drop table if exists bigt1');
$dbh->do($create);

my $statement= 'insert into bigt1 (id) values (?)';

my $sth= $dbh->prepare($statement);

my $rows= $sth->execute('9999999999999999');
print "rows $rows\n";

$statement= 'update bigt1 set id = ?';
$sth= $dbh->prepare($statement);
$rows= $sth->execute('9999999999999998');
print "rows $rows\n";

my $retref= $dbh->selectall_arrayref('select * from bigt1');
print Dumper $retref;
63 changes: 63 additions & 0 deletions t/51bind_type_guessing.t
@@ -0,0 +1,63 @@
#!/usr/bin/perl

use strict;
use warnings;

use DBI;
use DBI::Const::GetInfoType;
use Test::More;
use lib 't', '.';
require 'lib.pl';

use vars qw($test_dsn $test_user $test_password $table);

my $dbh;
eval {$dbh= DBI->connect($test_dsn, $test_user, $test_password,
{ RaiseError => 1, PrintError => 1, AutoCommit => 0 });};
if ($@) {
plan skip_all =>
"ERROR: $DBI::errstr. Can't continue test";
}
plan tests => 29;

ok $dbh->do("DROP TABLE IF EXISTS $table"), "drop table if exists $table";

my $create= <<"EOTABLE";
create table $table (
id bigint unsigned not null default 0
)
EOTABLE


ok $dbh->do($create), "creating table";

my $statement= 'insert into bigt1 (id) values (?)';

$sth1;
ok $sth1= $dbh->prepare($statement);

my $rows;
ok $rows= $sth1->execute('9999999999999999');
cmp_ok $rows, '==', 1;

$statement= 'update bigt1 set id = ?';
my $sth2;
ok $sth2= $dbh->prepare($statement);

ok $rows= $sth2->execute('9999999999999998');
cmp_ok $rows, '==', 1;

$dbh->{mysql_bind_type_guessing}= 1;
ok $rows= $sth1->execute('9999999999999997');
cmp_ok $rows, '==', 1;

$statement= 'update bigt1 set id = ? where id = ?';

ok $sth2= $dbh->prepare($statement);
ok $rows= $sth1->execute('9999999999999996', '9999999999999997');

my $retref;
ok $retref= $dbh->selectall_arrayref('select * from bigt1');

cmp_ok $retref->[0][0], '==', 9999999999999998;
cmp_ok $retref->[0][0], '==', 9999999999999996;

0 comments on commit ef87e45

Please sign in to comment.