[Bast-commits] r7972 - in branches/DBIx-Class-Schema-Loader/back-compat: . lib/DBIx/Class/Schema lib/DBIx/Class/Schema/Loader lib/DBIx/Class/Schema/Loader/DBI lib/DBIx/Class/Schema/Loader/DBI/ODBC lib/DBIx/Class/Schema/Loader/DBI/Sybase t/lib

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Sat Nov 28 08:20:12 GMT 2009


Author: caelum
Date: 2009-11-28 08:20:11 +0000 (Sat, 28 Nov 2009)
New Revision: 7972

Modified:
   branches/DBIx-Class-Schema-Loader/back-compat/
   branches/DBIx-Class-Schema-Loader/back-compat/Changes
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader.pm
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/Base.pm
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI.pm
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC/Microsoft_SQL_Server.pm
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Microsoft_SQL_Server.pm
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/RelBuilder.pm
   branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_common_tests.pm
   branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_mssql_extra_tests.pm
Log:
 r21183 at hlagh (orig r7929):  caelum | 2009-11-22 06:30:22 -0500
 fix default_value for MSSQL
 r21184 at hlagh (orig r7930):  caelum | 2009-11-22 07:03:31 -0500
 $dbh->quote some things
 r21186 at hlagh (orig r7932):  caelum | 2009-11-22 09:46:34 -0500
 redo AUTHOR sections to have one main CONTRIBUTORS section
 r21589 at hlagh (orig r7948):  caelum | 2009-11-24 07:57:25 -0500
 fix MSSQL default detection to work with numeric/integer columns
 r21590 at hlagh (orig r7949):  caelum | 2009-11-24 08:11:02 -0500
 handle un-parenthesized default numeric/integer values for some versions of MSSQL as well
 r21610 at hlagh (orig r7969):  caelum | 2009-11-28 02:36:00 -0500
 add test for norewrite
 r21611 at hlagh (orig r7970):  caelum | 2009-11-28 02:44:01 -0500
 added test to check for correct file count in common tests



Property changes on: branches/DBIx-Class-Schema-Loader/back-compat
___________________________________________________________________
Name: svk:merge
   - 46bc3436-8211-0410-8564-d96f7a728040:/local/DBIx-Class-Schema-Loader/branches/common-dump:37173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/current:7833
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/mssql_tweaks:7407
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/odbc-mssql:6439
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class-Schema-Loader:5726
   + 46bc3436-8211-0410-8564-d96f7a728040:/local/DBIx-Class-Schema-Loader/branches/common-dump:37173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/current:7970
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/mssql_tweaks:7407
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-Schema-Loader/odbc-mssql:6439
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class-Schema-Loader:5726

Modified: branches/DBIx-Class-Schema-Loader/back-compat/Changes
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/Changes	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/Changes	2009-11-28 08:20:11 UTC (rev 7972)
@@ -1,5 +1,8 @@
 Revision history for Perl extension DBIx::Class::Schema::Loader
 
