[Bps-public-commit] dbix-searchbuilder branch, delete-quote-vs-utf-flag-workaround, created. 1.59-10-g5245c42

Ruslan Zakirov ruz at bestpractical.com
Fri May 20 07:25:17 EDT 2011


The branch, delete-quote-vs-utf-flag-workaround has been created
        at  5245c424d8d3caf733dc684721457c383a87a2f4 (commit)

- Log -----------------------------------------------------------------
commit ca9e790481278b6114a42a90c8bd433346be6ce9
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri May 20 15:07:42 2011 +0400

    delete workaround for ->quote dropping UTF8 flag
    
    as far as I recall some DBD drivers were dropping UTF8 flag
    after quoting a string. I believe it's not a case these days.

diff --git a/lib/DBIx/SearchBuilder.pm b/lib/DBIx/SearchBuilder.pm
index b7e01e0..b894315 100755
--- a/lib/DBIx/SearchBuilder.pm
+++ b/lib/DBIx/SearchBuilder.pm
@@ -841,11 +841,7 @@ sub Limit {
         # we're doing an IS or IS NOT (null), don't quote the operator.
 
         if ( $args{'QUOTEVALUE'} && $args{'OPERATOR'} !~ /IS/i ) {
-            my $turn_utf = Encode::is_utf8( $args{'VALUE'} );
             $args{'VALUE'} = $self->_Handle->dbh->quote( $args{'VALUE'} );
-
-            # Accomodate DBI drivers that don't understand UTF8
-            Encode::_utf8_on( $args{'VALUE'} ) if $turn_utf;
         }
     }
 

commit 5245c424d8d3caf733dc684721457c383a87a2f4
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri May 20 15:24:28 2011 +0400

    check ->quote vs. utf-8 in a test

diff --git a/t/03compatibility.t b/t/03compatibility.t
new file mode 100644
index 0000000..0ed7124
--- /dev/null
+++ b/t/03compatibility.t
@@ -0,0 +1,40 @@
+#!/usr/bin/perl -w
+
+
+use strict;
+use warnings;
+use Test::More;
+BEGIN { require "t/utils.pl" }
+our (@AvailableDrivers);
+
+use constant TESTS_PER_DRIVER => 2;
+
+my $total = scalar(@AvailableDrivers) * TESTS_PER_DRIVER;
+plan tests => $total;
+
+my %QUOTE_CHAR = (
+    Pg => "'",
+    mysql => "'",
+    SQLite => "'",
+);
+
+foreach my $d ( @AvailableDrivers ) {
+SKIP: {
+    unless( should_test( $d ) ) {
+            skip "ENV is not defined for driver '$d'", TESTS_PER_DRIVER;
+    }
+
+    my $handle = get_handle( $d );
+    connect_handle( $handle );
+    isa_ok($handle->dbh, 'DBI::db');
+
+    my $dbh = $handle->dbh;
+
+    my $q = $QUOTE_CHAR{$d};
+
+    # was problem in DBD::Pg, fixed in 1.40 back in 2005
+    is( $dbh->quote("\x{420}"), "$q\x{420}$q", "->quote don't clobber UTF-8 flag");
+
+}} # SKIP, foreach blocks
+
+1;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list