File: rt_31324_full_names.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 (41 lines) | stat: -rw-r--r-- 948 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
39
40
41
use strict;
use warnings;
use lib "t/lib";
use SQLiteTest;
use Test::More;
use if -d ".git", "Test::FailWarnings";

my $dbh = connect_ok( RaiseError => 1 );
$dbh->do("CREATE TABLE f (f1, f2, f3)");
$dbh->do("INSERT INTO f VALUES (?, ?, ?)", {}, 'foo', 'bar', 1);

SCOPE: {
	my $sth = $dbh->prepare('SELECT f1 as "a.a", * FROM f', {});
	isa_ok( $sth, 'DBI::st' );
	ok( $sth->execute, '->execute ok' );
	my $row = $sth->fetchrow_hashref;
	is_deeply( $row, {
		'a.a' => 'foo',
		'f1'  => 'foo',
		'f2'  => 'bar',
		'f3'  => 1,
	}, 'Shortname row ok' );
}

$dbh->do("PRAGMA full_column_names = 1");
$dbh->do("PRAGMA short_column_names = 0");

SCOPE: {
	my $sth = $dbh->prepare('SELECT f1 as "a.a", * FROM f', {});
	isa_ok( $sth, 'DBI::st' );
	ok( $sth->execute, '->execute ok' );
	my $row = $sth->fetchrow_hashref;
	is_deeply( $row, {
		'a.a' => 'foo',
		'f.f1'  => 'foo',
		'f.f2'  => 'bar',
		'f.f3'  => 1,
	}, 'Shortname row ok' );
}

done_testing;