| 1 | package DBIx::Class::Storage::DBI::Informix; | ||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 3 | ▶ | use base qw/DBIx::Class::Storage::DBI/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 3 | ▶ | use mro 'c3'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 3 | ▶ | use Scope::Guard (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 3 | ▶ | use Context::Preserve 'preserve_context'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 3 | ▶ | use namespace::clean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 3 | __PACKAGE__->sql_limit_dialect ('SkipFirst'); | |||||||||||||||||||
| 13 | 3 | __PACKAGE__->sql_quote_char ('"'); | |||||||||||||||||||
| 14 | 3 | __PACKAGE__->datetime_parser_type ( | |||||||||||||||||||
| 15 | 'DBIx::Class::Storage::DBI::Informix::DateTime::Format' | ||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 3 | __PACKAGE__->mk_group_accessors('simple' => '__last_insert_id'); | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | =head1 NAME | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | DBIx::Class::Storage::DBI::Informix - Base Storage Class for Informix Support | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | =head1 DESCRIPTION | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | This class implements storage-specific support for the Informix RDBMS | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | =head1 METHODS | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | =cut | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 0 | ▶ | sub _execute { | ||||||||||||||||||
|
Subroutine
_execute: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 34 | 0 | my $self = shift; | |||||||||||||||||||
| 35 | 0 | my ($rv, $sth, @rest) = $self->next::method(@_); | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | ▶ | $self->__last_insert_id($sth->{ix_sqlerrd}[1]) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 38 | if $self->_perform_autoinc_retrieval; | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 0 | ▶ | return (wantarray ? ($rv, $sth, @rest) : $rv); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | ▶ | sub last_insert_id { | ||||||||||||||||||
|
Subroutine
last_insert_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 44 | 0 | shift->__last_insert_id; | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | ▶ | sub _exec_svp_begin { | ||||||||||||||||||
|
Subroutine
_exec_svp_begin: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 48 | 0 | my ($self, $name) = @_; | |||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | $self->_dbh->do("SAVEPOINT $name"); | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | # can't release savepoints | ||||||||||||||||||||
| 54 | 0 | ▶ | sub _exec_svp_release { 1 } | ||||||||||||||||||
|
Subroutine
_exec_svp_release: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 0 | ▶ | sub _exec_svp_rollback { | ||||||||||||||||||
|
Subroutine
_exec_svp_rollback: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 57 | 0 | my ($self, $name) = @_; | |||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 0 | $self->_dbh->do("ROLLBACK TO SAVEPOINT $name") | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | ▶ | sub with_deferred_fk_checks { | ||||||||||||||||||
|
Subroutine
with_deferred_fk_checks: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 63 | 0 | my ($self, $sub) = @_; | |||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 0 | my $txn_scope_guard = $self->txn_scope_guard; | |||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 0 | $self->_do_query('SET CONSTRAINTS ALL DEFERRED'); | |||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 0 | ▶ | my $sg = Scope::Guard->new(sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 70 | 0 | $self->_do_query('SET CONSTRAINTS ALL IMMEDIATE'); | |||||||||||||||||||
| 71 | 0 | }); | |||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | 0 | ▶ | return preserve_context { $sub->() } after => sub { $txn_scope_guard->commit }; | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 74 | } | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | =head2 connect_call_datetime_setup | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | Used as: | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | on_connect_call => 'datetime_setup' | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set the C<DATE> and | ||||||||||||||||||||
| 83 | C<DATETIME> formats. | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | Sets the following environment variables: | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | GL_DATE="%m/%d/%Y" | ||||||||||||||||||||
| 88 | GL_DATETIME="%Y-%m-%d %H:%M:%S%F5" | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | The C<DBDATE> and C<DBCENTURY> environment variables are cleared. | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | B<NOTE:> setting the C<GL_DATE> environment variable seems to have no effect | ||||||||||||||||||||
| 93 | after the process has started, so the default format is used. The C<GL_DATETIME> | ||||||||||||||||||||
| 94 | setting does take effect however. | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | The C<DATETIME> data type supports up to 5 digits after the decimal point for | ||||||||||||||||||||
| 97 | second precision, depending on how you have declared your column. The full | ||||||||||||||||||||
| 98 | possible precision is used. | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | The column declaration for a C<DATETIME> with maximum precision is: | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | column_name DATETIME YEAR TO FRACTION(5) | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | The C<DATE> data type stores the date portion only, and it B<MUST> be declared | ||||||||||||||||||||
| 105 | with: | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | data_type => 'date' | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | in your Result class. | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | You will need the L<DateTime::Format::Strptime> module for inflation to work. | ||||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | =cut | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | 0 | ▶ | sub connect_call_datetime_setup { | ||||||||||||||||||
|
Subroutine
connect_call_datetime_setup: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 116 | 0 | my $self = shift; | |||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | 0 | delete @ENV{qw/DBDATE DBCENTURY/}; | |||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | 0 | $ENV{GL_DATE} = "%m/%d/%Y"; | |||||||||||||||||||
| 121 | 0 | $ENV{GL_DATETIME} = "%Y-%m-%d %H:%M:%S%F5"; | |||||||||||||||||||
| 122 | } | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | package # hide from PAUSE | ||||||||||||||||||||
| 125 | DBIx::Class::Storage::DBI::Informix::DateTime::Format; | ||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | 3 | my $timestamp_format = '%Y-%m-%d %H:%M:%S.%5N'; # %F %T | |||||||||||||||||||
| 128 | 3 | my $date_format = '%m/%d/%Y'; | |||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | 3 | my ($timestamp_parser, $date_parser); | |||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | 0 | ▶ | sub parse_datetime { | ||||||||||||||||||
|
Subroutine
parse_datetime: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 133 | 0 | shift; | |||||||||||||||||||
| 134 | 0 | require DateTime::Format::Strptime; | |||||||||||||||||||
| 135 | 0 | ▶ | $timestamp_parser ||= DateTime::Format::Strptime->new( | ||||||||||||||||||
|
Condition0%0/3
$timestamp_parser ||= "DateTime::Format::Strptime"->new("pattern", $timestamp_format, "on_error", "croak")
MC/DC0%0/2
$timestamp_parser ||= "DateTime::Format::Strptime"->new("pattern", $timestamp_format, "on_error", "croak")
$timestamp_parser
"DateTime::Format::Strptime"->new("pattern", $timestamp_format, "on_error", "croak")
Truth table0%0/3
A ||= B
A= $timestamp_parserB= "DateTime::Format::Strptime"->new("pattern", $timestamp_format, "on_error", "croak")
| |||||||||||||||||||||
| 136 | pattern => $timestamp_format, | ||||||||||||||||||||
| 137 | on_error => 'croak', | ||||||||||||||||||||
| 138 | ); | ||||||||||||||||||||
| 139 | 0 | return $timestamp_parser->parse_datetime(shift); | |||||||||||||||||||
| 140 | } | ||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | 0 | ▶ | sub format_datetime { | ||||||||||||||||||
|
Subroutine
format_datetime: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 143 | 0 | shift; | |||||||||||||||||||
| 144 | 0 | require DateTime::Format::Strptime; | |||||||||||||||||||
| 145 | 0 | ▶ | $timestamp_parser ||= DateTime::Format::Strptime->new( | ||||||||||||||||||
|
Condition0%0/3
$timestamp_parser ||= "DateTime::Format::Strptime"->new("pattern", $timestamp_format, "on_error", "croak")
MC/DC0%0/2
$timestamp_parser ||= "DateTime::Format::Strptime"->new("pattern", $timestamp_format, "on_error", "croak")
$timestamp_parser
"DateTime::Format::Strptime"->new("pattern", $timestamp_format, "on_error", "croak")
Truth table0%0/3
A ||= B
A= $timestamp_parserB= "DateTime::Format::Strptime"->new("pattern", $timestamp_format, "on_error", "croak")
| |||||||||||||||||||||
| 146 | pattern => $timestamp_format, | ||||||||||||||||||||
| 147 | on_error => 'croak', | ||||||||||||||||||||
| 148 | ); | ||||||||||||||||||||
| 149 | 0 | return $timestamp_parser->format_datetime(shift); | |||||||||||||||||||
| 150 | } | ||||||||||||||||||||
| 151 | |||||||||||||||||||||
| 152 | 0 | ▶ | sub parse_date { | ||||||||||||||||||
|
Subroutine
parse_date: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 153 | 0 | shift; | |||||||||||||||||||
| 154 | 0 | require DateTime::Format::Strptime; | |||||||||||||||||||
| 155 | 0 | ▶ | $date_parser ||= DateTime::Format::Strptime->new( | ||||||||||||||||||
|
Condition0%0/3
$date_parser ||= "DateTime::Format::Strptime"->new("pattern", $date_format, "on_error", "croak")
MC/DC0%0/2
$date_parser ||= "DateTime::Format::Strptime"->new("pattern", $date_format, "on_error", "croak")
$date_parser
"DateTime::Format::Strptime"->new("pattern", $date_format, "on_error", "croak")
Truth table0%0/3
A ||= B
A= $date_parserB= "DateTime::Format::Strptime"->new("pattern", $date_format, "on_error", "croak")
| |||||||||||||||||||||
| 156 | pattern => $date_format, | ||||||||||||||||||||
| 157 | on_error => 'croak', | ||||||||||||||||||||
| 158 | ); | ||||||||||||||||||||
| 159 | 0 | return $date_parser->parse_datetime(shift); | |||||||||||||||||||
| 160 | } | ||||||||||||||||||||
| 161 | |||||||||||||||||||||
| 162 | 0 | ▶ | sub format_date { | ||||||||||||||||||
|
Subroutine
format_date: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 163 | 0 | shift; | |||||||||||||||||||
| 164 | 0 | require DateTime::Format::Strptime; | |||||||||||||||||||
| 165 | 0 | ▶ | $date_parser ||= DateTime::Format::Strptime->new( | ||||||||||||||||||
|
Condition0%0/3
$date_parser ||= "DateTime::Format::Strptime"->new("pattern", $date_format, "on_error", "croak")
MC/DC0%0/2
$date_parser ||= "DateTime::Format::Strptime"->new("pattern", $date_format, "on_error", "croak")
$date_parser
"DateTime::Format::Strptime"->new("pattern", $date_format, "on_error", "croak")
Truth table0%0/3
A ||= B
A= $date_parserB= "DateTime::Format::Strptime"->new("pattern", $date_format, "on_error", "croak")
| |||||||||||||||||||||
| 166 | pattern => $date_format, | ||||||||||||||||||||
| 167 | on_error => 'croak', | ||||||||||||||||||||
| 168 | ); | ||||||||||||||||||||
| 169 | 0 | return $date_parser->format_datetime(shift); | |||||||||||||||||||
| 170 | } | ||||||||||||||||||||
| 171 | |||||||||||||||||||||
| 172 | =head1 FURTHER QUESTIONS? | ||||||||||||||||||||
| 173 | |||||||||||||||||||||
| 174 | Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>. | ||||||||||||||||||||
| 175 | |||||||||||||||||||||
| 176 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 177 | |||||||||||||||||||||
| 178 | This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE> | ||||||||||||||||||||
| 179 | by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can | ||||||||||||||||||||
| 180 | redistribute it and/or modify it under the same terms as the | ||||||||||||||||||||
| 181 | L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>. | ||||||||||||||||||||
| 182 | |||||||||||||||||||||
| 183 | =cut | ||||||||||||||||||||
| 184 | |||||||||||||||||||||
| 185 | 3 | 1; | |||||||||||||||||||
| 186 | |||||||||||||||||||||