File: 22_listfields.t

package info (click to toggle)
libdbd-sqlite3-perl 1.62-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 9,708 kB
  • sloc: ansic: 140,930; perl: 8,458; pascal: 286; makefile: 7
file content (48 lines) | stat: -rw-r--r-- 1,006 bytes parent folder | download
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
#!/usr/bin/perl

# This is a test for statement attributes being present appropriately.

use strict;
BEGIN {
	$|  = 1;
	$^W = 1;
}

use lib "t/lib";
use SQLiteTest;
use Test::More tests => 12;
use Test::NoWarnings;

# Create a database
my $dbh = connect_ok();

# Create the table
ok( $dbh->do(<<'END_SQL'), 'CREATE TABLE' );
CREATE TABLE one (
    id INTEGER NOT NULL,
    name CHAR (64)
)
END_SQL

SCOPE: {
	# Create the statement
	my $sth = $dbh->prepare('SELECT * from one');
	isa_ok( $sth, 'DBI::st' );

	# Execute the statement
	ok( $sth->execute, '->execute' );

	# Check the field metadata
	is( $sth->{NUM_OF_FIELDS}, 2, 'Found 2 fields' );
	is_deeply( $sth->{NAME}, [ 'id', 'name' ], 'Names are ok' );
	ok( $sth->finish, '->finish ok' );
}

SCOPE: {
	# Check field metadata on a drop statement
	my $sth = $dbh->prepare('DROP TABLE one');
	isa_ok( $sth, 'DBI::st' );
	ok( $sth->execute, '->execute' );
	is( $sth->{NUM_OF_FIELDS}, 0, 'No fields in statement' );
	ok( $sth->finish, '->finish ok' );
}