Merge 'current' into 'back-compat'
Rafael Kitover [Sat, 28 Nov 2009 08:20:11 +0000 (08:20 +0000)]
r21183@hlagh (orig r7929):  caelum | 2009-11-22 06:30:22 -0500
fix default_value for MSSQL
r21184@hlagh (orig r7930):  caelum | 2009-11-22 07:03:31 -0500
$dbh->quote some things
r21186@hlagh (orig r7932):  caelum | 2009-11-22 09:46:34 -0500
redo AUTHOR sections to have one main CONTRIBUTORS section
r21589@hlagh (orig r7948):  caelum | 2009-11-24 07:57:25 -0500
fix MSSQL default detection to work with numeric/integer columns
r21590@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@hlagh (orig r7969):  caelum | 2009-11-28 02:36:00 -0500
add test for norewrite
r21611@hlagh (orig r7970):  caelum | 2009-11-28 02:44:01 -0500
added test to check for correct file count in common tests

19 files changed:
Changes
lib/DBIx/Class/Schema/Loader.pm
lib/DBIx/Class/Schema/Loader/Base.pm
lib/DBIx/Class/Schema/Loader/DBI.pm
lib/DBIx/Class/Schema/Loader/DBI/DB2.pm
lib/DBIx/Class/Schema/Loader/DBI/MSSQL.pm
lib/DBIx/Class/Schema/Loader/DBI/ODBC.pm
lib/DBIx/Class/Schema/Loader/DBI/ODBC/Microsoft_SQL_Server.pm
lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm
lib/DBIx/Class/Schema/Loader/DBI/Pg.pm
lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm
lib/DBIx/Class/Schema/Loader/DBI/Sybase.pm
lib/DBIx/Class/Schema/Loader/DBI/Sybase/Common.pm
lib/DBIx/Class/Schema/Loader/DBI/Sybase/Microsoft_SQL_Server.pm
lib/DBIx/Class/Schema/Loader/DBI/Writing.pm
lib/DBIx/Class/Schema/Loader/DBI/mysql.pm
lib/DBIx/Class/Schema/Loader/RelBuilder.pm
t/lib/dbixcsl_common_tests.pm
t/lib/dbixcsl_mssql_extra_tests.pm

diff --git a/Changes b/Changes
index 4e5b6f6..de5f14f 100644 (file)
--- a/Changes
+++ b/Changes
@@ -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
index ea670f2..3ffa38d 100644 (file)
@@ -389,18 +389,37 @@ arrayref of schemas to load.
 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@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
+
+blblack: Brandon Black <blblack@gmail.com>
 
-Matt S Trout, all of the #dbix-class folks, and everyone who's ever sent
-in a bug report or suggestion.
+=head1 CONTRIBUTORS
+
+ilmarii: Dagfinn Ilmari MannsÃ¥ker <ilmari@ilmari.org>
+
+arcanez: Justin Hunter <justin.d.hunter@gmail.com>
+
+ash: Ash Berlin <ash@cpan.org>
+
+Caelum: Rafael Kitover <rkitover@cpan.org>
+
+TSUNODA Kazuya <drk@drk7.jp>
+
+Robert Bohne <rbo@openserv.org>
+
+ribasushi: Peter Rabbitson <rabbit+dbic@rabbit.us>
+
+... and lots of other folks. If we forgot you, please write the current
+maintainer or RT.
 
 =head1 LICENSE
 
