},
);
- $schema->storage->debug (1);
- diag "\n";
- my @names = map { $_->name } ($owners->all);
- my @subq_names = map { $_->name } ($sealed_owners->all);
-
is_deeply (
- \@names,
- \@subq_names,
- 'Sort preserved from within a subquery'
- ) || diag do { require Data::Dumper::Concise; Data::Dumper::Concise::Dumper (\@names, \@subq_names) };
- $schema->storage->debug (0);
-
+ [ map { $_->name } ($sealed_owners->all) ],
+ [ map { $_->name } ($owners->all) ],
+ 'Sort preserved from within a subquery',
+ );
+}
+TODO: {
+ local $TODO = "This porbably will never work, but it isn't critical either afaik";
my $book_owner_ids = $schema->resultset ('BooksInLibrary')
->search ({}, { join => 'owner', distinct => 1, order_by => 'owner.name' })
id => { -in => $book_owner_ids->as_query }
});
- is ($book_owners->count, 8, 'Correct amount of book owners');
-
is_deeply (
[ map { $_->id } ($book_owners->all) ],
[ $book_owner_ids->all ],
is ($books->page(2)->count_rs->next, 1, 'Prefetched grouped search returns correct count_rs');
}
-
-
-# Just to aid bug-hunting, delete block before merging
-{
-
- my $limited_rs = $schema->resultset ('BooksInLibrary')->search (
- {
- 'owner.name' => { '!=', 'woggle' },
- },
- {
- prefetch => 'owner',
- order_by => 'owner.name',
- rows => 7,
- offset => 2,
- }
- );
-
-
-=begin
-
-Alan's SQL:
-
- SELECT me.id, me.surveyor_id, me.survey_site_id, me.year, surveyor.id, surveyor.name, surveyor.email, surveyor.phone, surveyor.login, surveyor.password, surveyor.is_active, surveyor.is_verifier, surveyor.arm_length, surveyor.eye_height, surveyor.year_joined
- FROM (
- SELECT *
- FROM (
- SELECT orig_query.*, ROW_NUMBER() OVER( ORDER BY (SELECT(1)) ) AS rno__row__index
- FROM (
- SELECT me.id, me.surveyor_id, me.survey_site_id, me.year
- FROM (
- SELECT TOP 100 PERCENT me.id, me.surveyor_id, me.survey_site_id, me.year
- FROM surveyors_survey_sites me
- JOIN surveyors surveyor ON surveyor.id = me.surveyor_id
- ORDER BY surveyor.name
- ) me
- ) orig_query
- ) rno_subq
- WHERE rno__row__index BETWEEN 136 AND 150
- ) me
- JOIN surveyors surveyor ON surveyor.id = me.surveyor_id
- ORDER BY surveyor.name
-=cut
-
- is_same_sql_bind (
- $limited_rs->as_query,
- '(
- SELECT TOP 100 PERCENT [me].[id], [me].[source], [me].[owner], [me].[title], [me].[price], [owner].[id], [owner].[name]
- FROM (
- SELECT *
- FROM (
- SELECT [me].*, ROW_NUMBER() OVER( ORDER BY (SELECT(1)) ) AS rno__row__index
- FROM (
- SELECT [me].[id], [me].[source], [me].[owner], [me].[title], [me].[price]
- FROM (
- SELECT TOP 100 PERCENT [me].[id], [me].[source], [me].[owner], [me].[title], [me].[price]
- FROM [books] [me]
- JOIN [owners] [owner] ON [owner].[id] = [me].[owner]
- WHERE ( ( [owner].[name] != ? AND [source] = ? ) )
- ORDER BY [owner].[name]
- ) [me]
- ) [me]
- ) rno_subq
- WHERE rno__row__index BETWEEN 3 AND 9
- ) [me]
- JOIN [owners] [owner] ON [owner].[id] = [me].[owner]
- WHERE ( ( [owner].[name] != ? AND [source] = ? ) )
- ORDER BY [owner].[name]
- )',
- [ ([ 'owner.name' => 'woggle' ], [ source => 'Library' ]) x 2 ],
- 'Expected SQL executed',
- );
-}
-
done_testing;
# clean up our mess