File: 03_create_table.t

package info (click to toggle)
libdbd-sqlite3-perl 1.44-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,756 kB
  • ctags: 10,154
  • sloc: ansic: 94,394; perl: 7,064; makefile: 6
file content (36 lines) | stat: -rw-r--r-- 836 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl

# Tests simple table creation

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

use t::lib::Test;
use Test::More tests => 7;
use Test::NoWarnings;

my $dbh = connect_ok();
$dbh->do(<<'END_SQL');
CREATE TABLE f
(
f1 integer NOT NULL PRIMARY KEY,
f2 integer,
f3 text
)
END_SQL

# Confirm fix for #34408: Primary key name wrong with newline in CREATE TABLE
my $pkh = $dbh->primary_key_info( undef, undef, 'f' );
my @pk  = $pkh->fetchall_arrayref();
is_deeply( \@pk, [ [ [ undef, 'main', 'f', 'f1', 1, 'PRIMARY KEY' ] ] ], '->primary_key_info ok' );

my $sth = $dbh->prepare("SELECT f.f1, f.* FROM f");
isa_ok( $sth, 'DBI::st' );
ok( $sth->execute, '->execute ok' );
my $names = $sth->{NAME};
is( scalar(@$names), 4, 'Got 4 columns' );
is_deeply( $names, [ 'f1', 'f1', 'f2', 'f3' ], 'Table prepending is disabled by default' );