SQL-Translator-0.11024/ 0000755 0001750 0001750 00000000000 13225114407 013762 5 ustar ilmari ilmari SQL-Translator-0.11024/share/ 0000755 0001750 0001750 00000000000 13225114407 015064 5 ustar ilmari ilmari SQL-Translator-0.11024/share/PrecompiledParsers/ 0000755 0001750 0001750 00000000000 13225114407 020667 5 ustar ilmari ilmari SQL-Translator-0.11024/share/PrecompiledParsers/Parse/ 0000755 0001750 0001750 00000000000 13225114407 021741 5 ustar ilmari ilmari SQL-Translator-0.11024/share/PrecompiledParsers/Parse/RecDescent/ 0000755 0001750 0001750 00000000000 13225114407 023760 5 ustar ilmari ilmari SQL-Translator-0.11024/share/PrecompiledParsers/Parse/RecDescent/DDL/ 0000755 0001750 0001750 00000000000 13225114407 024363 5 ustar ilmari ilmari SQL-Translator-0.11024/share/PrecompiledParsers/Parse/RecDescent/DDL/SQLT/ 0000755 0001750 0001750 00000000000 13225114407 025146 5 ustar ilmari ilmari SQL-Translator-0.11024/share/PrecompiledParsers/Parse/RecDescent/DDL/SQLT/README 0000644 0001750 0001750 00000000147 12163313615 026032 0 ustar ilmari ilmari The contents of this directory are automatically regenerated when
invoking Makefile.PL in author mode.
SQL-Translator-0.11024/share/DiaUml/ 0000755 0001750 0001750 00000000000 13225114407 016237 5 ustar ilmari ilmari SQL-Translator-0.11024/share/DiaUml/uml-class.tt2 0000644 0001750 0001750 00000000651 12163313615 020576 0 ustar ilmari ilmari [%# vim:ft=tt2
-%]
[% INCLUDE 'uml-class-start.tt2' %]
[%- FOREACH attributes;
INCLUDE "uml-attribute.tt2";
END %]
[% INCLUDE 'uml-class-end.tt2' %]
SQL-Translator-0.11024/share/DiaUml/schema.tt2 0000644 0001750 0001750 00000002144 12163313615 020135 0 ustar ilmari ilmari [%# vim:ft=tt2 -%]
[% WRAPPER diagram.tt2 %]
[% WRAPPER layer.tt2 name="Background" %]
[% FOREACH table IN schema.get_tables %]
[% INCLUDE 'uml-class-start.tt2'
name = table.name
stereotype = 'Table'
visible_operations = 'false'
%]
[% FOREACH field IN table.get_fields;
SET type = field.data_type;
SET type = "$type($field.size)" IF field.size;
INCLUDE "uml-attribute.tt2"
name = field.name
stereotype = 'Field'
type = type
value = field.default_value
;
END %]
[% INCLUDE 'uml-class-end.tt2' %]
[% END %]
[% END %]
[% END %]
SQL-Translator-0.11024/share/DiaUml/diagram.tt2 0000644 0001750 0001750 00000004110 12163313615 020274 0 ustar ilmari ilmari
#A4#
[% content %]
SQL-Translator-0.11024/share/DiaUml/uml-class-all.tt2 0000644 0001750 0001750 00000007375 12163313615 021356 0 ustar ilmari ilmari [%# vim:ft=tt2
-%]
#[% name %]#
#[% stereotype %]#
#[% comment %]#
[% FOREACH attributes %]
[% INCLUDE "uml-attribute.tt2" %]
[% END %]
SQL-Translator-0.11024/share/DiaUml/layer.tt2 0000644 0001750 0001750 00000000210 12163313615 020001 0 ustar ilmari ilmari [%-
DEFAULT name="Layer1" visible="true"
%]
[% content %]
SQL-Translator-0.11024/share/DiaUml/uml-class-end.tt2 0000644 0001750 0001750 00000000045 12163313615 021337 0 ustar ilmari ilmari [%# vim:ft=tt2
-%]
SQL-Translator-0.11024/share/DiaUml/uml-attribute.tt2 0000644 0001750 0001750 00000001727 12163313615 021501 0 ustar ilmari ilmari [%# vim:ft=tt2
-%]
[%-
DEFAULT visibility=0 abstract="false" class_scope="false"
%]
#[% name %]#
#[% type %]#
#[% value %]#
#[% comment %]#
SQL-Translator-0.11024/share/DiaUml/uml-class-start.tt2 0000644 0001750 0001750 00000006736 12163313615 021743 0 ustar ilmari ilmari [% # vim:ft=tt2
DEFAULT
visible_operations='true'
-%]
#[% name %]#
#[% stereotype %]#
#[% comment %]#
SQL-Translator-0.11024/MANIFEST 0000644 0001750 0001750 00000014514 13225114163 015117 0 ustar ilmari ilmari AUTHORS
Changes
inc/Module/AutoInstall.pm
inc/Module/Install.pm
inc/Module/Install/AuthorTests.pm
inc/Module/Install/AutoInstall.pm
inc/Module/Install/Base.pm
inc/Module/Install/Can.pm
inc/Module/Install/Fetch.pm
inc/Module/Install/Include.pm
inc/Module/Install/Makefile.pm
inc/Module/Install/Metadata.pm
inc/Module/Install/ReadmeFromPod.pm
inc/Module/Install/Scripts.pm
inc/Module/Install/Share.pm
inc/Module/Install/Win32.pm
inc/Module/Install/WriteAll.pm
lib/SQL/Translator.pm
lib/SQL/Translator/Diff.pm
lib/SQL/Translator/Filter/DefaultExtra.pm
lib/SQL/Translator/Filter/Globals.pm
lib/SQL/Translator/Filter/Names.pm
lib/SQL/Translator/Generator/DDL/MySQL.pm
lib/SQL/Translator/Generator/DDL/PostgreSQL.pm
lib/SQL/Translator/Generator/DDL/SQLite.pm
lib/SQL/Translator/Generator/DDL/SQLServer.pm
lib/SQL/Translator/Generator/Role/DDL.pm
lib/SQL/Translator/Generator/Role/Quote.pm
lib/SQL/Translator/Manual.pod
lib/SQL/Translator/Parser.pm
lib/SQL/Translator/Parser/Access.pm
lib/SQL/Translator/Parser/DB2.pm
lib/SQL/Translator/Parser/DB2/Grammar.pm
lib/SQL/Translator/Parser/DBI.pm
lib/SQL/Translator/Parser/DBI/DB2.pm
lib/SQL/Translator/Parser/DBI/MySQL.pm
lib/SQL/Translator/Parser/DBI/Oracle.pm
lib/SQL/Translator/Parser/DBI/PostgreSQL.pm
lib/SQL/Translator/Parser/DBI/SQLite.pm
lib/SQL/Translator/Parser/DBI/SQLServer.pm
lib/SQL/Translator/Parser/DBI/Sybase.pm
lib/SQL/Translator/Parser/Excel.pm
lib/SQL/Translator/Parser/JSON.pm
lib/SQL/Translator/Parser/MySQL.pm
lib/SQL/Translator/Parser/Oracle.pm
lib/SQL/Translator/Parser/PostgreSQL.pm
lib/SQL/Translator/Parser/SQLite.pm
lib/SQL/Translator/Parser/SQLServer.pm
lib/SQL/Translator/Parser/Storable.pm
lib/SQL/Translator/Parser/Sybase.pm
lib/SQL/Translator/Parser/XML.pm
lib/SQL/Translator/Parser/XML/SQLFairy.pm
lib/SQL/Translator/Parser/xSV.pm
lib/SQL/Translator/Parser/YAML.pm
lib/SQL/Translator/Producer.pm
lib/SQL/Translator/Producer/ClassDBI.pm
lib/SQL/Translator/Producer/DB2.pm
lib/SQL/Translator/Producer/Diagram.pm
lib/SQL/Translator/Producer/DiaUml.pm
lib/SQL/Translator/Producer/Dumper.pm
lib/SQL/Translator/Producer/GraphViz.pm
lib/SQL/Translator/Producer/HTML.pm
lib/SQL/Translator/Producer/JSON.pm
lib/SQL/Translator/Producer/Latex.pm
lib/SQL/Translator/Producer/MySQL.pm
lib/SQL/Translator/Producer/Oracle.pm
lib/SQL/Translator/Producer/POD.pm
lib/SQL/Translator/Producer/PostgreSQL.pm
lib/SQL/Translator/Producer/SQLite.pm
lib/SQL/Translator/Producer/SQLServer.pm
lib/SQL/Translator/Producer/Storable.pm
lib/SQL/Translator/Producer/Sybase.pm
lib/SQL/Translator/Producer/TT/Base.pm
lib/SQL/Translator/Producer/TT/Table.pm
lib/SQL/Translator/Producer/TTSchema.pm
lib/SQL/Translator/Producer/XML.pm
lib/SQL/Translator/Producer/XML/SQLFairy.pm
lib/SQL/Translator/Producer/YAML.pm
lib/SQL/Translator/Role/BuildArgs.pm
lib/SQL/Translator/Role/Debug.pm
lib/SQL/Translator/Role/Error.pm
lib/SQL/Translator/Role/ListAttr.pm
lib/SQL/Translator/Schema.pm
lib/SQL/Translator/Schema/Constants.pm
lib/SQL/Translator/Schema/Constraint.pm
lib/SQL/Translator/Schema/Field.pm
lib/SQL/Translator/Schema/Index.pm
lib/SQL/Translator/Schema/Object.pm
lib/SQL/Translator/Schema/Procedure.pm
lib/SQL/Translator/Schema/Role/Compare.pm
lib/SQL/Translator/Schema/Role/Extra.pm
lib/SQL/Translator/Schema/Table.pm
lib/SQL/Translator/Schema/Trigger.pm
lib/SQL/Translator/Schema/View.pm
lib/SQL/Translator/Types.pm
lib/SQL/Translator/Utils.pm
lib/Test/SQL/Translator.pm
Makefile.PL
MANIFEST This list of files
META.yml
README
script/sqlt
script/sqlt-diagram
script/sqlt-diff
script/sqlt-diff-old
script/sqlt-dumper
script/sqlt-graph
script/sqlt.cgi
share/DiaUml/diagram.tt2
share/DiaUml/layer.tt2
share/DiaUml/schema.tt2
share/DiaUml/uml-attribute.tt2
share/DiaUml/uml-class-all.tt2
share/DiaUml/uml-class-end.tt2
share/DiaUml/uml-class-start.tt2
share/DiaUml/uml-class.tt2
share/PrecompiledParsers/Parse/RecDescent/DDL/SQLT/README
t/02mysql-parser.t
t/03mysql-to-oracle.t
t/04file,fh,string.t
t/05bgep-re.t
t/06xsv.t
t/07p_args.t
t/08postgres-to-mysql.t
t/09sqlt-diagram.t
t/10excel.t
t/11normalize.t
t/12header_comment.t
t/13schema.t
t/14postgres-parser.t
t/15oracle-parser.t
t/16xml-parser.t
t/17sqlfxml-producer.t
t/18ttschema-producer.t
t/19sybase-parser.t
t/20format_X_name.t
t/23json.t
t/24yaml.t
t/25storable.t
t/26sybase.t
t/27sqlite-parser.t
t/29html.t
t/30sqlt-new-diff-mysql.t
t/30sqlt-new-diff-pgsql.t
t/30sqlt-new-diff-sqlite.t
t/30sqlt-new-diff.t
t/31dumper.t
t/32schema-lookups.t
t/33tt-table-producer.t
t/34tt-base.t
t/35-access-parser.t
t/36-filters.t
t/38-filter-names.t
t/38-mysql-producer.t
t/39-filter-globals.t
t/40oracle-parser-dbi.t
t/43xml-to-db2.t
t/44-xml-to-db2-array.t
t/45db2-producer.t
t/46xml-to-pg.t
t/47postgres-producer.t
t/48xml-to-sqlite.t
t/49xml-to-pg-samefield.t
t/50-sqlserver-parser.t
t/51-xml-to-oracle.t
t/51-xml-to-oracle_quoted.t
t/52-oracle-options.t
t/53-oracle-delay-constraints.t
t/53-oracle-delay-constraints_quoted.t
t/54-oracle-alter-field.t
t/55-oracle-add-field.t
t/55-oracle-producer.t
t/56-sqlite-producer.t
t/57-class-dbi.t
t/60roundtrip.t
t/61translator_agnostic.t
t/62roundtrip_datacheck.t
t/63-spacial-pgsql.t
t/64xml-to-mysql.t
t/66-postgres-dbi-parser.t
t/70sqlt-diff_script.t
t/70sqlt-diff_script_old.t
t/71-generator-sql_server.t
t/72-sqlite-add-drop-fields.t
t/73-sqlite-respects-quote.t
t/74-filename-arrayref.t
t/data/access/gdpdm.ddl
t/data/diff/create1.yml
t/data/diff/create2.yml
t/data/diff/pgsql/create1.yml
t/data/diff/pgsql/create2.yml
t/data/Excel/t.xls
t/data/mysql/Apache-Session-MySQL.sql
t/data/mysql/BGEP-RE-create.sql
t/data/mysql/cashmusic_db.sql
t/data/mysql/create.sql
t/data/mysql/create2.sql
t/data/mysql/entire_syntax.sql
t/data/mysql/sqlfxml-producer-basic.sql
t/data/oracle/create.sql
t/data/oracle/create2.sql
t/data/oracle/schema_diff_a.yaml
t/data/oracle/schema_diff_b.yaml
t/data/oracle/schema_diff_c.yaml
t/data/oracle/schema_with_options.yaml
t/data/pgsql/Chado-CV-PostGreSQL.sql
t/data/pgsql/entire_syntax.sql
t/data/pgsql/turnkey.sql
t/data/roundtrip.xml
t/data/roundtrip_autogen.yaml
t/data/sqlite/create.sql
t/data/sqlite/create2.sql
t/data/sqlite/named.sql
t/data/sqlserver/create.sql
t/data/sybase/create.sql
t/data/template/basic.tt
t/data/template/table.tt
t/data/template/testresult_basic.txt
t/data/template/testresult_table.txt
t/data/xml/samefield.xml
t/data/xml/schema.xml
t/lib/Producer/BaseTest.pm
t/mysql-sqlite-translate.t
t/postgresql-rename-table-and-field.t
t/sqlite-rename-field.t
xt/eol.t
xt/notabs.t
xt/pod.t
SQL-Translator-0.11024/README 0000644 0001750 0001750 00000034471 13225114154 014652 0 ustar ilmari ilmari NAME
SQL::Translator - manipulate structured data definitions (SQL and more)
SYNOPSIS
use SQL::Translator;
my $translator = SQL::Translator->new(
# Print debug info
debug => 1,
# Print Parse::RecDescent trace
trace => 0,
# Don't include comments in output
no_comments => 0,
# Print name mutations, conflicts
show_warnings => 0,
# Add "drop table" statements
add_drop_table => 1,
# to quote or not to quote, thats the question
quote_identifiers => 1,
# Validate schema object
validate => 1,
# Make all table names CAPS in producers which support this option
format_table_name => sub {my $tablename = shift; return uc($tablename)},
# Null-op formatting, only here for documentation's sake
format_package_name => sub {return shift},
format_fk_name => sub {return shift},
format_pk_name => sub {return shift},
);
my $output = $translator->translate(
from => 'MySQL',
to => 'Oracle',
# Or an arrayref of filenames, i.e. [ $file1, $file2, $file3 ]
filename => $file,
) or die $translator->error;
print $output;
DESCRIPTION
This documentation covers the API for SQL::Translator. For a more
general discussion of how to use the modules and scripts, please see
SQL::Translator::Manual.
SQL::Translator is a group of Perl modules that converts vendor-specific
SQL table definitions into other formats, such as other vendor-specific
SQL, ER diagrams, documentation (POD and HTML), XML, and Class::DBI
classes. The main focus of SQL::Translator is SQL, but parsers exist for
other structured data formats, including Excel spreadsheets and
arbitrarily delimited text files. Through the separation of the code
into parsers and producers with an object model in between, it's
possible to combine any parser with any producer, to plug in custom
parsers or producers, or to manipulate the parsed data via the built-in
object model. Presently only the definition parts of SQL are handled
(CREATE, ALTER), not the manipulation of data (INSERT, UPDATE, DELETE).
CONSTRUCTOR
new
The constructor is called "new", and accepts a optional hash of options.
Valid options are:
* parser / from
* parser_args
* producer / to
* producer_args
* filters
* filename / file
* data
* debug
* add_drop_table
* quote_identifiers
* quote_table_names (DEPRECATED)
* quote_field_names (DEPRECATED)
* no_comments
* trace
* validate
All options are, well, optional; these attributes can be set via
instance methods. Internally, they are; no (non-syntactical) advantage
is gained by passing options to the constructor.
METHODS
add_drop_table
Toggles whether or not to add "DROP TABLE" statements just before the
create definitions.
quote_identifiers
Toggles whether or not to quote identifiers (table, column, constraint,
etc.) with a quoting mechanism suitable for the chosen Producer. The
default (true) is to quote them.
quote_table_names
DEPRECATED - A legacy proxy to "quote_identifiers"
quote_field_names
DEPRECATED - A legacy proxy to "quote_identifiers"
no_comments
Toggles whether to print comments in the output. Accepts a true or false
value, returns the current value.
producer
The "producer" method is an accessor/mutator, used to retrieve or define
what subroutine is called to produce the output. A subroutine defined as
a producer will be invoked as a function (*not a method*) and passed its
container "SQL::Translator" instance, which it should call the "schema"
method on, to get the "SQL::Translator::Schema" generated by the parser.
It is expected that the function transform the schema structure to a
string. The "SQL::Translator" instance is also useful for informational
purposes; for example, the type of the parser can be retrieved using the
"parser_type" method, and the "error" and "debug" methods can be called
when needed.
When defining a producer, one of several things can be passed in: A
module name (e.g., "My::Groovy::Producer"), a module name relative to
the "SQL::Translator::Producer" namespace (e.g., "MySQL"), a module name
and function combination ("My::Groovy::Producer::transmogrify"), or a
reference to an anonymous subroutine. If a full module name is passed in
(for the purposes of this method, a string containing "::" is considered
to be a module name), it is treated as a package, and a function called
"produce" will be invoked: $modulename::produce. If $modulename cannot
be loaded, the final portion is stripped off and treated as a function.
In other words, if there is no file named
My/Groovy/Producer/transmogrify.pm, "SQL::Translator" will attempt to
load My/Groovy/Producer.pm and use "transmogrify" as the name of the
function, instead of the default "produce".
my $tr = SQL::Translator->new;
# This will invoke My::Groovy::Producer::produce($tr, $data)
$tr->producer("My::Groovy::Producer");
# This will invoke SQL::Translator::Producer::Sybase::produce($tr, $data)
$tr->producer("Sybase");
# This will invoke My::Groovy::Producer::transmogrify($tr, $data),
# assuming that My::Groovy::Producer::transmogrify is not a module
# on disk.
$tr->producer("My::Groovy::Producer::transmogrify");
# This will invoke the referenced subroutine directly, as
# $subref->($tr, $data);
$tr->producer(\&my_producer);
There is also a method named "producer_type", which is a string
containing the classname to which the above "produce" function belongs.
In the case of anonymous subroutines, this method returns the string
"CODE".
Finally, there is a method named "producer_args", which is both an
accessor and a mutator. Arbitrary data may be stored in name => value
pairs for the producer subroutine to access:
sub My::Random::producer {
my ($tr, $data) = @_;
my $pr_args = $tr->producer_args();
# $pr_args is a hashref.
Extra data passed to the "producer" method is passed to "producer_args":
$tr->producer("xSV", delimiter => ',\s*');
# In SQL::Translator::Producer::xSV:
my $args = $tr->producer_args;
my $delimiter = $args->{'delimiter'}; # value is ,\s*
parser
The "parser" method defines or retrieves a subroutine that will be
called to perform the parsing. The basic idea is the same as that of
"producer" (see above), except the default subroutine name is "parse",
and will be invoked as "$module_name::parse($tr, $data)". Also, the
parser subroutine will be passed a string containing the entirety of the
data to be parsed.
# Invokes SQL::Translator::Parser::MySQL::parse()
$tr->parser("MySQL");
# Invokes My::Groovy::Parser::parse()
$tr->parser("My::Groovy::Parser");
# Invoke an anonymous subroutine directly
$tr->parser(sub {
my $dumper = Data::Dumper->new([ $_[1] ], [ "SQL" ]);
$dumper->Purity(1)->Terse(1)->Deepcopy(1);
return $dumper->Dump;
});
There is also "parser_type" and "parser_args", which perform analogously
to "producer_type" and "producer_args"
filters
Set or retrieve the filters to run over the schema during the
translation, before the producer creates its output. Filters are sub
routines called, in order, with the schema object to filter as the 1st
arg and a hash of options (passed as a list) for the rest of the args.
They are free to do whatever they want to the schema object, which will
be handed to any following filters, then used by the producer.
Filters are set as an array, which gives the order they run in. Like
parsers and producers, they can be defined by a module name, a module
name relative to the SQL::Translator::Filter namespace, a module name
and function name together or a reference to an anonymous subroutine.
When using a module name a function called "filter" will be invoked in
that package to do the work.
To pass args to the filter set it as an array ref with the 1st value
giving the filter (name or sub) and the rest its args. e.g.
$tr->filters(
sub {
my $schema = shift;
# Do stuff to schema here!
},
DropFKeys,
[ "Names", table => 'lc' ],
[ "Foo", foo => "bar", hello => "world" ],
[ "Filter5" ],
);
Although you normally set them in the constructor, which calls through
to filters. i.e.
my $translator = SQL::Translator->new(
...
filters => [
sub { ... },
[ "Names", table => 'lc' ],
],
...
);
See t/36-filters.t for more examples.
Multiple set calls to filters are cumulative with new filters added to
the end of the current list.
Returns the filters as a list of array refs, the 1st value being a
reference to the filter sub and the rest its args.
show_warnings
Toggles whether to print warnings of name conflicts, identifier
mutations, etc. Probably only generated by producers to let the user
know when something won't translate very smoothly (e.g., MySQL "enum"
fields into Oracle). Accepts a true or false value, returns the current
value.
translate
The "translate" method calls the subroutine referenced by the "parser"
data member, then calls any "filters" and finally calls the "producer"
sub routine (these members are described above). It accepts as arguments
a number of things, in key => value format, including (potentially) a
parser and a producer (they are passed directly to the "parser" and
"producer" methods).
Here is how the parameter list to "translate" is parsed:
* 1 argument means it's the data to be parsed; which could be a string
(filename) or a reference to a scalar (a string stored in memory),
or a reference to a hash, which is parsed as being more than one
argument (see next section).
# Parse the file /path/to/datafile
my $output = $tr->translate("/path/to/datafile");
# Parse the data contained in the string $data
my $output = $tr->translate(\$data);
* More than 1 argument means its a hash of things, and it might be
setting a parser, producer, or datasource (this key is named
"filename" or "file" if it's a file, or "data" for a SCALAR
reference.
# As above, parse /path/to/datafile, but with different producers
for my $prod ("MySQL", "XML", "Sybase") {
print $tr->translate(
producer => $prod,
filename => "/path/to/datafile",
);
}
# The filename hash key could also be:
datasource => \$data,
You get the idea.
filename, data
Using the "filename" method, the filename of the data to be parsed can
be set. This method can be used in conjunction with the "data" method,
below. If both the "filename" and "data" methods are invoked as
mutators, the data set in the "data" method is used.
$tr->filename("/my/data/files/create.sql");
or:
my $create_script = do {
local $/;
open CREATE, "/my/data/files/create.sql" or die $!;
;
};
$tr->data(\$create_script);
"filename" takes a string, which is interpreted as a filename. "data"
takes a reference to a string, which is used as the data to be parsed.
If a filename is set, then that file is opened and read when the
"translate" method is called, as long as the data instance variable is
not set.
schema
Returns the SQL::Translator::Schema object.
trace
Turns on/off the tracing option of Parse::RecDescent.
validate
Whether or not to validate the schema object after parsing and before
producing.
version
Returns the version of the SQL::Translator release.
AUTHORS
See the included AUTHORS file:
GETTING HELP/SUPPORT
If you are stuck with a problem or have doubts about a particular
approach do not hesitate to contact us via any of the following options
(the list is sorted by "fastest response time"):
* IRC: irc.perl.org#sql-translator
* Mailing list:
* RT Bug Tracker:
HOW TO CONTRIBUTE
Contributions are always welcome, in all usable forms (we especially
welcome documentation improvements). The delivery methods include git-
or unified-diff formatted patches, GitHub pull requests, or plain bug
reports either via RT or the Mailing list. Contributors are generally
granted access to the official repository after their first several
patches pass successful review. Don't hesitate to contact us with any
further questions you may have.
This project is maintained in a git repository. The code and related
tools are accessible at the following locations:
* Official repo:
* Official gitweb:
* GitHub mirror:
* Authorized committers:
* Travis-CI log:
COPYRIGHT
Copyright 2012 the SQL::Translator authors, as listed in "AUTHORS".
LICENSE
This library is free software and may be distributed under the same
terms as Perl 5 itself.
PRAISE
If you find this module useful, please use
to rate
it.
SEE ALSO
perl, SQL::Translator::Parser, SQL::Translator::Producer,
Parse::RecDescent, GD, GraphViz, Text::RecordParser, Class::DBI,
XML::Writer.
SQL-Translator-0.11024/Makefile.PL 0000644 0001750 0001750 00000013220 13211233530 015724 0 ustar ilmari ilmari BEGIN { push @INC, '.' unless $INC[-1] eq '.' }
use inc::Module::Install 1.06;
use strict;
use warnings;
# to deal wuth x.y.z versions properly
configure_requires 'ExtUtils::MakeMaker' => '6.54';
perl_version '5.008001';
my $deps = {
requires => {
'Digest::SHA' => '0',
'Carp::Clan' => '0',
'Parse::RecDescent' => '1.967009',
'DBI' => '1.54',
'File::ShareDir' => '1.0',
'Moo' => '1.000003',
'Package::Variant' => '1.001001',
'Sub::Quote' => '0',
'Try::Tiny' => '0.04',
'Scalar::Util' => '0',
},
recommends => {
'Template' => '2.20',
'GD' => '0',
'GraphViz' => '0',
'Graph::Directed' => '0',
'Spreadsheet::ParseExcel' => '0.41',
'Text::RecordParser' => '0.02',
'XML::LibXML' => '1.69',
},
test_requires => {
'JSON' => '2.0',
'YAML' => '0.66',
'XML::Writer' => '0.500',
'Test::More' => '0.88',
'Test::Differences' => '0',
'Test::Exception' => '0.31',
'Text::ParseWords' => '0',
},
};
name 'SQL-Translator';
author 'Ken Youens-Clark ';
abstract 'SQL DDL transformations and more';
license 'perl';
resources repository => 'https://github.com/dbsrgits/sql-translator/';
resources bugtracker => 'https://rt.cpan.org/NoAuth/Bugs.html?Dist=SQL-Translator';
resources Ratings => 'http://cpanratings.perl.org/d/SQL-Translator';
resources IRC => 'irc://irc.perl.org/#sql-translator';
Meta->{values}{x_authority} = 'cpan:JROBINSON';
all_from 'lib/SQL/Translator.pm';
readme_from 'lib/SQL/Translator.pm';
for my $type (qw/requires recommends test_requires/) {
no strict qw/refs/;
my $f = \&$type;
for my $mod (sort keys %{$deps->{$type} || {} }) {
$f->($mod, $deps->{$type}{$mod});
}
}
install_script (qw|
script/sqlt-diagram
script/sqlt-diff
script/sqlt-diff-old
script/sqlt-dumper
script/sqlt-graph
script/sqlt
|);
install_share();
tests_recursive ();
# temporary(?) until I get around to fix M::I wrt xt/
# needs Module::Install::AuthorTests
eval {
# this should not be necessary since the autoloader is supposed
# to work, but there were reports of it failing
require Module::Install::AuthorTests;
recursive_author_tests (qw/xt/);
1;
} || do {
if ($Module::Install::AUTHOR) {
my $err = $@;
# better error message in case of missing dep
eval { require Module::Install::AuthorTests }
|| die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode:\n\n$@\n";
die $err;
}
};
auto_install();
if ($Module::Install::AUTHOR) {
_recompile_grammars();
_recreate_rt_source();
}
WriteAll();
sub _recompile_grammars {
return; # disabled until RT#74593 is resolved
require File::Spec;
my $compiled_parser_dir = File::Spec->catdir(qw/
share PrecompiledParsers Parse RecDescent DDL SQLT
/);
# Currently consider only single-name parsers containing a grammar marker
# This is somewhat fragile, but better than loading all kinds of parsers
# to some of which we may not even have the deps
my $parser_libdir = 'lib/SQL/Translator/Parser';
for my $parser_fn (glob "$parser_libdir/*.pm") {
die "$parser_fn does not look like a readable file\n"
unless ( -f $parser_fn and -r $parser_fn );
my ($type) = $parser_fn =~ /^\Q$parser_libdir\E\/(.+)\.pm$/i
or die "$parser_fn not named in expected format\n";
my $parser_source = do { local (@ARGV, $/) = $parser_fn; <> };
next unless $parser_source =~ /\$GRAMMAR.+?END_OF_GRAMMAR/s;
my $precomp_parser_fn = File::Spec->catfile($compiled_parser_dir, "$type.pm");
next if (
-f $precomp_parser_fn
and
(stat($parser_fn))[9] <= (stat($precomp_parser_fn))[9]
);
print "Precompiling parser for $type\n";
require $parser_fn;
require Parse::RecDescent;
Parse::RecDescent->Precompile(
do {
no strict 'refs';
${"SQL::Translator::Parser::${type}::GRAMMAR"}
|| die "No \$GRAMMAR global found in SQL::Translator::Parser::$type ($parser_fn)\n"
},
"Parse::RecDescent::DDL::SQLT::$type"
);
rename( "$type.pm", $precomp_parser_fn )
or die "Unable to move $type.pm to $compiled_parser_dir: $!\n";
}
}
sub _recreate_rt_source {
my $base_xml = "t/data/roundtrip.xml";
my $autogen_yaml = "t/data/roundtrip_autogen.yaml";
print "Updating $autogen_yaml\n";
unlink $autogen_yaml;
eval {
use lib 'lib';
require SQL::Translator;
require SQL::Translator::Parser::XML;
open (my $fh, '>', $autogen_yaml) or die "$autogen_yaml: $!\n";
my $tr = SQL::Translator->new;
my $yaml = $tr->translate (
parser => 'XML',
file => $base_xml,
producer => 'YAML',
) or die sprintf ("Unable to translate %s to YAML: %s\n",
$base_xml,
$tr->error || 'error unknown'
);
print $fh $yaml;
close $fh;
};
if ($@) {
die <