| 1 | package DBIx::Schema::Annotate::Driver::SQLite; | ||
| 2 | use parent 'DBIx::Schema::Annotate::Driver::Base'; | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use Smart::Args; | ||
| 6 | |||
| 7 | sub table_ddl { | ||
| 8 | args( | ||
| 9 | my $self, | ||
| 10 | my $table_name => 'Str', | ||
| 11 | ); | ||
| 12 | |||
| 13 | my $schema_row = do { | ||
| 14 | my $sth = $self->{dbh}->prepare(q! SELECT * FROM sqlite_master WHERE type='table' and name = ? !); | ||
| 15 | $sth->execute($table_name); | ||
| 16 | $sth->fetchrow_hashref; | ||
| 17 | }; | ||
| 18 | my $index_rows = do { | ||
| 19 | my $sth = $self->{dbh}->prepare(q! SELECT * FROM sqlite_master WHERE type='index' and tbl_name = ? !); | ||
| 20 | $sth->execute($table_name); | ||
| 21 | $sth->fetchall_hashref('sql'); | ||
| 22 | }; | ||
| 23 | |||
| 24 | return $schema_row->{sql} unless scalar keys %$index_rows; | ||
| 25 | return join("\n", $schema_row->{sql}, sort keys %$index_rows); | ||
| 26 | } | ||
| 27 | |||
| 28 | 1; | ||
| 29 |