1 package DBIx::Class::Storage::DBI::Sybase::Base;
6 use base qw/DBIx::Class::Storage::DBI/;
11 DBIx::Class::Storage::DBI::Sybase::Base - Common functionality for drivers using
16 This is the base class for L<DBIx::Class::Storage::DBI::Sybase> and
17 L<DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server>. It provides some
18 utility methods related to L<DBD::Sybase> and the supported functions of the
19 database you are connecting to.
28 my $dbh = $self->_dbh or return 0;
30 local $dbh->{RaiseError} = 1;
38 =head2 placeholders_supported
40 Whether or not string placeholders work. Does not check for implicit conversion
41 errors, see L</placeholders_with_type_conversion_supported>.
45 sub placeholders_supported {
47 my $dbh = $self->_get_dbh;
50 # There's also $dbh->{syb_dynamic_supported} but it can be inaccurate for this
52 local $dbh->{PrintError} = 0;
53 local $dbh->{RaiseError} = 1;
54 $dbh->selectrow_array('select ?', {}, 1);
58 =head2 placeholders_with_type_conversion_supported
60 Checks if placeholders bound to non-string types throw implicit type conversion
63 See L<DBIx::Class::Storage::DBI::Sybase/connect_call_set_auto_cast>.
67 sub placeholders_with_type_conversion_supported {
69 my $dbh = $self->_dbh;
72 local $dbh->{PrintError} = 0;
73 local $dbh->{RaiseError} = 1;
74 # this specifically tests a bind that is NOT a string
75 $dbh->selectrow_array('select 1 where 1 = ?', {}, 1);
79 sub _set_max_connect {
81 my $val = shift || 256;
83 my $dsn = $self->_dbi_connect_info->[0];
85 return if ref($dsn) eq 'CODE';
87 if ($dsn !~ /maxConnect=/) {
88 $self->_dbi_connect_info->[0] = "$dsn;maxConnect=$val";
89 my $connected = defined $self->_dbh;
91 $self->ensure_connected if $connected;
97 Whether or not L<DBD::Sybase> was compiled against FreeTDS. If false, it means
98 the Sybase OpenClient libraries were used.
105 return $self->_dbh->{syb_oc_version} =~ /freetds/i;
110 When using FreeTDS and/or MSSQL, C<< $dbh->{LongReadLen} >> is not available,
111 use this function instead. It does:
113 $dbh->do("SET TEXTSIZE $bytes");
115 Takes the number of bytes, or uses the C<LongReadLen> value from your
116 L<DBIx::Class/connect_info> if omitted.
122 my $text_size = shift ||
123 eval { $self->_dbi_connect_info->[-1]->{LongReadLen} };
125 return unless defined $text_size;
127 $self->_dbh->do("SET TEXTSIZE $text_size");
134 See L<DBIx::Class/CONTRIBUTORS>.
138 You may distribute this code under the same terms as Perl itself.