use Text::Balanced qw( extract_bracketed );
use Class::C3;
-our $VERSION = '0.03999_01';
+our $VERSION = '0.04999_01';
=head1 NAME
my @rels;
my @uniqs;
+ my %auto_inc;
my $dbh = $self->schema->storage->dbh;
my $sth = $self->{_cache}->{sqlite_master}
$sth->finish;
# Cut "CREATE TABLE ( )" blabla...
- $sql =~ /^[\w\s]+\((.*)\)$/si;
+ $sql =~ /^[\w\s']+\((.*)\)$/si;
my $cols = $1;
# strip single-line comments
# Grab reference
chomp $col;
- if($col =~ /^(.*)\s+UNIQUE/) {
+ if($col =~ /^(.*)\s+UNIQUE/i) {
my $colname = $1;
$colname =~ s/\s+.*$//;
push(@uniqs, [ "${colname}_unique" => [ lc $colname ] ]);
}
- elsif($col =~/^\s*UNIQUE\s*\(\s*(.*)\)/) {
+ elsif($col =~/^\s*UNIQUE\s*\(\s*(.*)\)/i) {
my $cols = $1;
$cols =~ s/\s+$//;
my @cols = map { lc } split(/\s*,\s*/, $cols);
push(@uniqs, [ $name => \@cols ]);
}
+ if ($col =~ /AUTOINCREMENT/i) {
+ $col =~ /^(\S+)/;
+ $auto_inc{lc $1} = 1;
+ }
+
next if $col !~ /^(.*\S)\s+REFERENCES\s+(\w+) (?: \s* \( (.*) \) )? /ix;
my ($cols, $f_table, $f_cols) = ($1, $2, $3);
});
}
- return { rels => \@rels, uniqs => \@uniqs };
+ return { rels => \@rels, uniqs => \@uniqs, auto_inc => \%auto_inc };
+}
+
+sub _extra_column_info {
+ my ($self, $table, $col_name, $sth, $col_num) = @_;
+ my %extra_info;
+
+ $self->{_sqlite_parse_data}->{$table} ||=
+ $self->_sqlite_parse_table($table);
+
+ if ($self->{_sqlite_parse_data}->{$table}->{auto_inc}->{$col_name}) {
+ $extra_info{is_auto_increment} = 1;
+ }
+
+ return \%extra_info;
}
sub _table_fk_info {
my @tables;
while ( my $row = $sth->fetchrow_hashref ) {
next unless lc( $row->{type} ) eq 'table';
+ next if $row->{tbl_name} =~ /^sqlite_/;
push @tables, $row->{tbl_name};
}
$sth->finish;