File: rt25389-bin-case.t

package info (click to toggle)
libdbd-mysql-perl 4.041-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,068 kB
  • ctags: 409
  • sloc: ansic: 4,511; perl: 817; makefile: 27; sh: 22
file content (59 lines) | stat: -rw-r--r-- 1,476 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use strict;
use warnings;

use DBI;

use vars qw($test_dsn $test_user $test_password);
require "t/lib.pl";

use Test::More;

my $dbh;
eval {$dbh= DBI->connect($test_dsn, $test_user, $test_password,
                      { RaiseError => 1, PrintError => 0, AutoCommit => 1 });};
if ($@) {
    plan skip_all => "no database connection";
}

if (!MinimumVersion($dbh, '5.1')) {
    plan skip_all =>
        "You must have MySQL version 5.1 or greater for this test"
}

plan tests => 8;

my ( $sth, $i );
my @test = qw(AA Aa aa aA);

for my $charset (qw(latin1 utf8)) {
    for my $unique ( "", "unique" ) {

        my $table = "dbd-mysql-$charset-$unique";
        my $create =
"CREATE TEMPORARY TABLE `$table` (name VARCHAR(8) CHARACTER SET $charset COLLATE ${charset}_bin $unique)";

        $dbh->do($create) or die $DBI::errstr;
        for (@test) {
            $dbh->do("insert into `$table` values ('$_')");
        }
        my $q1 = "select name from `$table`";
        $sth = $dbh->prepare($q1);
        $sth->execute;
        $i = 0;
        while ( my @row = $sth->fetchrow ) {
            $i++;
        }
        is( $i, scalar @test, $q1 );
        $sth->finish;

        my $q2 = "select name from `$table` where "
          . join( " OR ", map { "name = '$_'" } @test );
        $sth = $dbh->prepare($q2);
        $sth->execute;
        $i = 0;
        while ( my @row = $sth->fetchrow ) {
            $i++;
        }
        is( $i, scalar @test, $q2 );
    }
}