[Bast-commits] r6863 - in branches/DBIx-Class-Schema-Loader/mssql_tweaks: lib/DBIx/Class/Schema/Loader/DBI t

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Tue Jun 30 00:18:31 GMT 2009


Author: caelum
Date: 2009-06-30 00:18:30 +0000 (Tue, 30 Jun 2009)
New Revision: 6863

Modified:
   branches/DBIx-Class-Schema-Loader/mssql_tweaks/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm
   branches/DBIx-Class-Schema-Loader/mssql_tweaks/t/17mssql_odbc_dot_in_table_name.t
Log:
automatically set quote_char and name_sep for mssql

Modified: branches/DBIx-Class-Schema-Loader/mssql_tweaks/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/mssql_tweaks/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm	2009-06-29 23:13:49 UTC (rev 6862)
+++ branches/DBIx-Class-Schema-Loader/mssql_tweaks/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm	2009-06-30 00:18:30 UTC (rev 6863)
@@ -27,6 +27,16 @@
 
 =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;
 

Modified: branches/DBIx-Class-Schema-Loader/mssql_tweaks/t/17mssql_odbc_dot_in_table_name.t
===================================================================
--- branches/DBIx-Class-Schema-Loader/mssql_tweaks/t/17mssql_odbc_dot_in_table_name.t	2009-06-29 23:13:49 UTC (rev 6862)
+++ branches/DBIx-Class-Schema-Loader/mssql_tweaks/t/17mssql_odbc_dot_in_table_name.t	2009-06-30 00:18:30 UTC (rev 6863)
@@ -41,28 +41,39 @@
     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 $@;
 
+## this doesn't work either
+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"); <> };
+
+do "t/_common_dump/TestSL/Schema/Result/TestDot.pm";
+
 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};
+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};
 
-#diag do { local ($/, @ARGV) = (undef, "t/_common_dump/TestSL/Schema/Result/TestDot.pm"); <> };
+    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 $@;
+}
 
-eval {
-    TestSL::Schema->resultset('TestDot')->create({ dat => 'foo' });
-};
-ok !$@, 'used table from DBIC succeessfully';
-diag $@ if $@;
+#rmtree $DUMP_DIR;
 
-rmtree $DUMP_DIR;
-
 $dbh->do('DROP TABLE [test.dot]');




More information about the Bast-commits mailing list