[Bps-public-commit] dbix-searchbuilder branch, experimental, created. 1.63-35-g1ee3bf7
Ruslan Zakirov
ruz at bestpractical.com
Sun Feb 3 07:25:13 EST 2013
The branch, experimental has been created
at 1ee3bf731e3938fab838413492e077d8f1113e89 (commit)
- Log -----------------------------------------------------------------
commit 4ab613c61df3b111b10f564b153675d7490d56e9
Merge: 5d77a28 2025f04
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sun Feb 3 16:08:33 2013 +0400
Merge branch 'in-operator' into experimental
commit b05e73de89440464aae12a034410d6c683c1b14d
Merge: 4ab613c c7178fa
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sun Feb 3 16:10:38 2013 +0400
Merge branch 'functions-in-searches' into experimental
Conflicts:
t/01searches.t
diff --cc lib/DBIx/SearchBuilder.pm
index 798b8da,dd7922d..befcd90
--- a/lib/DBIx/SearchBuilder.pm
+++ b/lib/DBIx/SearchBuilder.pm
@@@ -848,35 -840,15 +852,42 @@@ sub Limit
elsif ( $args{'OPERATOR'} =~ /ENDSWITH/i ) {
$args{'VALUE'} = "%" . $args{'VALUE'};
}
+ elsif ( $args{'OPERATOR'} =~ /\bIN$/i ) {
+ if ( blessed $args{'VALUE'} && $args{'VALUE'}->isa(__PACKAGE__) ) {
+ # if no columns selected then select id
+ local $args{'VALUE'}{'columns'} = $args{'VALUE'}{'columns'};
+ unless ( $args{'VALUE'}{'columns'} ) {
+ $args{'VALUE'}->Column( FIELD => 'id' );
+ } elsif ( @{ $args{'VALUE'}{'columns'} } > 1 ) {
+ warn "Collection in '$args{OPERATOR}' with more than one column selected, using first";
+ splice @{ $args{'VALUE'}{'columns'} }, 1;
+ }
+ $args{'VALUE'} = '('. $args{'VALUE'}->BuildSelectQuery .')';
+ $args{'QUOTEVALUE'} = 0;
+ }
+ elsif ( ref $args{'VALUE'} ) {
+ if ( $args{'QUOTEVALUE'} ) {
+ my $dbh = $self->_Handle->dbh;
+ $args{'VALUE'} = join ', ', map $dbh->quote( $_ ), @{ $args{'VALUE'} };
+ } else {
+ $args{'VALUE'} = join ', ', @{ $args{'VALUE'} };
+ }
+ $args{'VALUE'} = "($args{VALUE})";
+ $args{'QUOTEVALUE'} = 0;
+ }
+ else {
+ # otherwise behave in backwards compatible way
+ }
+ }
$args{'OPERATOR'} =~ s/(?:MATCHES|ENDSWITH|STARTSWITH)/LIKE/i;
+ if ( $args{'OPERATOR'} =~ /IS/i ) {
+ $args{'VALUE'} = 'NULL';
+ $args{'QUOTEVALUE'} = 0;
+ }
+ }
+
+ if ( $args{'QUOTEVALUE'} ) {
#if we're explicitly told not to to quote the value or
# we're doing an IS or IS NOT (null), don't quote the operator.
diff --cc t/01searches.t
index 1957e6f,664fcb7..600b5ab
--- a/t/01searches.t
+++ b/t/01searches.t
@@@ -7,7 -7,7 +7,7 @@@ use Test::More
BEGIN { require "t/utils.pl" }
our (@AvailableDrivers);
- use constant TESTS_PER_DRIVER => 130;
-use constant TESTS_PER_DRIVER => 122;
++use constant TESTS_PER_DRIVER => 135;
my $total = scalar(@AvailableDrivers) * TESTS_PER_DRIVER;
plan tests => $total;
commit 1ee3bf731e3938fab838413492e077d8f1113e89
Merge: b05e73d d25a817
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sun Feb 3 16:16:29 2013 +0400
Merge branch 'set-undef-fix' into experimental
Conflicts:
Changes
diff --cc Changes
index d7bfd27,f44c1f4..e772ef2
--- a/Changes
+++ b/Changes
@@@ -2,7 -2,10 +2,11 @@@ Revision history for Perl extension DBI
1.64
+* IN and NOT IN operators in ->Limit method
+ * _Set now can take undef as argument to mean default or NULL.
+ Still may result in error if default is not defined and no_nulls
+ is true for the column. If old behaviour is required set
+ $record->{'no_undefs_in_set'} to true value.
1.63 Fri Sep 14 2012 01:19:38 GMT+0400 (MSK)
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list