Control: tag -1 patch

On Fri, Jan 11, 2019 at 05:37:52PM +0100, gregor herrmann wrote:
> Source: libclass-dbi-plugin-type-perl
> Version: 0.02-8
> Severity: serious
> Tags: upstream buster sid ftbfs
> Justification: fails to build from source
> Forwarded: https://rt.cpan.org/Public/Bug/Display.html?id=128135

> ok 1 - use Class::DBI::Plugin::Type;
> not ok 2 - notes is text
> #   Failed test 'notes is text'
> #   at t/1.t line 28.
> #                   undef
> #     doesn't match '(?^:text|blob)'

>From Class::DBI::Plugin::Type::import() :

           @hash{@{$sth->{NAME}}} =
            map {
                    my $info = scalar $self->db_Main->type_info($_);
                    if ($info) { $info->{TYPE_NAME} }
                    else { $_ } # Typeless databases (SQLite)
                }
                @{$sth->{TYPE}};

Looks like type_info() now returns more than it used to: with the older
libdbd-sqlite3-perl it gave just 'undef', but now it gives (somewhat
unhelpful)

$VAR1 = {
          'CASE_SENSITIVE' => undef,
          'MAXIMUM_SCALE' => undef,
          'NUM_PREC_RADIX' => undef,
          'MINIMUM_SCALE' => undef,
          'SQL_DATETIME_SUB' => undef,
          'NULLABLE' => undef,
          'LOCAL_TYPE_NAME' => undef,
          'LITERAL_PREFIX' => undef,
          'INTERVAL_PRECISION' => undef,
          'TYPE_NAME' => undef,
          'DATA_TYPE' => 0,
          'FIXED_PREC_SCALE' => undef,
          'AUTO_UNIQUE_VALUE' => undef,
          'SEARCHABLE' => undef,
          'UNSIGNED_ATTRIBUTE' => undef,
          'CREATE_PARAMS' => undef,
          'COLUMN_SIZE' => undef,
          'LITERAL_SUFFIX' => undef,
          'SQL_DATA_TYPE' => undef
        };

I'm not sure how intentional this is, but it seems to have changed
in DBD-SQLite 1.61_02 as noted in the upstream bug.

  
https://metacpan.org/diff/file?target=ISHIGAKI/DBD-SQLite-1.61_02/&source=ISHIGAKI/DBD-SQLite-1.61_01/

Checking that the value is defined seems to fix / work around this,
as seen in the attached patch. I'm not totally sure that this
won't break things on other DBD implementations though.
-- 
Niko Tyni   nt...@debian.org
>From b8cd9d0d853fdca08488f261d5856801e2ce2771 Mon Sep 17 00:00:00 2001
From: Niko Tyni <nt...@debian.org>
Date: Mon, 21 Jan 2019 21:07:59 +0200
Subject: [PATCH] Fix compatibility with DBD-SQLite >=  1.61_02

type_info() now returns an array of mostly undefined values, breaking
the t/1.t tests. Add a guard for definedness so we still take the other
branch in this case.

Bug: https://rt.cpan.org/Public/Bug/Display.html?id=128135
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=919006
---
 Type.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Type.pm b/Type.pm
index 688ca35..986fecd 100644
--- a/Type.pm
+++ b/Type.pm
@@ -29,7 +29,7 @@ sub import {
             @hash{@{$sth->{NAME}}} = 
             map { 
                     my $info = scalar $self->db_Main->type_info($_);
-                    if ($info) { $info->{TYPE_NAME} } 
+                    if ($info and defined $info->{TYPE_NAME}) { $info->{TYPE_NAME} }
                     else { $_ } # Typeless databases (SQLite)
                 }
                 @{$sth->{TYPE}};
-- 
2.20.1

Reply via email to