1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 14:19:10 -04:00

disabled sqlite_is_number related stuff

This commit is contained in:
Kenichi Ishigaki 2010-08-25 02:28:02 +00:00
parent cd431b9a57
commit 03c6c1ee19
4 changed files with 11 additions and 258 deletions

View file

@ -928,6 +928,7 @@ sqlite_st_execute(SV *sth, imp_sth_t *imp_sth)
sv_utf8_upgrade(value);
}
data = SvPV(value, len);
#if 0
numtype = sqlite_is_number(aTHX_ data);
if (numtype == 1) {
#if defined(USE_64_BIT_INT)
@ -940,8 +941,11 @@ sqlite_st_execute(SV *sth, imp_sth_t *imp_sth)
rc = sqlite3_bind_double(imp_sth->stmt, i+1, atof(data));
}
else {
#endif
rc = sqlite3_bind_text(imp_sth->stmt, i+1, data, len, SQLITE_TRANSIENT);
#if 0
}
#endif
}
if (value) {

View file

@ -53,7 +53,7 @@ is( scalar(@$ar), 2, 'Got 2 results' );
# and this is what should be tested
#TODO: {
# local $TODO = 'This test is currently broken again. Wait for a better fix, or use known workarounds shown above';
local $TODO = 'This test is currently broken again. Wait for a better fix, or use known workarounds shown above';
$ar = $dbh->selectall_arrayref(
'SELECT bar FROM foo GROUP BY bar HAVING count(*) > ?',
undef, 1

View file

@ -34,10 +34,10 @@ my $statement = 'select count(*) from artist where length(name) > ?';
# ...not with bind args
$sth = $dbh->prepare($statement);
ok( $sth->execute(2), "execute: $statement : [2]" );
#TODO: {
# local $TODO = 'This test is currently broken again. Wait for a better fix, or use known workarounds.';
TODO: {
local $TODO = 'This test is currently broken again. Wait for a better fix, or use known workarounds.';
is( $sth->fetchrow_arrayref->[0], 1, "result of: $statement : [2]" );
#}
}
### it does work, however, from the sqlite3 CLI...
# require Shell;
@ -60,10 +60,10 @@ is( $sth->fetchrow_arrayref->[0], 1, "result of: $statement" );
$statement =~ s/1/?/;
$sth = $dbh->prepare($statement);
ok( $sth->execute(1), "execute: $statement : [1]" );
#TODO: {
# local $TODO = 'This test is currently broken again. Wait for a better fix, or use known workarounds.';
TODO: {
local $TODO = 'This test is currently broken again. Wait for a better fix, or use known workarounds.';
is( $sth->fetchrow_arrayref->[0], 1, "result of: $statement [1]" );
#}
}
# known workarounds 1: use bind_param explicitly

View file

@ -1,251 +0,0 @@
#!/usr/bin/perl
use strict;
BEGIN {
$| = 1;
$^W = 1;
}
use t::lib::Test;
use Test::More;
use DBD::SQLite;
BEGIN {
plan skip_all => "failing tests herein will be dealt with after the current release";
exit;
}
use Test::NoWarnings;
my @values = qw/
0 1 1.0 1.1 2.0 1.0e+001 0000 01010101 10010101
0000002100000517
0000002200000517
0000001e00000517
00002.000
test 01234test -test +test
0.123e 0.123e+
0. .123 -.123 +.123
-1 -1.0 -1.1 -2.0 -1.0e-001 -0000 -0101 -002.00
+1 +1.0 +1.1 +2.0 +1.0e-001 +0000 +0101 +002.00
1234567890123456789012345678901234567890
-1234567890123456789012345678901234567890
+1234567890123456789012345678901234567890
*1234567890123456789012345678901234567890
-9223372036854775807 +9223372036854775806
-9223372036854775808 +9223372036854775807
-9223372036854775809 +9223372036854775808
-18446744073709551615 +18446744073709551615
-18446744073709551616 +18446744073709551616
-18446744073709551617 +18446744073709551617
-2147483646 +2147483647
-2147483647 +2147483648
-2147483648 +2147483649
-4294967295 +4294967295
-4294967296 +4294967296
-4294967297 +4294967297
+ -
/;
my @types = ('', 'text', 'integer', 'real');
my %prior_DBD_SQLITE_1_30_behaviors = prior_DBD_SQLITE_1_30_behaviors();
my %sqlite3_bin_behaviors = sqlite3_bin_behaviors();
my $has_sqlite;
my $sqlite3_bin;
eval {
$sqlite3_bin = -f 'sqlite3' ? './sqlite3' : 'sqlite3';
my $sqlite3_version = `$sqlite3_bin -version`;
chomp $sqlite3_version;
$has_sqlite = $sqlite3_version eq $DBD::SQLite::sqlite_version ? 1 : 0;
};
unless ($has_sqlite) {
diag "requires sqlite3 $DBD::SQLite::sqlite_version executable for extra tests";
}
plan tests => @values * (3 + $has_sqlite) * @types + 1;
for my $type (@types) {
my $typename = $type || 'default';
for my $value (@values) {
my $dbh = connect_ok( RaiseError => 1, AutoCommit => 1 );
$dbh->do("create table foo (value $type)");
ok $dbh->do('insert into foo values(?)', undef, $value), "inserting $value into a $typename column";
my ($got) = $dbh->selectrow_array('select value from foo where value = ?', undef, $value);
$got = '' unless defined $got;
if ($got eq $value) {
pass "type: $typename got: $got expected: $value";
}
else {
my $old_behavior = $prior_DBD_SQLITE_1_30_behaviors{$type}{$value};
$old_behavior = '' unless defined $old_behavior;
my $sqlite3_behavior = $sqlite3_bin_behaviors{$type}{$value};
$sqlite3_behavior = '' unless defined $sqlite3_behavior;
if ($sqlite3_behavior eq $got) {
pass "same as the sqlite3 bin: type: $typename got: $got expected: $value sqlite3_behavior: $sqlite3_behavior";
}
else {
if ($old_behavior eq $got) {
TODO: {
local $TODO = "same as the old behavior";
fail "same as the old behavior: type: $typename got: $got expected: $value sqlite3_behavior: $sqlite3_behavior";
}
}
else {
fail "type: $typename got: $got expected: $value old_behavior: $old_behavior sqlite3_behavior: $sqlite3_behavior";
}
}
}
if ($has_sqlite) {
my $cmd = "create table f (v $type);insert into f values(\"$value\");select * from f;";
my $got_from_bin = `$sqlite3_bin -list ':memory:' '$cmd'`;
chomp $got_from_bin;
if ($got_from_bin eq $got) {
pass "sqlite3: type: $typename got: $got expected: $value";
}
else {
TODO: {
local $TODO = "sqlite3 shell behaves differently";
fail "sqlite3: type: $typename got: $got expected: $value got_from_bin: $got_from_bin";
}
}
}
}
}
sub prior_DBD_SQLITE_1_30_behaviors {(
integer => {
'1.0' => 1,
'2.0' => 2,
'1.0e+001' => 10,
'0000' => 0,
'01010101' => 1010101,
'0000002100000517' => 2100000517,
'0000002200000517' => 2200000517,
'0000001e00000517' => 'inf',
'00002.000' => 2,
'-1.0' => -1,
'-2.0' => -2,
'-1.0e-001' => -0.1,
'-0000' => 0,
'-0101' => -101,
'-002.00' => -2,
'+1' => 1,
'+1.0' => 1,
'+1.1' => 1.1,
'+2.0' => 2,
'+1.0e-001' => 0.1,
'+0000' => 0,
'+0101' => 101,
'+002.00' => 2,
'1234567890123456789012345678901234567890' => '1.23456789012346e+39',
'-1234567890123456789012345678901234567890' => '-1.23456789012346e+39',
'+1234567890123456789012345678901234567890' => '1.23456789012346e+39',
'-9223372036854775807' => '-9.22337203685478e+18',
'+9223372036854775806' => '9.22337203685478e+18',
'-9223372036854775808' => '-9.22337203685478e+18',
'+9223372036854775807' => '9.22337203685478e+18',
'-9223372036854775809' => '-9.22337203685478e+18',
'+9223372036854775808' => '9.22337203685478e+18',
'-18446744073709551615' => '-1.84467440737096e+19',
'+18446744073709551615' => '1.84467440737096e+19',
'-18446744073709551616' => '-1.84467440737096e+19',
'+18446744073709551616' => '1.84467440737096e+19',
'-18446744073709551617' => '-1.84467440737096e+19',
'+18446744073709551617' => '1.84467440737096e+19',
'+2147483647' => '2147483647',
'+2147483648' => '2147483648',
'+2147483649' => '2147483649',
'+4294967295' => '4294967295',
'+4294967296' => '4294967296',
'+4294967297' => '4294967297',
},
real => {
'1.0' => 1,
'2.0' => 2,
'1.0e+001' => 10,
'0000' => 0,
'01010101' => 1010101,
'0000002100000517' => 2100000517,
'0000002200000517' => 2200000517,
'0000001e00000517' => 'inf',
'00002.000' => 2,
'-1.0' => -1,
'-2.0' => -2,
'-1.0e-001' => -0.1,
'-0000' => 0,
'-0101' => -101,
'-002.00' => -2,
'+1' => 1,
'+1.0' => 1,
'+1.1' => 1.1,
'+2.0' => 2,
'+1.0e-001' => 0.1,
'+0000' => 0,
'+0101' => 101,
'+002.00' => 2,
'1234567890123456789012345678901234567890' => '1.23456789012346e+39',
'-1234567890123456789012345678901234567890' => '-1.23456789012346e+39',
'+1234567890123456789012345678901234567890' => '1.23456789012346e+39',
'-9223372036854775807' => '',
'+9223372036854775806' => '',
'-9223372036854775808' => '-9.22337203685478e+18',
'+9223372036854775807' => '',
'-9223372036854775809' => '-9.22337203685478e+18',
'+9223372036854775808' => '9.22337203685478e+18',
'-18446744073709551615' => '-1.84467440737096e+19',
'+18446744073709551615' => '1.84467440737096e+19',
'-18446744073709551616' => '-1.84467440737096e+19',
'+18446744073709551616' => '1.84467440737096e+19',
'-18446744073709551617' => '-1.84467440737096e+19',
'+18446744073709551617' => '1.84467440737096e+19',
'+2147483647' => '2147483647',
'+2147483648' => '2147483648',
'+2147483649' => '2147483649',
'+4294967295' => '4294967295',
'+4294967296' => '4294967296',
'+4294967297' => '4294967297',
},
)}
sub sqlite3_bin_behaviors {(
integer => {
'0000001e00000517' => 'Inf', # previously 'inf'
'+9223372036854775806' => '9223372036854775806', # previously 9.22337203685478e+18
'+9223372036854775807' => '9223372036854775807', # previously 9.22337203685478e+18
},
real => {
'0' => '0.0', # previously 0
'1' => '1.0', # previously 1
'1.0e+001' => '10.0', # previously 10
'0000' => '0.0', # previously 0
'01010101' => '1010101.0', # previously 1010101
'10010101' => '10010101.0', # previously 10010101
'0000002100000517' => '2100000517.0', # previously 2100000517
'0000002200000517' => '2200000517.0', # previously 2200000517
'0000001e00000517' => 'Inf', # previously 'inf'
'00002.000' => '2.0', # previously 2
'-1' => '-1.0', # previously -1
'-0000' => '0.0', # previously 0
'-0101' => '-101.0', # previously -101
'-002.00' => '-2.0', # previously -2
'+1' => '1.0', # previously 1
'+1.0' => '1.0', # previously 1
'+2.0' => '2.0', # previously 2
'+0000' => '0.0', # previously 0
'+0101' => '101.0', # previously 101
'+002.00' => '2.0', # previously 2
'-2147483646' => '-2147483646.0', # previously -2147483646
'+2147483647' => '2147483647.0', # previously 2147483647
'-2147483647' => '-2147483647.0', # previously -2147483647
'+2147483648' => '2147483648.0', # previously 2147483648
'-2147483648' => '-2147483648.0', # previously -2147483648
'+2147483649' => '2147483649.0', # previously 2147483649
'-4294967295' => '-4294967295.0', # previously -4294967295
'+4294967295' => '4294967295.0', # previously 4294967295
'-4294967296' => '-4294967296.0', # previously -4294967296
'+4294967296' => '4294967296.0', # previously 4294967296
'-4294967297' => '-4294967297.0', # previously -4294967297
'+4294967297' => '4294967297.0', # previously 4294967297
},
)}