+        - added test for norewrite feature
+        - fix default_value for MSSQL
+
 0.04999_10  2009-10-31 12:28:53
         - patch from Robert Bohne to make _table_uniq_info more correct for
           Oracle

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/Base.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/Base.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/Base.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -528,6 +528,9 @@
 sub _reload_classes {
     my ($self, @tables) = @_;
 
+    # so that we don't repeat custom sections
+    @INC = grep $_ ne $self->dump_directory, @INC;
+
     $self->_dump_to_dir(map { $self->classes->{$_} } @tables);
 
     unshift @INC, $self->dump_directory;
@@ -1012,6 +1015,15 @@
 
 L<DBIx::Class::Schema::Loader>
 
+=head1 AUTHOR
+
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
 =cut
 
 1;

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -132,6 +132,15 @@
 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
 L<DBIx::Class::Schema::Loader::DBI>
 
+=head1 AUTHOR
+
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
 =cut
 
 1;

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -98,7 +98,7 @@
     my $sth = $dbh->prepare(qq{SELECT CCU.CONSTRAINT_NAME, CCU.COLUMN_NAME FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE CCU
                                JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC ON (CCU.CONSTRAINT_NAME = TC.CONSTRAINT_NAME)
                                JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE KCU ON (CCU.CONSTRAINT_NAME = KCU.CONSTRAINT_NAME AND CCU.COLUMN_NAME = KCU.COLUMN_NAME)
-                               WHERE CCU.TABLE_NAME = '$table' AND CONSTRAINT_TYPE = 'UNIQUE' ORDER BY KCU.ORDINAL_POSITION});
+                               WHERE CCU.TABLE_NAME = @{[ $dbh->quote($table) ]} AND CONSTRAINT_TYPE = 'UNIQUE' ORDER BY KCU.ORDINAL_POSITION});
     $sth->execute;
     my $constraints;
     while (my $row = $sth->fetchrow_hashref) {
@@ -118,20 +118,41 @@
     my ($table, $column) = @$info{qw/TABLE_NAME COLUMN_NAME/};
 
     my $dbh = $self->schema->storage->dbh;
-    my $sth = $dbh->prepare(qq{SELECT COLUMN_NAME 
-                               FROM INFORMATION_SCHEMA.COLUMNS
-                               WHERE COLUMNPROPERTY(object_id('$table', 'U'), '$column', 'IsIdentity') = 1 AND TABLE_NAME = '$table' AND COLUMN_NAME = '$column'
-                              });
+    my $sth = $dbh->prepare(qq{
+        SELECT COLUMN_NAME 
+        FROM INFORMATION_SCHEMA.COLUMNS
+        WHERE COLUMNPROPERTY(object_id(@{[ $dbh->quote($table) ]}, 'U'), '$column', 'IsIdentity') = 1
+          AND TABLE_NAME = @{[ $dbh->quote($table) ]} AND COLUMN_NAME = @{[ $dbh->quote($column) ]}
+    });
     $sth->execute();
 
     if ($sth->fetchrow_array) {
         $extra_info{is_auto_increment} = 1;
     }
 
+# get default
+    $sth = $dbh->prepare(qq{
+        SELECT COLUMN_DEFAULT
+        FROM INFORMATION_SCHEMA.COLUMNS
+        WHERE TABLE_NAME = @{[ $dbh->quote($table) ]} AND COLUMN_NAME = @{[ $dbh->quote($column) ]}
+    });
+    $sth->execute;
+    my ($default) = $sth->fetchrow_array;
+
+    if (defined $default) {
+        # strip parens
+        $default =~ s/^\( (.*) \)\z/$1/x;
+
+        # Literal strings are in ''s, numbers are in ()s (in some versions of
+        # MSSQL, in others they are unquoted) everything else is a function.
+        $extra_info{default_value} =
+            $default =~ /^['(] (.*) [)']\z/x ? $1 :
+                $default =~ /^\d/ ? $default : \$default;
+    }
+
     return \%extra_info;
 }
 
-
 =head1 SEE ALSO
 
 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
@@ -139,11 +160,12 @@
 
 =head1 AUTHOR
 
-Justin Hunter C<justin.d.hunter at gmail.com>
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
 
-=head1 CONTRIBUTORS
+=head1 LICENSE
 
-Rafael Kitover <rkitover at cpan.org>
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
 
 =cut
 

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC/Microsoft_SQL_Server.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC/Microsoft_SQL_Server.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC/Microsoft_SQL_Server.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -35,8 +35,13 @@
 
 =head1 AUTHOR
 
-Rafael Kitover C<rkitover at cpan.org>
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
 
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
 =cut
 
 1;

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -51,8 +51,13 @@
 
 =head1 AUTHOR
 
-Rafael Kitover C<rkitover at cpan.org>
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
 
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
 =cut
 
 1;

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -153,10 +153,13 @@
 
 =head1 AUTHOR
 
-TSUNODA Kazuya C<drk at drk7.jp>
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
 
-Dagfinn Ilmari Mannsåker C<ilmari at ilmari.org>
+=head1 LICENSE
 
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
 =cut
 
 1;

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -111,6 +111,15 @@
 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
 L<DBIx::Class::Schema::Loader::DBI>
 
+=head1 AUTHOR
+
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
 =cut
 
 1;

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -200,6 +200,15 @@
 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
 L<DBIx::Class::Schema::Loader::DBI>
 
+=head1 AUTHOR
+
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
 =cut
 
 1;

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -72,8 +72,13 @@
 
 =head1 AUTHOR
 
