mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 14:19:10 -04:00
are correctly assumed Perl unicode strings, instead of relying on its internal character encoding as UTF-8. This *might* break (potentially broken) apps that passes UTF-8 encoded strings, instead of decoded strings, to ->execute or ->bind_param() without SQL_BLOB. But this new behavior is more natural to how Perl handles strings and consisten to what other drivers do under UTF-8 options set, e.g. DBD::mysql with mysql_enable_utf8 option. See also http://use.perl.org/~miyagawa/journal/38770 for details. Fixes RT bug 25371.
31 lines
790 B
Perl
31 lines
790 B
Perl
#!/usr/bin/perl
|
|
|
|
use strict;
|
|
BEGIN {
|
|
$| = 1;
|
|
$^W = 1;
|
|
}
|
|
|
|
use t::lib::Test;
|
|
use Test::More tests => 22;
|
|
use Test::NoWarnings;
|
|
|
|
my $dbh = connect_ok();
|
|
$dbh->{unicode} = 1;
|
|
|
|
ok( $dbh->do(<<'END_SQL'), 'CREATE TABLE' );
|
|
CREATE TABLE foo (
|
|
bar varchar(255)
|
|
)
|
|
END_SQL
|
|
|
|
foreach ( "\0", "A", "\xe9", "\x{20ac}" ) {
|
|
ok( $dbh->do("INSERT INTO foo VALUES ( ? )", {}, $_), 'INSERT' );
|
|
my $foo = $dbh->selectall_arrayref("SELECT bar FROM foo");
|
|
is_deeply( $foo, [ [ $_ ] ], 'Value round-tripped ok' );
|
|
my $len = $dbh->selectall_arrayref("SELECT length(bar) FROM foo");
|
|
is $len->[0][0], 1 unless $_ eq "\0";
|
|
my $match = $dbh->selectall_arrayref("SELECT bar FROM foo WHERE bar = ?", {}, $_);
|
|
is $match->[0][0], $_;
|
|
ok( $dbh->do("DELETE FROM foo"), 'DELETE ok' );
|
|
}
|