9 use DBIC::SqlMakerTest;
10 use Data::Query::ExprDeclare;
11 use Data::Query::ExprHelpers;
13 my $schema = DBICTest->init_schema();
15 $schema->source($_)->resultset_class('DBIx::Class::ResultSet::WithDQMethods')
18 my $cds = $schema->resultset('CD');
21 $cds->_remap_identifiers(Identifier('name'))
22 } qr/Invalid name on me: name/;
25 [ $cds->_remap_identifiers(Identifier('title')) ],
26 [ Identifier('me', 'title'), [] ],
31 $cds->_remap_identifiers(Identifier('artist'))
32 } qr/Invalid name on me: artist is a relationship/;
35 [ $cds->_remap_identifiers(Identifier('artist', 'name')) ],
36 [ Identifier('artist', 'name'), [ { artist => {} } ] ],
41 [ $cds->search({}, { join => { single_track => { cd => 'artist' } } })
42 ->_remap_identifiers(Identifier('artist', 'name')) ],
43 [ Identifier('artist_2', 'name'), [ { artist => {} } ] ],
44 'Remap column on rel with re-alias'
48 [ $cds->_remap_identifiers(Identifier('artist_id')) ],
49 [ Identifier('me', 'artist'), [] ],
50 'Remap column w/column name rename'
53 my $double_name = expr { $_->artist->name == $_->artist->name }->{expr};
56 [ $cds->_remap_identifiers($double_name) ],
57 [ $double_name, [ { artist => {} } ] ],
58 'Remap column on rel only adds rel once'