[Bps-public-commit] dbix-searchbuilder branch master updated. 1.71-11-g094bef7
BPS Git Server
git at git.bestpractical.com
Tue Sep 20 20:19:15 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "dbix-searchbuilder".
The branch, master has been updated
via 094bef78b0cb35462e8abf590c1acd2b1e0d75e6 (commit)
via 11277b82ce775d2e86574c6f8516c40a3639b5fc (commit)
via 29223a9081df8dd5334986699bcba854d7544ec9 (commit)
via a93681454ae9076f79cc27653c93bb5e3a9833c7 (commit)
via 06e02ee1d3cd4b136cec0218e808e88c5c162c0d (commit)
via be943d219d8cc2849ba753095389d552162a7867 (commit)
via d4b5250977dbd8845b99b77d70487f0b8135acbf (commit)
via 457c907e60e1ea6f08eb5d456414a5b69fc68db8 (commit)
via 7866354c60b6ac0ccf880017e240cb7cc59a642c (commit)
via 73cf9e92655deade535ef2534a96207bce753276 (commit)
via b4e8d777c6376392ec58e022125d80454f3214bb (commit)
from 5001eec5254c1506ff9d458874c010fae000b29c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 094bef78b0cb35462e8abf590c1acd2b1e0d75e6
Author: Jason Crome <jcrome at bestpractical.com>
Date: Tue Sep 20 16:18:40 2022 -0400
Prep version 1.72_01
diff --git a/Changes b/Changes
index 60d999a..e43f8f6 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,12 @@
Revision history for Perl extension DBIx::SearchBuilder.
+1.72_01 2022-09-20
+- Simplify count's internal logic to always use the "count_all" key
+- Fix Count method to always returns count in selected page
+- Support search and count in same query
+- Redo search only if ORDER/GROUP BY is really updated
+- Add bind values support for LIMIT clauses
+
1.71 2021-09-24
- Add dot to load utils in tests for perl 5.26+
diff --git a/MANIFEST b/MANIFEST
index cec146c..aaf9219 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -55,6 +55,7 @@ t/02searches_joins.t
t/03compatibility.t
t/03cud_from_select.t
t/03rebless.t
+t/03searches_combine.t
t/03transactions.t
t/03versions.t
t/04mysql_identifier_quoting.t
diff --git a/META.yml b/META.yml
index 180e7ca..1065776 100644
--- a/META.yml
+++ b/META.yml
@@ -35,4 +35,4 @@ requires:
capitalization: '0.03'
resources:
license: http://dev.perl.org/licenses/
-version: '1.71'
+version: 1.72_01
diff --git a/lib/DBIx/SearchBuilder.pm b/lib/DBIx/SearchBuilder.pm
index 3fcd96c..30dc090 100755
--- a/lib/DBIx/SearchBuilder.pm
+++ b/lib/DBIx/SearchBuilder.pm
@@ -4,7 +4,7 @@ package DBIx::SearchBuilder;
use strict;
use warnings;
-our $VERSION = "1.71";
+our $VERSION = "1.72_01";
use Clone qw();
use Encode qw();
commit 11277b82ce775d2e86574c6f8516c40a3639b5fc
Merge: 06e02ee 29223a9
Author: Jason Crome <jcrome at bestpractical.com>
Date: Tue Sep 20 15:57:15 2022 -0400
Merge branch 'bind-values-in-limit'
commit 29223a9081df8dd5334986699bcba854d7544ec9
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Aug 31 00:38:06 2022 +0800
Test bind values support for LIMIT clauses
diff --git a/t/03searches_bind.t b/t/03searches_bind.t
index f83289b..40d5b98 100644
--- a/t/03searches_bind.t
+++ b/t/03searches_bind.t
@@ -4,7 +4,7 @@ use Test::More;
BEGIN { require "./t/utils.pl" }
our (@AvailableDrivers);
-use constant TESTS_PER_DRIVER => 39;
+use constant TESTS_PER_DRIVER => 45;
my $total = scalar(@AvailableDrivers) * TESTS_PER_DRIVER;
plan tests => $total;
@@ -62,6 +62,20 @@ SKIP: {
[ "Baggins' Frodo", "Bilbo\\Baggins" ],
'2 Baggins',
);
+ $users_obj->OrderBy( FIELD => 'id', ORDER => 'ASC' );
+ $users_obj->RowsPerPage(1);
+
+ is( $users_obj->First->Login, "Bilbo\\Baggins", "Bilbo\\Baggins on the first page" );
+ is( $users_obj->Count, 1, "1 value on the first page" );
+ ok( $users_obj->BuildSelectQuery =~ /LIMIT\s*\?|rownum\s*<=\s*\?.*limitrownum\s*>=\s*\?/i,
+ 'found placeholders in limit in select query' );
+
+ $users_obj->GotoPage(1);
+ is( $users_obj->First->Login, "Baggins' Frodo", "Baggins' Frodo on the second page" );
+ is( $users_obj->Count, 1, "1 value on the second page" );
+ ok( $users_obj->BuildSelectQuery =~ /LIMIT\s*\?,\s*\?|rownum\s*<=\s*\?.*limitrownum\s*>=\s*\?/i,
+ 'found placeholders in limit in select query' );
+
$users_obj->CleanSlate;
for my $name ( "Shire's Bag End", 'The Fellowship of the Ring' ) {
commit a93681454ae9076f79cc27653c93bb5e3a9833c7
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Aug 31 00:35:26 2022 +0800
Add bind values support for LIMIT clauses
diff --git a/lib/DBIx/SearchBuilder.pm b/lib/DBIx/SearchBuilder.pm
index 1d7f4be..3fcd96c 100755
--- a/lib/DBIx/SearchBuilder.pm
+++ b/lib/DBIx/SearchBuilder.pm
@@ -360,7 +360,7 @@ enforcing an ordering on the rows (with C<OrderByCols>, say).
sub _ApplyLimits {
my $self = shift;
my $statementref = shift;
- $self->_Handle->ApplyLimits($statementref, $self->RowsPerPage, $self->FirstRow);
+ $self->_Handle->ApplyLimits($statementref, $self->RowsPerPage, $self->FirstRow, $self);
$$statementref =~ s/main\.\*/join(', ', @{$self->{columns}})/eg
if $self->{columns} and @{$self->{columns}};
}
@@ -1977,9 +1977,10 @@ sub _OptimizeQuery {
undef $self->{_bind_values};
if ( $args{PreferBind} ) {
( $$query, my @bind_values ) = $self->_Handle->_ExtractBindValues($$query);
- if (@bind_values) {
- $self->{_bind_values} = \@bind_values;
- }
+
+ # Set _bind_values even if no values are extracted, as we use it in
+ # ApplyLimits to determine if bind is enabled.
+ $self->{_bind_values} = \@bind_values;
}
}
diff --git a/lib/DBIx/SearchBuilder/Handle.pm b/lib/DBIx/SearchBuilder/Handle.pm
index b18d9b9..079bcda 100755
--- a/lib/DBIx/SearchBuilder/Handle.pm
+++ b/lib/DBIx/SearchBuilder/Handle.pm
@@ -983,11 +983,18 @@ sub ApplyLimits {
my $statementref = shift;
my $per_page = shift;
my $first = shift;
+ my $sb = shift;
my $limit_clause = '';
if ( $per_page) {
$limit_clause = " LIMIT ";
+ if ( $sb->{_bind_values} ) {
+ push @{$sb->{_bind_values}}, $first || (), $per_page;
+ $first = '?' if $first;
+ $per_page = '?';
+ }
+
if ( $first ) {
$limit_clause .= $first . ", ";
}
diff --git a/lib/DBIx/SearchBuilder/Handle/Oracle.pm b/lib/DBIx/SearchBuilder/Handle/Oracle.pm
index 14bf2f1..8e5b02a 100755
--- a/lib/DBIx/SearchBuilder/Handle/Oracle.pm
+++ b/lib/DBIx/SearchBuilder/Handle/Oracle.pm
@@ -247,6 +247,7 @@ sub ApplyLimits {
my $statementref = shift;
my $per_page = shift;
my $first = shift;
+ my $sb = shift;
# Transform an SQL query from:
#
@@ -275,7 +276,12 @@ sub ApplyLimits {
# Oracle orders from 1 not zero
$first++;
# Make current query a sub select
- $$statementref = "SELECT * FROM ( SELECT limitquery.*,rownum limitrownum FROM ( $$statementref ) limitquery WHERE rownum <= " . ($first + $per_page - 1) . " ) WHERE limitrownum >= " . $first;
+ my $last = $first + $per_page - 1;
+ if ( $sb->{_bind_values} ) {
+ push @{ $sb->{_bind_values} }, $last, $first;
+ $first = $last = '?';
+ }
+ $$statementref = "SELECT * FROM ( SELECT limitquery.*,rownum limitrownum FROM ( $$statementref ) limitquery WHERE rownum <= " . $last . " ) WHERE limitrownum >= " . $first;
}
}
diff --git a/lib/DBIx/SearchBuilder/Handle/Pg.pm b/lib/DBIx/SearchBuilder/Handle/Pg.pm
index d7c48f2..f9adafb 100755
--- a/lib/DBIx/SearchBuilder/Handle/Pg.pm
+++ b/lib/DBIx/SearchBuilder/Handle/Pg.pm
@@ -172,11 +172,19 @@ sub ApplyLimits {
my $statementref = shift;
my $per_page = shift;
my $first = shift;
+ my $sb = shift;
my $limit_clause = '';
if ( $per_page) {
$limit_clause = " LIMIT ";
+
+ if ( $sb->{_bind_values} ) {
+ push @{ $sb->{_bind_values} }, $per_page, $first || ();
+ $first = '?' if $first;
+ $per_page = '?';
+ }
+
$limit_clause .= $per_page;
if ( $first && $first != 0 ) {
$limit_clause .= " OFFSET $first";
commit 06e02ee1d3cd4b136cec0218e808e88c5c162c0d
Merge: 5001eec be943d2
Author: Jason Crome <jcrome at bestpractical.com>
Date: Tue Sep 20 15:56:32 2022 -0400
Merge branch 'combine-search-and-count'
-----------------------------------------------------------------------
Summary of changes:
Changes | 7 +
MANIFEST | 1 +
META.yml | 2 +-
lib/DBIx/SearchBuilder.pm | 185 +++++++++++++++++++-------
lib/DBIx/SearchBuilder/Handle.pm | 32 +++++
lib/DBIx/SearchBuilder/Handle/Oracle.pm | 8 +-
lib/DBIx/SearchBuilder/Handle/Pg.pm | 8 ++
t/01searches.t | 3 +-
t/03searches_bind.t | 16 ++-
t/{03searches_bind.t => 03searches_combine.t} | 98 +++++---------
10 files changed, 242 insertions(+), 118 deletions(-)
copy t/{03searches_bind.t => 03searches_combine.t} (68%)
hooks/post-receive
--
dbix-searchbuilder
More information about the Bps-public-commit
mailing list