1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
8 use DBICTest ':DiffSQL';
10 my $schema = DBICTest->init_schema(
13 storage_type => 'DBIx::Class::Storage::DBI::Pg'
16 my $rs = $schema->resultset('Artist')->search_related('cds_unordered',
21 order_by => [ 'genre.name', { -desc => \ 'tracks.title' }, { -asc => "me.name" }, { -desc => [qw(year cds_unordered.title)] } ], # me. is the artist, *NOT* the cd
27 # THIS IS AN OFFLINE TEST
28 # We only need this so that the thing can be verified to work without PG_DSN
29 # Executing it while "lying" this way won't work
30 local $rs->result_source->related_source('tracks')->column_info('title')->{data_type} = 'bool';
31 local $rs->result_source->related_source('genre')->column_info('name')->{data_type} = 'BOOLEAN';
36 SELECT "cds_unordered"."cdid", "cds_unordered"."artist", "cds_unordered"."title", "cds_unordered"."year", "cds_unordered"."genreid", "cds_unordered"."single_track",
37 "tracks"."trackid", "tracks"."cd", "tracks"."position", "tracks"."title", "tracks"."last_updated_on", "tracks"."last_updated_at"
40 SELECT "cds_unordered"."cdid", "cds_unordered"."artist", "cds_unordered"."title", "cds_unordered"."year", "cds_unordered"."genreid", "cds_unordered"."single_track"
42 JOIN cd "cds_unordered"
43 ON "cds_unordered"."artist" = "me"."artistid"
44 LEFT JOIN "genre" "genre"
45 ON "genre"."genreid" = "cds_unordered"."genreid"
46 LEFT JOIN "track" "tracks"
47 ON "tracks"."cd" = "cds_unordered"."cdid"
49 GROUP BY "cds_unordered"."cdid", "cds_unordered"."artist", "cds_unordered"."title", "cds_unordered"."year", "cds_unordered"."genreid", "cds_unordered"."single_track", "me"."name"
50 ORDER BY BOOL_AND("genre"."name"),
51 BOOL_OR( tracks.title ) DESC,
54 "cds_unordered"."title" DESC
57 ON "cds_unordered"."artist" = "me"."artistid"
58 LEFT JOIN "genre" "genre"
59 ON "genre"."genreid" = "cds_unordered"."genreid"
60 LEFT JOIN "track" "tracks"
61 ON "tracks"."cd" = "cds_unordered"."cdid"
63 ORDER BY "genre"."name",
67 "cds_unordered"."title" DESC
70 [ { sqlt_datatype => 'integer', dbic_colname => 'me.rank' } => 13 ],
71 [ DBIx::Class::SQLMaker::LimitDialects->__rows_bindtype => 1 ],
72 [ { sqlt_datatype => 'integer', dbic_colname => 'me.rank' } => 13 ],
74 'correct SQL with aggregate boolean order on Pg',