Skip Menu |

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

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

People
Owner: JZUCKER [...] cpan.org
Requestors: rrwo [...] cpan.org
Cc:
AdminCc:

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



Subject: Improper parsing of column names that have aliases
SQL::Statement seems unable to handle field aliases. When I run a parse of a simple but valid statement: SELECT "field3" AS "my_field3", "field2" AS "my_field2", "field1" AS "my_field1" FROM "sometable" and get the following structure: $VAR1 = { 'table_alias' => {}, 'original_string' => 'SELECT "field3" AS "my_field3", "field2" AS "my_field2", "field1" AS "my_field1" FROM "sometable"', 'org_table_names' => [ '"sometable"' ], 'ORG_NAME' => { '?QI0? AS ?QI1?' => '?QI0? AS ?QI1?', '?QI4? AS ?QI5?' => '?QI4? AS ?QI5?', '?QI2? AS ?QI3?' => '?QI2? AS ?QI3?' }, 'column_names' => [ '?QI0? AS ?QI1?', '?QI2? AS ?QI3?', '?QI4? AS ?QI5?' ], 'org_col_names' => [ '?QI0? AS ?QI1?', '?QI2? AS ?QI3?', '?QI4? AS ?QI5?' ], 'table_names' => [ '"SOMETABLE"' ], 'command' => 'SELECT' };
use strict; use SQL::Parser; use Data::Dumper; my $sql = qq{ SELECT "field3" AS "my_field3", "field2" AS "my_field2", "field1" AS "my_field1" FROM "sometable" }; # print $sql; my $parser = SQL::Parser->new(); if ($parser->parse($sql)) { print Dumper $parser->structure; } else { print "Parse failed\n"; }
There's nothing in the documentation to suggest that column aliases are supported by the parser. I do intend to add this in the fairly near future, but if you are submitting this as a feature request, please mark it as that, rather than as a bug and please give me some indication of how you are using the module so that I can gage how important the request is in comparison to other requests I get.