hide internal Sybase classes from PAUSE
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Sybase.pm
CommitLineData
f68f4d44 1package DBIx::Class::Storage::DBI::Sybase;
2
3use strict;
4use warnings;
5
0814e804 6use base qw/DBIx::Class::Storage::DBI/;
f68f4d44 7
47d9646a 8sub _rebless {
0814e804 9 my $self = shift;
10
11 if (ref($self) eq 'DBIx::Class::Storage::DBI::Sybase') {
12 my $dbtype = eval {
13 @{$self->dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2]
14 } || '';
15
16 my $exception = $@;
17 $dbtype =~ s/\W/_/gi;
18 my $subclass = "DBIx::Class::Storage::DBI::Sybase::${dbtype}";
19
20 if (!$exception && $dbtype && $self->load_optional_class($subclass)) {
21 bless $self, $subclass;
22 $self->_rebless;
23 } else { # probably real Sybase
24 if (not $self->dbh->{syb_dynamic_supported}) {
25 bless $self, 'DBIx::Class::Storage:DBI::Sybase::NoBindVars';
26 $self->_rebless;
27 }
28
29 $self->dbh->syb_date_fmt('ISO_strict');
30 $self->dbh->do('set dateformat mdy');
47d9646a 31 }
0814e804 32 }
47d9646a 33}
34
a964a928 35sub _dbh_last_insert_id {
0814e804 36 my ($self, $dbh, $source, $col) = @_;
37
38 if (not $self->dbh->{syb_dynamic_supported}) {
39 # @@identity works only if not using placeholders
40 # Should this query be cached?
41 return ($dbh->selectrow_array('select @@identity'))[0];
42 }
43
44 # sorry, there's no other way!
45 my $sth = $dbh->prepare_cached("select max($col) from ".$source->from);
46 return ($dbh->selectrow_array($sth))[0];
a964a928 47}
48
0814e804 49sub datetime_parser_type { "DBIx::Class::Storage::DBI::Sybase::DateTime" }
50
f68f4d44 511;
52
53=head1 NAME
54
55DBIx::Class::Storage::DBI::Sybase - Storage::DBI subclass for Sybase
56
57=head1 SYNOPSIS
58
59This subclass supports L<DBD::Sybase> for real Sybase databases. If
60you are using an MSSQL database via L<DBD::Sybase>, see
61L<DBIx::Class::Storage::DBI::Sybase::MSSQL>.
62
d4483998 63=head1 CAVEATS
64
0814e804 65If your version of Sybase does not support placeholders, then this storage
66driver uses L<DBIx::Class::Storage::DBI::NoBindVars> as a base,
67
68In which case, bind variables will be interpolated (properly quoted of course)
d4483998 69into the SQL query itself, without using bind placeholders.
70
71More importantly this means that caching of prepared statements is explicitly
72disabled, as the interpolation renders it useless.
73
0814e804 74If your version of Sybase B<DOES> support placeholders (check
75C<<$dbh->{syb_dynamic_supported}>> then unfortunately there's no way to get the
76C<last_insert_id> without doing a C<select max(col)>.
77
78But your queries will be cached.
79
80=head1 DATES
81
82On connection C<syb_date_fmt> is set to C<ISO_strict>, e.g.:
83C<2004-08-21T14:36:48.080Z> and C<dateformat> is set to C<mdy>, e.g.:
84C<08/13/1979>.
85
86You will need the L<DateTime::Format::Strptime> module if you are going to use
87L<DBIx::Class::InflateColumn::DateTime>.
88
f68f4d44 89=head1 AUTHORS
90
91Brandon L Black <blblack@gmail.com>
92
47d9646a 93Justin Hunter <justin.d.hunter@gmail.com>
94
0814e804 95Rafael Kitover <rkitover@cpan.org>
96
f68f4d44 97=head1 LICENSE
98
99You may distribute this code under the same terms as Perl itself.
100
101=cut
0814e804 102# vim:sts=2 sw=2: