From: Peter Rabbitson Date: Wed, 27 Jul 2011 15:37:44 +0000 (+0200) Subject: Fix oracle (I am so stupid) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e12571af7ad4e36930a77e2e67ca6f0e4e64ad92;p=dbsrgits%2FDBIx-Class-Historic.git Fix oracle (I am so stupid) --- diff --git a/Changes b/Changes index a808b1f..b87ec9c 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for DBIx::Class + * Fixes + - Fix horrible oversight in the Oracle sqlmaker when dealing with + queries updating blobs (RT#69829) + 0.08194 2011-07-20 16:10 (UTC) * Fixes - Fix $rs->populate([]) to be a no-op rather than an exception diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index cfefc77..f582b94 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -515,7 +515,8 @@ sub _prep_for_execute { $self->throw_exception('Update with complex WHERE clauses currently not supported') if $sql =~ /\bWHERE\b .+ \bWHERE\b/xs; - ($final_sql, $sql) = $sql =~ /^ (.+?) ( \bWHERE\b .+) /xs; + my $where_sql; + ($final_sql, $where_sql) = $sql =~ /^ (.+?) ( \bWHERE\b .+) /xs; if (my $set_bind_count = $final_sql =~ y/?//) { @@ -530,6 +531,10 @@ sub _prep_for_execute { keys %$lob_bind_indices }; } + + # if we got that far - assume the where SQL is all we got + # (the first part is already shoved into $final_sql) + $sql = $where_sql; } elsif ($op ne 'select' and $op ne 'delete') { $self->throw_exception("Unsupported \$op: $op"); diff --git a/t/73oracle.t b/t/73oracle.t index 8ac87ee..907c278 100644 --- a/t/73oracle.t +++ b/t/73oracle.t @@ -449,7 +449,7 @@ sub _run_tests { lives_ok { $rs->search({ id => $id, blob => "blob:$str", clob => "clob:$str" }) ->update({ blob => 'updated blob', clob => 'updated clob' }); - } 'blob UPDATE with WHERE clause survived'; + } 'blob UPDATE with blobs in WHERE clause survived'; @objs = $rs->search({ blob => "updated blob", clob => 'updated clob' })->all; is @objs, 1, 'found updated row'; @@ -457,10 +457,20 @@ sub _run_tests { ok (try { $objs[0]->clob }||'' eq "updated clob", 'clob updated/retrieved correctly'); lives_ok { - $rs->search({ blob => "updated blob", clob => "updated clob" }) + $rs->search({ id => $id }) + ->update({ blob => 're-updated blob', clob => 're-updated clob' }); + } 'blob UPDATE without blobs in WHERE clause survived'; + + @objs = $rs->search({ blob => 're-updated blob', clob => 're-updated clob' })->all; + is @objs, 1, 'found updated row'; + ok (try { $objs[0]->blob }||'' eq 're-updated blob', 'blob updated/retrieved correctly'); + ok (try { $objs[0]->clob }||'' eq 're-updated clob', 'clob updated/retrieved correctly'); + + lives_ok { + $rs->search({ blob => "re-updated blob", clob => "re-updated clob" }) ->delete; } 'blob DELETE with WHERE clause survived'; - @objs = $rs->search({ blob => "updated blob", clob => 'updated clob' })->all; + @objs = $rs->search({ blob => "re-updated blob", clob => 're-updated clob' })->all; is @objs, 0, 'row deleted successfully'; }