-Rafael Kitover <rkitover at cpan.org>
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
 
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
 =cut
 
 1;

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Microsoft_SQL_Server.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Microsoft_SQL_Server.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase/Microsoft_SQL_Server.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -42,8 +42,13 @@
 
 =head1 AUTHOR
 
-Rafael Kitover <rkitover at cpan.org>
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
 
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
 =cut
 
 1;

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -59,7 +59,7 @@
     my ($self, $table) = @_;
 
     my $dbh = $self->schema->storage->dbh;
-    my $columns = $dbh->selectcol_arrayref(qq{SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name = '$table' AND type = 'U')});
+    my $columns = $dbh->selectcol_arrayref(qq{SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name = @{[ $dbh->quote($table) ]} AND type = 'U')});
 
     return $columns;
 }
@@ -68,7 +68,7 @@
     my ($self, $table) = @_;
 
     my $dbh = $self->schema->storage->dbh;
-    my $sth = $dbh->prepare(qq{sp_pkeys '$table'});
+    my $sth = $dbh->prepare(qq{sp_pkeys @{[ $dbh->quote($table) ]}});
     $sth->execute;
 
     my @keydata;
@@ -89,7 +89,7 @@
     local $dbh->{FetchHashKeyName} = 'NAME_lc';
     # hide "Object does not exist in this database." when trying to fetch fkeys
     local $dbh->{syb_err_handler} = sub { return $_[0] == 17461 ? 0 : 1 }; 
-    my $sth = $dbh->prepare(qq{sp_fkeys \@fktable_name = '$table'});
+    my $sth = $dbh->prepare(qq{sp_fkeys \@fktable_name = @{[ $dbh->quote($table) ]}});
     $sth->execute;
     my $row = $sth->fetchrow_hashref;
 
@@ -112,7 +112,7 @@
     local $dbh->{FetchHashKeyName} = 'NAME_lc';
     # hide "Object does not exist in this database." when trying to fetch fkeys
     local $dbh->{syb_err_handler} = sub { return $_[0] == 17461 ? 0 : 1 }; 
-    my $sth = $dbh->prepare(qq{sp_fkeys \@fktable_name = '$table'});
+    my $sth = $dbh->prepare(qq{sp_fkeys \@fktable_name = @{[ $dbh->quote($table) ]}});
     $sth->execute;
 
     while (my $row = $sth->fetchrow_hashref) {
@@ -142,7 +142,7 @@
     local $dbh->{FetchHashKeyName} = 'NAME_lc';
     # hide "Object does not exist in this database." when trying to fetch fkeys
     local $dbh->{syb_err_handler} = sub { return 0 if $_[0] == 17461; }; 
-    my $sth = $dbh->prepare(qq{sp_fkeys \@fktable_name = '$table'});
+    my $sth = $dbh->prepare(qq{sp_fkeys \@fktable_name = @{[ $dbh->quote($table) ]}});
     $sth->execute;
 
     my @fk_info;
@@ -199,7 +199,7 @@
 
     my $dbh = $self->schema->storage->dbh;
     local $dbh->{FetchHashKeyName} = 'NAME_lc';
-    my $sth = $dbh->prepare(qq{sp_helpconstraint \@objname='$table', \@nomsg='nomsg'});
+    my $sth = $dbh->prepare(qq{sp_helpconstraint \@objname=@{[ $dbh->quote($table) ]}, \@nomsg='nomsg'});
     eval { $sth->execute };
     return if $@;
 
@@ -234,7 +234,7 @@
     my ($table, $column) = @$info{qw/TABLE_NAME COLUMN_NAME/};
 
     my $dbh = $self->schema->storage->dbh;
-    my $sth = $dbh->prepare(qq{SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name = '$table') AND (status & 0x80) = 0x80 AND name = '$column'});
+    my $sth = $dbh->prepare(qq{SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name = @{[ $dbh->quote($table) ]}) AND (status & 0x80) = 0x80 AND name = @{[ $dbh->quote($column) ]}});
     $sth->execute();
 
     if ($sth->fetchrow_array) {
@@ -251,11 +251,12 @@
 
 =head1 AUTHOR
 
-Justin Hunter C<justin.d.hunter at gmail.com>
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
 
-=head1 CONTRIBUTORS
+=head1 LICENSE
 
-Rafael Kitover <rkitover at cpan.org>
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
 
 =cut
 

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -5,8 +5,6 @@
 
 # Empty. POD only.
 
-1;
-
 =head1 NAME                                                                     
                                                                                 
 DBIx::Class::Schema::Loader::DBI::Writing - Loader subclass writing guide for DBI
@@ -55,6 +53,15 @@
 C<_tables_list> and C<_extra_column_info>.  See the included DBD drivers
 for examples of these.
 
+=head1 AUTHOR
+
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
 =cut
 
 1;

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -149,6 +149,15 @@
 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
 L<DBIx::Class::Schema::Loader::DBI>
 
+=head1 AUTHOR
+
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
 =cut
 
 1;

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/DBI.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -298,6 +298,15 @@
 
 L<DBIx::Class::Schema::Loader>
 
+=head1 AUTHOR
+
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
 =cut
 
 1;

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/RelBuilder.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/RelBuilder.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/RelBuilder.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -260,4 +260,15 @@
     return $all_code;
 }
 
