File: 04_insert.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 (38 lines) | stat: -rw-r--r-- 1,190 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
26
27
28
29
30
31
32
33
34
35
36
37
38
use strict;
use warnings;
use lib "t/lib";
use SQLiteTest;
use Test::More;
use if -d ".git", "Test::FailWarnings";

my $dbh = connect_ok();

ok( $dbh->do("CREATE TABLE f (f1, f2, f3)"), 'CREATE TABLE f' );
ok( $dbh->do("delete from f"), 'DELETE FROM f' );

SCOPE: {
	my $sth = $dbh->prepare("INSERT INTO f VALUES (?, ?, ?)", { go_last_insert_id_args => [undef, undef, undef, undef] });
	isa_ok($sth, 'DBI::st');
	my $rows = $sth->execute("Fred", "Bloggs", "fred\@bloggs.com");
	is( $rows, 1, '->execute returns 1 row' );

	is( $sth->execute("test", "test", "1"), 1 );
	is( $sth->execute("test", "test", "2"), 1 );
	is( $sth->execute("test", "test", "3"), 1 );

	SKIP: {
    		skip( 'last_insert_id requires DBI v1.43', 2 ) if $DBI::VERSION < 1.43;
    		is( $dbh->last_insert_id(undef, undef, undef, undef), 4 );
    		is( $dbh->func('last_insert_rowid'), 4, 'last_insert_rowid should be 4' );
	}

	SKIP: {
    		skip( 'method installation requires DBI v1.608', 2 ) if $DBI::VERSION < 1.608;
			can_ok($dbh, 'sqlite_last_insert_rowid');
    		is( $dbh->sqlite_last_insert_rowid, 4, 'last_insert_rowid should be 4' );
	}
}

is( $dbh->do("delete from f where f1='test'"), 3 );

done_testing;