Standardize the struct-cloning interface throughout the codebase
[dbsrgits/DBIx-Class.git] / t / search / empty_attrs.t
CommitLineData
d16df239 1use strict;
2use warnings;
3
4use Test::More;
5
6use lib qw(t/lib);
7use DBICTest ':DiffSQL';
8
9my $schema = DBICTest->init_schema();
10
11my $rs = $schema->resultset('Artist')->search(
12 [ -and => [ {}, [] ], -or => [ {}, [] ] ],
13 {
14 select => [],
15 columns => {},
16 '+columns' => 'artistid',
17 join => [ {}, [ [ {}, {} ] ], {} ],
18 prefetch => [ [ [ {}, [] ], {} ], {}, [ {} ] ],
19 order_by => [],
20 group_by => [],
21 offset => 0,
22 }
23);
24
25is_same_sql_bind(
26 $rs->as_query,
27 '(SELECT me.artistid FROM artist me)',
28 [],
29);
30
31is_same_sql_bind(
32 $rs->count_rs->as_query,
33 '(SELECT COUNT(*) FROM artist me)',
34 [],
35);
36
37is_same_sql_bind(
38 $rs->as_subselect_rs->search({}, { columns => 'artistid' })->as_query,
39 '(SELECT me.artistid FROM (SELECT me.artistid FROM artist me) me)',
40 [],
41);
42
43{
44 local $TODO = 'Stupid misdesigned as_subselect_rs';
45 is_same_sql_bind(
46 $rs->as_subselect_rs->as_query,
47 $rs->as_subselect_rs->search({}, { columns => 'artistid' })->as_query,
48 );
49}
50
51done_testing;