+=head1 AUTHOR
+
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+=cut
+
 1;

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -389,19 +389,38 @@
 In "normal" L<DBIx::Class::Schema> usage, manually-defined
 source classes and relationships have no problems crossing vendor schemas.
 
-=head1 AUTHOR
+=head1 ACKNOWLEDGEMENTS
 
-Brandon Black, C<blblack at gmail.com>
+Matt S Trout, all of the #dbix-class folks, and everyone who's ever sent
+in a bug report or suggestion.
 
 Based on L<DBIx::Class::Loader> by Sebastian Riedel
 
 Based upon the work of IKEBE Tomohiro
 
-=head1 THANK YOU
+=head1 AUTHOR
 
-Matt S Trout, all of the #dbix-class folks, and everyone who's ever sent
-in a bug report or suggestion.
+blblack: Brandon Black <blblack at gmail.com>
 
+=head1 CONTRIBUTORS
+
+ilmarii: Dagfinn Ilmari Mannsåker <ilmari at ilmari.org>
+
+arcanez: Justin Hunter <justin.d.hunter at gmail.com>
+
+ash: Ash Berlin <ash at cpan.org>
+
+Caelum: Rafael Kitover <rkitover at cpan.org>
+
+TSUNODA Kazuya <drk at drk7.jp>
+
+Robert Bohne <rbo at openserv.org>
+
+ribasushi: Peter Rabbitson <rabbit+dbic at rabbit.us>
+
+... and lots of other folks. If we forgot you, please write the current
+maintainer or RT.
+
 =head1 LICENSE
 
 This library is free software; you can redistribute it and/or modify it under

Modified: branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_common_tests.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_common_tests.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_common_tests.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -8,6 +8,8 @@
 use Class::Unload;
 use File::Path;
 use DBI;
+use Digest::MD5;
+use File::Find 'find';
 
 my $DUMP_DIR = './t/_common_dump';
 rmtree $DUMP_DIR;
@@ -54,7 +56,7 @@
 sub run_tests {
     my $self = shift;
 
-    plan tests => 3 + 134 + ($self->{extra}->{count} || 0);
+    plan tests => 139 + ($self->{extra}->{count} || 0);
 
     $self->create();
 
@@ -108,8 +110,14 @@
             __PACKAGE__->connection(\@connect_info);
         };
 
-        ok(!$@, "Loader initialization") or diag $@;
+       ok(!$@, "Loader initialization") or diag $@;
 
+       my $file_count;
+       find sub { return if -d; $file_count++ }, $DUMP_DIR;
+
+       is $file_count, 34, 'correct number of files generated';
+       exit if $file_count != 34;
+
        my $warn_count = 2;
        $warn_count++ if grep /ResultSetManager/, @loader_warnings;
 
@@ -616,11 +624,8 @@
         }
     }
 
