1 package DBIx::Class::Storage::DBI::Sybase;
8 use base qw/DBIx::Class::Storage::DBI/;
12 DBIx::Class::Storage::DBI::Sybase - Base class for drivers using
17 This is the base class/dispatcher for Storage's designed to work with
29 $dbtype = @{$self->_get_dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2]
31 $self->throw_exception("Unable to establish connection to determine database type: $_")
38 $dbtype = 'ASE' if $dbtype eq 'SQL_Server';
40 my $subclass = __PACKAGE__ . "::$dbtype";
41 if ($self->load_optional_class($subclass)) {
42 bless $self, $subclass;
49 # once the driver is determined see if we need to insert the DBD::Sybase w/ FreeTDS fixups
50 # this is a dirty version of "instance role application", \o/ DO WANT Moo \o/
52 if (! $self->isa('DBIx::Class::Storage::DBI::Sybase::FreeTDS') and $self->_using_freetds) {
53 require DBIx::Class::Storage::DBI::Sybase::FreeTDS;
55 my @isa = @{mro::get_linear_isa(ref $self)};
56 my $class = shift @isa; # this is our current ref
58 my $trait_class = $class . '::FreeTDS';
59 mro::set_mro ($trait_class, 'c3');
61 @{"${trait_class}::ISA"} = ($class, 'DBIx::Class::Storage::DBI::Sybase::FreeTDS', @isa);
63 bless ($self, $trait_class);
65 Class::C3->reinitialize() if DBIx::Class::_ENV_::OLD_MRO;
70 $self->next::method(@_);
76 my $dbh = $self->_dbh or return 0;
78 local $dbh->{RaiseError} = 1;
79 local $dbh->{PrintError} = 0;
81 # FIXME if the main connection goes stale, does opening another for this statement
82 # really determine anything?
84 if ($dbh->{syb_no_child_con}) {
86 $self->_connect(@{$self->_dbi_connect_info || [] })
104 sub _set_max_connect {
106 my $val = shift || 256;
108 my $dsn = $self->_dbi_connect_info->[0];
110 return if ref($dsn) eq 'CODE';
112 if ($dsn !~ /maxConnect=/) {
113 $self->_dbi_connect_info->[0] = "$dsn;maxConnect=$val";
114 my $connected = defined $self->_dbh;
116 $self->ensure_connected if $connected;
120 # Whether or not DBD::Sybase was compiled against FreeTDS. If false, it means
121 # the Sybase OpenClient libraries were used.
124 return ($self->_get_dbh->{syb_oc_version}||'') =~ /freetds/i;
127 # Either returns the FreeTDS version against which DBD::Sybase was compiled,
128 # 0 if can't be determined, or undef otherwise
129 sub _using_freetds_version {
130 my $inf = shift->_get_dbh->{syb_oc_version};
131 return undef unless ($inf||'') =~ /freetds/i;
132 return $inf =~ /v([0-9\.]+)/ ? $1 : 0;
139 See L<DBIx::Class/CONTRIBUTORS>.
143 You may distribute this code under the same terms as Perl itself.