Skip Menu |
 

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

Report information
The Basics
Id: 102290
Status: rejected
Priority: 0/
Queue: SQL-Statement

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

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



Subject: Cannot parse columns names with spaces
Download (untitled) / with headers
text/plain 1.3k
It seems the parser cannot handle column names that contain spaces. Here are two examples that break: ~$ perl -MSQL::Statement -le 'SQL::Statement->new("SELECT `a b` FROM c",SQL::Parser->new)' Bad table or column name: '`a b`' has chars not alphanumeric or underscore! at /usr/local/share/perl/5.20.1/SQL/Statement.pm line 88. ~$ perl -MSQL::Statement -le 'SQL::Statement->new("SELECT [a b] FROM c",SQL::Parser->new)' Bad table or column name: '[a b]' has chars not alphanumeric or underscore! at /usr/local/share/perl/5.20.1/SQL/Statement.pm line 88. ~$ Looking at the source code it seems that a /\W/ match will trigger failure: ################################################################### # IDENTIFIER ::= <alphabetic_char> { <alphanumeric_char> | _ }... # # and must not be a reserved word or over 128 chars in length ################################################################### sub IDENTIFIER { my ( $self, $id ) = @_; ... my $err = "Bad table or column name: '$id' "; # BAD CHARS if ( $id =~ /\W/ ) { $err .= "has chars not alphanumeric or underscore!"; return $self->do_err($err); } ... } I'm not sure what better regular expression would be to allow spaces in column names. Perhaps it would be better to have an option to altogether disable constraints on characters in columns names?
Download (untitled) / with headers
text/plain 177b
Column names with spaces are forbidden by ANSI SQL-92 definition. You can quote those column names using the correct quoting character ("). See t/17quoting.t for some examples.


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.