Commit | Line | Data |
fe67d343 |
1 | use strict; |
2 | use lib qw(t/lib); |
3 | use dbixcsl_common_tests; |
804c115d |
4 | use Test::More; |
2d1dc6de |
5 | use Test::Exception; |
f9f65ded |
6 | |
fe67d343 |
7 | my $dsn = $ENV{DBICTEST_SYBASE_DSN} || ''; |
8 | my $user = $ENV{DBICTEST_SYBASE_USER} || ''; |
9 | my $password = $ENV{DBICTEST_SYBASE_PASS} || ''; |
10 | |
11 | my $tester = dbixcsl_common_tests->new( |
7cb9244f |
12 | vendor => 'sybase', |
fe67d343 |
13 | auto_inc_pk => 'INTEGER IDENTITY NOT NULL PRIMARY KEY', |
14 | dsn => $dsn, |
15 | user => $user, |
16 | password => $password, |
804c115d |
17 | extra => { |
18 | create => [ |
19 | q{ |
20 | CREATE TABLE sybase_loader_test1 ( |
21 | id INTEGER IDENTITY NOT NULL PRIMARY KEY, |
de82711a |
22 | ts timestamp, |
23 | charfield VARCHAR(10) DEFAULT 'foo', |
24 | computed_dt AS getdate() |
804c115d |
25 | ) |
26 | }, |
27 | ], |
28 | drop => [ qw/ sybase_loader_test1 / ], |
2d1dc6de |
29 | count => 9, |
804c115d |
30 | run => sub { |
31 | my ($schema, $monikers, $classes) = @_; |
32 | |
33 | my $rs = $schema->resultset($monikers->{sybase_loader_test1}); |
de82711a |
34 | my $rsrc = $rs->result_source; |
35 | |
36 | is $rsrc->column_info('id')->{data_type}, |
2fb9a4b3 |
37 | 'int', |
de82711a |
38 | 'INTEGER IDENTITY data_type is correct'; |
39 | |
40 | is $rsrc->column_info('id')->{is_auto_increment}, |
41 | 1, |
42 | 'INTEGER IDENTITY is_auto_increment => 1'; |
804c115d |
43 | |
2fb9a4b3 |
44 | is $rsrc->column_info('ts')->{data_type}, |
45 | 'timestamp', |
46 | 'timestamps have the correct data_type'; |
de82711a |
47 | |
48 | is $rsrc->column_info('charfield')->{data_type}, |
49 | 'varchar', |
50 | 'VARCHAR has correct data_type'; |
51 | |
de82711a |
52 | |
2fb9a4b3 |
53 | is $rsrc->column_info('charfield')->{default_value}, |
54 | 'foo', |
55 | 'constant DEFAULT is correct'; |
de82711a |
56 | |
57 | is $rsrc->column_info('charfield')->{size}, |
58 | 10, |
59 | 'VARCHAR(10) has correct size'; |
60 | |
db4d62ad |
61 | ok ((exists $rsrc->column_info('computed_dt')->{data_type} |
62 | && (not defined $rsrc->column_info('computed_dt')->{data_type})), |
63 | 'data_type for computed column exists and is undef') |
64 | or diag "Data type is: ", |
65 | $rsrc->column_info('computed_dt')->{data_type} |
66 | ; |
2d1dc6de |
67 | |
2fb9a4b3 |
68 | my $computed_dt_default = |
69 | $rsrc->column_info('computed_dt')->{default_value}; |
2d1dc6de |
70 | |
2fb9a4b3 |
71 | ok ((ref $computed_dt_default eq 'SCALAR'), |
72 | 'default_value for computed column is a scalar ref') |
73 | or diag "default_value is: ", $computed_dt_default |
74 | ; |
2d1dc6de |
75 | |
2fb9a4b3 |
76 | eval { is $$computed_dt_default, |
77 | 'getdate()', |
78 | 'default_value for computed column is correct' }; |
804c115d |
79 | }, |
80 | }, |
fe67d343 |
81 | ); |
82 | |
83 | if( !$dsn || !$user ) { |
84 | $tester->skip_tests('You need to set the DBICTEST_SYBASE_DSN, _USER, and _PASS environment variables'); |
85 | } |
86 | else { |
87 | $tester->run_tests(); |
88 | } |