[Bps-public-commit] dbix-searchbuilder branch produce-correct-oracle-query-hints created. 1.78-3-g8716164
BPS Git Server
git at git.bestpractical.com
Mon Nov 27 20:10:22 UTC 2023
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, produce-correct-oracle-query-hints has been created
at 871616448ca175cc5bba442d7034b8872307aa35 (commit)
- Log -----------------------------------------------------------------
commit 871616448ca175cc5bba442d7034b8872307aa35
Author: Jason Crome <jcrome at bestpractical.com>
Date: Mon Nov 27 14:47:54 2023 -0500
Add some basic testing for query hints
diff --git a/t/01searches.t b/t/01searches.t
index 6bbd273..3320061 100644
--- a/t/01searches.t
+++ b/t/01searches.t
@@ -7,7 +7,7 @@ use Test::More;
BEGIN { require "./t/utils.pl" }
our (@AvailableDrivers);
-use constant TESTS_PER_DRIVER => 151;
+use constant TESTS_PER_DRIVER => 153;
my $total = scalar(@AvailableDrivers) * TESTS_PER_DRIVER;
plan tests => $total;
@@ -447,6 +447,16 @@ SKIP: {
$users_obj->OrderBy( FIELD => "Login", ORDER => "ASC" );
is $users_obj->Last->Login, "obra", "Found last record correctly before search was run";
+ # Check SQL produced by QueryHint() and QueryHintFormatted()
+ $users_obj->UnLimit;
+ my $hintless_sql = $users_obj->BuildSelectQuery( PreferBind => 0 );
+ unlike( $hintless_sql, qr/\/\*/, "Query hint markers aren't present when QueryHint() isn't called" );
+
+ $users_obj->UnLimit;
+ $users_obj->QueryHint( '+FooBar' );
+ my $hinted_sql = $users_obj->BuildSelectQuery( PreferBind => 0 );
+ like( $hinted_sql, qr|/\*\+FooBar \*/|, "..but are when QueryHint() IS called" );
+
cleanup_schema( 'TestApp', $handle );
}} # SKIP, foreach blocks
commit e220a2e3774aba948d556725131583f53fe59653
Author: Jason Crome <jcrome at bestpractical.com>
Date: Mon Nov 27 14:47:01 2023 -0500
Add some guidance for using query hints
diff --git a/lib/DBIx/SearchBuilder.pm b/lib/DBIx/SearchBuilder.pm
index 3ed5bb4..7cbc514 100755
--- a/lib/DBIx/SearchBuilder.pm
+++ b/lib/DBIx/SearchBuilder.pm
@@ -1957,7 +1957,9 @@ sub Table {
=head2 QueryHint [Hint]
-If called with an argument, sets a query hint for this collection.
+If called with an argument, sets a query hint for this collection. Call
+this method before performing additional operations on a collection,
+such as C<Count()>, C<Next()>, etc.
Always returns the query hint.
commit ec23588133354cc67183af18eda5bc80ad82b2bf
Author: Jason Crome <jcrome at bestpractical.com>
Date: Mon Nov 27 14:45:25 2023 -0500
Produce correct query hints on Oracle
Originally, query hints were written as /* +FooBar */, which Oracle
treats as comments. By removing the first space, Oracle treats them as
hints instead.
diff --git a/lib/DBIx/SearchBuilder.pm b/lib/DBIx/SearchBuilder.pm
index 636c9d5..3ed5bb4 100755
--- a/lib/DBIx/SearchBuilder.pm
+++ b/lib/DBIx/SearchBuilder.pm
@@ -1983,7 +1983,10 @@ Returns the query hint formatted appropriately for inclusion in SQL queries.
sub QueryHintFormatted {
my $self = shift;
my $QueryHint = $self->QueryHint;
- return $QueryHint ? " /* $QueryHint */ " : " ";
+
+ # As it turns out, we can't have a space between the opening /*
+ # and the query hint, otherwise Oracle treats this as a comment.
+ return $QueryHint ? " /*$QueryHint */ " : " ";
}
-----------------------------------------------------------------------
hooks/post-receive
--
dbix-searchbuilder
More information about the Bps-public-commit
mailing list