From: Norbert Buchmuller Date: Fri, 30 Jan 2009 20:22:09 +0000 (+0000) Subject: Passing a hashref as bind value in insert() does not blow up, but passes the hashref... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5db47f9fe6d06048b35092378a04e3a292d03a19;p=scpubgit%2FQ-Branch.git Passing a hashref as bind value in insert() does not blow up, but passes the hashref through (like older SQLA versions did) and emits a warning. Later to be changed to die (with a helpful message). --- diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index 22594ce..6fb68e9 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -161,6 +161,12 @@ sub _insert_ARRAYREF { # just generate values(?,?) part (no list of fields) }, # THINK : anything useful to do with a HASHREF ? + HASHREF => sub { # (nothing, but old SQLA passed it through) + #TODO in SQLA >= 2.0 it will die instead + belch "HASH ref as bind value in insert is not supported"; + push @values, '?'; + push @all_bind, $v; + }, SCALARREF => sub { # literal SQL without bind push @values, $$v; diff --git a/t/01generate.t b/t/01generate.t index 419d3e4..319f1a9 100644 --- a/t/01generate.t +++ b/t/01generate.t @@ -360,6 +360,14 @@ my @tests = ( stmt_q => 'SELECT * FROM `test` WHERE ( `a` < to_date(?, \'MM/DD/YY\') AND `b` = ? )', bind => ['02/02/02', 8], }, + #39 + { #TODO in SQLA >= 2.0 it will die instead (we kept this just because old SQLA passed it through) + func => 'insert', + args => ['test', {a => 1, b => 2, c => 3, d => 4, e => { answer => 42 }}], + stmt => 'INSERT INTO test (a, b, c, d, e) VALUES (?, ?, ?, ?, ?)', + stmt_q => 'INSERT INTO `test` (`a`, `b`, `c`, `d`, `e`) VALUES (?, ?, ?, ?, ?)', + bind => [qw/1 2 3 4/, { answer => 42}], + }, );