File Coverage

blib/lib/DBIx/Class/Storage/DBI/InterBase.pm
Criterion Covered Total %
statement 18 40 45.0
branch 0 10 0.0
condition 0 2 0.0
subroutine 6 12 50.0
pod 2 2 100.0
total 26 66 39.3


line stmt bran cond sub pod time code
1             package DBIx::Class::Storage::DBI::InterBase;
2              
3 3     3   726 use strict;
  3         8  
  3         84  
4 3     3   17 use warnings;
  3         6  
  3         71  
5 3     3   14 use base qw/DBIx::Class::Storage::DBI::Firebird::Common/;
  3         6  
  3         1032  
6 3     3   21 use mro 'c3';
  3         9  
  3         13  
7 3     3   95 use DBIx::Class::_Util 'dbic_internal_try';
  3         7  
  3         148  
8 3     3   21 use namespace::clean;
  3         7  
  3         18  
9              
10             =head1 NAME
11              
12             DBIx::Class::Storage::DBI::InterBase - Driver for the Firebird RDBMS via
13             L
14              
15             =head1 DESCRIPTION
16              
17             This driver is a subclass of L for
18             use with L, see that driver for general details.
19              
20             You need to use either the
21             L option or
22             L (see L) for your code to function
23             correctly with this driver. Otherwise you will likely get bizarre error messages
24             such as C. The alternative is to use the
25             L driver, which is more suitable
26             for long running processes such as under L.
27              
28             To turn on L support, see
29             L.
30              
31             =cut
32              
33             sub _ping {
34 0     0     my $self = shift;
35              
36 0 0         my $dbh = $self->_dbh or return 0;
37              
38 0           local $dbh->{RaiseError} = 1;
39 0           local $dbh->{PrintError} = 0;
40              
41             (dbic_internal_try {
42 0     0     $dbh->do('select 1 from rdb$database');
43 0           1;
44             })
45 0 0         ? 1
46             : 0
47             ;
48             }
49              
50             # We want dialect 3 for new features and quoting to work, DBD::InterBase uses
51             # dialect 1 (interbase compat) by default.
52             sub _init {
53 0     0     my $self = shift;
54 0           $self->_set_sql_dialect(3);
55             }
56              
57             sub _set_sql_dialect {
58 0     0     my $self = shift;
59 0   0       my $val = shift || 3;
60              
61 0           my $dsn = $self->_dbi_connect_info->[0];
62              
63 0 0         return if ref($dsn) eq 'CODE';
64              
65 0 0         if ($dsn !~ /ib_dialect=/) {
66 0           $self->_dbi_connect_info->[0] = "$dsn;ib_dialect=$val";
67 0           my $connected = defined $self->_dbh;
68 0           $self->disconnect;
69 0 0         $self->ensure_connected if $connected;
70             }
71             }
72              
73             =head2 connect_call_use_softcommit
74              
75             Used as:
76              
77             on_connect_call => 'use_softcommit'
78              
79             In L to set the
80             L C option.
81              
82             You need either this option or C<< disable_sth_caching => 1 >> for
83             L code to function correctly (otherwise you may get C
84             executing> errors.) Or use the L
85             driver.
86              
87             The downside of using this option is that your process will B see UPDATEs,
88             INSERTs and DELETEs from other processes for already open statements.
89              
90             =cut
91              
92             sub connect_call_use_softcommit {
93 0     0 1   my $self = shift;
94              
95 0           $self->_dbh->{ib_softcommit} = 1;
96             }
97              
98             =head2 connect_call_datetime_setup
99              
100             Used as:
101              
102             on_connect_call => 'datetime_setup'
103              
104             In L to set the date and
105             timestamp formats using:
106              
107             $dbh->{ib_time_all} = 'ISO';
108              
109             See L for more details.
110              
111             The C data type supports up to 4 digits after the decimal point for
112             second precision. The full precision is used.
113              
114             The C data type stores the date portion only, and it B be declared
115             with:
116              
117             data_type => 'date'
118              
119             in your Result class.
120              
121             Timestamp columns can be declared with either C or C.
122              
123             You will need the L module for inflation to work.
124              
125             For L, this is a noop.
126              
127             =cut
128              
129             sub connect_call_datetime_setup {
130 0     0 1   my $self = shift;
131              
132 0           $self->_get_dbh->{ib_time_all} = 'ISO';
133             }
134              
135             =head1 CAVEATS
136              
137             =over 4
138              
139             =item *
140              
141             with L, you will not be able to see changes made
142             to data in other processes. If this is an issue, use
143             L as a
144             workaround for the C errors, this of course adversely
145             affects performance.
146              
147             Alternately, use the L driver.
148              
149             =back
150              
151             =head1 FURTHER QUESTIONS?
152              
153             Check the list of L.
154              
155             =head1 COPYRIGHT AND LICENSE
156              
157             This module is free software L
158             by the L. You can
159             redistribute it and/or modify it under the same terms as the
160             L.
161              
162             =cut
163              
164             1;
165              
166             # vim:sts=2 sw=2: