From: Rafael Kitover Date: Thu, 26 May 2011 20:54:46 +0000 (-0400) Subject: automatically turn on quoting for MySQL (RT#60469) X-Git-Tag: 0.07011~102 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6ebd0f33f8942d901bd53444ad617f0abcefaaaa;p=dbsrgits%2FDBIx-Class-Schema-Loader.git automatically turn on quoting for MySQL (RT#60469) --- diff --git a/Changes b/Changes index 0258327..ec8d49f 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ Revision history for Perl extension DBIx::Class::Schema::Loader + - automatically turn on quoting for MySQL (RT#60469) - become utf8-aware (RT#67920) - handle duplicate relationship names (RT#64041) - fix a bug in Sybase ASE foreign key detection diff --git a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm index 8489e30..4712fdf 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm @@ -22,6 +22,9 @@ See L and L. sub _setup { my $self = shift; + $self->schema->storage->sql_maker->quote_char("`"); + $self->schema->storage->sql_maker->name_sep("."); + $self->next::method(@_); if (not defined $self->preserve_case) { diff --git a/t/10_02mysql_common.t b/t/10_02mysql_common.t index e414380..9f1a366 100644 --- a/t/10_02mysql_common.t +++ b/t/10_02mysql_common.t @@ -20,6 +20,7 @@ my $tester = dbixcsl_common_tests->new( connect_info_opts=> { on_connect_call => 'set_strict_mode' }, loader_options => { preserve_case => 1 }, skip_rels => $test_innodb ? 0 : $skip_rels_msg, + quote_char => '`', no_inline_rels => 1, no_implicit_rels => 1, data_types => { @@ -127,21 +128,24 @@ my $tester = dbixcsl_common_tests->new( extra => { create => [ q{ - CREATE TABLE mysql_loader_test1 ( + CREATE TABLE `mysql_loader-test1` ( id INT AUTO_INCREMENT PRIMARY KEY, value varchar(100) ) }, q{ - CREATE VIEW mysql_loader_test2 AS SELECT * FROM mysql_loader_test1 + CREATE VIEW mysql_loader_test2 AS SELECT * FROM `mysql_loader-test1` }, ], pre_drop_ddl => [ 'DROP VIEW mysql_loader_test2', ], - drop => [ 'mysql_loader_test1', ], - count => 1, + drop => [ 'mysql_loader-test1', ], + count => 2, run => sub { my ($schema, $monikers, $classes) = @_; + is $monikers->{'mysql_loader-test1'}, 'MysqlLoaderTest1', + 'table with dash correctly monikerized'; + my $rsrc = $schema->resultset($monikers->{mysql_loader_test2})->result_source; is $rsrc->column_info('value')->{data_type}, 'varchar', diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index 40e8da8..6e86008 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -211,7 +211,7 @@ sub setup_schema { my %loader_opts = ( constraint => - qr/^(?:\S+\.)?(?:(?:$self->{vendor}|extra)_?)?loader_?test[0-9]+(?!.*_)/i, + qr/^(?:\S+\.)?(?:(?:$self->{vendor}|extra)[_-]?)?loader[_-]?test[0-9]+(?!.*_)/i, relationships => 1, additional_classes => 'TestAdditional', additional_base_classes => 'TestAdditionalBase',