Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: gwolf [...] debian.org
Cc:
AdminCc:

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



Subject: Does not correctly handle SQL statements with comments
When given SQL code containing comments, SQL::Parser does not remove them, so it fails to parse them. I stumbled upon this with the following code: CREATE TABLE users ( id integer PRIMARY KEY, login varchar(100) NOT NULL UNIQUE, name varchar(100) NOT NULL, passwd char(32), level integer NOT NULL, -- DEFAULT 0, session char(32) UNIQUE, session_exp varchar(20)) I commented the 'DEFAULT 0', as it cannot be represented without a real DBMS, and SQL::Parser choked on it: SQL ERROR: Bad table or column name '--' has chars not alphanumeric or underscore! Execution ERROR: No command found!. The patch I am attaching fixes the problem - I cannot guarantee it will always work (or, for that matter, that it is at the right place), but it works for me.
--- /usr/share/perl5/SQL/Parser.pm 2005-04-22 19:47:11.000000000 -0500 +++ /tmp/testmod/SQL/Parser.pm 2005-08-17 15:58:21.000000000 -0500 @@ -72,9 +72,8 @@ } # SQL STYLE # - if ($sql =~ /^\s*--(.*)(\n|$)/) { + if ($sql =~ s/(--.*)(\n|$)/\n/) { $self->{"comment"} = $1; - return 1; } ################################################################
Applied