#!/usr/bin/perl
+# vim: set ft=perl:
use strict;
-use Test::More 'no_plan'; #tests => 105;
+use Test::More;
use SQL::Translator;
use SQL::Translator::Schema::Constants;
-use SQL::Translator::Parser::Oracle qw(parse);
+use Test::SQL::Translator qw(maybe_plan);
+
+maybe_plan(76, 'SQL::Translator::Parser::Oracle');
+SQL::Translator::Parser::Oracle->import('parse');
my $t = SQL::Translator->new( trace => 0 );
my $sql = q[
comment on column qtl_trait_category.qtl_trait_category_id
is 'the primary key!';
+ -- foo bar comment
CREATE TABLE qtl_trait
(
qtl_trait_id NUMBER(11) NOT NULL
FOREIGN KEY ( qtl_trait_category_id ) REFERENCES qtl_trait_category
);
+ /* qtl table comment */
CREATE TABLE qtl
(
+ /* qtl_id comment */
qtl_id NUMBER(11) NOT NULL
CONSTRAINT pk_qtl PRIMARY KEY,
- qtl_accession_id VARCHAR2(20) NOT NULL,
+ qtl_accession_id VARCHAR2(20) NOT NULL /* accession comment */,
published_symbol VARCHAR2(100),
qtl_trait_id NUMBER(11) NOT NULL,
linkage_group VARCHAR2(32) NOT NULL,
my $data = parse( $t, $sql );
my $schema = $t->schema;
-#use Data::Dumper;
-#print Dumper($schema), "\n";
-
isa_ok( $schema, 'SQL::Translator::Schema', 'Schema object' );
my @tables = $schema->get_tables;
is( scalar @tables, 4, 'Found four tables' );
is( $f1->is_nullable, 0, 'Field cannot be null' );
is( $f1->default_value, undef, 'Default value is undefined' );
is( $f1->is_primary_key, 1, 'Field is PK' );
-is( $f1->comments, 'the primary key!', 'Comment = "the primary key!"' );
+is( join(',', $f1->comments), 'the primary key!', 'Comment = "the primary key!"' );
my $f2 = shift @t1_fields;
is( $f2->name, 'trait_category', 'Second field is "trait_category"' );
#
my $t2 = shift @tables;
is( $t2->name, 'qtl_trait', 'Table "qtl_trait" exists' );
+is( $t2->comments, 'foo bar comment', 'Comment "foo bar" exists' );
my @t2_fields = $t2->get_fields;
is( scalar @t2_fields, 4, '4 fields in table' );
my @t3_constraints = $t3->get_constraints;
is( scalar @t3_constraints, 3, '3 constraints on table' );
+is( $t3->comments, 'qtl table comment', 'Comment "qtl table comment" exists' );
+
+my $t3_f1 = shift @t3_fields;
+is( $t3_f1->comments, 'qtl_id comment', 'Comment "qtl_id comment" exists' );
+
+my $t3_f2 = shift @t3_fields;
+is( $t3_f2->comments, 'accession comment',
+ 'Comment "accession comment" exists' );
+
#
# qtl_trait_synonym
#