Hi,
Any outstanding patches, please send to this thread. Can somebody also
go through rt.cpan.org and work out if there's anything on there we need
to apply as well?
attached the test and patch for DBIx::Class::InflateColumn::Datetime
The recreation of the test-schema generates many changes - many more
then my :-(
jens
Index: t/89inflate_datetime.t
===================================================================
--- t/89inflate_datetime.t (Revision 4887)
+++ t/89inflate_datetime.t (Arbeitskopie)
@@ -10,7 +10,7 @@
eval { require DateTime::Format::MySQL };
plan skip_all => "Need DateTime::Format::MySQL for inflation tests" if $@;
-plan tests => 21;
+plan tests => 25;
# inflation test
my $event = $schema->resultset("Event")->find(1);
@@ -92,3 +92,26 @@
like( $@, qr/invalid date format/i, "Invalid date format exception");
}
+my $datetime_timezone_invalid = $schema->resultset('Event')->create( {
+
+ starts_at => DateTime->new(year=>2007, month=>12, day=>31, time_zone =>
"America/Chicago" ),
+ created_on => DateTime->new(year=>2006, month=>1, day=>31, hour => 13,
minute => 34, second => 56, time_zone => "America/New_York" ),
+ ends_at => "",
+});
+
+is( $datetime_timezone_invalid->ends_at, undef, "Inflate to undef");
+
+$datetime_timezone_invalid->update({ ends_at => undef } );
+
+is( $datetime_timezone_invalid->ends_at, undef, "Inflate to undef");
+
+my $datetime_timezone_valid = $schema->resultset('Event')->create( {
+
+ starts_at => DateTime->new(year=>2007, month=>12, day=>31, time_zone =>
"America/Chicago" ),
+ created_on => DateTime->new(year=>2006, month=>1, day=>31, hour => 13,
minute => 34, second => 56, time_zone => "America/New_York" ),
+ ends_at => DateTime->new(year=>2008, month=>1, day=>1, hour => 1,
minute => 0, second => 0, time_zone => "Europe/Berlin" ) ,
+});
+
+isa_ok( $datetime_timezone_valid->ends_at,'DateTime', "Inflate to DateTime");
+is( $datetime_timezone_valid->ends_at->time_zone->name, 'UTC', "Timezone is
UTC" );
+
Index: t/lib/sqlite.sql
===================================================================
--- t/lib/sqlite.sql (Revision 4887)
+++ t/lib/sqlite.sql (Arbeitskopie)
@@ -1,88 +1,40 @@
--
-- Created by SQL::Translator::Producer::SQLite
--- Created on Tue Aug 8 01:53:20 2006
+-- Created on Mon Oct 6 00:02:21 2008
--
BEGIN TRANSACTION;
--
--- Table: employee
---
-CREATE TABLE employee (
- employee_id INTEGER PRIMARY KEY NOT NULL,
- position integer NOT NULL,
- group_id integer,
- group_id_2 integer,
- name varchar(100)
-);
-
---
--- Table: serialized
---
-CREATE TABLE serialized (
- id INTEGER PRIMARY KEY NOT NULL,
- serialized text NOT NULL
-);
-
---
--- Table: liner_notes
---
-CREATE TABLE liner_notes (
- liner_id INTEGER PRIMARY KEY NOT NULL,
- notes varchar(100) NOT NULL
-);
-
---
--- Table: cd_to_producer
---
-CREATE TABLE cd_to_producer (
- cd integer NOT NULL,
- producer integer NOT NULL,
- PRIMARY KEY (cd, producer)
-);
-
---
-- Table: artist
--
CREATE TABLE artist (
artistid INTEGER PRIMARY KEY NOT NULL,
name varchar(100)
);
-
--
--- Table: twokeytreelike
+-- Table: artist_undirected_map
--
-CREATE TABLE twokeytreelike (
+CREATE TABLE artist_undirected_map (
id1 integer NOT NULL,
id2 integer NOT NULL,
- parent1 integer NOT NULL,
- parent2 integer NOT NULL,
- name varchar(100) NOT NULL,
PRIMARY KEY (id1, id2)
);
-
---
--- Table: fourkeys_to_twokeys
+CREATE INDEX artist_undirected_map_idx_id1_ ON artist_undirected_map
(id1);CREATE INDEX artist_undirected_map_idx_id2_ ON artist_undirected_map
(id2);--
+-- Table: bookmark
--
-CREATE TABLE fourkeys_to_twokeys (
- f_foo integer NOT NULL,
- f_bar integer NOT NULL,
- f_hello integer NOT NULL,
- f_goodbye integer NOT NULL,
- t_artist integer NOT NULL,
- t_cd integer NOT NULL,
- autopilot character NOT NULL,
- PRIMARY KEY (f_foo, f_bar, f_hello, f_goodbye, t_artist, t_cd)
+CREATE TABLE bookmark (
+ id INTEGER PRIMARY KEY NOT NULL,
+ link integer NOT NULL
);
-
---
--- Table: self_ref_alias
+CREATE INDEX bookmark_idx_link_bookmark ON bookmark (link);--
+-- Table: books
--
-CREATE TABLE self_ref_alias (
- self_ref integer NOT NULL,
- alias integer NOT NULL,
- PRIMARY KEY (self_ref, alias)
+CREATE TABLE books (
+ id INTEGER PRIMARY KEY NOT NULL,
+ source varchar(100) NOT NULL,
+ owner integer NOT NULL,
+ title varchar(100) NOT NULL
);
-
--
-- Table: cd
--
@@ -93,95 +45,109 @@
year varchar(100) NOT NULL,
genreid integer
);
-
+CREATE INDEX cd_idx_artist_cd ON cd (artist);CREATE INDEX cd_idx_genreid_cd ON
cd (genreid);CREATE UNIQUE INDEX cd_artist_title_cd ON cd (artist, title);--
+-- Table: cd_to_producer
--
--- Table: genre
+CREATE TABLE cd_to_producer (
+ cd integer NOT NULL,
+ producer integer NOT NULL,
+ PRIMARY KEY (cd, producer)
+);
+CREATE INDEX cd_to_producer_idx_cd_cd_to_pr ON cd_to_producer (cd);CREATE
INDEX cd_to_producer_idx_producer_cd ON cd_to_producer (producer);--
+-- Table: collection
--
-CREATE TABLE genre (
- genreid INTEGER PRIMARY KEY NOT NULL,
+CREATE TABLE collection (
+ collectionid INTEGER PRIMARY KEY NOT NULL,
name varchar(100) NOT NULL
);
-
--
--- Table: bookmark
+-- Table: collection_object
--
-CREATE TABLE bookmark (
- id INTEGER PRIMARY KEY NOT NULL,
- link integer NOT NULL
+CREATE TABLE collection_object (
+ collection integer NOT NULL,
+ object integer NOT NULL,
+ PRIMARY KEY (collection, object)
);
-
---
--- Table: track
+CREATE INDEX collection_object_idx_collection_collection_obj ON
collection_object (collection);CREATE INDEX collection_object_idx_object_c ON
collection_object (object);--
+-- Table: employee
--
-CREATE TABLE track (
- trackid INTEGER PRIMARY KEY NOT NULL,
- cd integer NOT NULL,
+CREATE TABLE employee (
+ employee_id INTEGER PRIMARY KEY NOT NULL,
position integer NOT NULL,
- title varchar(100) NOT NULL,
- last_updated_on datetime NULL
-);
-
---
--- Table: self_ref
---
-CREATE TABLE self_ref (
- id INTEGER PRIMARY KEY NOT NULL,
- name varchar(100) NOT NULL
+ group_id integer,
+ group_id_2 integer,
+ name varchar(100)
);
-
--
--- Table: link
+-- Table: event
--
-CREATE TABLE link (
+CREATE TABLE event (
id INTEGER PRIMARY KEY NOT NULL,
- url varchar(100),
- title varchar(100)
+ starts_at datetime NOT NULL,
+ created_on timestamp NOT NULL,
+ ends_at datetime NOT NULL
);
-
--
-- Table: file_columns
--
CREATE TABLE file_columns (
id INTEGER PRIMARY KEY NOT NULL,
- file varchar(255)
+ file varchar(255) NOT NULL
);
-
--
--- Table: tags
+-- Table: forceforeign
--
-CREATE TABLE tags (
- tagid INTEGER PRIMARY KEY NOT NULL,
- cd integer NOT NULL,
- tag varchar(100) NOT NULL
+CREATE TABLE forceforeign (
+ artist INTEGER PRIMARY KEY NOT NULL,
+ cd integer NOT NULL
);
-
+CREATE INDEX forceforeign_idx_artist_forcef ON forceforeign (artist);--
+-- Table: fourkeys
--
--- Table: treelike
+CREATE TABLE fourkeys (
+ foo integer NOT NULL,
+ bar integer NOT NULL,
+ hello integer NOT NULL,
+ goodbye integer NOT NULL,
+ sensors character NOT NULL,
+ PRIMARY KEY (foo, bar, hello, goodbye)
+);
--
-CREATE TABLE treelike (
- id INTEGER PRIMARY KEY NOT NULL,
- parent integer NULL,
- name varchar(100) NOT NULL
+-- Table: fourkeys_to_twokeys
+--
+CREATE TABLE fourkeys_to_twokeys (
+ f_foo integer NOT NULL,
+ f_bar integer NOT NULL,
+ f_hello integer NOT NULL,
+ f_goodbye integer NOT NULL,
+ t_artist integer NOT NULL,
+ t_cd integer NOT NULL,
+ autopilot character NOT NULL,
+ PRIMARY KEY (f_foo, f_bar, f_hello, f_goodbye, t_artist, t_cd)
);
-
+CREATE INDEX fourkeys_to_twokeys_idx_f_foo_f_bar_f_hello_f_goodbye_ ON
fourkeys_to_twokeys (f_foo, f_bar, f_hello, f_goodbye);CREATE INDEX
fourkeys_to_twokeys_idx_t_artist_t_cd_fourkeys_to ON fourkeys_to_twokeys
(t_artist, t_cd);--
+-- Table: genre
--
--- Table: event
+CREATE TABLE genre (
+ genreid NOT NULL,
+ name NOT NULL,
+ PRIMARY KEY (genreid)
+);
--
-CREATE TABLE event (
- id INTEGER PRIMARY KEY NOT NULL,
- starts_at datetime NOT NULL,
- created_on timestamp NOT NULL
+-- Table: liner_notes
+--
+CREATE TABLE liner_notes (
+ liner_id INTEGER PRIMARY KEY NOT NULL,
+ notes varchar(100) NOT NULL
);
-
--
--- Table: twokeys
+-- Table: link
--
-CREATE TABLE twokeys (
- artist integer NOT NULL,
- cd integer NOT NULL,
- PRIMARY KEY (artist, cd)
+CREATE TABLE link (
+ id INTEGER PRIMARY KEY NOT NULL,
+ url varchar(100),
+ title varchar(100)
);
-
--
-- Table: noprimarykey
--
@@ -190,28 +156,21 @@
bar integer NOT NULL,
baz integer NOT NULL
);
-
---
--- Table: fourkeys
+CREATE UNIQUE INDEX foo_bar_noprimarykey ON noprimarykey (foo, bar);--
+-- Table: onekey
--
-CREATE TABLE fourkeys (
- foo integer NOT NULL,
- bar integer NOT NULL,
- hello integer NOT NULL,
- goodbye integer NOT NULL,
- sensors character NOT NULL,
- PRIMARY KEY (foo, bar, hello, goodbye)
+CREATE TABLE onekey (
+ id INTEGER PRIMARY KEY NOT NULL,
+ artist integer NOT NULL,
+ cd integer NOT NULL
);
-
--
--- Table: artist_undirected_map
+-- Table: owners
--
-CREATE TABLE artist_undirected_map (
- id1 integer NOT NULL,
- id2 integer NOT NULL,
- PRIMARY KEY (id1, id2)
+CREATE TABLE owners (
+ ownerid INTEGER PRIMARY KEY NOT NULL,
+ name varchar(100) NOT NULL
);
-
--
-- Table: producer
--
@@ -219,64 +178,89 @@
producerid INTEGER PRIMARY KEY NOT NULL,
name varchar(100) NOT NULL
);
-
---
--- Table: onekey
+CREATE UNIQUE INDEX prod_name_producer ON producer (name);--
+-- Table: self_ref
--
-CREATE TABLE onekey (
+CREATE TABLE self_ref (
id INTEGER PRIMARY KEY NOT NULL,
- artist integer NOT NULL,
- cd integer NOT NULL
+ name varchar(100) NOT NULL
);
-
--
--- Table: typed_object
+-- Table: self_ref_alias
--
-CREATE TABLE typed_object (
- objectid INTEGER PRIMARY KEY NOT NULL,
- type VARCHAR(100) NOT NULL,
- value VARCHAR(100)
+CREATE TABLE self_ref_alias (
+ self_ref integer NOT NULL,
+ alias integer NOT NULL,
+ PRIMARY KEY (self_ref, alias)
);
-
---
--- Table: collection
+CREATE INDEX self_ref_alias_idx_alias_self_ ON self_ref_alias (alias);CREATE
INDEX self_ref_alias_idx_self_ref_se ON self_ref_alias (self_ref);--
+-- Table: sequence_test
--
-CREATE TABLE collection (
- collectionid INTEGER PRIMARY KEY NOT NULL,
- name VARCHAR(100)
+CREATE TABLE sequence_test (
+ pkid1 integer NOT NULL,
+ pkid2 integer NOT NULL,
+ nonpkid integer NOT NULL,
+ name varchar(100),
+ PRIMARY KEY (pkid1, pkid2)
);
-
--
--- Table: collection_object
+-- Table: serialized
--
-CREATE TABLE collection_object (
- collection INTEGER NOT NULL,
- object INTEGER NOT NULL
+CREATE TABLE serialized (
+ id INTEGER PRIMARY KEY NOT NULL,
+ serialized text NOT NULL
);
-
--
--- Table: owners
+-- Table: tags
--
-CREATE TABLE owners (
- ownerid INTEGER PRIMARY KEY NOT NULL,
- name varchar(100)
+CREATE TABLE tags (
+ tagid INTEGER PRIMARY KEY NOT NULL,
+ cd integer NOT NULL,
+ tag varchar(100) NOT NULL
);
-
+CREATE INDEX tags_idx_cd_tags ON tags (cd);--
+-- Table: track
--
--- Table: books
+CREATE TABLE track (
+ trackid INTEGER PRIMARY KEY NOT NULL,
+ cd integer NOT NULL,
+ position integer NOT NULL,
+ title varchar(100) NOT NULL,
+ last_updated_on datetime
+);
+CREATE INDEX track_idx_cd_track ON track (cd);CREATE UNIQUE INDEX
track_cd_position_track ON track (cd, position);CREATE UNIQUE INDEX
track_cd_title_track ON track (cd, title);--
+-- Table: treelike
--
-CREATE TABLE books (
+CREATE TABLE treelike (
id INTEGER PRIMARY KEY NOT NULL,
- owner INTEGER,
- source varchar(100),
- title varchar(100)
+ parent integer,
+ name varchar(100) NOT NULL
+);
+CREATE INDEX treelike_idx_parent_treelike ON treelike (parent);--
+-- Table: twokeytreelike
+--
+CREATE TABLE twokeytreelike (
+ id1 integer NOT NULL,
+ id2 integer NOT NULL,
+ parent1 integer NOT NULL,
+ parent2 integer NOT NULL,
+ name varchar(100) NOT NULL,
+ PRIMARY KEY (id1, id2)
+);
+CREATE INDEX twokeytreelike_idx_parent1_parent2_twokeytre ON twokeytreelike
(parent1, parent2);CREATE UNIQUE INDEX tktlnameunique_twokeytreelike ON
twokeytreelike (name);--
+-- Table: twokeys
+--
+CREATE TABLE twokeys (
+ artist integer NOT NULL,
+ cd integer NOT NULL,
+ PRIMARY KEY (artist, cd)
+);
+CREATE INDEX twokeys_idx_artist_twokeys ON twokeys (artist);--
+-- Table: typed_object
+--
+CREATE TABLE typed_object (
+ objectid INTEGER PRIMARY KEY NOT NULL,
+ type varchar(100) NOT NULL,
+ value varchar(100) NOT NULL
);
-
-
-CREATE UNIQUE INDEX tktlnameunique_twokeytreelike on twokeytreelike (name);
-CREATE UNIQUE INDEX cd_artist_title_cd on cd (artist, title);
-CREATE UNIQUE INDEX track_cd_position_track on track (cd, position);
-CREATE UNIQUE INDEX track_cd_title_track on track (cd, title);
-CREATE UNIQUE INDEX foo_bar_noprimarykey on noprimarykey (foo, bar);
-CREATE UNIQUE INDEX prod_name_producer on producer (name);
COMMIT;
Index: t/lib/DBICTest/Schema/Event.pm
===================================================================
--- t/lib/DBICTest/Schema/Event.pm (Revision 4887)
+++ t/lib/DBICTest/Schema/Event.pm (Arbeitskopie)
@@ -11,7 +11,8 @@
__PACKAGE__->add_columns(
id => { data_type => 'integer', is_auto_increment => 1 },
starts_at => { data_type => 'datetime', datetime_undef_if_invalid => 1 },
- created_on => { data_type => 'timestamp' }
+ created_on => { data_type => 'timestamp' },
+ ends_at => { data_type => 'datetime', datetime_undef_if_invalid => 1,
extra => { timezone => 'UTC' }}
);
__PACKAGE__->set_primary_key('id');
Index: lib/DBIx/Class/InflateColumn/DateTime.pm
===================================================================
--- lib/DBIx/Class/InflateColumn/DateTime.pm (Revision 4887)
+++ lib/DBIx/Class/InflateColumn/DateTime.pm (Arbeitskopie)
@@ -90,7 +90,7 @@
my $dt = eval { $obj->_datetime_parser->$parse($value); };
die "Error while inflating ${value} for ${column} on ${self}: $@"
if $@ and not $undef_if_invalid;
- $dt->set_time_zone($timezone) if $timezone;
+ $dt->set_time_zone($timezone) if $timezone and $dt;
return $dt;
},
deflate => sub {
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]