From: Rafael Kitover Date: Fri, 19 Jun 2009 15:12:20 +0000 (+0000) Subject: cleanups X-Git-Tag: v0.08112~14^2~124 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6636ad53c7480e9546c2a0a3ecaa5a807874c819;p=dbsrgits%2FDBIx-Class.git cleanups --- diff --git a/lib/DBIx/Class/Storage/DBI/NoBindVars.pm b/lib/DBIx/Class/Storage/DBI/NoBindVars.pm index 3256846..637e411 100644 --- a/lib/DBIx/Class/Storage/DBI/NoBindVars.pm +++ b/lib/DBIx/Class/Storage/DBI/NoBindVars.pm @@ -55,8 +55,11 @@ sub _prep_for_execute { 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 @@ sub _prep_for_execute { 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 @@ sub _prep_for_execute { return ($new_sql, []); } -=head2 should_quote_data_type +=head2 should_quote This method is called by L for every column in order to determine if its value should be quoted or not. The arguments @@ -94,7 +97,7 @@ columns). The default method always returns true (do quote). =cut -sub should_quote_data_type { 1 } +sub should_quote { 1 } =head1 AUTHORS diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 9cfc047..f754cea 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -52,6 +52,8 @@ Used as: Does C<< $dbh->{syb_binary_images} = 1; >> to return C data as raw binary instead of as a hex string. +Recommended. + =cut sub connect_call_blob_setup { @@ -100,6 +102,8 @@ C columns only have minute precision. } } +sub datetime_parser_type { "DateTime::Format::Sybase" } + sub _dbh_last_insert_id { my ($self, $dbh, $source, $col) = @_; @@ -108,6 +112,15 @@ sub _dbh_last_insert_id { 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 @@ sub count { return $count - $offset; } -sub datetime_parser_type { "DateTime::Format::Sybase" } - 1; =head1 NAME @@ -162,16 +173,25 @@ without doing a C list (one way to insure that is to define the column last in your +C class.) + =head1 AUTHORS See L. diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm b/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm index d0fea5e..8f80c3d 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm @@ -31,7 +31,7 @@ my %noquote = ( numeric => $decimal, ); -sub should_quote_data_type { +sub should_quote { my $self = shift; my ($type, $value) = @_; diff --git a/t/746sybase.t b/t/746sybase.t index e27b658..5b25b06 100644 --- a/t/746sybase.t +++ b/t/746sybase.t @@ -136,7 +136,7 @@ SQL 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 @@ SQL 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" ); } } }