1 package DBIx::Class::Storage::DBI::Sybase::NoBindVars;
4 DBIx::Class::Storage::DBI::NoBindVars
5 DBIx::Class::Storage::DBI::Sybase
12 my $self = shift->next::method(@_);
19 $self->disable_sth_caching(1);
20 $self->_identity_method('@@IDENTITY');
23 sub _fetch_identity_sql { 'SELECT ' . $_[0]->_identity_method }
25 my $number = sub { Scalar::Util::looks_like_number($_[0]) };
27 my $decimal = sub { $_[0] =~ /^ [-+]? \d+ (?:\.\d*)? \z/x };
30 int => sub { $_[0] =~ /^ [-+]? \d+ \z/x },
31 bit => => sub { $_[0] =~ /^[01]\z/ },
32 money => sub { $_[0] =~ /^\$ \d+ (?:\.\d*)? \z/x },
40 sub interpolate_unquoted {
42 my ($type, $value) = @_;
44 return $self->next::method(@_) if not defined $value or not defined $type;
46 if (my $key = List::Util::first { $type =~ /$_/i } keys %noquote) {
47 return 1 if $noquote{$key}->($value);
49 elsif ($self->is_datatype_numeric($type) && $number->($value)) {
53 return $self->next::method(@_);
56 sub _prep_interpolated_value {
57 my ($self, $type, $value) = @_;
59 if ($type =~ /money/i && defined $value) {
60 # change a ^ not followed by \$ to a \$
61 $value =~ s/^ (?! \$) /\$/x;
71 DBIx::Class::Storage::DBI::Sybase::NoBindVars - Storage::DBI subclass for Sybase
72 without placeholder support
76 If you're using this driver than your version of Sybase, or the libraries you
77 use to connect to it, do not support placeholders.
79 You can also enable this driver explicitly using:
81 my $schema = SchemaClass->clone;
82 $schema->storage_type('::DBI::Sybase::NoBindVars');
83 $schema->connect($dsn, $user, $pass, \%opts);
85 See the discussion in L<< DBD::Sybase/Using ? Placeholders & bind parameters to
86 $sth->execute >> for details on the pros and cons of using placeholders.
88 One advantage of not using placeholders is that C<select @@identity> will work
89 for obtainging the last insert id of an C<IDENTITY> column, instead of having to
90 do C<select max(col)> in a transaction as the base Sybase driver does.
92 When using this driver, bind variables will be interpolated (properly quoted of
93 course) into the SQL query itself, without using placeholders.
95 The caching of prepared statements is also explicitly disabled, as the
96 interpolation renders it useless.
100 See L<DBIx::Class/CONTRIBUTORS>.
104 You may distribute this code under the same terms as Perl itself.