File: bindtype_columns.t

package info (click to toggle)
libdbix-class-perl 0.08010-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,052 kB
  • ctags: 1,064
  • sloc: perl: 10,536; sql: 225; makefile: 45
file content (60 lines) | stat: -rwxr-xr-x 1,209 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
49
50
51
52
53
54
55
56
57
58
59
60
use strict;
use warnings;  

use Test::More;
use lib qw(t/lib);
use DBICTest;

my ($dsn, $dbuser, $dbpass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/};

plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test'
  unless ($dsn && $dbuser);
  
plan tests => 3;

my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass, { AutoCommit => 1 });

my $dbh = $schema->storage->dbh;

$dbh->do(qq[

	CREATE TABLE artist
	(
		artistid		serial	NOT NULL	PRIMARY KEY,
		media			bytea	NOT NULL,
		name			varchar NULL
	);
],{ RaiseError => 1, PrintError => 1 });


$schema->class('Artist')->load_components(qw/ 

	PK::Auto 
	Core 
/);

$schema->class('Artist')->add_columns(
	
	"media", { 
	
		data_type => "bytea", 
		is_nullable => 0,
	},
);

# test primary key handling
my $big_long_string	= 'abcd' x 250000;

my $new = $schema->resultset('Artist')->create({ media => $big_long_string });

ok($new->artistid, "Created a blob row");
is($new->media, 	$big_long_string, "Set the blob correctly.");

my $rs = $schema->resultset('Artist')->find({artistid=>$new->artistid});

is($rs->get_column('media'), $big_long_string, "Created the blob correctly.");

$dbh->do("DROP TABLE artist");