[Bps-public-commit] dbix-searchbuilder branch master updated. 1.71-18-gc88f83b
BPS Git Server
git at git.bestpractical.com
Wed Dec 7 21:56:41 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 c88f83b2aed26848b4f5edd6196f90321f331893 (commit)
via cb8c67f4c202499b0e48e12ab77c6b4da4e2b8ad (commit)
via 9622d57fb2a318e000f20b71b5c7f1e748a18973 (commit)
via 56d157fb5a6434bea5fbf52e9bacd1f3f9d6cf20 (commit)
from bf094dcc42a9f78b06cbc3cd206b2e809db34240 (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 c88f83b2aed26848b4f5edd6196f90321f331893
Merge: cb8c67f 56d157f
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Wed Dec 7 16:54:22 2022 -0500
Merge branch 'fix-pg-bind-value-in-limit'
commit cb8c67f4c202499b0e48e12ab77c6b4da4e2b8ad
Merge: bf094dc 9622d57
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Wed Dec 7 16:01:17 2022 -0500
Merge branch 'disable-combine-search-on-old-mysql'
commit 9622d57fb2a318e000f20b71b5c7f1e748a18973
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Oct 25 01:35:25 2022 +0800
Disable CombineSearchAndCount for old MariaDB and MySQL versions
This feature requires MariaDB 10.2+ and MySQL 8+. On old versions
enabling this feature will cause SQL syntax error like:
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near '() AS search_builder_count_all FROM ...'
diff --git a/lib/DBIx/SearchBuilder.pm b/lib/DBIx/SearchBuilder.pm
index 30dc090..57dc12f 100755
--- a/lib/DBIx/SearchBuilder.pm
+++ b/lib/DBIx/SearchBuilder.pm
@@ -808,7 +808,13 @@ in a single query.
sub CombineSearchAndCount {
my $self = shift;
if ( @_ ) {
- $self->{'_combine_search_and_count'} = shift;
+ if ( $self->_Handle->HasSupportForCombineSearchAndCount ) {
+ $self->{'_combine_search_and_count'} = shift;
+ }
+ else {
+ warn "Current database version " . $self->_Handle->DatabaseVersion . " does not support CombineSearchAndCount. Consider upgrading to a newer version with support for windowing functions.";
+ return undef;
+ }
}
return $self->{'_combine_search_and_count'};
}
diff --git a/lib/DBIx/SearchBuilder/Handle.pm b/lib/DBIx/SearchBuilder/Handle.pm
index 079bcda..33a4f60 100755
--- a/lib/DBIx/SearchBuilder/Handle.pm
+++ b/lib/DBIx/SearchBuilder/Handle.pm
@@ -1802,6 +1802,16 @@ sub HasSupportForNullsOrder {
return 0;
}
+=head2 HasSupportForCombineSearchAndCount
+
+Returns true value if DB supports to combine search and count in single
+query.
+
+=cut
+
+sub HasSupportForCombineSearchAndCount {
+ return 1;
+}
=head2 QuoteName
diff --git a/lib/DBIx/SearchBuilder/Handle/mysql.pm b/lib/DBIx/SearchBuilder/Handle/mysql.pm
index 7e2ae77..09720ce 100755
--- a/lib/DBIx/SearchBuilder/Handle/mysql.pm
+++ b/lib/DBIx/SearchBuilder/Handle/mysql.pm
@@ -355,6 +355,24 @@ sub _RequireQuotedTables {
return 0;
}
+=head2 HasSupportForCombineSearchAndCount
+
+MariaDB 10.2+ and MySQL 8+ support this.
+
+=cut
+
+sub HasSupportForCombineSearchAndCount {
+ my $self = shift;
+ my ($version) = $self->DatabaseVersion =~ /^(\d+\.\d+)/;
+
+ if ( $self->_IsMariaDB ) {
+ return $version >= 10.2 ? 1 : 0;
+ }
+ else {
+ return $version >= 8 ? 1 : 0;
+ }
+}
+
1;
__END__
diff --git a/t/03searches_combine.t b/t/03searches_combine.t
index 25c06e6..39f5cdd 100644
--- a/t/03searches_combine.t
+++ b/t/03searches_combine.t
@@ -24,6 +24,11 @@ SKIP: {
my $handle = get_handle($d);
connect_handle($handle);
+
+ if ( !$handle->HasSupportForCombineSearchAndCount ) {
+ skip "Database version doesn't support CombineSearchAndCount", TESTS_PER_DRIVER;
+ }
+
isa_ok( $handle->dbh, 'DBI::db' );
my $ret = init_schema( 'TestApp', $handle );
-----------------------------------------------------------------------
Summary of changes:
lib/DBIx/SearchBuilder.pm | 8 +++++++-
lib/DBIx/SearchBuilder/Handle.pm | 10 ++++++++++
lib/DBIx/SearchBuilder/Handle/Pg.pm | 2 +-
lib/DBIx/SearchBuilder/Handle/mysql.pm | 18 ++++++++++++++++++
t/03searches_bind.t | 2 +-
t/03searches_combine.t | 5 +++++
6 files changed, 42 insertions(+), 3 deletions(-)
hooks/post-receive
--
dbix-searchbuilder
More information about the Bps-public-commit
mailing list