Commit | Line | Data |
dff4c3a3 |
1 | package DBIx::Class::Storage::DBI::ODBC::Firebird; |
2 | |
3 | use strict; |
4 | use warnings; |
e02b39b4 |
5 | use base 'DBIx::Class::Storage::DBI::InterBase'; |
dff4c3a3 |
6 | use mro 'c3'; |
e02b39b4 |
7 | use Try::Tiny; |
8 | use namespace::clean; |
dff4c3a3 |
9 | |
dff4c3a3 |
10 | =head1 NAME |
11 | |
12 | DBIx::Class::Storage::DBI::ODBC::Firebird - Driver for using the Firebird RDBMS |
13 | through ODBC |
14 | |
d1fc96c7 |
15 | =head1 DESCRIPTION |
dff4c3a3 |
16 | |
32323fc2 |
17 | Most functionality is provided by L<DBIx::Class::Storage::DBI::Interbase>, see |
dff4c3a3 |
18 | that module for details. |
19 | |
90489c23 |
20 | To build the ODBC driver for Firebird on Linux for unixODBC, see: |
21 | |
22 | L<http://www.firebirdnews.org/?p=1324> |
23 | |
d1fc96c7 |
24 | This driver does not suffer from the nested statement handles across commits |
a870aa85 |
25 | issue that the L<DBD::InterBase|DBIx::Class::Storage::DBI::InterBase> or the |
26 | L<DBD::Firebird|DBIx::Class::Storage::DBI::Firebird> based driver does. This |
27 | makes it more suitable for long running processes such as under L<Catalyst>. |
d1fc96c7 |
28 | |
1ae0a36c |
29 | =cut |
30 | |
6f7a118e |
31 | __PACKAGE__->datetime_parser_type ('DBIx::Class::Storage::DBI::ODBC::Firebird::DateTime::Format'); |
32 | |
c5827074 |
33 | # XXX seemingly no equivalent to ib_time_all from DBD::InterBase via ODBC |
32323fc2 |
34 | sub connect_call_datetime_setup { 1 } |
1ae0a36c |
35 | |
9633951d |
36 | # we don't need DBD::InterBase-specific initialization |
37 | sub _init { 1 } |
38 | |
39 | # ODBC uses dialect 3 by default, good |
40 | sub _set_sql_dialect { 1 } |
41 | |
e02b39b4 |
42 | # releasing savepoints doesn't work for some reason, but that shouldn't matter |
5c6ed0b5 |
43 | sub _svp_release { 1 } |
44 | |
e02b39b4 |
45 | sub _svp_rollback { |
46 | my ($self, $name) = @_; |
47 | |
48 | try { |
49 | $self->_dbh->do("ROLLBACK TO SAVEPOINT $name") |
50 | } |
51 | catch { |
52 | # Firebird ODBC driver bug, ignore |
53 | if (not /Unable to fetch information about the error/) { |
54 | $self->throw_exception($_); |
55 | } |
56 | }; |
57 | } |
58 | |
c5827074 |
59 | package # hide from PAUSE |
60 | DBIx::Class::Storage::DBI::ODBC::Firebird::DateTime::Format; |
61 | |
62 | # inherit parse/format date |
63 | our @ISA = 'DBIx::Class::Storage::DBI::InterBase::DateTime::Format'; |
64 | |
a870aa85 |
65 | my $timestamp_format = '%Y-%m-%d %H:%M:%S.%4N'; # %F %T |
c5827074 |
66 | my $timestamp_parser; |
67 | |
68 | sub parse_datetime { |
69 | shift; |
70 | require DateTime::Format::Strptime; |
71 | $timestamp_parser ||= DateTime::Format::Strptime->new( |
72 | pattern => $timestamp_format, |
73 | on_error => 'croak', |
74 | ); |
75 | return $timestamp_parser->parse_datetime(shift); |
76 | } |
77 | |
78 | sub format_datetime { |
79 | shift; |
80 | require DateTime::Format::Strptime; |
81 | $timestamp_parser ||= DateTime::Format::Strptime->new( |
82 | pattern => $timestamp_format, |
83 | on_error => 'croak', |
84 | ); |
85 | return $timestamp_parser->format_datetime(shift); |
86 | } |
87 | |
1ae0a36c |
88 | 1; |
89 | |
dff4c3a3 |
90 | =head1 AUTHOR |
91 | |
92 | See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>. |
93 | |
94 | =head1 LICENSE |
95 | |
96 | You may distribute this code under the same terms as Perl itself. |
97 | |
98 | =cut |
e02b39b4 |
99 | # vim:sts=2 sw=2: |