NAME
Dia::SQL::Output - Base sql formatter class.
SYNOPSIS
use Dia::SQL;
my $dia = Dia::SQL->new(...);
my $output = $dia->get_output_instance();
print $output->get_sql();
DESCRIPTION
This is the base sql formatter class for creating sql. It contains basic functionality, which can be overridden in subclasses, one for each RDBMS.
SEE ALSO
Dia::SQL::Output::DB2
Dia::SQL::Output::Oracle
new
The constructor. Arguments:
db - the target database type
_init_log
Initialize logger
_init_const
Initialize Constants component
_init_utils
Initialize Dia::SQL::Utils class.
get_comment
Return string with comment containing target database, $VERSION, time and list of files etc.
get_sql
Return all sql
get_inserts
Return insert statements. These are based on content of the components.
get_constraints_drop
drop all constraints (e.g. foreign keys)
get_view_drop
create drop view for all views
_check_components
Sanity check on internal state.
Return true if and only if
$self->{components} should be a defined array ref with 1 or more
hash ref elements having two keys 'name' and 'text'
otherwise false.
_check_classes
Sanity check on internal state.
Return true if and only if
$self->{classes} should be a defined array ref with 1 or more elements
_check_associations
Sanity check on internal state.
Return true if and only if
$self->{associations} should be a defined array ref with 1 or more elements
otherwise false.
_check_attlist
Sanity check on given reference.
Return true if and only if
$arg should be a defined hash ref with 1 or more elements
$arg->{name} exists and is a defined scalar
$arg->{attList} exists and is a defined array ref.
otherwise false.
get_schema_drop
create drop table for all tables
TODO: Consider rename to get_table[s]_drop
get_permissions_drop
Create revoke sql
get_permissions_create
Create grant sql
get_associations_create
create associations statements:
This includes the following elements
- foreign key
- index
- unique index
get_schema_create
create table statements
get_view_create
create view statements
_create_pk_string
Create primary key clause, e.g.
constraint pk_<tablename> primary key (<column1>,..,<columnN>)
_get_create_table_sql
Create sql for given table
TODO: Consider Text::Table or something for nice formatting
_get_create_view_sql
Create sql for given view.
Similar to _get_create_table_sql, but must handle 'from', 'where', 'order by', 'group by',
TODO: ADD support for 'having' clause.
_get_create_association_sql
Create sql for given association.
_get_create_index_sql
Create sql for all indices for given table.
Super class for outputting SQL