From: Rafael Kitover Date: Sat, 6 Jun 2009 03:36:03 +0000 (+0000) Subject: temporary sybase noquote hack X-Git-Tag: v0.08112~14^2~143 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8242035e7f824106e902a7667d0e82c4ec442b0b;p=dbsrgits%2FDBIx-Class.git temporary sybase noquote hack --- diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm b/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm index 4ebb8cf..f3a46f6 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm @@ -37,9 +37,14 @@ sub should_quote_data_type { return $self->next::method(@_) if not defined $value; - if (my $key = List::Util::first { $type =~ /$_/i } keys %noquote) { - return 0 if $noquote{$key}->($value); - } +## this is the correct method, but we have no type yet +# if (my $key = List::Util::first { $type =~ /$_/i } keys %noquote) { +# return 0 if $noquote{$key}->($value); +# } + +# temporary hack + return 0 if Scalar::Util::looks_like_number($value) || + ($value =~ /^\$(\S*)\z/ && Scalar::Util::looks_like_number($1)); return $self->next::method(@_); } diff --git a/t/746sybase.t b/t/746sybase.t index 5bc5ec8..16823ba 100644 --- a/t/746sybase.t +++ b/t/746sybase.t @@ -105,21 +105,17 @@ SQL is( $it->count, 7, 'COUNT of GROUP_BY ok' ); - SKIP: { - skip 'quoting bug with NoBindVars', 4*2 - if $storage_type eq 'DBI::Sybase::NoBindVars'; - # Test DateTime inflation with DATETIME - my @dt_types = ( - ['DATETIME', '2004-08-21T14:36:48.080Z'], - ['SMALLDATETIME', '2004-08-21T14:36:00.000Z'], # minute precision - ); - - for my $dt_type (@dt_types) { - my ($type, $sample_dt) = @$dt_type; - - eval { $schema->storage->dbh->do("DROP TABLE track") }; - $schema->storage->dbh->do(<<"SQL"); + my @dt_types = ( + ['DATETIME', '2004-08-21T14:36:48.080Z'], + ['SMALLDATETIME', '2004-08-21T14:36:00.000Z'], # minute precision + ); + + for my $dt_type (@dt_types) { + my ($type, $sample_dt) = @$dt_type; + + eval { $schema->storage->dbh->do("DROP TABLE track") }; + $schema->storage->dbh->do(<<"SQL"); CREATE TABLE track ( trackid INT IDENTITY PRIMARY KEY, cd INT, @@ -127,20 +123,19 @@ CREATE TABLE track ( last_updated_on $type, ) SQL - ok(my $dt = DBIx::Class::Storage::DBI::Sybase::DateTime - ->parse_datetime($sample_dt)); - - my $row; - ok( $row = $schema->resultset('Track')->create({ - last_updated_on => $dt, - cd => 1, - })); - ok( $row = $schema->resultset('Track') - ->search({ trackid => $row->trackid }, { select => ['last_updated_on'] }) - ->first - ); - is( $row->updated_date, $dt, 'DateTime inflation works' ); - } + ok(my $dt = DBIx::Class::Storage::DBI::Sybase::DateTime + ->parse_datetime($sample_dt)); + + my $row; + ok( $row = $schema->resultset('Track')->create({ + last_updated_on => $dt, + cd => 1, + })); + ok( $row = $schema->resultset('Track') + ->search({ trackid => $row->trackid }, { select => ['last_updated_on'] }) + ->first + ); + is( $row->updated_date, $dt, 'DateTime inflation works' ); } }