Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
more tests and examples
  • Loading branch information
kraih committed Jan 28, 2018
1 parent 75e4248 commit 13ac0fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/SQL/Abstract/Pg.pm
Expand Up @@ -242,6 +242,9 @@ for.
# "select * from foo join bar on (bar.foo_id = foo.id)"
$abstract->select(['foo', ['bar', foo_id => 'id']]);
# "select * from a join b on (b.a_id = a.id) join c on (c.a_id = a.id)"
$abstract->select(['a', ['b', a_id => 'id'], ['c', a_id => 'id']]);
# "select * from foo left join bar on (bar.foo_id = foo.id)"
$abstract->select(['foo', [-left => 'bar', foo_id => 'id']]);
Expand Down
8 changes: 8 additions & 0 deletions t/sql.t
Expand Up @@ -118,6 +118,14 @@ is_deeply \@sql, $result, 'right query';
is_deeply \@sql,
['SELECT * FROM "foo" LEFT JOIN "bar" ON ("bar"."foo_id" = "foo"."id")'],
'right query';
@sql = $abstract->select(['foo', [-right => 'bar', foo_id => 'id']]);
is_deeply \@sql,
['SELECT * FROM "foo" RIGHT JOIN "bar" ON ("bar"."foo_id" = "foo"."id")'],
'right query';
@sql = $abstract->select(['foo', [-inner => 'bar', foo_id => 'id']]);
is_deeply \@sql,
['SELECT * FROM "foo" INNER JOIN "bar" ON ("bar"."foo_id" = "foo"."id")'],
'right query';

# JOIN (unsupported value)
eval { $abstract->select(['foo', []]) };
Expand Down

0 comments on commit 13ac0fa

Please sign in to comment.