[Bast-commits] r6723 - in DBIx-Class/0.08/branches/sybase:
lib/DBIx/Class/Storage/DBI lib/DBIx/Class/Storage/DBI/Sybase t
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Fri Jun 19 15:12:21 GMT 2009
Author: caelum
Date: 2009-06-19 15:12:20 +0000 (Fri, 19 Jun 2009)
New Revision: 6723
Modified:
DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/NoBindVars.pm
DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm
DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm
DBIx-Class/0.08/branches/sybase/t/746sybase.t
Log:
cleanups
Modified: DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/NoBindVars.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/NoBindVars.pm 2009-06-19 14:36:54 UTC (rev 6722)
+++ DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/NoBindVars.pm 2009-06-19 15:12:20 UTC (rev 6723)
@@ -55,8 +55,11 @@
foreach my $bound (@$bind) {
my $col = shift @$bound;
- my $name_sep = $self->_sql_maker_opts->{name_sep} || '.';
+ my $name_sep = $self->_sql_maker_opts->{name_sep} || '.';
+ my $quote_char = $self->_sql_maker_opts->{quote_char} || '';
+ $quote_char = join '', @$quote_char if ref $quote_char eq 'ARRAY';
+ $col =~ s/[\Q${quote_char}\E]//g if $quote_char;
$col =~ s/^([^\Q${name_sep}\E]*)\Q${name_sep}\E//;
my $alias = $1 || 'me';
@@ -65,10 +68,10 @@
my $datatype = $rsrc && $rsrc->column_info($col)->{data_type};
foreach my $data (@$bound) {
- if(ref $data) {
- $data = ''.$data;
- }
- $data = $self->_dbh->quote($data) if $self->should_quote_data_type($datatype, $data);
+ $data = ''.$data if ref $data;
+
+ $data = $self->_dbh->quote($data) if $self->should_quote($datatype, $data);
+
$new_sql .= shift(@sql_part) . $data;
}
}
@@ -77,7 +80,7 @@
return ($new_sql, []);
}
-=head2 should_quote_data_type
+=head2 should_quote
This method is called by L</_prep_for_execute> for every column in
order to determine if its value should be quoted or not. The arguments
@@ -94,7 +97,7 @@
=cut
-sub should_quote_data_type { 1 }
+sub should_quote { 1 }
=head1 AUTHORS
Modified: DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm 2009-06-19 14:36:54 UTC (rev 6722)
+++ DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm 2009-06-19 15:12:20 UTC (rev 6723)
@@ -31,7 +31,7 @@
numeric => $decimal,
);
-sub should_quote_data_type {
+sub should_quote {
my $self = shift;
my ($type, $value) = @_;
Modified: DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm 2009-06-19 14:36:54 UTC (rev 6722)
+++ DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm 2009-06-19 15:12:20 UTC (rev 6723)
@@ -52,6 +52,8 @@
Does C<< $dbh->{syb_binary_images} = 1; >> to return C<IMAGE> data as raw binary
instead of as a hex string.
+Recommended.
+
=cut
sub connect_call_blob_setup {
@@ -100,6 +102,8 @@
}
}
+sub datetime_parser_type { "DateTime::Format::Sybase" }
+
sub _dbh_last_insert_id {
my ($self, $dbh, $source, $col) = @_;
@@ -108,6 +112,15 @@
return ($dbh->selectrow_array($sth))[0];
}
+=head2 count
+
+Counts for limited queries are emulated by executing select queries and
+returning the number of successful executions minus the offset.
+
+This is necessary due to the limitations of Sybase.
+
+=cut
+
sub count {
my $self = shift;
my ($source, $attrs) = @_;
@@ -137,8 +150,6 @@
return $count - $offset;
}
-sub datetime_parser_type { "DateTime::Format::Sybase" }
-
1;
=head1 NAME
@@ -162,16 +173,25 @@
But your queries will be cached.
+A recommended L<DBIx::Class::Storage::DBI/connect_info> setting:
+
+ on_connect_call => [qw/datetime_setup blob_setup/]
+
=head1 DATES
See L</connect_call_datetime_setup> to setup date formats
for L<DBIx::Class::InflateColumn::DateTime>.
-=head1 IMAGE COLUMNS
+=head1 IMAGE AND TEXT COLUMNS
See L</connect_call_blob_setup> for a L<DBIx::Class::Storage::DBI/connect_info>
setting you need to work with C<IMAGE> columns.
+Due to limitations in L<DBD::Sybase> and this driver, it is only possible to
+select one C<TEXT> or C<IMAGE> column at a time, and it must be at the end of
+your C<select> list (one way to insure that is to define the column last in your
+C<Result> class.)
+
=head1 AUTHORS
See L<DBIx::Class/CONTRIBUTORS>.
Modified: DBIx-Class/0.08/branches/sybase/t/746sybase.t
===================================================================
--- DBIx-Class/0.08/branches/sybase/t/746sybase.t 2009-06-19 14:36:54 UTC (rev 6722)
+++ DBIx-Class/0.08/branches/sybase/t/746sybase.t 2009-06-19 15:12:20 UTC (rev 6723)
@@ -136,7 +136,7 @@
is( $row->updated_date, $dt, 'DateTime inflation works' );
}
-# stole the blob stuff Nniuq wrote for 73oracle.t
+# mostly stole the blob stuff Nniuq wrote for t/73oracle.t
my $dbh = $schema->storage->dbh;
{
local $SIG{__WARN__} = sub {};
@@ -164,17 +164,18 @@
my $id = 0;
TODO: {
- local $TODO = 'text/image columns don\'t work yet';
+ local $TODO = 'TEXT/IMAGE columns don\'t work yet';
- foreach my $type (qw(clob blob)) {
+ foreach my $type (qw(blob clob)) {
foreach my $size (qw(small large)) {
no warnings 'uninitialized';
$id++;
- lives_ok { $rs->create( { 'id' => $id, $type => $binstr{$size} } ) }
- "inserted $size $type without dying";
- ok(eval { $rs->find($id)->$type } eq $binstr{$size},
- "verified inserted $size $type" );
+ eval { $rs->create( { 'id' => $id, $type => $binstr{$size} } ) };
+ ok(!$@, "inserted $size $type without dying");
+ ok(eval {
+ $rs->search({ id=> $id }, { select => [$type] })->single->$type
+ } eq $binstr{$size}, "verified inserted $size $type" );
}
}
}
More information about the Bast-commits
mailing list