1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 14:19:10 -04:00
DBD-SQLite-SQLcipher/t/22_listfields.t
Kenichi Ishigaki 11c2f4e70f use warnings
2019-01-02 21:17:30 +09:00

42 lines
972 B
Perl

# This is a test for statement attributes being present appropriately.
use strict;
use warnings;
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' );
}