monikers
dynamic
naming
+ datetime_timezone
+ datetime_locale
/);
Add to all columns with type DATE the attribute timezone => "Europe/Berlin".
+=head2 datetime_timezone
+
+Set timezone attribute for L<DBIx::Class::InflateColumn::DateTime>
+to all columns with the type DATE.
+
+=head2 datetime_locale
+
+Set local attribute for L<DBIx::Class::InflateColumn::DateTime>
+to all columns with the type DATE.
+
=head1 METHODS
None of these methods are intended for direct invocation by regular
return {};
}
+sub _datetime_column_info {
+ my ( $self, $info, $column_info) = @_;
+ # warn "_datetime_column_info XXXXXXXXX";
+ # use Data::Dumper;
+ # warn Dumper $info;
+ # warn Dumper $column_info;
+ my $return = {};
+ my $type = lc ( $info->{TYPE_NAME} );
+
+ if (
+ ( defined $column_info->{inflate_datetime} and $column_info->{inflate_datetime} )
+ or ( defined $column_info->{inflate_date} and $column_info->{inflate_date} )
+ or ( $type eq 'date')
+ or ( $type eq 'datetime')
+ or ( $type eq 'timestamp')
+ ){
+ $return->{timezone} = $self->datetime_timezone if $self->datetime_timezone;
+ $return->{locale} = $self->datetime_locale if $self->datetime_locale;
+ }
+ return $return;
+}
+
# remove the dump dir from @INC on destruction
sub DESTROY {
my $self = shift;
my $extra_info = $self->_extra_column_info($info) || {};
my $custom_info = $self->_custom_column_info($info) || {};
- $result{$col_name} = { %column_info, %$extra_info, %$custom_info };
+ my $datetime_info = $self->_datetime_column_info($info,
+ { %column_info, %$extra_info, %$custom_info }) || {};
+ $result{$col_name} = { %column_info, %$extra_info, %$custom_info, %$datetime_info };
}
$sth->finish;
};
sub run_tests {
my $self = shift;
- plan tests => 146 + ($self->{extra}->{count} || 0);
+ plan tests => 149 + ($self->{extra}->{count} || 0);
$self->create();
debug => $debug,
use_namespaces => 0,
dump_directory => $DUMP_DIR,
+ datetime_timezone => 'Europe/Berlin',
+ datetime_locale => 'de_DE'
);
$loader_opts{db_schema} = $self->{db_schema} if $self->{db_schema};
my $file_count;
find sub { return if -d; $file_count++ }, $DUMP_DIR;
- my $expected_count = 35;
+ my $expected_count = 36;
$expected_count += grep /CREATE (?:TABLE|VIEW)/i,
@{ $self->{extra}{create} || [] };
my $class34 = $classes->{loader_test34};
my $rsobj34 = $conn->resultset($moniker34);
+ my $moniker36 = $monikers->{loader_test36};
+ my $class36 = $classes->{loader_test36};
+ my $rsobj36 = $conn->resultset($moniker36);
+
isa_ok( $rsobj3, "DBIx::Class::ResultSet" );
isa_ok( $rsobj4, "DBIx::Class::ResultSet" );
isa_ok( $rsobj5, "DBIx::Class::ResultSet" );
isa_ok( $rsobj32, "DBIx::Class::ResultSet" );
isa_ok( $rsobj33, "DBIx::Class::ResultSet" );
isa_ok( $rsobj34, "DBIx::Class::ResultSet" );
+ isa_ok( $rsobj36, "DBIx::Class::ResultSet" );
# basic rel test
my $obj4 = $rsobj4->find(123);
# Added by custom_column_info
ok($class11->column_info('loader_test10')->{is_numeric}, 'is_numeric detected');
+ is($class36->column_info('a_date')->{locale},'de_DE','locale is correct');
+ is($class36->column_info('a_date')->{timezone},'Europe/Berlin','locale is correct');
+
my $obj10 = $rsobj10->create({ subject => 'xyzzy' });
$obj10->update();
a_function $self->{default_function_def}
) $self->{innodb}
},
+
+ qq{
+ CREATE TABLE loader_test36 (
+ id INTEGER NOT NULL PRIMARY KEY,
+ a_date DATE
+ ) $self->{innodb}
+ },
);
@statements_reltests = (
LOADER_TEST23
LoAdEr_test24
loader_test35
+ loader_test36
/;
my @tables_auto_inc = (