3
# ##########################################################################
4
# This is a magic test file that is designed to be run manually.
5
# ##########################################################################
7
# This program is copyright (c) 2007 Baron Schwartz.
8
# Feedback and improvements are welcome.
10
# THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
11
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
12
# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14
# This program is free software; you can redistribute it and/or modify it under
15
# the terms of the GNU General Public License as published by the Free Software
16
# Foundation, version 2; OR the Perl Artistic License. On UNIX and similar
17
# systems, you can issue `man perlgpl' or `man perlartistic' to read these
20
# You should have received a copy of the GNU General Public License along with
21
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22
# Place, Suite 330, Boston, MA 02111-1307 USA.
24
use warnings FATAL => 'all';
26
use Test::More qw(no_plan);
27
use English qw(-no_match_vars);
30
require "../TableParser.pm";
31
require "../MySQLFind.pm";
32
require "../MySQLDump.pm";
33
require "../Quoter.pm";
35
my $p = new TableParser();
37
my $d = new MySQLDump();
40
# This part of the test inspects every table in the local MySQL server, if a
41
# connection can be made. It checks that parsing produces the same columns
42
# and types and nullability etc as reported by SHOW COLUMNS.
47
"DBI:mysql:;mysql_read_default_group=mysql", undef, undef,
48
{ PrintError => 0, RaiseError => 1 })
51
diag "Cannot connect";
55
my $f = new MySQLFind(
63
foreach my $database ( $f->find_databases() ) {
64
foreach my $table ( $f->find_tables(database => $database) ) {
65
my $ddl = $d->get_create_table($dbh, $q, $database, $table);
66
my $str = $p->parse($ddl);
67
my $cols = $d->get_columns($dbh, $q, $database, $table);
71
[ map { $_->{field} } @$cols ],
72
"Columns for $database.$table",
82
"Column types for $database.$table",
87
[ map { $_->{field} } grep { $_->{null} eq 'YES' } @$cols ],
88
"Nullability for $database.$table",