Blame t/22_listfields.t

Packit 723767
#!/usr/bin/perl
Packit 723767
Packit 723767
# This is a test for statement attributes being present appropriately.
Packit 723767
Packit 723767
use strict;
Packit 723767
BEGIN {
Packit 723767
	$|  = 1;
Packit 723767
	$^W = 1;
Packit 723767
}
Packit 723767
Packit 723767
use lib "t/lib";
Packit 723767
use SQLiteTest;
Packit 723767
use Test::More tests => 12;
Packit 723767
use Test::NoWarnings;
Packit 723767
Packit 723767
# Create a database
Packit 723767
my $dbh = connect_ok();
Packit 723767
Packit 723767
# Create the table
Packit 723767
ok( $dbh->do(<<'END_SQL'), 'CREATE TABLE' );
Packit 723767
CREATE TABLE one (
Packit 723767
    id INTEGER NOT NULL,
Packit 723767
    name CHAR (64)
Packit 723767
)
Packit 723767
END_SQL
Packit 723767
Packit 723767
SCOPE: {
Packit 723767
	# Create the statement
Packit 723767
	my $sth = $dbh->prepare('SELECT * from one');
Packit 723767
	isa_ok( $sth, 'DBI::st' );
Packit 723767
Packit 723767
	# Execute the statement
Packit 723767
	ok( $sth->execute, '->execute' );
Packit 723767
Packit 723767
	# Check the field metadata
Packit 723767
	is( $sth->{NUM_OF_FIELDS}, 2, 'Found 2 fields' );
Packit 723767
	is_deeply( $sth->{NAME}, [ 'id', 'name' ], 'Names are ok' );
Packit 723767
	ok( $sth->finish, '->finish ok' );
Packit 723767
}
Packit 723767
Packit 723767
SCOPE: {
Packit 723767
	# Check field metadata on a drop statement
Packit 723767
	my $sth = $dbh->prepare('DROP TABLE one');
Packit 723767
	isa_ok( $sth, 'DBI::st' );
Packit 723767
	ok( $sth->execute, '->execute' );
Packit 723767
	is( $sth->{NUM_OF_FIELDS}, 0, 'No fields in statement' );
Packit 723767
	ok( $sth->finish, '->finish ok' );
Packit 723767
}