From: Rafael Kitover Date: Tue, 30 Jun 2009 00:18:30 +0000 (+0000) Subject: automatically set quote_char and name_sep for mssql X-Git-Tag: 0.04999_08~2^2~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6ed0a90ca50ebfff74e95066acec78a7c7714d55;p=dbsrgits%2FDBIx-Class-Schema-Loader.git automatically set quote_char and name_sep for mssql --- diff --git a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm index 74ba030..fef1f2e 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm @@ -27,6 +27,16 @@ See L. =cut +sub _rebless { + my $self = shift; + + $self->schema->storage->sql_maker->quote_char([qw/[ ]/]) + unless $self->schema->storage->sql_maker->quote_char; + + $self->schema->storage->sql_maker->name_sep('.') + unless $self->schema->storage->sql_maker->name_sep; +} + sub _setup { my $self = shift; diff --git a/t/17mssql_odbc_dot_in_table_name.t b/t/17mssql_odbc_dot_in_table_name.t index a6c4e97..f608d27 100644 --- a/t/17mssql_odbc_dot_in_table_name.t +++ b/t/17mssql_odbc_dot_in_table_name.t @@ -41,28 +41,39 @@ eval { make_schema_at( 'TestSL::Schema', { use_namespaces => 1 }, - [ $dsn, $user, $password, { quote_char => [qw/[ ]/], name_sep => '.' }] + [ $dsn, $user, $password, ] ); }; ok !$@, 'table name with . parsed correctly'; diag $@ if $@; -eval 'use TestSL::Schema'; -ok !$@, 'loaded schema'; -diag $@ if $@; - ## this doesn't work either -#system qq{$^X -pi -e 's/"test\.dot"/\\\\"test.dot"/' t/_common_dump/TestSL/Schema/Result/TestDot.pm}; +system qq{$^X -pi -e 's/"test\.dot"/\\\\"[test.dot]"/' t/_common_dump/TestSL/Schema/Result/TestDot.pm}; #diag do { local ($/, @ARGV) = (undef, "t/_common_dump/TestSL/Schema/Result/TestDot.pm"); <> }; -eval { - TestSL::Schema->resultset('TestDot')->create({ dat => 'foo' }); -}; -ok !$@, 'used table from DBIC succeessfully'; +do "t/_common_dump/TestSL/Schema/Result/TestDot.pm"; + +eval 'use TestSL::Schema'; +ok !$@, 'loaded schema'; diag $@ if $@; -rmtree $DUMP_DIR; +TODO: { + local $TODO = q{this is really a DBIC test to check if the table is usable, +and it doesn't work in the released version yet}; + + eval { + my $rs = TestSL::Schema->resultset('TestDot'); + my $row = $rs->create({ dat => 'foo' }); + $row->update({ dat => 'bar' }); + $row = $rs->find($row->id); + $row->delete; + }; + ok !$@, 'used table from DBIC succeessfully'; + diag $@ if $@; +} + +#rmtree $DUMP_DIR; $dbh->do('DROP TABLE [test.dot]');