1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
use strict;
use warnings;
use lib "t/lib";
use SQLiteTest;
use Test::More;
use if -d ".git", "Test::FailWarnings";
our $scan_results = [
{ nodepath => 1 },
{ nodepath => 2 },
{ nodepath => 3 },
];
my $dbh = connect_ok(RaiseError => 1, AutoCommit => 1);
# register the module
$dbh->$sqlite_call(create_module => perl => "DBD::SQLite::VirtualTable::PerlData");
$dbh->do(<<'SQL');
CREATE VIRTUAL TABLE temp.scan_results
USING perl(file varchar,
value varchar,
selector varchar,
nodepath varchar,
expected integer,
preference integer,
complexity integer,
location varchar,
type varchar,
hashrefs="main::scan_results")
SQL
my $ok = eval {
my $sth = $dbh->prepare(<<'SQL');
select distinct r.selector
from temp.scan_results r
left join temp.scan_results m
on r.nodepath = m.nodepath+1
where m.nodepath = 1
SQL
$sth->execute;
#use DBIx::RunSQL; print DBIx::RunSQL->format_results( sth => $sth );
1;
};
is $ok, 1, "We survive a numeric comparison";
undef $ok;
$ok = eval {
my $sth = $dbh->prepare(<<'SQL');
select distinct r.selector
from temp.scan_results r
left join temp.scan_results m
on r.nodepath = m.nodepath+1
where m.nodepath is not null
SQL
$sth->execute;
1;
#use DBIx::RunSQL; print DBIx::RunSQL->format_results( sth => $sth );
};
is $ok, 1, "We survive an isnull comparison";
undef $ok;
$ok = eval {
my $sth = $dbh->prepare(<<'SQL');
select r.nodepath
from temp.scan_results r
left join temp.scan_results m
on r.nodepath = m.nodepath+1
where r.nodepath is null
SQL
$sth->execute;
1;
#use DBIx::RunSQL; print DBIx::RunSQL->format_results( sth => $sth );
};
is $ok, 1, "We survive an isnull comparison on the left side";
undef $ok;
my $sth;
$ok = eval {
$sth = $dbh->prepare(<<'SQL');
select r.nodepath
from temp.scan_results r
left join temp.scan_results m
on r.nodepath = m.nodepath+1
where m.nodepath is null
SQL
$sth->execute;
1;
#use DBIx::RunSQL; print DBIx::RunSQL->format_results( sth => $sth );
};
is $ok, 1, "We survive an isnull comparison on the right side";
undef $ok;
#my $rows = $sth->fetchall_arrayref;
#use Data::Dumper;
#warn Dumper $rows;
done_testing;
|