4 use SQL::Abstract::Test import => [ qw(is_same_sql_bind) ];
5 use SQL::Abstract::ExtraClauses;
7 my $sqlac = SQL::Abstract::ExtraClauses->new;
9 my ($sql, @bind) = $sqlac->select({
10 select => [ qw(artist.id artist.name), { -func => [ json_agg => 'cd' ] } ],
12 artist => -join => [ cd => on => { 'cd.artist_id' => 'artist.id' } ],
14 where => { 'artist.genres', => { '@>', { -value => [ 'Rock' ] } } },
15 order_by => 'artist.name',
16 group_by => 'artist.id',
17 having => { '>' => [ { -func => [ count => 'cd.id' ] }, 3 ] }
23 SELECT artist.id, artist.name, JSON_AGG(cd)
24 FROM artist JOIN cd ON cd.artist_id = artist.id
25 WHERE artist.genres @> ?
28 HAVING COUNT(cd.id) > ?