--- /dev/null
+package SQL::Translator::Parser::DBI;
+use Class::MOP;
+use Moose;
+use MooseX::Types::Moose qw(Str);
+use SQL::Translator::Types qw(DBIHandle);
+use DBI::Const::GetInfoType;
+extends 'SQL::Translator::Parser';
+
+has 'dbh' => (
+ is => 'rw',
+ isa => DBIHandle,
+ required => 1
+);
+
+has 'translator' => (
+ is => 'rw',
+ does => 'SQL::Translator::Parser::DBI::Dialect',
+ handles => {
+ make_create_string => 'make_create_string',
+ make_update_string => 'make_update_string'
+ }
+);
+
+has 'db_schema' => (
+ is => 'rw',
+ isa => Str,
+ lazy => 1,
+ required => 1,
+ default => sub { shift->translator->db_schema }
+);
+
+has 'quoter' => (
+ is => 'rw',
+ isa => Str,
+ requried => 1,
+ default => q{"}
+);
+
+has 'namesep' => (
+ is => 'rw',
+ isa => Str,
+ required => 1,
+ default => '.'
+);
+
+sub BUILD {
+ my $self = shift;
+
+ local $self->dbh->{RaiseError} = 1;
+ local $self->dbh->{PrintError} = 0;
+
+ my $dbtypename = $self->dbh->get_info( $GetInfoType{SQL_DBMS_NAME} ) || $self->dbh->{Driver}{Name};
+
+ my $class = 'SQL::Translator::Parser::DBI::' . $dbtypename;
+ Class::MOP::load_class( $class );
+ my $translator = $class->new( dbh => $self->dbh );
+ $self->translator($translator);
+
+ $self->quoter( $self->dbh->get_info(29) || q{"} );
+ $self->namesep( $self->dbh->get_info(41) || q{.} );
+}
+
+sub _tables_list {
+ my $self = shift;
+
+ my $dbh = $self->dbh;
+ my @tables = $dbh->tables(undef, $self->db_schema, '%', '%');
+ s/\Q$self->quoter\E//g for @tables;
+ s/^.*\Q$self->namesep\E// for @tables;
+
+ return @tables;
+}
+
+1;
--- /dev/null
+package SQL::Translator::Parser::DBI::Dialect;
+use Moose::Role;
+
+requires 'make_create_string',
+ 'make_update_string';
+
+sub do_common_stuff {
+ my ($self, @args) = @_;
+ print "COMMON STUFF!\n";
+ # ....
+}
+
+1;
package SQL::Translator::Parser::DBI::MySQL;
use Moose;
-extends 'SQL::Translator::Parser::DBI';
+with 'SQL::Translator::Parser::DBI::Dialect';
+
+sub make_create_string {
+ print "MYSQL!\n";
+ # .....
+}
+
+sub make_update_string {
+ print "mYSQL!\n";
+}
+
1;
package SQL::Translator::Parser::DBI::Oracle;
use Moose;
-extends 'SQL::Translator::Parser::DBI';
+with 'SQL::Translator::Parser::DBI::Dialect';
+
+sub make_create_string {
+ print "Oracle!\n";
+ # .....
+}
+
+sub make_update_string {
+ print "Oracle!\n";
+}
+
1;
package SQL::Translator::Parser::DBI::PostgreSQL;
use Moose;
-extends 'SQL::Translator::Parser::DBI';
+use MooseX::Types::Moose qw(Str);
+with 'SQL::Translator::Parser::DBI::Dialect';
+
+has 'db_schema' => (is => 'ro', isa => Str, default => 'public');
+
+sub make_create_string {
+ print "HELLO WORLD\n";
+ # .....
+}
+
+sub make_update_string {
+ print "WOOT\n";
+}
1;
package SQL::Translator::Parser::DBI::SQLite;
use Moose;
-extends 'SQL::Translator::Parser::DBI';
+with 'SQL::Translator::Parser::DBI::Dialect';
+
+sub make_create_string {
+ print "SQLite\n";
+ # .....
+}
+
+sub make_update_string {
+ print "SQLite\n";
+}
+
1;
package SQL::Translator::Parser::DBI::Sybase;
use Moose;
-extends 'SQL::Translator::Parser::DBI';
+with 'SQL::Translator::Parser::DBI::Dialect';
+
+sub make_create_string {
+ print "Sybase!\n";
+ # .....
+}
+
+sub make_update_string {
+ print "Sybase!\n";
+}
+
1;