Skip to content

Commit

Permalink
Passing a hashref as bind value in insert() does not blow up, but pas…
Browse files Browse the repository at this point in the history
…ses the hashref through (like older SQLA versions did) and emits a warning. Later to be changed to die (with a helpful message).
  • Loading branch information
mendel committed Jan 30, 2009
1 parent 1496d4c commit 5db47f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/SQL/Abstract.pm
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions t/01generate.t
Expand Up @@ -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}],
},
);


Expand Down

0 comments on commit 5db47f9

Please sign in to comment.