Skip Menu |

This queue is for tickets about the DBD-SQLite CPAN distribution.

Report information
The Basics
Id: 312
Status: resolved
Priority: 0/
Queue: DBD-SQLite

People
Owner: Nobody in particular
Requestors: greg [...] evilfunhouse.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 0.06
  • 0.08
Fixed in: (no value)



Subject: fetchrow_hashref bug?
PACKAGE: DBD-SQLite-0.08.tar.gz PERLVER: 5.6.0 UNAME : Linux mangala.evilfunhouse.com 2.4.2-2smp #1 SMP Sun Apr 8 20:21:34 EDT 2001 i686 unknown I believe this to be a bug in DBD::SQLite, but it could be a bug in SQLite library. When using DBI's fetchrow_hashref method, the hash keys (table columns) include the SQL alias (if one was given). For example, the query "SELECT t.data FROM table t" might return the hashref { "t.data" => "foo" }. I believe this to be a bug. Testing against DBD::mysql and DBD::Sybase, the same query returns { data => "foo" }. A test script is included which demonstrates this problem. Thanks for such an awesome module! -Greg Williams
#!/usr/bin/perl use DBI; use strict; my $dbh = DBI->connect( "dbi:SQLite:dbname=sqlite.db", "", "" ); $dbh->do( <<"END_SQL" ); CREATE TABLE test ( pkey INT PRIMARY KEY, data VARCHAR(32) ) END_SQL { my $insert = $dbh->prepare( "INSERT INTO test VALUES (?, ?)" ); $insert->execute( 1, "foo" ); $insert->execute( 2, "bar" ); my $select = $dbh->prepare( "SELECT t.data FROM test t" ); $select->execute; while (my $h = $select->fetchrow_hashref) { while (my($k, $v) = each(%{$h})) { print "$k => $v\n"; } } } $dbh->disconnect; unlink( "sqlite.db" );
Date: Thu, 28 Feb 2002 03:58:19 +0000 (GMT)
From: Matt Sergeant <matt [...] sergeant.org>
To: Guest via RT <bug-DBD-SQLite [...] rt.cpan.org>
Subject: Re: [cpan #312] fetchrow_hashref bug?
On Wed, 27 Feb 2002, Guest via RT wrote: Show quoted text
> > > This message about DBD-SQLite was sent to you by guest via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=312 > > > PACKAGE: DBD-SQLite-0.08.tar.gz PERLVER: 5.6.0 UNAME : Linux > mangala.evilfunhouse.com 2.4.2-2smp #1 SMP Sun Apr 8 20:21:34 EDT 2001 > i686 unknown > > I believe this to be a bug in DBD::SQLite, but it could be a bug in > SQLite library. When using DBI's fetchrow_hashref method, the hash > keys (table columns) include the SQL alias (if one was given). For > example, the query "SELECT t.data FROM table t" might return the > hashref { "t.data" => "foo" }. I believe this to be a bug. Testing > against DBD::mysql and DBD::Sybase, the same query returns { data => > "foo" }.
That shouldn't be the default... According to http://www.hwaci.com/sw/sqlite/lang.html#pragma full_column_names should be off by default. Try playing with that and let me know if it changes. -- <!-- Matt --> <:->Get a smart net</:->
Resolving. No submitter response.