X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FDBI%2FSQLite.pm;h=285d02714494c66e1d8737ce2a313e682427f233;hb=b1ad1a8402a5eb0955c6b76310809c2ab29291a9;hp=98c467e0a42818cfaa6d43c6591b5013a5fd9b18;hpb=3fe9c5d92b3872c146c93f99b77aa330bffe04ef;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm b/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm index 98c467e..285d027 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm @@ -7,7 +7,7 @@ use Carp::Clan qw/^DBIx::Class/; use Text::Balanced qw( extract_bracketed ); use Class::C3; -our $VERSION = '0.03999_02'; +our $VERSION = '0.04999_10'; =head1 NAME @@ -52,6 +52,7 @@ sub _sqlite_parse_table { my @rels; my @uniqs; + my %auto_inc; my $dbh = $self->schema->storage->dbh; my $sth = $self->{_cache}->{sqlite_master} @@ -110,6 +111,11 @@ sub _sqlite_parse_table { 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); @@ -137,7 +143,22 @@ sub _sqlite_parse_table { }); } - 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) = @_; + ($table, $col_name) = @{$table}{qw/TABLE_NAME COLUMN_NAME/} if ref $table; + 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 {