Skip Menu |
 

This queue is for tickets about the Tie-DBI CPAN distribution.

Report information
The Basics
Id: 104338
Status: resolved
Priority: 0/
Queue: Tie-DBI

People
Owner: Nobody in particular
Requestors: bruce [...] brucereed.com
Cc:
AdminCc:

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



MIME-Version: 1.0
X-Spam-Status: No, score=-1.9 tagged_above=-99.9 required=10 tests=[AWL=0.000, BAYES_00=-1.9] autolearn=ham
X-Spam-Flag: NO
content-type: text/plain; charset="utf-8"; format="flowed"
Message-ID: <555013FD.3050808 [...] brucereed.com>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Spam-Score: -1.9
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 81E1D240406 for <cpan-bug+Tie-DBI [...] hipster.bestpractical.com>; Sun, 10 May 2015 22:29:30 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MIRtqrh17FHz for <cpan-bug+Tie-DBI [...] hipster.bestpractical.com>; Sun, 10 May 2015 22:29:29 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id C85AC2400D8 for <bug-Tie-DBI [...] rt.cpan.org>; Sun, 10 May 2015 22:29:28 -0400 (EDT)
Received: (qmail 31563 invoked by alias); 11 May 2015 02:29:28 -0000
Received: from s433.sureserver.com (HELO s433.sureserver.com) (64.14.74.71) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Sun, 10 May 2015 19:29:24 -0700
Received: (qmail 10867 invoked by uid 504); 11 May 2015 02:29:19 -0000
Received: from unknown (HELO ?192.168.1.122?) (bruce [...] 97.95.211.81) by 192.252.155.178 with ESMTPA; 11 May 2015 02:29:19 -0000
Delivered-To: cpan-bug+Tie-DBI [...] hipster.bestpractical.com
Subject: Tie::DBI with SQLite - prepare failed, syntax error line 402 - fix included!
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0
Return-Path: <bruce [...] brucereed.com>
X-RT-Mail-Extension: tie-dbi
X-Original-To: cpan-bug+Tie-DBI [...] hipster.bestpractical.com
X-Spam-Check-BY: la.mx.develooper.com
Date: Sun, 10 May 2015 22:29:17 -0400
X-Spam-Level:
To: bug-Tie-DBI [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Bruce Reed <bruce [...] brucereed.com>
X-RT-Original-Encoding: utf-8
X-RT-Interface: Email
Content-Length: 1674
Download (untitled) / with headers
text/plain 1.6k
I am using Tie::DBI V1.06 with DBD::SQLite V1.46, and I am getting the following errors when I have a question mark in a text field: DBD::SQLite::db prepare failed: near "11879": syntax error at Tie/DBI.pm line 397, <GEN18> line 13. STORE: near "11879": syntax error at Tie/DBI.pm line 627. The '11879' value is the record key of the record being updated. --------------------- The problem is that in the case of CanBind being false, function _run_query is replacing the placeholders with the field values in the query. I added some print statements to see what is occurring. query: insert into transactions (description,key) values (?,?) values: 'test?','11879' updated query: insert into transactions (description,key) values ('test'11879'',null) query: update transactions set description=? where key=? values: 'test?','11879' updated query: update transactions set description='test'11879'' where key=null --------------------- Function _run_query contains this code at line 393: while ( ( my $pos = index( $query, '?' ) ) >= 0 ) { my $value = shift(@bind_variables); substr( $query, $pos, 1 ) = ( defined($value) ? ( $self->{CanBind} ? $self->{'dbh'}->quote($value) : $value ) : 'null' ); } The index call is starting from the beginning of the string on each call. The following code addresses this: my $pos = 0; while ( ( $pos = index( $query, '?', $pos ) ) >= 0 ) { my $value = shift(@bind_variables); $value = ( defined($value) ? ( $self->{CanBind} ? $self->{'dbh'}->quote($value) : $value ) : 'null' ); substr( $query, $pos, 1 ) = $value; $pos += length($value); }
MIME-Version: 1.0
In-Reply-To: <555013FD.3050808 [...] brucereed.com>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <555013FD.3050808 [...] brucereed.com>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-18164-1460496225-1365.104338-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 50


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.