6f6acdfdec5a0faa4d9d90fc4ac1f2ea4a5ddd36
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / ODBC / Firebird.pm
1 package DBIx::Class::Storage::DBI::ODBC::Firebird;
2
3 use strict;
4 use warnings;
5 use base qw/DBIx::Class::Storage::DBI::InterBase/;
6 use mro 'c3';
7
8 =head1 NAME
9
10 DBIx::Class::Storage::DBI::ODBC::Firebird - Driver for using the Firebird RDBMS
11 through ODBC
12
13 =head1 DESCRIPTION
14
15 Most functionality is provided by L<DBIx::Class::Storage::DBI::Interbase>, see
16 that module for details.
17
18 To build the ODBC driver for Firebird on Linux for unixODBC, see:
19
20 L<http://www.firebirdnews.org/?p=1324>
21
22 This driver does not suffer from the nested statement handles across commits
23 issue that the L<DBD::InterBase|DBIx::Class::Storage::DBI::InterBase> based
24 driver does. This makes it more suitable for long running processes such as
25 under L<Catalyst>.
26
27 =cut
28
29 # XXX seemingly no equivalent to ib_time_all from DBD::InterBase via ODBC
30 sub connect_call_datetime_setup { 1 }
31
32 # we don't need DBD::InterBase-specific initialization
33 sub _init { 1 }
34
35 # ODBC uses dialect 3 by default, good
36 sub _set_sql_dialect { 1 }
37
38 # releasing savepoints doesn't work, but that shouldn't matter
39 sub _svp_release { 1 }
40
41 sub datetime_parser_type {
42   'DBIx::Class::Storage::DBI::ODBC::Firebird::DateTime::Format'
43 }
44
45 package # hide from PAUSE
46   DBIx::Class::Storage::DBI::ODBC::Firebird::DateTime::Format;
47
48 # inherit parse/format date
49 our @ISA = 'DBIx::Class::Storage::DBI::InterBase::DateTime::Format';
50
51 my $timestamp_format = '%Y-%m-%d %H:%M:%S'; # %F %T, no fractional part
52 my $timestamp_parser;
53
54 sub parse_datetime {
55   shift;
56   require DateTime::Format::Strptime;
57   $timestamp_parser ||= DateTime::Format::Strptime->new(
58     pattern  => $timestamp_format,
59     on_error => 'croak',
60   );
61   return $timestamp_parser->parse_datetime(shift);
62 }
63
64 sub format_datetime {
65   shift;
66   require DateTime::Format::Strptime;
67   $timestamp_parser ||= DateTime::Format::Strptime->new(
68     pattern  => $timestamp_format,
69     on_error => 'croak',
70   );
71   return $timestamp_parser->format_datetime(shift);
72 }
73
74 1;
75
76 =head1 CAVEATS
77
78 =over 4
79
80 =item *
81
82 This driver (unlike L<DBD::InterBase>) does not currently support reading or
83 writing C<TIMESTAMP> values with sub-second precision.
84
85 =back
86
87 =head1 AUTHOR
88
89 See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
90
91 =head1 LICENSE
92
93 You may distribute this code under the same terms as Perl itself.
94
95 =cut