Skip to content

Commit

Permalink
Merge pull request #1 from spechenin/prc
Browse files Browse the repository at this point in the history
fix sql_obj() incorrent @Bind
  • Loading branch information
nekokak committed Feb 19, 2015
2 parents 6ef6d09 + 88318a5 commit f90dd6c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 7 additions & 1 deletion lib/SQL/Object.pm
Expand Up @@ -34,8 +34,14 @@ sub sql_obj {
}
}ge;
}
elsif (ref($args) eq 'ARRAY') {
$bind = $args;
}
elsif (defined($args)) {
$bind = [$args];
}
else {
$bind = ref($args) eq 'ARRAY' ? $args : [$args];
$bind = [];
}

SQL::Object->new(sql => $sql, bind => $bind);
Expand Down
4 changes: 1 addition & 3 deletions t/01_basic.t
Expand Up @@ -26,11 +26,9 @@ subtest 'basic' => sub {
is $sql->as_sql, '(((foo.id=? AND bar.name=?) OR bar.age=?) OR (foo.id=?)) OR (bar.name=?)';
is_deeply [$sql->bind], [qw/1 nekokak 33 2 tokuhirom/];

is $sql->as_sql , '(((foo.id=? AND bar.name=?) OR bar.age=?) OR (foo.id=?)) OR (bar.name=?)';

$sql = sql_obj('SELECT * FROM user WHERE ') + $sql;

is $sql->as_sql , 'SELECT * FROM user WHERE (((foo.id=? AND bar.name=?) OR bar.age=?) OR (foo.id=?)) OR (bar.name=?)';
is_deeply [$sql->bind], [qw/1 nekokak 33 2 tokuhirom/];
};

subtest 'sql_type' => sub {
Expand Down

0 comments on commit f90dd6c

Please sign in to comment.