-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use v6; | ||
use Test; | ||
use DBIish; | ||
|
||
plan 21; | ||
my %con-parms = :database<dbdishtest>, :user<testuser>, :password<testpass>; | ||
my $dbh; | ||
|
||
# Test buffer size scaling | ||
|
||
try { | ||
$dbh = DBIish.connect('mysql', |%con-parms); | ||
CATCH { | ||
when X::DBIish::LibraryMissing | X::DBDish::ConnectionFailed { | ||
diag "$_\nCan't continue."; | ||
} | ||
default { .throw; } | ||
} | ||
} | ||
without $dbh { | ||
skip-rest 'prerequisites failed'; | ||
exit; | ||
} | ||
|
||
ok $dbh, 'Connected'; | ||
lives-ok { | ||
$dbh.do(qq| | ||
CREATE TEMPORARY TABLE test_long_string ( | ||
col1 varchar(16383) | ||
)|) | ||
}, 'Table created'; | ||
|
||
my @string-lengths = 100, 8191, 8192, 8193, 10_000, 16383; | ||
my @long-strings; | ||
for @string-lengths -> $length { | ||
@long-strings.push('x' x $length); | ||
} | ||
|
||
my $sth = $dbh.prepare('INSERT INTO test_long_string (col1) VALUES(?)'); | ||
for @long-strings -> $string { | ||
lives-ok { | ||
$sth.execute($string); | ||
}, 'Add value: %d chars'.sprintf($string.chars); | ||
} | ||
$sth.dispose; | ||
|
||
$sth = $dbh.prepare('SELECT col1 FROM test_long_string ORDER BY length(col1)'); | ||
|
||
is $sth.execute, @long-strings.elems, '%d row'.sprintf(@long-strings.elems); | ||
|
||
# Compare both source and DB long strings in order by length. | ||
for @long-strings -> $string { | ||
my ($col1) = $sth.row; | ||
|
||
isa-ok $col1, Str; | ||
is $col1, $string, 'Value: %d chars'.sprintf($string.chars) ; | ||
} | ||
|
||
|
||
|