2 # vim: set ft=perl ts=4 et:
9 use Test::SQL::Translator qw(maybe_plan);
11 use SQL::Translator::Schema::Constants;
14 maybe_plan(41, 'SQL::Translator::Parser::Sybase');
15 SQL::Translator::Parser::Sybase->import('parse');
18 my $file = "$Bin/data/sybase/create.sql";
20 ok( -e $file, "File exists" );
25 open my $fh, "<$file" or die "Can't read file '$file': $!\n";
32 my $t = SQL::Translator->new;
34 my $val = parse($t, $data);
36 is( $val, 1, 'Parse' );
38 my $schema = $t->schema;
40 isa_ok( $schema, 'SQL::Translator::Schema', 'Schema' );
42 is( $schema->is_valid, 1, 'Schema is valid' );
44 my @tables = $schema->get_tables;
46 is( scalar @tables, 9, 'Nine tables' );
49 my $t = $schema->get_table( 'jdbc_function_escapes' );
50 isa_ok( $t, 'SQL::Translator::Schema::Table', 'Table' );
51 is( $t->name, 'jdbc_function_escapes', "Name = 'jdbc_function_escapes'" );
53 my @fields = $t->get_fields;
54 is( scalar @fields, 2, 'Two fields' );
56 is( $fields[0]->name, 'escape_name', "First field name is 'escape_name'" );
57 is( $fields[0]->data_type, 'varchar', "First field is 'varchar'" );
58 is( $fields[0]->size, 40, "First field size is '40'" );
59 is( $fields[0]->is_nullable, 0, "First field cannot be null" );
61 is( $fields[1]->name, 'map_string', "Second field name is 'map_string'" );
62 is( $fields[1]->data_type, 'varchar', "Second field is 'varchar'" );
63 is( $fields[1]->size, 40, "Second field size is '40'" );
64 is( $fields[1]->is_nullable, 0, "Second field cannot be null" );
68 my $t = $schema->get_table( 'spt_jtext' );
69 isa_ok( $t, 'SQL::Translator::Schema::Table', 'Table' );
70 is( $t->name, 'spt_jtext', "Name = 'spt_jtext'" );
72 my @fields = $t->get_fields;
73 is( scalar @fields, 2, 'Two fields' );
75 is( $fields[0]->name, 'mdinfo', "First field name is 'mdinfo'" );
76 is( $fields[0]->data_type, 'varchar', "First field is 'varchar'" );
77 is( $fields[0]->size, 30, "First field size is '30'" );
78 is( $fields[0]->is_nullable, 0, "First field cannot be null" );
80 is( $fields[1]->name, 'value', "Second field name is 'value'" );
81 is( $fields[1]->data_type, 'text', "Second field is 'text'" );
82 is( $fields[1]->size, 0, "Second field size is '0'" );
83 is( $fields[1]->is_nullable, 0, "Second field cannot be null" );
85 my @constraints = $t->get_constraints;
86 is( scalar @constraints, 1, 'One constraint' );
88 is( $constraints[0]->type, UNIQUE, 'Constraint is UNIQUE' );
89 is( join(',', $constraints[0]->fields), 'mdinfo', 'On "mdinfo"' );
93 my $t = $schema->get_table( 'spt_mda' );
94 isa_ok( $t, 'SQL::Translator::Schema::Table', 'Table' );
95 is( $t->name, 'spt_mda', "Name = 'spt_mda'" );
97 my @fields = $t->get_fields;
98 is( scalar @fields, 7, 'Seven fields' );
100 is( $fields[0]->name, 'mdinfo', "First field name is 'mdinfo'" );
101 is( $fields[0]->data_type, 'varchar', "First field is 'varchar'" );
102 is( $fields[0]->size, 30, "First field size is '30'" );
103 is( $fields[0]->is_nullable, 0, "First field cannot be null" );
105 my @constraints = $t->get_constraints;
106 is( scalar @constraints, 1, 'One constraint' );
108 is( $constraints[0]->type, UNIQUE, 'Constraint is UNIQUE' );
109 is( join(',', $constraints[0]->fields),
110 'mdinfo,mdaver_end,srvver_end', 'On "mdinfo,mdaver_end,srvver_end"' );