From: Rafael Kitover Date: Sat, 9 Apr 2011 21:48:38 +0000 (-0400) Subject: support sub-second precision for TIMESTAMPs for Firebird over ODBC X-Git-Tag: v0.08191~27 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a870aa85e;p=dbsrgits%2FDBIx-Class.git support sub-second precision for TIMESTAMPs for Firebird over ODBC --- diff --git a/Changes b/Changes index 0648bec..63e49ef 100644 --- a/Changes +++ b/Changes @@ -19,6 +19,7 @@ Revision history for DBIx::Class changes the output of as_query (should not cause compat issues) - Support ancient DB2 versions (5.4 and older), with proper limit dialect + - Support sub-second precision for TIMESTAMPs for Firebird over ODBC * Fixes - Fix ::Storage::DBI::* MRO problems on 5.8.x perls diff --git a/lib/DBIx/Class/Storage/DBI/InterBase.pm b/lib/DBIx/Class/Storage/DBI/InterBase.pm index 97c556b..6779e47 100644 --- a/lib/DBIx/Class/Storage/DBI/InterBase.pm +++ b/lib/DBIx/Class/Storage/DBI/InterBase.pm @@ -214,8 +214,7 @@ Timestamp columns can be declared with either C or C. You will need the L module for inflation to work. -For L, this is a noop and sub-second -precision is not currently available. +For L, this is a noop. =cut @@ -296,11 +295,6 @@ C support by default only works for Firebird versions 2 or greater, L however should work with earlier versions. -=item * - -Sub-second precision for TIMESTAMPs is not currently available when using the -L driver. - =back =head1 AUTHOR diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm b/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm index d4a5f50..b1a2a47 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm @@ -22,9 +22,9 @@ To build the ODBC driver for Firebird on Linux for unixODBC, see: L This driver does not suffer from the nested statement handles across commits -issue that the L based -driver does. This makes it more suitable for long running processes such as -under L. +issue that the L or the +L based driver does. This +makes it more suitable for long running processes such as under L. =cut @@ -62,7 +62,7 @@ package # hide from PAUSE # inherit parse/format date our @ISA = 'DBIx::Class::Storage::DBI::InterBase::DateTime::Format'; -my $timestamp_format = '%Y-%m-%d %H:%M:%S'; # %F %T, no fractional part +my $timestamp_format = '%Y-%m-%d %H:%M:%S.%4N'; # %F %T my $timestamp_parser; sub parse_datetime { @@ -87,17 +87,6 @@ sub format_datetime { 1; -=head1 CAVEATS - -=over 4 - -=item * - -This driver (unlike L) does not currently support reading or -writing C values with sub-second precision. - -=back - =head1 AUTHOR See L and L. diff --git a/t/750firebird.t b/t/750firebird.t index 84c0929..b2964ec 100644 --- a/t/750firebird.t +++ b/t/750firebird.t @@ -185,7 +185,6 @@ EOF my ($updated) = $schema->resultset('Artist')->search({name => 'foo'}); is eval { $updated->rank }, 4, 'and the update made it to the database'; - # test LIMIT support my $lim = $ars->search( {}, { diff --git a/t/inflate/datetime_firebird.t b/t/inflate/datetime_firebird.t index 572fc4e..0f62161 100644 --- a/t/inflate/datetime_firebird.t +++ b/t/inflate/datetime_firebird.t @@ -49,10 +49,10 @@ foreach my $conn_idx (0..$#info) { "created_on" TIMESTAMP ) SQL - my $rs = $schema->resultset('Event'); + my $rs = $schema->resultset('Event'); my $dt = DateTime->now; - $dt->set_nanosecond($dsn =~ /odbc/i ? 0 : 555600000); + $dt->set_nanosecond(555600000); my $date_only = DateTime->new( year => $dt->year, month => $dt->month, day => $dt->day @@ -70,7 +70,7 @@ SQL is $row->created_on, $dt, 'TIMESTAMP as DateTime roundtrip'; cmp_ok $row->created_on->nanosecond, '==', $dt->nanosecond, - 'fractional part of a second survived' if 0+$dt->nanosecond; + 'fractional part of a second survived'; is $row->starts_at, $date_only, 'DATE as DateTime roundtrip'; }