File: 64_limit.t

package info (click to toggle)
libdbd-sqlite3-perl 1.76-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,004 kB
  • sloc: ansic: 167,715; perl: 1,788; pascal: 277; makefile: 9
file content (25 lines) | stat: -rw-r--r-- 920 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;
use lib "t/lib";
use SQLiteTest qw/connect_ok @CALL_FUNCS/;
use Test::More;
use DBD::SQLite::Constants qw/SQLITE_LIMIT_VARIABLE_NUMBER/;
use if -d ".git", "Test::FailWarnings";

for my $func (@CALL_FUNCS) {
	my $dbh = connect_ok(PrintError => 0, RaiseError => 1);
    my $current_limit = $dbh->$func(SQLITE_LIMIT_VARIABLE_NUMBER, 'limit');
    ok $current_limit, "current limit: $current_limit";

    $current_limit = $dbh->$func(SQLITE_LIMIT_VARIABLE_NUMBER, -1, 'limit');
    ok $current_limit, "current limit: $current_limit";

    ok $dbh->do('create table foo (id, text)');
    ok $dbh->do('insert into foo values(?, ?)', undef, 1, 'OK');

    ok $dbh->$func(SQLITE_LIMIT_VARIABLE_NUMBER, 1, 'limit');
    eval { $dbh->do('insert into foo values(?, ?)', undef, 2, 'NOT OK') };
    like $@ => qr/too many SQL variables/, "should raise error because of the variable limit";
}

done_testing;