index 2e39d31..575345c 100644 (file)
@@ -528,6 +528,9 @@ sub _load_tables {
 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 @@ names, as above in L</monikers>.
 
 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;
index 139be54..3e648bf 100644 (file)
@@ -298,6 +298,15 @@ sub _extra_column_info {}
 
 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;
index 87e4150..f8c0629 100644 (file)
@@ -132,6 +132,15 @@ sub _extra_column_info {
 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;
index d9f0972..72a0d27 100644 (file)
@@ -98,7 +98,7 @@ sub _table_uniq_info {
     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 @@ sub _extra_column_info {
     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 @@ L<DBIx::Class::Schema::Loader::DBI>
 
 =head1 AUTHOR
 
-Justin Hunter C<justin.d.hunter@gmail.com>
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
 
-=head1 CONTRIBUTORS
+=head1 LICENSE
 
-Rafael Kitover <rkitover@cpan.org>
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
 
 =cut
 
index 4f84d8a..557dae6 100644 (file)
@@ -51,7 +51,12 @@ L<DBIx::Class::Schema::Loader::DBI>
 
 =head1 AUTHOR
 
-Rafael Kitover C<rkitover@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
 
index 19b19d3..a4a9f14 100644 (file)
@@ -35,7 +35,12 @@ L<DBIx::Class::Schema::Loader::DBI>
 
 =head1 AUTHOR
 
-Rafael Kitover C<rkitover@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
 
index 957b00a..13a2cea 100644 (file)
@@ -153,9 +153,12 @@ L<DBIx::Class::Schema::Loader::DBI>
 
 =head1 AUTHOR
 
-TSUNODA Kazuya C<drk@drk7.jp>
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
 
-Dagfinn Ilmari MannsÃ¥ker C<ilmari@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
 
index 5528183..8f6c0be 100644 (file)
@@ -111,6 +111,15 @@ sub _extra_column_info {
 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;
index 285d027..195b6d9 100644 (file)
@@ -200,6 +200,15 @@ sub _tables_list {
 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;
index e3d2ed2..9220e6f 100644 (file)
@@ -59,7 +59,7 @@ sub _table_columns {
     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 @@ sub _table_pk_info {
     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 @@ sub _table_fk_info {
     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 @@ sub _table_fk_info_by_name {
     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 @@ sub _table_fk_info_builder {
     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 @@ sub _table_uniq_info {
 
     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 @@ sub _extra_column_info {
     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 @@ L<DBIx::Class::Schema::Loader::DBI>
 
 =head1 AUTHOR
 
-Justin Hunter C<justin.d.hunter@gmail.com>
+See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
 
-=head1 CONTRIBUTORS
+=head1 LICENSE
 
-Rafael Kitover <rkitover@cpan.org>
+This library is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
 
 =cut
 
index dd4e347..ec276c0 100644 (file)
@@ -72,7 +72,12 @@ L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
 
 =head1 AUTHOR
 
-Rafael Kitover <rkitover@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
 
index 46926e5..a0e3aa6 100644 (file)
@@ -42,7 +42,12 @@ L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
 
 =head1 AUTHOR
 
-Rafael Kitover <rkitover@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
 
index 12506b2..64b5df1 100644 (file)
@@ -5,8 +5,6 @@ our $VERSION = '0.04999_10';
 
 # Empty. POD only.
 
-1;
-
 =head1 NAME                                                                     
                                                                                 
 DBIx::Class::Schema::Loader::DBI::Writing - Loader subclass writing guide for DBI
@@ -55,6 +53,15 @@ likely want to override are: C<_table_pk_info>, C<_table_fk_info>,
 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;
index 64b1ab7..b603eb4 100644 (file)
@@ -149,6 +149,15 @@ sub _extra_column_info {
 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;
index 550d66c..a7095c8 100644 (file)
@@ -260,4 +260,15 @@ sub generate_code {
     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;
index 674ec2e..54c4049 100644 (file)
@@ -8,6 +8,8 @@ use DBIx::Class::Schema::Loader;
 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 _monikerize {
 sub run_tests {
     my $self = shift;
 
-    plan tests => 3 + 134 + ($self->{extra}->{count} || 0);
+    plan tests => 139 + ($self->{extra}->{count} || 0);
 
     $self->create();
 
@@ -108,7 +110,13 @@ sub setup_schema {
             __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 @@ sub test_schema {
         }
     }
 
-    # 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 @@ sub test_schema {
             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);
 
index d4125ef..ea38461 100644 (file)
@@ -17,9 +17,18 @@ sub extra { +{
                 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,15 +37,42 @@ sub extra { +{
 
         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.