Subject: | SQL::Parser no longer needed (patch included) |
SQL::Parser/SQL::Dialects::AnyData do not play well with SQLite sql
( see http://rt.cpan.org/NoAuth/Bug.html?ShowHeaders=6308&id=6308 )
but IT DOESN'T MATTER because since
'DBD::SQLite' => 0.29,
PRAGMA table_info(?) returns a "pk" field, which tells you if it's a primary key (either a 0 or a 1).
PS - Just call me PodMaster
--- SQLite.pm Mon Mar 15 03:57:19 2004
+++ SQLite.pm.new Sun May 16 04:47:17 2004
@@ -2,11 +2,10 @@
use strict;
use vars qw($VERSION);
-$VERSION = 0.04;
+$VERSION = 0.041;
require Class::DBI;
use base qw(Class::DBI);
-use SQL::Statement;
sub _auto_increment_value {
my $self = shift;
@@ -22,34 +21,13 @@
SQL
$sth->execute($table);
my @columns;
+ my $primary;
while (my $row = $sth->fetchrow_hashref) {
- push @columns,$row->{name};
+ push @columns,$row->{name};
+ $primary = $row->{name} if $row->{pk};
}
$sth->finish;
- # find primary key. so complex ;-(
- $sth = $class->db_Main->prepare(<<'SQL');
-SELECT sql FROM sqlite_master WHERE tbl_name = ?
-SQL
- $sth->execute($table);
- my($sql) = $sth->fetchrow_array;
- $sth->finish;
-
- my $parser = SQL::Parser->new('AnyData', { RaiseError => 1});
- $parser->feature("valid_data_types","TIMESTAMP",1);
- $parser->parse($sql);
- my $structure = $parser->structure;
- my $primary;
- foreach my $key (keys %{$structure->{column_defs}}) {
- my $def = $structure->{column_defs}->{$key};
- next unless $def->{constraints};
- foreach my $constraint(@{$def->{constraints}}) {
- if (uc($constraint) eq 'PRIMARY KEY') {
- $primary = $key;
- last;
- }
- }
- }
$class->table($table);
$class->columns(All => @columns);
$class->columns(Primary => $primary);