Merge 'trunk' into 'sybase_noquote'
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / Storage / DBI / Sybase.pm
CommitLineData
148e3b50 1package DBIx::Class::Storage::DBI::Sybase;
2
3use strict;
4use warnings;
5
6use base qw/DBIx::Class::Storage::DBI::NoBindVars/;
7
47d9646a 8sub _rebless {
d29565e0 9 my $self = shift;
10
11 my $dbtype = eval { @{$self->dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2] };
12 unless ( $@ ) {
13 $dbtype =~ s/\W/_/gi;
14 my $subclass = "DBIx::Class::Storage::DBI::Sybase::${dbtype}";
15 if ($self->load_optional_class($subclass) && !$self->isa($subclass)) {
16 bless $self, $subclass;
17 $self->_rebless;
18 }
47d9646a 19 }
20}
21
a964a928 22sub _dbh_last_insert_id {
90ffec0d 23 my ($self, $dbh, $source, $col) = @_;
24 return ($dbh->selectrow_array('select @@identity'))[0];
a964a928 25}
26
148e3b50 27my $noquote = {
28 int => qr/^ \-? \d+ $/x,
29 integer => qr/^ \-? \d+ $/x,
30
31 # TODO maybe need to add float/real/etc
32};
33
34sub should_quote_data_type {
35 my $self = shift;
36 my ($type, $value) = @_;
37
38 return $self->next::method(@_) if not defined $value;
39
40 if (my $re = $noquote->{$type}) {
41 return 0 if $value =~ $re;
42 }
43
44 return $self->next::method(@_);
45}
46
471;
48
49=head1 NAME
50
51DBIx::Class::Storage::DBI::Sybase - Storage::DBI subclass for Sybase
52
53=head1 SYNOPSIS
54
55This subclass supports L<DBD::Sybase> for real Sybase databases. If
56you are using an MSSQL database via L<DBD::Sybase>, see
57L<DBIx::Class::Storage::DBI::Sybase::MSSQL>.
58
d4483998 59=head1 CAVEATS
60
d29565e0 61This storage driver uses L<DBIx::Class::Storage::DBI::NoBindVars> as a base.
62This means that bind variables will be interpolated (properly quoted of course)
d4483998 63into the SQL query itself, without using bind placeholders.
64
65More importantly this means that caching of prepared statements is explicitly
66disabled, as the interpolation renders it useless.
67
148e3b50 68=head1 AUTHORS
69
70Brandon L Black <blblack@gmail.com>
71
47d9646a 72Justin Hunter <justin.d.hunter@gmail.com>
73
148e3b50 74=head1 LICENSE
75
76You may distribute this code under the same terms as Perl itself.
77
78=cut