X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F15sybase_common.t;h=cace91e45fd25ecfda5f0d5f8610d8ff56cd526d;hb=5163dc4a1bc63e65a670f6d2f6a381f8eef5534a;hp=903592f6ba54c5552f68f4c5145054c0badd0938;hpb=2d1dc6de7c39309d9a4e8298ecaace25ac749ad6;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/t/15sybase_common.t b/t/15sybase_common.t index 903592f..cace91e 100644 --- a/t/15sybase_common.t +++ b/t/15sybase_common.t @@ -3,6 +3,7 @@ use lib qw(t/lib); use dbixcsl_common_tests; use Test::More; use Test::Exception; +use List::MoreUtils 'apply'; my $dsn = $ENV{DBICTEST_SYBASE_DSN} || ''; my $user = $ENV{DBICTEST_SYBASE_USER} || ''; @@ -11,83 +12,50 @@ my $password = $ENV{DBICTEST_SYBASE_PASS} || ''; my $tester = dbixcsl_common_tests->new( vendor => 'sybase', auto_inc_pk => 'INTEGER IDENTITY NOT NULL PRIMARY KEY', + default_function => 'getdate()', + default_function_def => 'AS getdate()', dsn => $dsn, user => $user, password => $password, - extra => { - create => [ - q{ - CREATE TABLE sybase_loader_test1 ( - id INTEGER IDENTITY NOT NULL PRIMARY KEY, - ts timestamp, - charfield VARCHAR(10) DEFAULT 'foo', - computed_dt AS getdate() - ) - }, - ], - drop => [ qw/ sybase_loader_test1 / ], - count => 9, - run => sub { - my ($schema, $monikers, $classes) = @_; - - my $rs = $schema->resultset($monikers->{sybase_loader_test1}); - my $rsrc = $rs->result_source; - - is $rsrc->column_info('id')->{data_type}, - 'numeric', - 'INTEGER IDENTITY data_type is correct'; - - is $rsrc->column_info('id')->{is_auto_increment}, - 1, - 'INTEGER IDENTITY is_auto_increment => 1'; - - { - local $TODO = 'timestamp introspection broken'; - - is $rsrc->column_info('ts')->{data_type}, - 'timestamp', - 'timestamps have the correct data_type'; - } - - is $rsrc->column_info('charfield')->{data_type}, - 'varchar', - 'VARCHAR has correct data_type'; - - { - local $TODO = 'constant DEFAULT introspection'; - - is $rsrc->column_info('charfield')->{default_value}, - 'foo', - 'constant DEFAULT is correct'; - } - - is $rsrc->column_info('charfield')->{size}, - 10, - 'VARCHAR(10) has correct size'; - - ok ((exists $rsrc->column_info('computed_dt')->{data_type} - && (not defined $rsrc->column_info('computed_dt')->{data_type})), - 'data_type for computed column exists and is undef') - or diag "Data type is: ", - $rsrc->column_info('computed_dt')->{data_type} - ; - - { - local $TODO = 'default_value for computed columns'; - - my $computed_dt_default = - $rsrc->column_info('computed_dt')->{default_value}; - - ok ((ref $computed_dt_default eq 'SCALAR'), - 'default_value for computed column is a scalar ref') -# or diag "default_value is: ", $computed_dt_default - ; - - eval { is $$computed_dt_default, - 'getdate()', - 'default_value for computed column is correct' }; - } - }, +# Test data types, see http://ispirer.com/wiki/sqlways/sybase/data-types + data_types => { + 'integer identity' => { data_type => 'integer', is_auto_increment => 1 }, + 'AS getdate()' => { data_type => undef, inflate_datetime => 1, default_value => \'getdate()' }, + text => { data_type => 'text' }, + unitext => { data_type => 'unitext' }, + image => { data_type => 'image' }, + bigint => { data_type => 'bigint' }, + int => { data_type => 'integer' }, + integer => { data_type => 'integer' }, + smallint => { data_type => 'smallint' }, + tinyint => { data_type => 'tinyint' }, + date => { data_type => 'date' }, + time => { data_type => 'time' }, + datetime => { data_type => 'datetime' }, + smalldatetime => { data_type => 'smalldatetime' }, + money => { data_type => 'money' }, + smallmoney => { data_type => 'smallmoney' }, + timestamp => { data_type => 'timestamp', inflate_datetime => 0 }, + bit => { data_type => 'bit' }, + 'char(2)' => { data_type => 'char', size => 2 }, + 'nchar(2)' => { data_type => 'nchar', size => 2 }, + 'unichar(2)' => { data_type => 'unichar', size => 2 }, + 'varchar(2)' => { data_type => 'varchar', size => 2 }, + 'nvarchar(2)' => { data_type => 'nvarchar', size => 2 }, + 'univarchar(2)' => { data_type => 'univarchar', size => 2 }, + 'binary(2)' => { data_type => 'binary', size => 2 }, + 'varbinary(2)' => { data_type => 'varbinary', size => 2 }, + 'double precision' => { data_type => 'double precision' }, + real => { data_type => 'real' }, + float => { data_type => 'double precision' }, + 'float(14)' => { data_type => 'real' }, + 'float(15)' => { data_type => 'real' }, + 'float(16)' => { data_type => 'double precision' }, + 'float(48)' => { data_type => 'double precision' }, + 'numeric(6,3)' => { data_type => 'numeric', size => [6,3] }, + 'decimal(6,3)' => { data_type => 'numeric', size => [6,3] }, + numeric => { data_type => 'numeric' }, + decimal => { data_type => 'numeric' }, }, );