Skip Menu |
 

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

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

People
Owner: Nobody in particular
Requestors: jj [...] dangercreative.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: bug in prepare?
Date: Tue, 27 Feb 2007 17:48:10 -0500
To: bug-DBD-SQLite [...] rt.cpan.org.
From: "JJ Knitis" <jj [...] dangercreative.com>
distribution: M/MS/MSERGEANT/DBD-SQLite-1.12.tar.gz perl: This is perl, v5.8.8 built for i586-linux-thread-multi os: Linux d530 2.6.18.2-34-default #1 SMP Mon Nov 27 11:46:27 UTC 2006 i686 i686 i386 GNU/Linux Code and output below. In a where clause, comparing an absolute value of anything on the left to a place holder on the right evaluates to true. ---- #!/usr/bin/perl use strict; use DBI; use Data::Dumper; my $dbh = DBI->connect( "dbi:SQLite:dbname=", '', '' ); { my $SQL = "SELECT 'b' where abs('a') < -1"; my $getSTH = $dbh->prepare( $SQL ); $getSTH->execute(); print Dumper( [$SQL, undef, $getSTH->fetchall_arrayref()] ); $getSTH->finish; print "\n\n"; } { my $value = 'a'; my $SQL = "SELECT 'b' where abs('a') < ?"; my $getSTH = $dbh->prepare( $SQL ); $getSTH->execute( $value ); print Dumper( [$SQL, $value, $getSTH->fetchall_arrayref()] ); $getSTH->finish; print "\n\n"; } my $value = -1; my @SQL = ( "SELECT 'b' where abs('a') < ?", "SELECT 'b' where ? < abs('a')", "SELECT 'b' where CAST( abs('a') as 'real' ) < ?", "SELECT 'b' where abs('a') < CAST(? as 'real')", ); foreach my $thisSQL ( @SQL ) { my $getSTH = $dbh->prepare( $thisSQL ); $getSTH->execute( $value ); print Dumper( [$thisSQL, $value, $getSTH->fetchall_arrayref()] ), "\n"; $getSTH->finish; } ------ Show quoted text
> perl check_dbi.pl
$VAR1 = [ 'SELECT \'b\' where abs(\'a\') < -1', undef, [] ]; $VAR1 = [ 'SELECT \'b\' where abs(\'a\') < ?', 'a', [ [ 'b' ] ] ]; $VAR1 = [ 'SELECT \'b\' where abs(\'a\') < ?', -1, [ [ 'b' ] ] ]; $VAR1 = [ 'SELECT \'b\' where ? < abs(\'a\')', -1, [] ]; $VAR1 = [ 'SELECT \'b\' where CAST( abs(\'a\') as \'real\' ) < ?', -1, [] ]; $VAR1 = [ 'SELECT \'b\' where abs(\'a\') < CAST(? as \'real\')', -1, [] ]; -- JJ Knitis
Download (untitled) / with headers
text/plain 205b
This appears to be correct behaviour. More to the point, I get the same results when I don't use placeholders and use literals, suggesting this issue is one in the underlying SQLite. Resolving as NOTABUG


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.