Skip Menu |

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

Report information
The Basics
Id: 69609
Status: resolved
Priority: 0/
Queue: SQL-Statement

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

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



Subject: COUNT(*) and WHERE stoped working in 0.31
In 0.30 the following SQL statement worked: "SELECT COUNT(*) FROM logfile WHERE (REGEX(logfile.remote,'/test/i') IS TRUE) Starting with 0.31 it throws the following error: DBD::CSV::st execute failed: Can't call method "column" on an undefined value at /usr/share/perl5/SQL/Statement/Term.pm line 200, <GEN24> line 1.
Further, it ignores starting with 0.41 any ORDER BY clause.
Put it in the right queue (this is an SQL::Statement issue, not a DBD::CSV issue)
Please submit some sample code (easy script, no external requirements beside SQL::Statement and probably DBD::CSV or DBD::DBM, including test data).
Sorry... bug is different. WHERE with functions works only on joins. Don't know since when this problem occures: NOT WORKING: "SELECT MAX(logfile.id) AS MAX_id FROM logfile WHERE REGEX(id,'//i') IS TRUE WORKING: SELECT MAX(logfile.id) AS MAX_id FROM logfile LEFT JOIN certs ON certs.id=logfile.certs_id WHERE REGEX(id,'//i') IS TRUE MESSAGE: root@test:~/GUI# perl CSVtester.pl DBD::CSV::st execute failed: Can't call method "column" on an undefined value at /usr/share/perl5/SQL/Statement/Term.pm line 200, <GEN0> line 1. [for Statement "SELECT MAX(logfile.id) AS MAX_id FROM logfile WHERE REGEX(id,'//i') IS TRUE"] at CSVtester.pl line 25. DBD::CSV::st fetchrow_hashref failed: Attempt to fetch row without a preceeding execute () call or from a non-SELECT statement [for Statement "SELECT MAX(logfile.id) AS MAX_id FROM logfile WHERE REGEX(id,'//i') IS TRUE"] at CSVtester.pl line 26. root@test:~/GUI# Is this reproduceable for you?
I can guess from there, but it would help me a lot when you create simple scripts, which: 1) create a simple data file or create the table and inserts some data 2) prepare the several statements and executes them Sorry, I'm very limited on time and without samples I will need much more time to reproduce to debug and fix (count that I can do 1-2 hours per business day, not every business day). Jens
Please look for script. Output: # perl CSVtester.pl Statement 1 did work! DBD::CSV::st execute failed: Can't call method "column" on an undefined value at /usr/share/perl5/SQL/Statement/Term.pm line 200, <GEN2> line 1. [for Statement "SELECT MAX(logfile.id) AS MAX_id FROM logfile WHERE REGEX(id,'//i') IS TRUE"] at CSVtester.pl line 28. Statement 2 did NOT work: Can't call method "column" on an undefined value at /usr/share/perl5/SQL/Statement/Term.pm line 200, <GEN2> line 1. #
Subject: SQL.pl
#!/usr/bin/perl use DBI; use DBD::CSV; use strict; my $i = 0; open(NIX, ">", "/tmp/logfile") || die("Unable to /tmp: ".$!); print NIX "1\n"; close NIX; open(NIX, ">", "/tmp/certs") || die("Unable to /tmp: ".$!); print NIX "1\n"; close NIX; my $dbm = DBI->connect("DBI:CSV:", undef, undef, { csv_class => "Text::CSV_XS"}); $dbm->{csv_tables}->{logfile} = { f_dir => "/", file => "/tmp/logfile", col_names => ["id"] }; $dbm->{csv_tables}->{certs} = { f_dir => "/", file => "/tmp/certs", col_names => ["id"] }; foreach my $statement ("SELECT MAX(logfile.id) AS MAX_id FROM logfile LEFT JOIN certs ON certs.id=logfile.id WHERE REGEX(id,'//i') IS TRUE", "SELECT MAX(logfile.id) AS MAX_id FROM logfile WHERE REGEX(id,'//i') IS TRUE") { my $sth = $dbm->prepare($statement); $sth->execute(); syswrite(STDOUT, "Statement ".++$i." did ".($@ ? "NOT work: ".$@ : "work!")."\n"); }
Great. And the same please demonstrating the "ORDER BY" issue. Thanks, Jens
$ perl /tmp/SQL.pl Statement 1 did work! Statement 2 did work! After applying submitted patches and fixing own found stuff during the last days applied script works with current versions of DBI, SQL::Statement and DBD::CSV. I think, coming releases should fix that for the world, too.
Release out now.