1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 06:08:38 -04:00
DBD-SQLite-SQLcipher/t/68_upgraded_no_unicode.t
Felipe Gasper 9dc75eaead Replace “string_unicode” boolean with “string_mode” enum.
Issue #78 and issue #68: This introduces additional, more robust
schemas for translating strings between SQLite and Perl.
2021-05-29 19:19:58 -04:00

63 lines
1.5 KiB
Perl

# This is a test for correct handling of upgraded strings without
# the sqlite_unicode parameter.
use strict;
use warnings;
use lib "t/lib";
use SQLiteTest;
use DBD::SQLite::Constants;
use Test::More;
use if -d ".git", "Test::FailWarnings";
{
my $dbh = connect_ok( dbfile => 'foo', RaiseError => 1 );
$dbh->{sqlite_string_mode} = DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_BYTES;
my $tbl_name = "\xe9p\xe9e";
utf8::encode $tbl_name;
my $str = "CREATE TABLE $tbl_name ( col1 TEXT )";
utf8::upgrade $str;
$dbh->do($str);
my $master_ar = $dbh->selectall_arrayref('SELECT * FROM sqlite_master', { Slice => {} });
is(
$master_ar->[0]{'name'},
$tbl_name,
'do() takes correct string value',
);
#----------------------------------------------------------------------
my $dummy_str = "SELECT '$tbl_name'";
utf8::upgrade $dummy_str;
my $sth = $dbh->prepare($dummy_str);
$sth->execute();
my $row = $sth->fetchrow_arrayref();
is(
$row->[0],
$tbl_name,
'prepare() takes correct string value',
);
#----------------------------------------------------------------------
my $tbl_name_ug = $tbl_name;
utf8::upgrade $tbl_name_ug;
my $sth2 = $dbh->prepare('SELECT ?');
$sth2->execute( do { my $v = $tbl_name_ug } );
$row = $sth2->fetchrow_arrayref();
is(
$row->[0],
$tbl_name,
'execute() takes correct string value',
);
}
done_testing;