-    # rescan test
+    # rescan and norewrite test
     SKIP: {
-        skip $self->{skip_rels}, 4 if $self->{skip_rels};
-        skip "Can't rescan dumped schema", 4 if $self->{dump};
-
         my @statements_rescan = (
             qq{
                 CREATE TABLE loader_test30 (
@@ -633,15 +638,47 @@
             q{ INSERT INTO loader_test30 (id,loader_test2) VALUES(321, 2) },
         );
 
+        # get md5
+        my $digest  = Digest::MD5->new;
+
+        my $find_cb = sub {
+            return if -d;
+            return if $_ eq 'LoaderTest30.pm';
+
+            open my $fh, '<', $_ or die "Could not open $_ for reading: $!";
+            binmode $fh;
+            $digest->addfile($fh);
+        };
+
+        find $find_cb, $DUMP_DIR;
+
+        my $before_digest = $digest->digest;
+
         my $dbh = $self->dbconnect(1);
         $dbh->do($_) for @statements_rescan;
         $dbh->disconnect;
 
-        my @new = $conn->rescan;
+        sleep 1;
+
+        my @new = do {
+            # kill the 'Dumping manual schema' warnings
+            local $SIG{__WARN__} = sub {};
+            $conn->rescan;
+        };
         is_deeply(\@new, [ qw/LoaderTest30/ ], "Rescan");
 
+        $digest = Digest::MD5->new;
+        find $find_cb, $DUMP_DIR;
+        my $after_digest = $digest->digest;
+
+        is $before_digest, $after_digest,
+            'dumped files are not rewritten when there is no modification';
+
         my $rsobj30   = $conn->resultset('LoaderTest30');
         isa_ok($rsobj30, 'DBIx::Class::ResultSet');
+
+        skip 'no rels', 2 if $self->{skip_rels};
+
         my $obj30 = $rsobj30->find(123);
         isa_ok( $obj30->loader_test2, $class2);
 

Modified: branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_mssql_extra_tests.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_mssql_extra_tests.pm	2009-11-28 08:17:05 UTC (rev 7971)
+++ branches/DBIx-Class-Schema-Loader/back-compat/t/lib/dbixcsl_mssql_extra_tests.pm	2009-11-28 08:20:11 UTC (rev 7972)
@@ -17,9 +17,18 @@
                 dat VARCHAR(8)
             )
         },
+        qq{
+            CREATE TABLE ${vendor}_loader_test2 (
+                id INT IDENTITY NOT NULL PRIMARY KEY,
+                dat VARCHAR(100) DEFAULT 'foo',
+                num NUMERIC DEFAULT 10.89,
+                anint INT DEFAULT 6,
+                ts DATETIME DEFAULT getdate()
+            )
+        },
     ],
-    drop   => [ "[${vendor}_loader_test1.dot]" ],
-    count  => 6,
+    drop   => [ "[${vendor}_loader_test1.dot]", "${vendor}_loader_test2"  ],
+    count  => 13,
     run    => sub {
         my ($schema, $monikers, $classes) = @_;
 
@@ -28,16 +37,43 @@
 
         ok((my $rs = eval {
             $schema->resultset("${vendor_titlecased}LoaderTest1Dot") }),
-            'got a resultset');
+            'got a resultset for table with dot in name');
 
         ok((my $from = eval { $rs->result_source->from }),
-            'got an $rsrc->from');
+            'got an $rsrc->from for table with dot in name');
 
-        is ref($from), 'SCALAR', '->table is a scalar ref';
+        is ref($from), 'SCALAR', '->table with dot in name is a scalar ref';
 
         is eval { $$from }, "[${vendor}_loader_test1.dot]",
-            '->table name is correct';
+            '->table with dot in name has correct name';
 
+# Test that column defaults are set correctly
+        ok(($rs = eval {
+            $schema->resultset("${vendor_titlecased}LoaderTest2") }),
+            'got a resultset for table with column with default value');
+
+        my $rsrc = $rs->result_source;
+
+        is eval { $rsrc->column_info('dat')->{default_value} }, 'foo',
+            'correct default_value for column with literal string default';
+
+        is eval { $rsrc->column_info('anint')->{default_value} }, 6,
+            'correct default_value for column with literal integer default';
+
+        cmp_ok eval { $rsrc->column_info('num')->{default_value} },
+            '==', 10.89,
+            'correct default_value for column with literal numeric default';
+
+        ok((my $function_default =
+            eval { $rsrc->column_info('ts')->{default_value} }),
+            'got default_value for column with function default');
+
+        is ref($function_default), 'SCALAR',
+            'default_value for function default is a SCALAR ref';
+
+        is eval { $$function_default }, 'getdate()',
+            'default_value for function default is correct';
+
 # Test that identity columns do not have 'identity' in the data_type, and do
 # have is_auto_increment.
         my $identity_col_info = $schema->resultset('LoaderTest10')




More information about the Bast-commits mailing list