From: Graham Barr Date: Fri, 9 Oct 2009 05:18:44 +0000 (-0500) Subject: If schema name is unspecified, select from database X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2ac3a8e115f2316b07bb10638b1ed3cfce234935;p=dbsrgits%2FSQL-Translator-2.0-ish.git If schema name is unspecified, select from database --- diff --git a/lib/SQL/Translator/Parser/DBI/MySQL.pm b/lib/SQL/Translator/Parser/DBI/MySQL.pm index 217c0d6..b4d8b82 100644 --- a/lib/SQL/Translator/Parser/DBI/MySQL.pm +++ b/lib/SQL/Translator/Parser/DBI/MySQL.pm @@ -1,7 +1,17 @@ use MooseX::Declare; role SQL::Translator::Parser::DBI::MySQL { - use MooseX::Types::Moose qw(HashRef Str); - use SQL::Translator::Types qw(View); + use MooseX::Types::Moose qw(HashRef Maybe Str); + use SQL::Translator::Types qw(View Table Schema); + + has 'schema_name' => ( + is => 'rw', + isa => Maybe [Str], + lazy => 1, + default => sub { + my ($name) = shift->dbh->selectrow_array("select database()"); + return $name; + }, + ); method _get_view_sql(View $view) { #my ($sql) = $self->dbh->selectrow_array('');