Skip Menu |

This queue is for tickets about the SQL-Statement CPAN distribution.

Report information
The Basics
Id: 124028
Status: open
Priority: 0/
Queue: SQL-Statement

People
Owner: Nobody in particular
Requestors: HMBRAND [...] cpan.org
Cc:
AdminCc:

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



From the DBI manual: You can tell if the statement was a "SELECT" statement by checking if "$sth->{NUM_OF_FIELDS}" is greater than zero after calling "execute". In DBD::CSV, and thus SQL::Statement, NOF is correctly set on select statements, and is correctly set to 0 - though that could arguably be undef - on delete statements, but may be erroneously set to one on update statements. See https://github.com/perl5-dbi/DBD-CSV/blob/master/sandbox/irc-001.pl $ ./irc-001.pl Using DBI-1.639 + DBD::CSV-0.50 + SQL::Statement-1.412 + Text::CSV_XS-1.35 Rows NOF Select1 1 2 Select2 0E0 2 Update1 1 1 Update2 0E0 1 Delete1 1 0 Delete2 0E0 0 $ ./irc-001.pl -p Using DBI-1.639 + DBD::Pg-3.7.0 Rows NOF Select1 1 2 Select2 0E0 2 Update1 1 Update2 0E0 Delete1 1 Delete2 0E0 I'll see if I can find time to find the cause
On Sun Jan 07 08:04:38 2018, HMBRAND wrote: Show quoted text
> From the DBI manual: > > You can tell if the statement was a "SELECT" statement by checking if > "$sth->{NUM_OF_FIELDS}" is > greater than zero after calling "execute". > > In DBD::CSV, and thus SQL::Statement, NOF is correctly set on select > statements, and is correctly set to 0 - though that could arguably be > undef - on delete statements, but may be erroneously set to one on > update statements. > > See https://github.com/perl5-dbi/DBD-CSV/blob/master/sandbox/irc- > 001.pl > > $ ./irc-001.pl > Using DBI-1.639 + DBD::CSV-0.50 + SQL::Statement-1.412 + Text::CSV_XS- > 1.35 > Rows NOF > Select1 1 2 > Select2 0E0 2 > Update1 1 1 > Update2 0E0 1 > Delete1 1 0 > Delete2 0E0 0 > > $ ./irc-001.pl -p > Using DBI-1.639 + DBD::Pg-3.7.0 > Rows NOF > Select1 1 2 > Select2 0E0 2 > Update1 1 > Update2 0E0 > Delete1 1 > Delete2 0E0 > > I'll see if I can find time to find the cause
The cause is trivial - it's intended in SQL::Statement to return the number off affected rows (https://github.com/perl5-dbi/SQL-Statement/blob/master/lib/SQL/Statement.pm#L410). If we want to change this for $DBD::*::st::NUMBER_OF_FIELDS - we need to wrap that. It shouldn't be a big deal, since S::S knows which command was executed (https://github.com/perl5-dbi/SQL-Statement/blob/master/lib/SQL/Statement.pm#L1649).