Codebase list libclass-dbi-plugin-pager-perl / 38220e5
Imported Upstream version 0.566 Xavier Guimard 11 years ago
10 changed file(s) with 201 addition(s) and 90 deletion(s). Raw diff Collapse all Expand all
44 my $builder = Module::Build->new(
55 module_name => 'Class::DBI::Plugin::Pager',
66 license => 'perl',
7 dist_author => 'David Baird <cpan@riverside-cms.co.uk>',
7 dist_author => ['David Baird', 'Nikolay S. <majestic@cpan.org>'],
88 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 },
914 requires => { 'Test::More' => 0,
1015 'Test::Exception' => 0,
1116 'Test::Warn' => 0,
1217 'Class::DBI' => 0.90,
13 'SQL::Abstract' => 0,
18 'SQL::Abstract' => 1.61,
1419 'Data::Page' => 2,
1520 'Class::DBI::Plugin::AbstractCount' => 0,
1621 'Class::Data::Inheritable' => 0,
00 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)
117
218 0.561 Sun July 31 15:10:00 2005
319 - avoid bug in Class::DBI::Plugin::AbstractCount 0.04 which dies if a WHERE clause
4157 - minor POD fixes, added LimitYX subclass
4258
4359 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
00 Build.PL
1 Makefile.PL
21 Changes
3 MANIFEST
4 META.yml
5 README
62 lib/Class/DBI/Plugin/Pager.pm
73 lib/Class/DBI/Plugin/Pager/LimitOffset.pm
84 lib/Class/DBI/Plugin/Pager/LimitXY.pm
95 lib/Class/DBI/Plugin/Pager/LimitYX.pm
106 lib/Class/DBI/Plugin/Pager/RowsTo.pm
7 MANIFEST This list of files
8 README
119 t/00.load.t
1210 t/01.load_subclass.t
1311 t/02.main.t
1513 t/04.auto_syntax.t
1614 t/pod-coverage.t
1715 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
114 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
731 requires:
832 Carp: 0
933 Class::DBI: 0.9
1034 Class::DBI::Plugin::AbstractCount: 0
1135 Class::Data::Inheritable: 0
1236 Data::Page: 2
13 SQL::Abstract: 0
37 SQL::Abstract: 1.61
1438 Test::Exception: 0
1539 Test::More: 0
1640 Test::Warn: 0
1741 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
11 use ExtUtils::MakeMaker;
22 WriteMakefile
33 (
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 )
2122 ;
2525 This library is free software; you can redistribute it and/or modify it
2626 under the same terms as Perl itself.
2727
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>
99 my $offset = $self->skipped;
1010 my $rows = $self->entries_per_page;
1111
12 "LIMIT $rows OFFSET $offset";
12 return "LIMIT $rows OFFSET $offset";
1313 }
1414
1515 1;
99
1010 use vars qw( $VERSION );
1111
12 $VERSION = 0.561;
12 $VERSION = '0.566';
1313
1414 # D::P inherits from Class::Accessor::Chained::Fast
1515 __PACKAGE__->mk_accessors( qw( where abstract_attr per_page page order_by _cdbi_app ) );
334334
335335 # SQL::Abstract::_recurse_where eats the WHERE clause
336336 #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 );
357357 #}
358358
359359 =item set_syntax( [ $name || $class || $coderef ] )
513513 #clause and re-write it this way:
514514 #
515515 #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
521521 #) AS bar ORDER BY my_column ASC
522522 #
523523 #=cut
609609 the entire results set, before chopping out the requested subset. It's probably
610610 a good idea to have an index on the column(s) used to order the results. For
611611 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!
612617
613618 =head1 DEPENDENCIES
614619
631636
632637 =head1 COPYRIGHT AND LICENSE
633638
634 Copyright 2004 by David Baird.
639 Copyright 2004-2012 by David Baird.
640
641 Copyright 2012 Nikolay S. C<majestic@cpan.org>
635642
636643 This library is free software; you can redistribute it and/or modify
637644 it under the same terms as Perl itself.
638645
639646 =head1 AUTHOR
640647
641 David Baird, C<cpan@riverside-cms.co.uk>
642
648 David Baird
649
104104
105105 $conf{ where } = [
106106 age => {'<=', 80},
107 age => {'=>', 20},
107 age => {'>=', 20},
108108 city => 'Jerusalem',
109109 ];
110110
114114 lives_ok { $pager = TestApp->pager( %conf ) } 'new pager - arrayref where (named args)';
115115 lives_ok { @results = $pager->search_where } 'search_where';
116116 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' );
122122
123123
124124
129129
130130 $conf{ where } = [
131131 age => {'<=', 80},
132 age => {'=>', 20},
132 age => {'>=', 20},
133133 city => 'Jerusalem',
134134 ];
135135
140140 lives_ok { $pager = TestApp->pager( $args[0], { logic => 'AND' }, @args[1..$#args] ) } 'new pager - arrayref where (positional args)';
141141 lives_ok { @results = $pager->search_where } 'search_where';
142142 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' );
148148
149149
150150