| 1 | package DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use base qw/ | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | DBIx::Class::Storage::DBI::Sybase | ||||||||||||||||||||||||||||||||
| 8 | DBIx::Class::Storage::DBI::MSSQL | ||||||||||||||||||||||||||||||||
| 9 | 3 | /; | |||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use DBIx::Class::Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server - Support for Microsoft | ||||||||||||||||||||||||||||||||
| 18 | SQL Server via DBD::Sybase | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | This subclass supports MSSQL server connections via L<DBD::Sybase>. | ||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | This driver tries to determine whether your version of L<DBD::Sybase> and | ||||||||||||||||||||||||||||||||
| 27 | supporting libraries (usually FreeTDS) support using placeholders, if not the | ||||||||||||||||||||||||||||||||
| 28 | storage will be reblessed to | ||||||||||||||||||||||||||||||||
| 29 | L<DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars>. | ||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | The MSSQL specific functionality is provided by | ||||||||||||||||||||||||||||||||
| 32 | L<DBIx::Class::Storage::DBI::MSSQL>. | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | =head1 METHODS | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | =cut | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 3 | __PACKAGE__->datetime_parser_type( | |||||||||||||||||||||||||||||||
| 39 | 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::DateTime::Format' | ||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub _rebless { | ||||||||||||||||||||||||||||||
|
Subroutine
_rebless: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 43 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 44 | 0 | my $dbh = $self->_get_dbh; | |||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | return if ref $self ne __PACKAGE__; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if (not $self->_use_typeless_placeholders) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | carp_once <<'EOF' unless $ENV{DBIC_MSSQL_FREETDS_LOWVER_NOWARN}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 49 | Placeholders do not seem to be supported in your configuration of | ||||||||||||||||||||||||||||||||
| 50 | DBD::Sybase/FreeTDS. | ||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | This means you are taking a large performance hit, as caching of prepared | ||||||||||||||||||||||||||||||||
| 53 | statements is disabled. | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | Make sure to configure your server with "tds version" of 8.0 or 7.0 in | ||||||||||||||||||||||||||||||||
| 56 | /etc/freetds/freetds.conf . | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | To turn off this warning, set the DBIC_MSSQL_FREETDS_LOWVER_NOWARN environment | ||||||||||||||||||||||||||||||||
| 59 | variable. | ||||||||||||||||||||||||||||||||
| 60 | EOF | ||||||||||||||||||||||||||||||||
| 61 | require | ||||||||||||||||||||||||||||||||
| 62 | 0 | DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars; | |||||||||||||||||||||||||||||||
| 63 | 0 | bless $self, | |||||||||||||||||||||||||||||||
| 64 | 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars'; | ||||||||||||||||||||||||||||||||
| 65 | 0 | $self->_rebless; | |||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 1 | ▶ | sub _init { | ||||||||||||||||||||||||||||||
|
Subroutine
_init: called CC=4 SCAR=21.1
| |||||||||||||||||||||||||||||||||
| 70 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 1 | $self->next::method(@_); | |||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | # work around massively broken freetds versions after 0.82 | ||||||||||||||||||||||||||||||||
| 75 | # - explicitly no scope_identity | ||||||||||||||||||||||||||||||||
| 76 | # - no sth caching | ||||||||||||||||||||||||||||||||
| 77 | # | ||||||||||||||||||||||||||||||||
| 78 | # warn about the fact as well, do not provide a mechanism to shut it up | ||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | if ($self->_using_freetds and (my $ver = $self->_using_freetds_version||999) > 0.82) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
$self->_using_freetds and (my $ver = $self->_using_freetds_version || 999) > "0.82"
$self->_using_freetds_version || 999
MC/DC0%0/2
$self->_using_freetds and (my $ver = $self->_using_freetds_version || 999) > "0.82"
$self->_using_freetds
$self->_using_freetds_version
Truth table33%1/3
A and B
A= $self->_using_freetdsB= $self->_using_freetds_version
| |||||||||||||||||||||||||||||||||
| 80 | 0 | carp_once( | |||||||||||||||||||||||||||||||
| 81 | "Your DBD::Sybase was compiled against buggy FreeTDS version $ver. " | ||||||||||||||||||||||||||||||||
| 82 | . 'Statement caching does not work and will be disabled.' | ||||||||||||||||||||||||||||||||
| 83 | ); | ||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||
| 85 | 0 | $self->_identity_method('@@identity'); | |||||||||||||||||||||||||||||||
| 86 | 0 | $self->_no_scope_identity_query(1); | |||||||||||||||||||||||||||||||
| 87 | 0 | $self->disable_sth_caching(1); | |||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | # invoked only if DBD::Sybase is compiled against FreeTDS | ||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub _set_autocommit_stmt { | ||||||||||||||||||||||||||||||
|
Subroutine
_set_autocommit_stmt: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 93 | 0 | my ($self, $on) = @_; | |||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | return 'SET IMPLICIT_TRANSACTIONS ' . ($on ? 'OFF' : 'ON'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub _get_server_version { | ||||||||||||||||||||||||||||||
|
Subroutine
_get_server_version: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 99 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | 0 | my $product_version = $self->_get_dbh->selectrow_hashref('master.dbo.xp_msver ProductVersion'); | |||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if ((my $version = $product_version->{Character_Value}) =~ /^(\d+)\./) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 104 | 0 | return $version; | |||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||
| 106 | else { | ||||||||||||||||||||||||||||||||
| 107 | 0 | $self->throw_exception( | |||||||||||||||||||||||||||||||
| 108 | "MSSQL Version Retrieval Failed, Your ProductVersion's Character_Value is missing or malformed!" | ||||||||||||||||||||||||||||||||
| 109 | ); | ||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | =head2 connect_call_datetime_setup | ||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||
| 115 | Used as: | ||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||
| 117 | on_connect_call => 'datetime_setup' | ||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||
| 119 | In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set: | ||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | $dbh->syb_date_fmt('ISO_strict'); # output fmt: 2004-08-21T14:36:48.080Z | ||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | On connection for use with L<DBIx::Class::InflateColumn::DateTime> | ||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | This works for both C<DATETIME> and C<SMALLDATETIME> columns, although | ||||||||||||||||||||||||||||||||
| 126 | C<SMALLDATETIME> columns only have minute precision. | ||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | =cut | ||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | sub connect_call_datetime_setup { | ||||||||||||||||||||||||||||||
|
Subroutine
connect_call_datetime_setup: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 131 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 132 | 0 | my $dbh = $self->_get_dbh; | |||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ($dbh->can('syb_date_fmt')) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 135 | # amazingly, this works with FreeTDS | ||||||||||||||||||||||||||||||||
| 136 | 0 | $dbh->syb_date_fmt('ISO_strict'); | |||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||
| 138 | else{ | ||||||||||||||||||||||||||||||||
| 139 | 0 | carp_once | |||||||||||||||||||||||||||||||
| 140 | 'Your DBD::Sybase is too old to support ' | ||||||||||||||||||||||||||||||||
| 141 | . 'DBIx::Class::InflateColumn::DateTime, please upgrade!'; | ||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | package # hide from PAUSE | ||||||||||||||||||||||||||||||||
| 147 | DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::DateTime::Format; | ||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | 3 | my $datetime_parse_format = '%Y-%m-%dT%H:%M:%S.%3NZ'; | |||||||||||||||||||||||||||||||
| 150 | 3 | my $datetime_format_format = '%Y-%m-%d %H:%M:%S.%3N'; # %F %T | |||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||
| 152 | 3 | my ($datetime_parser, $datetime_formatter); | |||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | sub parse_datetime { | ||||||||||||||||||||||||||||||
|
Subroutine
parse_datetime: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 155 | 0 | shift; | |||||||||||||||||||||||||||||||
| 156 | 0 | require DateTime::Format::Strptime; | |||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | $datetime_parser ||= DateTime::Format::Strptime->new( | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$datetime_parser ||= "DateTime::Format::Strptime"->new("pattern", $datetime_parse_format, "on_error", "croak")
MC/DC0%0/2
$datetime_parser ||= "DateTime::Format::Strptime"->new("pattern", $datetime_parse_format, "on_error", "croak")
$datetime_parser
"DateTime::Format::Strptime"->new("pattern", $datetime_parse_format, "on_error", "croak")
Truth table0%0/3
A ||= B
A= $datetime_parserB= "DateTime::Format::Strptime"->new("pattern", $datetime_parse_format, "on_error", "croak")
| |||||||||||||||||||||||||||||||||
| 158 | pattern => $datetime_parse_format, | ||||||||||||||||||||||||||||||||
| 159 | on_error => 'croak', | ||||||||||||||||||||||||||||||||
| 160 | ); | ||||||||||||||||||||||||||||||||
| 161 | 0 | return $datetime_parser->parse_datetime(shift); | |||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | sub format_datetime { | ||||||||||||||||||||||||||||||
|
Subroutine
format_datetime: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 165 | 0 | shift; | |||||||||||||||||||||||||||||||
| 166 | 0 | require DateTime::Format::Strptime; | |||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | $datetime_formatter ||= DateTime::Format::Strptime->new( | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$datetime_formatter ||= "DateTime::Format::Strptime"->new("pattern", $datetime_format_format, "on_error", "croak")
MC/DC0%0/2
$datetime_formatter ||= "DateTime::Format::Strptime"->new("pattern", $datetime_format_format, "on_error", "croak")
$datetime_formatter
"DateTime::Format::Strptime"->new("pattern", $datetime_format_format, "on_error", "croak")
Truth table0%0/3
A ||= B
A= $datetime_formatterB= "DateTime::Format::Strptime"->new("pattern", $datetime_format_format, "on_error", "croak")
| |||||||||||||||||||||||||||||||||
| 168 | pattern => $datetime_format_format, | ||||||||||||||||||||||||||||||||
| 169 | on_error => 'croak', | ||||||||||||||||||||||||||||||||
| 170 | ); | ||||||||||||||||||||||||||||||||
| 171 | 0 | return $datetime_formatter->format_datetime(shift); | |||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||
| 174 | =head1 FURTHER QUESTIONS? | ||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||
| 176 | Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>. | ||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||
| 178 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||
| 180 | This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE> | ||||||||||||||||||||||||||||||||
| 181 | by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can | ||||||||||||||||||||||||||||||||
| 182 | redistribute it and/or modify it under the same terms as the | ||||||||||||||||||||||||||||||||
| 183 | L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>. | ||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||
| 185 | =cut | ||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||
| 187 | 3 | 1; | |||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||