Strip evil svn:keywords
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Parser / DBI / SQLite.pm
1 package SQL::Translator::Parser::DBI::SQLite;
2
3 # -------------------------------------------------------------------
4 # $Id: SQLite.pm 1440 2009-01-17 16:31:57Z jawnsy $
5 # -------------------------------------------------------------------
6 # Copyright (C) 2002-2009 SQLFairy Authors
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
25 SQL::Translator::Parser::DBI::SQLite - parser for DBD::SQLite
26
27 =head1 SYNOPSIS
28
29 See SQL::Translator::Parser::DBI.
30
31 =head1 DESCRIPTION
32
33 Queries the "sqlite_master" table for schema definition.  The schema
34 is held in this table simply as CREATE statements for the database
35 objects, so it really just builds up a string of all these and passes
36 the result to the regular SQLite parser.  Therefore there is no gain 
37 (at least in performance) to using this module over simply dumping the 
38 schema to a text file and parsing that.
39
40 =cut
41
42 use strict;
43 use DBI;
44 use SQL::Translator::Parser::SQLite;
45 use Data::Dumper;
46
47 use vars qw[ $DEBUG @EXPORT_OK ];
48 $DEBUG   = 0 unless defined $DEBUG;
49
50 # -------------------------------------------------------------------
51 sub parse {
52     my ( $tr, $dbh ) = @_;
53
54     my $create = join(";\n",
55         map { $_ || () }
56         @{ $dbh->selectcol_arrayref('select sql from sqlite_master') },
57     );
58     $create .= ";";
59     $tr->debug( "create =\n$create\n" );
60
61     my $schema = $tr->schema;
62
63     SQL::Translator::Parser::SQLite::parse( $tr, $create );
64     return 1;
65 }
66
67 1;
68
69 # -------------------------------------------------------------------
70 # Where man is not nature is barren.
71 # William Blake
72 # -------------------------------------------------------------------
73
74 =pod
75
76 =head1 AUTHOR
77
78 Ken Y. Clark E<lt>kclark@cpan.orgE<gt>.
79
80 =head1 SEE ALSO
81
82 SQL::Translator::Parser::SQLite.
83
84 =cut