Actually there was an empty test for it as well :)
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Parser / DBI / SQLite.pm
CommitLineData
6a9f7bae 1package SQL::Translator::Parser::DBI::SQLite;
2
3# -------------------------------------------------------------------
d4f84dd1 4# $Id: SQLite.pm 1440 2009-01-17 16:31:57Z jawnsy $
6a9f7bae 5# -------------------------------------------------------------------
478f608d 6# Copyright (C) 2002-2009 SQLFairy Authors
6a9f7bae 7#
8# This program is free software; you can redistribute it and/or
9# modify it under the terms of the GNU General Public License as
10# published by the Free Software Foundation; version 2.
11#
12# This program is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15# General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20# 02111-1307 USA
21# -------------------------------------------------------------------
22
23=head1 NAME
24
25SQL::Translator::Parser::DBI::SQLite - parser for DBD::SQLite
26
27=head1 SYNOPSIS
28
29See SQL::Translator::Parser::DBI.
30
31=head1 DESCRIPTION
32
9156433b 33Queries the "sqlite_master" table for schema definition. The schema
34is held in this table simply as CREATE statements for the database
35objects, so it really just builds up a string of all these and passes
36the result to the regular SQLite parser. Therefore there is no gain
37(at least in performance) to using this module over simply dumping the
38schema to a text file and parsing that.
6a9f7bae 39
40=cut
41
42use strict;
43use DBI;
44use SQL::Translator::Parser::SQLite;
45use Data::Dumper;
46
478f608d 47use vars qw[ $DEBUG @EXPORT_OK ];
6a9f7bae 48$DEBUG = 0 unless defined $DEBUG;
49
50# -------------------------------------------------------------------
51sub parse {
52 my ( $tr, $dbh ) = @_;
53
bdfd8a3f 54 my $create = join(";\n",
55 map { $_ || () }
56 @{ $dbh->selectcol_arrayref('select sql from sqlite_master') },
6a9f7bae 57 );
bdfd8a3f 58 $create .= ";";
59 $tr->debug( "create =\n$create\n" );
6a9f7bae 60
61 my $schema = $tr->schema;
62
6a9f7bae 63 SQL::Translator::Parser::SQLite::parse( $tr, $create );
64 return 1;
65}
66
671;
68
69# -------------------------------------------------------------------
70# Where man is not nature is barren.
71# William Blake
72# -------------------------------------------------------------------
73
74=pod
75
76=head1 AUTHOR
77
da804135 78Ken Y. Clark E<lt>kclark@cpan.orgE<gt>.
6a9f7bae 79
80=head1 SEE ALSO
81
9156433b 82SQL::Translator::Parser::SQLite.
6a9f7bae 83
84=cut