@@ -14,7 +14,7 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/};
14
14
15
15
if (not ($dsn && $user && $pass )) {
16
16
plan skip_all => ' Set $ENV{DBICTEST_ORA_DSN}, _USER and _PASS to run this test. ' .
17
- ' Warning: This test drops and creates a table called \' track \' ' ;
17
+ ' Warning: This test drops and creates a table called \' event \' ' ;
18
18
}
19
19
20
20
# DateTime::Format::Oracle needs this set
@@ -32,21 +32,25 @@ my $timestamp_datatype = ($schema->storage->_server_info->{normalized_dbms_versi
32
32
: ' TIMESTAMP'
33
33
;
34
34
35
- # Need to redefine the last_updated_on column
36
- my $col_metadata = $schema -> class(' Track' )-> column_info(' last_updated_on' );
37
- $schema -> class(' Track' )-> add_column( ' last_updated_on' => {
38
- data_type => ' date' });
39
- $schema -> class(' Track' )-> add_column( ' last_updated_at' => {
40
- data_type => $timestamp_datatype });
41
-
42
35
my $dbh = $schema -> storage-> dbh;
43
36
44
37
# $dbh->do("alter session set nls_timestamp_format = 'YYYY-MM-DD HH24:MI:SSXFF'");
45
38
46
39
eval {
47
- $dbh -> do(" DROP TABLE track " );
40
+ $dbh -> do(" DROP TABLE event " );
48
41
};
49
- $dbh -> do(" CREATE TABLE track (trackid NUMBER(12), cd NUMBER(12), position NUMBER(12), title VARCHAR(255), last_updated_on DATE, last_updated_at $timestamp_datatype )" );
42
+ $dbh -> do(<<EOS );
43
+ CREATE TABLE event (
44
+ id number NOT NULL,
45
+ starts_at date NOT NULL,
46
+ created_on $timestamp_datatype NOT NULL,
47
+ varchar_date varchar(20),
48
+ varchar_datetime varchar(20),
49
+ skip_inflation date,
50
+ ts_without_tz date,
51
+ PRIMARY KEY (id)
52
+ )
53
+ EOS
50
54
51
55
# TODO is in effect for the rest of the tests
52
56
local $TODO = ' FIXME - something odd is going on with Oracle < 9 datetime support'
@@ -55,27 +59,26 @@ local $TODO = 'FIXME - something odd is going on with Oracle < 9 datetime suppor
55
59
lives_ok {
56
60
57
61
# insert a row to play with
58
- my $new = $schema -> resultset(' Track ' )-> create({ trackid => 1, cd => 1, position => 1, title => ' Track1 ' , last_updated_on => ' 06-MAY-07' , last_updated_at => ' 2009-05-03 21:17:18.5' });
59
- is($new -> trackid , 1, " insert sucessful" );
62
+ my $new = $schema -> resultset(' Event ' )-> create({ id => 1, starts_at => ' 06-MAY-07' , created_on => ' 2009-05-03 21:17:18.5' });
63
+ is($new -> id , 1, " insert sucessful" );
60
64
61
- my $track = $schema -> resultset(' Track ' )-> find( 1 );
65
+ my $event = $schema -> resultset(' Event ' )-> find( 1 );
62
66
63
- is( ref ($track -> last_updated_on ), ' DateTime' , " last_updated_on inflated ok" );
67
+ is( ref ($event -> starts_at ), ' DateTime' , " starts_at inflated ok" );
64
68
65
- is( $track -> last_updated_on -> month, 5, " DateTime methods work on inflated column" );
69
+ is( $event -> starts_at -> month, 5, " DateTime methods work on inflated column" );
66
70
67
- # note '$track->last_updated_at => ', $track->last_updated_at;
68
- is( ref ($track -> last_updated_at), ' DateTime' , " last_updated_at inflated ok" );
71
+ is( ref ($event -> created_on), ' DateTime' , " created_on inflated ok" );
69
72
70
- is( $track -> last_updated_at -> nanosecond, 500_000_000, " DateTime methods work with nanosecond precision" );
73
+ is( $event -> created_on -> nanosecond, 500_000_000, " DateTime methods work with nanosecond precision" );
71
74
72
75
my $dt = DateTime-> now();
73
- $track -> last_updated_on ($dt );
74
- $track -> last_updated_at ($dt );
75
- $track -> update;
76
+ $event -> starts_at ($dt );
77
+ $event -> created_on ($dt );
78
+ $event -> update;
76
79
77
- is( $track -> last_updated_on -> month, $dt -> month, " deflate ok" );
78
- is( int $track -> last_updated_at -> nanosecond, int $dt -> nanosecond, " deflate ok with nanosecond precision" );
80
+ is( $event -> starts_at -> month, $dt -> month, " deflate ok" );
81
+ is( int $event -> created_on -> nanosecond, int $dt -> nanosecond, " deflate ok with nanosecond precision" );
79
82
80
83
# test datetime_setup
81
84
@@ -93,15 +96,15 @@ $dt = DateTime->now();
93
96
my $timestamp = $dt -> clone;
94
97
$timestamp -> set_nanosecond( int 500_000_000 );
95
98
96
- $track = $schema -> resultset(' Track ' )-> find( 1 );
97
- $track -> update({ last_updated_on => $dt , last_updated_at => $timestamp });
99
+ $event = $schema -> resultset(' Event ' )-> find( 1 );
100
+ $event -> update({ starts_at => $dt , created_on => $timestamp });
98
101
99
- $track = $schema -> resultset(' Track ' )-> find(1);
102
+ $event = $schema -> resultset(' Event ' )-> find(1);
100
103
101
- is( $track -> last_updated_on , $dt , ' DateTime round-trip as DATE' );
102
- is( $track -> last_updated_at , $timestamp , ' DateTime round-trip as TIMESTAMP' );
104
+ is( $event -> starts_at , $dt , ' DateTime round-trip as DATE' );
105
+ is( $event -> created_on , $timestamp , ' DateTime round-trip as TIMESTAMP' );
103
106
104
- is( int $track -> last_updated_at -> nanosecond, int 500_000_000,
107
+ is( int $event -> created_on -> nanosecond, int 500_000_000,
105
108
' TIMESTAMP nanoseconds survived' );
106
109
107
110
} ' dateteime operations executed correctly' ;
@@ -111,7 +114,7 @@ done_testing;
111
114
# clean up our mess
112
115
END {
113
116
if ($schema && (my $dbh = $schema -> storage-> dbh)) {
114
- $dbh -> do(" DROP TABLE track " );
117
+ $dbh -> do(" DROP TABLE event " );
115
118
}
116
119
undef $schema ;
117
120
}
0 commit comments