4 use Test::More tests => 5;
7 use_ok('SQL::Abstract') or BAIL_OUT( "$@" );
9 my $sqla = SQL::Abstract->create(1);
13 ident => {-type => 'identifier', elements => [qw/foo/]},
16 my $me_foo_id = { -type => 'identifier', elements => [qw/me foo_id/] };
20 tablespec => $foo_as_me,
22 { -type => 'identifier', elements => [qw/me id/] },
23 { -type => 'alias', ident => $me_foo_id, as => 'foo' },
26 ), "SELECT me.id, me.foo_id AS foo FROM foo AS me",
27 "simple select clause";
32 { -type => 'identifier', elements => [qw/me id/] },
33 { -type => 'alias', ident => $me_foo_id, as => 'foo' },
34 { -type => 'identifier', elements => [qw/bar name/] },
39 rhs => {-type => 'identifier', elements => [qw/bar/] },
44 {-type => 'identifier', elements => [qw/bar id/]},
45 {-type => 'identifier', elements => [qw/me bar_id/]}
52 ), "SELECT me.id, me.foo_id AS foo, bar.name FROM foo AS me JOIN bar ON (bar.id = me.bar_id)",
53 "select with join clause";
59 { -type => 'identifier', elements => [qw/me */] },
61 tablespec => $foo_as_me,
66 {-type => 'identifier', elements => [qw/me id/]},
67 {-type => 'value', value => 1 },
73 ), "SELECT me.* FROM foo AS me WHERE me.id = ?",
79 tablespec => $foo_as_me,
81 { -type => 'identifier', elements => [qw/me id/] },
82 { -type => 'alias', ident => $me_foo_id, as => 'foo' },
85 { -type => 'ordering', expr => { -type => 'identifier', elements => [qw/me name/] }, direction => 'desc' },
89 ), "SELECT me.id, me.foo_id AS foo FROM foo AS me ORDER BY me.name DESC, me.foo_id",
90 "select clause with order by";