1 package DBIx::Class::Storage::DBI::Sybase::NoBindVars;
5 DBIx::Class::Storage::DBI::NoBindVars
6 DBIx::Class::Storage::DBI::Sybase
13 $self->disable_sth_caching(1);
14 $self->unsafe_insert(1); # there is nothing unsafe as the
15 # last_insert_id mechanism is different
19 # this works when NOT using placeholders
20 sub _fetch_identity_sql { 'SELECT @@IDENTITY' }
22 my $number = sub { Scalar::Util::looks_like_number($_[0]) };
24 my $decimal = sub { $_[0] =~ /^ [-+]? \d+ (?:\.\d*)? \z/x };
27 int => sub { $_[0] =~ /^ [-+]? \d+ \z/x },
28 bit => => sub { $_[0] =~ /^[01]\z/ },
29 money => sub { $_[0] =~ /^\$ \d+ (?:\.\d*)? \z/x },
37 sub interpolate_unquoted {
39 my ($type, $value) = @_;
41 return $self->next::method(@_) if not defined $value or not defined $type;
43 if (my $key = List::Util::first { $type =~ /$_/i } keys %noquote) {
44 return 1 if $noquote{$key}->($value);
46 elsif ($self->is_datatype_numeric($type) && $number->($value)) {
50 return $self->next::method(@_);
53 sub _prep_interpolated_value {
54 my ($self, $type, $value) = @_;
56 if ($type =~ /money/i && defined $value) {
57 # change a ^ not followed by \$ to a \$
58 $value =~ s/^ (?! \$) /\$/x;
68 DBIx::Class::Storage::DBI::Sybase::NoBindVars - Storage::DBI subclass for Sybase
69 without placeholder support
73 If you're using this driver than your version of Sybase, or the libraries you
74 use to connect to it, do not support placeholders.
76 You can also enable this driver explicitly using:
78 my $schema = SchemaClass->clone;
79 $schema->storage_type('::DBI::Sybase::NoBindVars');
80 $schema->connect($dsn, $user, $pass, \%opts);
82 See the discussion in L<< DBD::Sybase/Using ? Placeholders & bind parameters to
83 $sth->execute >> for details on the pros and cons of using placeholders.
85 One advantage of not using placeholders is that C<select @@identity> will work
86 for obtainging the last insert id of an C<IDENTITY> column, instead of having to
87 do C<select max(col)> in a transaction as the base Sybase driver does.
89 When using this driver, bind variables will be interpolated (properly quoted of
90 course) into the SQL query itself, without using placeholders.
92 The caching of prepared statements is also explicitly disabled, as the
93 interpolation renders it useless.
97 See L<DBIx::Class/CONTRIBUTORS>.
101 You may distribute this code under the same terms as Perl itself.