Skip Menu |

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

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

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

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



Subject: SQL ERROR: 'DECIMAL(6' is not a recognized data type!
# SQL ERROR: 'DECIMAL(6' is not a recognized data type! # SQL ERROR: 'DECIMAL(6' is not a recognized data type! # discovered while attempting to # use Class::DBI::Loader::Relationship; # via Maypole with Class::DBI::SQLite, which basically does use SQL::Statement; my $sql = q~ CREATE TABLE product ( id INTEGER PRIMARY KEY NOT NULL, category int(11), subcategory int(11), manufacturer int(11), part_number varchar(50), name varchar(50), cost decimal(6,2), description text(65535) )~; # $sql .= ';'; # dunno if it matters, but adding a ; at the end causes: # SQL ERROR: Can't find column definitions! # SQL ERROR: Can't find column definitions! # # which is misleading my $parser = SQL::Parser->new('AnyData', { RaiseError => 1}); $parser->feature("valid_data_types","TIMESTAMP",1); $parser->parse($sql);
Here's a patch to correctly parse this stuff (it's still not SQL::Translator ) Now the error with AnyData dialect is SQL ERROR: 'DECIMAL' is not a recognized data type! and ANSI dialect is SQL ERROR: 'TEXT' is not a recognized data type! so the dialects obviously need some work. You should look at SQL::Translator to harvest that information --- Parser.pm Thu Apr 22 11:25:52 2004 +++ Parser.pm.new Sat May 15 06:18:08 2004 @@ -615,7 +615,22 @@ return undef unless $self->TABLE_NAME($table_name); $table_element_def =~ s/\s+\(/(/g; my $primary_defined; - for my $col(split ',',$table_element_def) { +# for my $col(split ',',$table_element_def) { + for my $col(grep { length } split m{ + ( + \s* + \S+ # name + \s+ + [^\s\(]+ # type + (?: # length (optional) + \( + [^\)]+ + \) + )? + [^,]* + ), + }x,$table_element_def) { + my($name,$type,$constraints)=($col =~/\s*(\S+)\s+(\S+)\s* (.*)/); if (!$type) { return $self->do_err( "Column definition is missing a data type!" );