From: Norbert Buchmuller Date: Tue, 11 Nov 2008 22:27:47 +0000 (+0000) Subject: Changed behaviour to not stringify blessed objects, but pass them through to the... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ba566dc378d0c4c7dac535acc986e9ded83f2e19;p=scpubgit%2FQ-Branch.git Changed behaviour to not stringify blessed objects, but pass them through to the bind data structure untouched. --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 92d52ad..8034548 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -874,11 +874,11 @@ sub _refkind { # $suffix = 'REF' x (length of ref chain, i. e. \\[] is REFREFREF) while (1) { + # blessed references are considered like scalars + last if blessed $data; $suffix .= 'REF'; + $ref = ref $data; - # blessed references that can stringify are considered like scalars - $ref = (blessed $data && overload::Method($data, '""')) ? '' - : ref $data; last if $ref ne 'REF'; $data = $$data; } diff --git a/t/02where.t b/t/02where.t index b47fdf9..60cbf84 100644 --- a/t/02where.t +++ b/t/02where.t @@ -6,13 +6,15 @@ use Test::More; use Test::Exception; use SQL::Abstract::Test import => ['is_same_sql_bind']; -plan tests => 17; +plan tests => 18; use SQL::Abstract; # Make sure to test the examples, since having them break is somewhat # embarrassing. :-( +my $not_stringifiable = SQLA::NotStringifiable->new(); + my @handle_tests = ( { where => { @@ -188,6 +190,12 @@ my @handle_tests = ( bind => [ 'The Life, the Universe and Everything.' ], }, + { + where => { foo => $not_stringifiable, }, + stmt => " WHERE ( foo = ? )", + bind => [ $not_stringifiable ], + }, + ); @@ -225,3 +233,18 @@ sub to_str } 1; + + +#====================================================================== +package SQLA::NotStringifiable; # testing stringification of arguments +#====================================================================== + +use strict; +use warnings; + +sub new +{ + bless {}, shift; +} + +1;