Imported Upstream version 0.566
Xavier Guimard
11 years ago
4 | 4 | my $builder = Module::Build->new( |
5 | 5 | module_name => 'Class::DBI::Plugin::Pager', |
6 | 6 | license => 'perl', |
7 | dist_author => 'David Baird <cpan@riverside-cms.co.uk>', | |
7 | dist_author => ['David Baird', 'Nikolay S. <majestic@cpan.org>'], | |
8 | 8 | dist_version_from => 'lib/Class/DBI/Plugin/Pager.pm', |
9 | meta_add => { | |
10 | resources => { | |
11 | repository => 'git://github.com/majesticcpan/class-dbi-plugin-pager.git', | |
12 | }, | |
13 | }, | |
9 | 14 | requires => { 'Test::More' => 0, |
10 | 15 | 'Test::Exception' => 0, |
11 | 16 | 'Test::Warn' => 0, |
12 | 17 | 'Class::DBI' => 0.90, |
13 | 'SQL::Abstract' => 0, | |
18 | 'SQL::Abstract' => 1.61, | |
14 | 19 | 'Data::Page' => 2, |
15 | 20 | 'Class::DBI::Plugin::AbstractCount' => 0, |
16 | 21 | 'Class::Data::Inheritable' => 0, |
0 | 0 | Revision history for Class-DBI-Plugin-Pager |
1 | ||
2 | 0.566 Sun September 16 16:45:00 2012 | |
3 | - code repository moved to github | |
4 | - pod changes | |
5 | ||
6 | 0.564 Mon August 16 13:36:00 2012 | |
7 | - fixed version issues | |
8 | ||
9 | 0.563 Mon August 16 03:54:00 2012 | |
10 | - maintainance release | |
11 | ||
12 | 0.562_01 Mon August 13 00:25:00 2012 | |
13 | - maintainance developer release. fixing test case that was broken because SQL::Abstract | |
14 | (patch from Ansgar Burchardt and Tim Retout) | |
15 | - SQL::Abstract 1.61 is now required | |
16 | - new co-maintainer Nikolay S. (~MAJESTIC) | |
1 | 17 | |
2 | 18 | 0.561 Sun July 31 15:10:00 2005 |
3 | 19 | - avoid bug in Class::DBI::Plugin::AbstractCount 0.04 which dies if a WHERE clause |
41 | 57 | - minor POD fixes, added LimitYX subclass |
42 | 58 | |
43 | 59 | 0.4 Fri Oct 22 00:41:07 2004 |
44 | - original version; created by h2xs 1.21 with options | |
45 | -XAn Class::DBI::Plugin::Pager | |
60 | - original version; created by h2xs 1.21 with options | |
61 | -XAn Class::DBI::Plugin::Pager |
0 | 0 | Build.PL |
1 | Makefile.PL | |
2 | 1 | Changes |
3 | MANIFEST | |
4 | META.yml | |
5 | README | |
6 | 2 | lib/Class/DBI/Plugin/Pager.pm |
7 | 3 | lib/Class/DBI/Plugin/Pager/LimitOffset.pm |
8 | 4 | lib/Class/DBI/Plugin/Pager/LimitXY.pm |
9 | 5 | lib/Class/DBI/Plugin/Pager/LimitYX.pm |
10 | 6 | lib/Class/DBI/Plugin/Pager/RowsTo.pm |
7 | MANIFEST This list of files | |
8 | README | |
11 | 9 | t/00.load.t |
12 | 10 | t/01.load_subclass.t |
13 | 11 | t/02.main.t |
15 | 13 | t/04.auto_syntax.t |
16 | 14 | t/pod-coverage.t |
17 | 15 | t/pod.t |
16 | Makefile.PL | |
17 | META.yml | |
18 | META.json |
0 | { | |
1 | "abstract" : "paged queries for CDBI", | |
2 | "author" : [ | |
3 | "David Baird", | |
4 | "Nikolay S. <majestic@cpan.org>" | |
5 | ], | |
6 | "dynamic_config" : 1, | |
7 | "generated_by" : "Module::Build version 0.4003, CPAN::Meta::Converter version 2.120921", | |
8 | "license" : [ | |
9 | "perl_5" | |
10 | ], | |
11 | "meta-spec" : { | |
12 | "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", | |
13 | "version" : "2" | |
14 | }, | |
15 | "name" : "Class-DBI-Plugin-Pager", | |
16 | "prereqs" : { | |
17 | "configure" : { | |
18 | "requires" : { | |
19 | "Module::Build" : "0.40" | |
20 | } | |
21 | }, | |
22 | "runtime" : { | |
23 | "requires" : { | |
24 | "Carp" : "0", | |
25 | "Class::DBI" : "0.9", | |
26 | "Class::DBI::Plugin::AbstractCount" : "0", | |
27 | "Class::Data::Inheritable" : "0", | |
28 | "Data::Page" : "2", | |
29 | "SQL::Abstract" : "1.61", | |
30 | "Test::Exception" : "0", | |
31 | "Test::More" : "0", | |
32 | "Test::Warn" : "0", | |
33 | "UNIVERSAL::require" : "0" | |
34 | } | |
35 | } | |
36 | }, | |
37 | "provides" : { | |
38 | "Class::DBI::Plugin::Pager" : { | |
39 | "file" : "lib/Class/DBI/Plugin/Pager.pm", | |
40 | "version" : "0.566" | |
41 | }, | |
42 | "Class::DBI::Plugin::Pager::LimitOffset" : { | |
43 | "file" : "lib/Class/DBI/Plugin/Pager/LimitOffset.pm", | |
44 | "version" : 0 | |
45 | }, | |
46 | "Class::DBI::Plugin::Pager::LimitXY" : { | |
47 | "file" : "lib/Class/DBI/Plugin/Pager/LimitXY.pm", | |
48 | "version" : 0 | |
49 | }, | |
50 | "Class::DBI::Plugin::Pager::LimitYX" : { | |
51 | "file" : "lib/Class/DBI/Plugin/Pager/LimitYX.pm", | |
52 | "version" : 0 | |
53 | }, | |
54 | "Class::DBI::Plugin::Pager::RowsTo" : { | |
55 | "file" : "lib/Class/DBI/Plugin/Pager/RowsTo.pm", | |
56 | "version" : 0 | |
57 | } | |
58 | }, | |
59 | "release_status" : "stable", | |
60 | "resources" : { | |
61 | "repository" : { | |
62 | "url" : "git://github.com/majesticcpan/class-dbi-plugin-pager.git" | |
63 | } | |
64 | }, | |
65 | "version" : "0.566" | |
66 | } |
0 | --- #YAML:1.0 | |
0 | --- | |
1 | abstract: 'paged queries for CDBI' | |
2 | author: | |
3 | - 'David Baird' | |
4 | - 'Nikolay S. <majestic@cpan.org>' | |
5 | build_requires: {} | |
6 | configure_requires: | |
7 | Module::Build: 0.40 | |
8 | dynamic_config: 1 | |
9 | generated_by: 'Module::Build version 0.4003, CPAN::Meta::Converter version 2.120921' | |
10 | license: perl | |
11 | meta-spec: | |
12 | url: http://module-build.sourceforge.net/META-spec-v1.4.html | |
13 | version: 1.4 | |
1 | 14 | name: Class-DBI-Plugin-Pager |
2 | version: 0.561 | |
3 | author: | |
4 | - David Baird <cpan@riverside-cms.co.uk> | |
5 | abstract: paged queries for CDBI | |
6 | license: perl | |
15 | provides: | |
16 | Class::DBI::Plugin::Pager: | |
17 | file: lib/Class/DBI/Plugin/Pager.pm | |
18 | version: 0.566 | |
19 | Class::DBI::Plugin::Pager::LimitOffset: | |
20 | file: lib/Class/DBI/Plugin/Pager/LimitOffset.pm | |
21 | version: 0 | |
22 | Class::DBI::Plugin::Pager::LimitXY: | |
23 | file: lib/Class/DBI/Plugin/Pager/LimitXY.pm | |
24 | version: 0 | |
25 | Class::DBI::Plugin::Pager::LimitYX: | |
26 | file: lib/Class/DBI/Plugin/Pager/LimitYX.pm | |
27 | version: 0 | |
28 | Class::DBI::Plugin::Pager::RowsTo: | |
29 | file: lib/Class/DBI/Plugin/Pager/RowsTo.pm | |
30 | version: 0 | |
7 | 31 | requires: |
8 | 32 | Carp: 0 |
9 | 33 | Class::DBI: 0.9 |
10 | 34 | Class::DBI::Plugin::AbstractCount: 0 |
11 | 35 | Class::Data::Inheritable: 0 |
12 | 36 | Data::Page: 2 |
13 | SQL::Abstract: 0 | |
37 | SQL::Abstract: 1.61 | |
14 | 38 | Test::Exception: 0 |
15 | 39 | Test::More: 0 |
16 | 40 | Test::Warn: 0 |
17 | 41 | UNIVERSAL::require: 0 |
18 | provides: | |
19 | Class::DBI::Plugin::Pager: | |
20 | file: lib/Class/DBI/Plugin/Pager.pm | |
21 | version: 0.561 | |
22 | Class::DBI::Plugin::Pager::LimitOffset: | |
23 | file: lib/Class/DBI/Plugin/Pager/LimitOffset.pm | |
24 | Class::DBI::Plugin::Pager::LimitXY: | |
25 | file: lib/Class/DBI/Plugin/Pager/LimitXY.pm | |
26 | Class::DBI::Plugin::Pager::LimitYX: | |
27 | file: lib/Class/DBI/Plugin/Pager/LimitYX.pm | |
28 | Class::DBI::Plugin::Pager::RowsTo: | |
29 | file: lib/Class/DBI/Plugin/Pager/RowsTo.pm | |
30 | generated_by: Module::Build version 0.2609 | |
42 | resources: | |
43 | repository: git://github.com/majesticcpan/class-dbi-plugin-pager.git | |
44 | version: 0.566 |
0 | # Note: this file was auto-generated by Module::Build::Compat version 0.03 | |
0 | # Note: this file was auto-generated by Module::Build::Compat version 0.4003 | |
1 | 1 | use ExtUtils::MakeMaker; |
2 | 2 | WriteMakefile |
3 | 3 | ( |
4 | 'NAME' => 'Class::DBI::Plugin::Pager', | |
5 | 'VERSION_FROM' => 'lib/Class/DBI/Plugin/Pager.pm', | |
6 | 'PREREQ_PM' => { | |
7 | 'Carp' => '0', | |
8 | 'Class::DBI' => '0.9', | |
9 | 'Class::DBI::Plugin::AbstractCount' => '0', | |
10 | 'Class::Data::Inheritable' => '0', | |
11 | 'Data::Page' => '2', | |
12 | 'SQL::Abstract' => '0', | |
13 | 'Test::Exception' => '0', | |
14 | 'Test::More' => '0', | |
15 | 'Test::Warn' => '0', | |
16 | 'UNIVERSAL::require' => '0' | |
17 | }, | |
18 | 'INSTALLDIRS' => 'site', | |
19 | 'PL_FILES' => {} | |
20 | ) | |
4 | 'NAME' => 'Class::DBI::Plugin::Pager', | |
5 | 'VERSION_FROM' => 'lib/Class/DBI/Plugin/Pager.pm', | |
6 | 'PREREQ_PM' => { | |
7 | 'Carp' => 0, | |
8 | 'Class::DBI' => '0.9', | |
9 | 'Class::DBI::Plugin::AbstractCount' => 0, | |
10 | 'Class::Data::Inheritable' => 0, | |
11 | 'Data::Page' => 2, | |
12 | 'SQL::Abstract' => '1.61', | |
13 | 'Test::Exception' => 0, | |
14 | 'Test::More' => 0, | |
15 | 'Test::Warn' => 0, | |
16 | 'UNIVERSAL::require' => 0 | |
17 | }, | |
18 | 'INSTALLDIRS' => 'site', | |
19 | 'EXE_FILES' => [], | |
20 | 'PL_FILES' => {} | |
21 | ) | |
21 | 22 | ; |
25 | 25 | This library is free software; you can redistribute it and/or modify it |
26 | 26 | under the same terms as Perl itself. |
27 | 27 | |
28 | Copyright (C) 2004 David R. Baird | |
29 | ||
28 | Copyright (C) 2004-2012 David R. Baird | |
29 | Copyright (C) 2012 Nikolay S. C<majestic@cpan.org>⏎ |
9 | 9 | my $offset = $self->skipped; |
10 | 10 | my $rows = $self->entries_per_page; |
11 | 11 | |
12 | "LIMIT $rows OFFSET $offset"; | |
12 | return "LIMIT $rows OFFSET $offset"; | |
13 | 13 | } |
14 | 14 | |
15 | 15 | 1; |
9 | 9 | |
10 | 10 | use vars qw( $VERSION ); |
11 | 11 | |
12 | $VERSION = 0.561; | |
12 | $VERSION = '0.566'; | |
13 | 13 | |
14 | 14 | # D::P inherits from Class::Accessor::Chained::Fast |
15 | 15 | __PACKAGE__->mk_accessors( qw( where abstract_attr per_page page order_by _cdbi_app ) ); |
334 | 334 | |
335 | 335 | # SQL::Abstract::_recurse_where eats the WHERE clause |
336 | 336 | #sub where { |
337 | # my ( $self, $where_ref ) = @_; | |
338 | # | |
339 | # return $self->_where unless $where_ref; | |
340 | # | |
341 | # my $where_copy; | |
342 | # | |
343 | # if ( ref( $where_ref ) eq 'HASH' ) { | |
344 | # $where_copy = { %$where_ref }; | |
345 | # } | |
346 | # elsif ( ref( $where_ref ) eq 'ARRAY' ) | |
347 | # { | |
348 | # $where_copy = [ @$where_ref ]; | |
349 | # } | |
350 | # else | |
351 | # { | |
352 | # die "WHERE clause [$where_ref] must be specified as an ARRAYREF or HASHREF"; | |
353 | # } | |
354 | # | |
355 | # # this will get eaten, but the caller's value is now protected | |
356 | # $self->_where( $where_copy ); | |
337 | # my ( $self, $where_ref ) = @_; | |
338 | # | |
339 | # return $self->_where unless $where_ref; | |
340 | # | |
341 | # my $where_copy; | |
342 | # | |
343 | # if ( ref( $where_ref ) eq 'HASH' ) { | |
344 | # $where_copy = { %$where_ref }; | |
345 | # } | |
346 | # elsif ( ref( $where_ref ) eq 'ARRAY' ) | |
347 | # { | |
348 | # $where_copy = [ @$where_ref ]; | |
349 | # } | |
350 | # else | |
351 | # { | |
352 | # die "WHERE clause [$where_ref] must be specified as an ARRAYREF or HASHREF"; | |
353 | # } | |
354 | # | |
355 | # # this will get eaten, but the caller's value is now protected | |
356 | # $self->_where( $where_copy ); | |
357 | 357 | #} |
358 | 358 | |
359 | 359 | =item set_syntax( [ $name || $class || $coderef ] ) |
513 | 513 | #clause and re-write it this way: |
514 | 514 | # |
515 | 515 | #SELECT * FROM ( |
516 | # SELECT TOP 5 * FROM ( | |
517 | # SELECT TOP 15 my_column | |
518 | # FROM my_table | |
519 | # ORDER BY my_column ASC | |
520 | # ) AS foo ORDER BY my_column DESC | |
516 | # SELECT TOP 5 * FROM ( | |
517 | # SELECT TOP 15 my_column | |
518 | # FROM my_table | |
519 | # ORDER BY my_column ASC | |
520 | # ) AS foo ORDER BY my_column DESC | |
521 | 521 | #) AS bar ORDER BY my_column ASC |
522 | 522 | # |
523 | 523 | #=cut |
609 | 609 | the entire results set, before chopping out the requested subset. It's probably |
610 | 610 | a good idea to have an index on the column(s) used to order the results. For |
611 | 611 | huge tables, this approach to paging may be too inefficient. |
612 | ||
613 | =head1 SOURCE CODE | |
614 | ||
615 | The source code for this module is hosted on GitHub L<https://github.com/majesticcpan/class-dbi-plugin-pager>. | |
616 | Feel free to fork the repository and submit pull requests! | |
612 | 617 | |
613 | 618 | =head1 DEPENDENCIES |
614 | 619 | |
631 | 636 | |
632 | 637 | =head1 COPYRIGHT AND LICENSE |
633 | 638 | |
634 | Copyright 2004 by David Baird. | |
639 | Copyright 2004-2012 by David Baird. | |
640 | ||
641 | Copyright 2012 Nikolay S. C<majestic@cpan.org> | |
635 | 642 | |
636 | 643 | This library is free software; you can redistribute it and/or modify |
637 | 644 | it under the same terms as Perl itself. |
638 | 645 | |
639 | 646 | =head1 AUTHOR |
640 | 647 | |
641 | David Baird, C<cpan@riverside-cms.co.uk> | |
642 | ||
648 | David Baird | |
649 |
104 | 104 | |
105 | 105 | $conf{ where } = [ |
106 | 106 | age => {'<=', 80}, |
107 | age => {'=>', 20}, | |
107 | age => {'>=', 20}, | |
108 | 108 | city => 'Jerusalem', |
109 | 109 | ]; |
110 | 110 | |
114 | 114 | lives_ok { $pager = TestApp->pager( %conf ) } 'new pager - arrayref where (named args)'; |
115 | 115 | lives_ok { @results = $pager->search_where } 'search_where'; |
116 | 116 | is_deeply( \@results, [ @dataset, |
117 | 'TestApp', | |
118 | '( ( age <= ? ) AND ( age => ? ) AND ( city = ? ) ) ORDER BY fig LIMIT 10, 5', | |
119 | '80', '20', 'Jerusalem', | |
120 | ], | |
121 | 'arrayref where (named args) results' ); | |
117 | 'TestApp', | |
118 | '( ( age <= ? AND age >= ? AND city = ? ) ) ORDER BY fig LIMIT 10, 5', | |
119 | '80', '20', 'Jerusalem', | |
120 | ], | |
121 | 'arrayref where (named args) results' ); | |
122 | 122 | |
123 | 123 | |
124 | 124 | |
129 | 129 | |
130 | 130 | $conf{ where } = [ |
131 | 131 | age => {'<=', 80}, |
132 | age => {'=>', 20}, | |
132 | age => {'>=', 20}, | |
133 | 133 | city => 'Jerusalem', |
134 | 134 | ]; |
135 | 135 | |
140 | 140 | lives_ok { $pager = TestApp->pager( $args[0], { logic => 'AND' }, @args[1..$#args] ) } 'new pager - arrayref where (positional args)'; |
141 | 141 | lives_ok { @results = $pager->search_where } 'search_where'; |
142 | 142 | is_deeply( \@results, [ @dataset, |
143 | 'TestApp', | |
144 | '( ( age <= ? ) AND ( age => ? ) AND ( city = ? ) ) ORDER BY fig ROWS 10 TO 15', | |
145 | '80', '20', 'Jerusalem', | |
146 | ], | |
147 | 'arrayref where (positional args) results' ); | |
143 | 'TestApp', | |
144 | '( ( age <= ? AND age >= ? AND city = ? ) ) ORDER BY fig ROWS 10 TO 15', | |
145 | '80', '20', 'Jerusalem', | |
146 | ], | |
147 | 'arrayref where (positional args) results' ); | |
148 | 148 | |
149 | 149 | |
150 | 150 |