mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-06 21:58:01 -04:00
Use imported constants
This commit is contained in:
parent
9e59c780a7
commit
f14744d31a
12 changed files with 39 additions and 23 deletions
|
@ -7,7 +7,9 @@ use SQLiteTest qw/connect_ok @CALL_FUNCS/;
|
|||
use Test::More;
|
||||
use if -d ".git", "Test::FailWarnings";
|
||||
|
||||
my $unicode_opt = DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_STRICT;
|
||||
use DBD::SQLite::Constants ':dbd_sqlite_string_mode';
|
||||
|
||||
my $unicode_opt = DBD_SQLITE_STRING_MODE_UNICODE_STRICT;
|
||||
|
||||
my $show_diag = 0;
|
||||
foreach my $call_func (@CALL_FUNCS) {
|
||||
|
|
|
@ -8,7 +8,9 @@ use SQLiteTest;
|
|||
use Test::More;
|
||||
use if -d ".git", "Test::FailWarnings";
|
||||
|
||||
my $unicode_opt = DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_STRICT;
|
||||
use DBD::SQLite::Constants ':dbd_sqlite_string_mode';
|
||||
|
||||
my $unicode_opt = DBD_SQLITE_STRING_MODE_UNICODE_STRICT;
|
||||
|
||||
BEGIN { requires_unicode_support() }
|
||||
|
||||
|
|
|
@ -7,8 +7,9 @@ use Test::More;
|
|||
use if -d ".git", "Test::FailWarnings";
|
||||
use Encode qw/decode/;
|
||||
use DBD::SQLite;
|
||||
use DBD::SQLite::Constants ':dbd_sqlite_string_mode';
|
||||
|
||||
my $unicode_opt = DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_STRICT;
|
||||
my $unicode_opt = DBD_SQLITE_STRING_MODE_UNICODE_STRICT;
|
||||
|
||||
BEGIN { requires_unicode_support(); }
|
||||
|
||||
|
@ -73,7 +74,7 @@ is($DBD::SQLite::COLLATION{foo}, \&by_num_desc, "overridden collation");
|
|||
|
||||
foreach my $call_func (@CALL_FUNCS) {
|
||||
|
||||
for my $unicode_opt ( DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_BYTES, DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_STRICT) {
|
||||
for my $unicode_opt (DBD_SQLITE_STRING_MODE_BYTES, DBD_SQLITE_STRING_MODE_UNICODE_STRICT) {
|
||||
|
||||
# connect
|
||||
my $dbh = connect_ok( RaiseError => 1, sqlite_string_mode => $unicode_opt );
|
||||
|
@ -86,7 +87,7 @@ foreach my $call_func (@CALL_FUNCS) {
|
|||
HAT hâôer
|
||||
féôu fêôe fèöe ferme
|
||||
};
|
||||
if ($unicode_opt != DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_BYTES) {
|
||||
if ($unicode_opt != DBD_SQLITE_STRING_MODE_BYTES) {
|
||||
utf8::upgrade($_) foreach @words;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,9 @@ use if -d ".git", "Test::FailWarnings";
|
|||
use File::Temp ();
|
||||
use File::Spec::Functions ':ALL';
|
||||
|
||||
my $unicode_opt = DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_STRICT;
|
||||
use DBD::SQLite::Constants ':dbd_sqlite_string_mode';
|
||||
|
||||
my $unicode_opt = DBD_SQLITE_STRING_MODE_UNICODE_STRICT;
|
||||
|
||||
BEGIN { requires_unicode_support() }
|
||||
|
||||
|
|
|
@ -28,10 +28,11 @@ BEGIN {
|
|||
use locale;
|
||||
|
||||
use DBD::SQLite;
|
||||
use DBD::SQLite::Constants ':dbd_sqlite_string_mode';
|
||||
|
||||
foreach my $call_func (@CALL_FUNCS) {
|
||||
|
||||
for my $string_mode (DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_BYTES, DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_STRICT) {
|
||||
for my $string_mode (DBD_SQLITE_STRING_MODE_BYTES, DBD_SQLITE_STRING_MODE_UNICODE_STRICT) {
|
||||
|
||||
# connect
|
||||
my $dbh = connect_ok( RaiseError => 1, sqlite_string_mode => $string_mode );
|
||||
|
@ -43,7 +44,7 @@ foreach my $call_func (@CALL_FUNCS) {
|
|||
|
||||
# populate test data
|
||||
my @vals = @words;
|
||||
if ($string_mode == DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_BYTES) {
|
||||
if ($string_mode == DBD_SQLITE_STRING_MODE_BYTES) {
|
||||
utf8::upgrade($_) foreach @vals;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use SQLiteTest;
|
|||
use Test::More;
|
||||
use if -d ".git", "Test::FailWarnings";
|
||||
use DBD::SQLite;
|
||||
|
||||
use DBD::SQLite::Constants ':dbd_sqlite_string_mode';
|
||||
|
||||
my @texts = ("il était une bergère",
|
||||
"qui gardait ses moutons",
|
||||
|
@ -59,7 +59,7 @@ sub Unicode_Word_tokenizer { # see also: Search::Tokenizer
|
|||
|
||||
use DBD::SQLite;
|
||||
|
||||
for my $string_mode (DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_BYTES, DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_STRICT) {
|
||||
for my $string_mode (DBD_SQLITE_STRING_MODE_BYTES, DBD_SQLITE_STRING_MODE_UNICODE_STRICT) {
|
||||
|
||||
# connect
|
||||
my $dbh = connect_ok( RaiseError => 1, sqlite_string_mode => $string_mode );
|
||||
|
@ -106,7 +106,7 @@ for my $string_mode (DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_BYTES, DBD::
|
|||
# the 'offsets' function should return integer offsets for the words in the MATCH query
|
||||
my $sql_offsets = "SELECT offsets(try_$fts) FROM try_$fts WHERE content MATCH ?";
|
||||
$result = $dbh->selectcol_arrayref($sql_offsets, undef, 'une');
|
||||
my $offset_une = $string_mode == DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_STRICT ? $ix_une_utf8 : $ix_une_native;
|
||||
my $offset_une = $string_mode == DBD_SQLITE_STRING_MODE_UNICODE_STRICT ? $ix_une_utf8 : $ix_une_native;
|
||||
my $expected_offsets = "0 0 $offset_une 3";
|
||||
is_deeply($result, [$expected_offsets], "offsets ($fts, string_mode=$string_mode)");
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ use Test::More;
|
|||
|
||||
BEGIN { requires_unicode_support() }
|
||||
|
||||
use DBD::SQLite::Constants ':dbd_sqlite_string_mode';
|
||||
|
||||
# special case for multibyte (non-ASCII) character class,
|
||||
# which only works correctly under the unicode mode
|
||||
my @words = ("\x{e3}\x{83}\x{86}\x{e3}\x{82}\x{b9}\x{e3}\x{83}\x{88}", "\x{e3}\x{83}\x{86}\x{e3}\x{83}\x{b3}\x{e3}\x{83}\x{88}"); # テスト テント
|
||||
|
@ -15,15 +17,15 @@ my $regex = "\x{e3}\x{83}\x{86}[\x{e3}\x{82}\x{b9}\x{e3}\x{83}\x{b3}]\x{e3}\x{83
|
|||
|
||||
foreach my $call_func (@CALL_FUNCS) {
|
||||
|
||||
for my $use_unicode (0, 1) {
|
||||
for my $string_mode (DBD_SQLITE_STRING_MODE_PV, DBD_SQLITE_STRING_MODE_UNICODE_STRICT) {
|
||||
|
||||
# connect
|
||||
my $dbh = connect_ok( RaiseError => 1, sqlite_unicode => $use_unicode );
|
||||
my $dbh = connect_ok( RaiseError => 1, sqlite_string_mode => $string_mode );
|
||||
|
||||
# populate test data
|
||||
my @vals = @words;
|
||||
my $re = $regex;
|
||||
if ($use_unicode) {
|
||||
if ($string_mode == DBD_SQLITE_STRING_MODE_UNICODE_STRICT) {
|
||||
utf8::decode($_) foreach @vals;
|
||||
utf8::decode($re);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,9 @@ use SQLiteTest;
|
|||
use Test::More;
|
||||
use if -d ".git", "Test::FailWarnings";
|
||||
|
||||
my $unicode_opt = DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_STRICT;
|
||||
use DBD::SQLite::Constants ':dbd_sqlite_string_mode';
|
||||
|
||||
my $unicode_opt = DBD_SQLITE_STRING_MODE_UNICODE_STRICT;
|
||||
|
||||
BEGIN { requires_unicode_support(); }
|
||||
|
||||
|
|
|
@ -5,7 +5,9 @@ use SQLiteTest;
|
|||
use Test::More;
|
||||
use if -d ".git", "Test::FailWarnings";
|
||||
|
||||
my $unicode_opt = DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_STRICT;
|
||||
use DBD::SQLite::Constants ':dbd_sqlite_string_mode';
|
||||
|
||||
my $unicode_opt = DBD_SQLITE_STRING_MODE_UNICODE_STRICT;
|
||||
|
||||
BEGIN { requires_unicode_support() }
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ use Test::More;
|
|||
use if -d ".git", "Test::FailWarnings";
|
||||
use DBI qw/:sql_types/;
|
||||
|
||||
use DBD::SQLite::Constants;
|
||||
use DBD::SQLite::Constants ':dbd_sqlite_string_mode';
|
||||
|
||||
BEGIN{ requires_unicode_support(); }
|
||||
|
||||
my $dbh = connect_ok(sqlite_string_mode => DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_STRICT);
|
||||
my $dbh = connect_ok(sqlite_string_mode => DBD_SQLITE_STRING_MODE_UNICODE_STRICT);
|
||||
$dbh->do('create table test1 (id integer, b blob)');
|
||||
|
||||
my $blob = "\x{82}\x{A0}";
|
||||
|
|
|
@ -6,7 +6,7 @@ use Test::More;
|
|||
use if -d ".git", "Test::FailWarnings";
|
||||
use Encode;
|
||||
|
||||
use DBD::SQLite::Constants;
|
||||
use DBD::SQLite::Constants ':dbd_sqlite_string_mode';
|
||||
|
||||
BEGIN { requires_unicode_support() }
|
||||
|
||||
|
@ -22,7 +22,7 @@ sub unicode_test {
|
|||
|
||||
{ # tests for an environment where everything is encoded
|
||||
|
||||
my $dbh = connect_ok(sqlite_string_mode => DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_BYTES);
|
||||
my $dbh = connect_ok(sqlite_string_mode => DBD_SQLITE_STRING_MODE_BYTES);
|
||||
$dbh->do("pragma foreign_keys = on");
|
||||
my $unicode_quoted = $dbh->quote_identifier($unicode_encoded);
|
||||
$dbh->do("create table $unicode_quoted (id, $unicode_quoted primary key)");
|
||||
|
@ -89,7 +89,7 @@ sub unicode_test {
|
|||
}
|
||||
|
||||
{ # tests for an environment where everything is decoded
|
||||
my $dbh = connect_ok(sqlite_string_mode => DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_STRICT);
|
||||
my $dbh = connect_ok(sqlite_string_mode => DBD_SQLITE_STRING_MODE_UNICODE_STRICT);
|
||||
$dbh->do("pragma foreign_keys = on");
|
||||
my $unicode_quoted = $dbh->quote_identifier($unicode);
|
||||
$dbh->do("create table $unicode_quoted (id, $unicode_quoted primary key)");
|
||||
|
|
|
@ -11,8 +11,10 @@ use if -d ".git", "Test::FailWarnings";
|
|||
|
||||
BEGIN { requires_unicode_support() }
|
||||
|
||||
my $dbh = connect_ok( sqlite_string_mode => DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_NAIVE );
|
||||
is( $dbh->{sqlite_string_mode}, DBD::SQLite::Constants::DBD_SQLITE_STRING_MODE_UNICODE_NAIVE, 'Unicode is on' );
|
||||
use DBD::SQLite::Constants ':dbd_sqlite_string_mode';
|
||||
|
||||
my $dbh = connect_ok( sqlite_string_mode => DBD_SQLITE_STRING_MODE_UNICODE_NAIVE );
|
||||
is( $dbh->{sqlite_string_mode}, DBD_SQLITE_STRING_MODE_UNICODE_NAIVE, 'Unicode is on' );
|
||||
|
||||
ok( $dbh->do(<<'END_SQL'), 'CREATE TABLE' );
|
||||
CREATE TABLE foo (
|
||||
|
|
Loading…
Add table
Reference in a new issue