[Bps-public-commit] dbix-searchbuilder branch fix-pg-bind-value-in-limit created. 1.71-15-g56d157f
BPS Git Server
git at git.bestpractical.com
Mon Oct 24 18:55:02 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, fix-pg-bind-value-in-limit has been created
at 56d157fb5a6434bea5fbf52e9bacd1f3f9d6cf20 (commit)
- Log -----------------------------------------------------------------
commit 56d157fb5a6434bea5fbf52e9bacd1f3f9d6cf20
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Oct 25 02:09:37 2022 +0800
Fix the condition to determine if to add OFFSET to SQL or not for Pg
Since we added bind value support in LIMIT clause, $first can be '?', as
it makes "$first != 0" a false value, this can cause the 'OFFSET...'
part to be wrongly skipped.
diff --git a/lib/DBIx/SearchBuilder/Handle/Pg.pm b/lib/DBIx/SearchBuilder/Handle/Pg.pm
index f9adafb..a29f192 100755
--- a/lib/DBIx/SearchBuilder/Handle/Pg.pm
+++ b/lib/DBIx/SearchBuilder/Handle/Pg.pm
@@ -186,7 +186,7 @@ sub ApplyLimits {
}
$limit_clause .= $per_page;
- if ( $first && $first != 0 ) {
+ if ( $first ) {
$limit_clause .= " OFFSET $first";
}
}
diff --git a/t/03searches_bind.t b/t/03searches_bind.t
index 40d5b98..30d4739 100644
--- a/t/03searches_bind.t
+++ b/t/03searches_bind.t
@@ -73,7 +73,7 @@ SKIP: {
$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,
+ ok( $users_obj->BuildSelectQuery =~ /LIMIT\s*\?,\s*\?|LIMIT\s*\? OFFSET|rownum\s*<=\s*\?.*limitrownum\s*>=\s*\?/i,
'found placeholders in limit in select query' );
$users_obj->CleanSlate;
-----------------------------------------------------------------------
hooks/post-receive
--
dbix-searchbuilder
More information about the Bps-public-commit
mailing list