fix picking up quoted tables for SQLite, patch from schwern
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / DBI / SQLite.pm
index 3998fe8..d141258 100644 (file)
@@ -2,12 +2,15 @@ package DBIx::Class::Schema::Loader::DBI::SQLite;
 
 use strict;
 use warnings;
-use base qw/DBIx::Class::Schema::Loader::DBI/;
+use base qw/
+    DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault
+    DBIx::Class::Schema::Loader::DBI
+/;
 use Carp::Clan qw/^DBIx::Class/;
 use Text::Balanced qw( extract_bracketed );
 use Class::C3;
 
-our $VERSION = '0.04999_01';
+our $VERSION = '0.05001';
 
 =head1 NAME
 
@@ -63,7 +66,7 @@ sub _sqlite_parse_table {
     $sth->finish;
 
     # Cut "CREATE TABLE ( )" blabla...
-    $sql =~ /^[\w\s']+\((.*)\)$/si;
+    $sql =~ /^[\w\s"]+\((.*)\)$/si;
     my $cols = $1;
 
     # strip single-line comments
@@ -146,13 +149,19 @@ sub _sqlite_parse_table {
     return { rels => \@rels, uniqs => \@uniqs, auto_inc => \%auto_inc };
 }
 
-sub _column_is_auto_increment {
+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);
 
-    return $self->{_sqlite_parse_data}->{$table}->{auto_inc}->{$col_name};
+    if ($self->{_sqlite_parse_data}->{$table}->{auto_inc}->{$col_name}) {
+        $extra_info{is_auto_increment} = 1;
+    }
+
+    return \%extra_info;
 }
 
 sub _table_fk_info {
@@ -194,6 +203,15 @@ sub _tables_list {
 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
 L<DBIx::Class::Schema::Loader::DBI>
 
+=head1 AUTHOR
+
+See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
 =cut
 
 1;