package Test::SQL::Translator;
# ----------------------------------------------------------------------
-# $Id: Translator.pm,v 1.6 2004-07-08 17:29:56 grommit Exp $
+# $Id: Translator.pm,v 1.8 2005-01-13 09:02:15 grommit Exp $
# ----------------------------------------------------------------------
# Copyright (C) 2003 The SQLFairy Authors
#
use base qw(Exporter);
use vars qw($VERSION @EXPORT @EXPORT_OK);
-$VERSION = sprintf "%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.8 $ =~ /(\d+)\.(\d+)/;
@EXPORT = qw(
schema_ok
table_ok
on_update => '',
reference_fields => [],
reference_table => '',
+ extra => {},
};
$ATTRIBUTES{'index'} = {
fields => [],
name => "",
options => [],
type => NORMAL,
+ extra => {},
};
$ATTRIBUTES{'view'} = {
name => "",
sql => "",
fields => [],
is_valid => 1,
+ extra => {},
};
$ATTRIBUTES{'trigger'} = {
name => '',
on_table => undef,
action => undef,
is_valid => 1,
+ extra => {},
};
$ATTRIBUTES{'procedure'} = {
name => '',
parameters => [],
owner => '',
comments => '',
+ extra => {},
};
$ATTRIBUTES{table} = {
comments => undef,
constraints => undef,
indices => undef,
is_valid => 1,
+ extra => {},
};
$ATTRIBUTES{schema} = {
name => '',
triggers => undef, # [] when set
views => undef, # [] when set
is_valid => 1,
+ extra => {},
};
is_deeply( [$obj->options], $test->{options},
"$t_name options are '".join(",",@{$test->{options}})."'" );
+
+ is_deeply( { $obj->extra }, $test->{extra}, "$t_name extra" );
}
sub index_ok {
is_deeply( [$obj->options], $test->{options},
"$t_name options are '".join(",",@{$test->{options}})."'" );
+
+ is_deeply( { $obj->extra }, $test->{extra}, "$t_name extra" );
}
sub trigger_ok {
my $t_name = t_name($name);
default_attribs($test,"index");
- is( $obj->name, $test->{name}, "${t_name}Constraint '$test->{name}'" );
+ is( $obj->name, $test->{name}, "${t_name}Trigger '$test->{name}'" );
is( $obj->is_valid, $test->{is_valid},
"$t_name is ".($test->{is_valid} ? '' : 'not ').'valid' );
"$t_name on_table is '$test->{on_table}'" );
is( $obj->action, $test->{action}, "$t_name action is '$test->{action}'" );
+
+ is_deeply( { $obj->extra }, $test->{extra}, "$t_name extra" );
}
sub view_ok {
is_deeply( [$obj->fields], $test->{fields},
"$t_name fields are '".join(",",@{$test->{fields}})."'" );
+
+ is_deeply( { $obj->extra }, $test->{extra}, "$t_name extra" );
}
sub procedure_ok {
"$t_name comments is '$test->{comments}'" );
is( $obj->owner, $test->{owner}, "$t_name owner is '$test->{owner}'" );
+
+ is_deeply( { $obj->extra }, $test->{extra}, "$t_name extra" );
}
sub table_ok {
is_deeply( [$obj->options], $test->{options},
"$t_name options are '".join(",",@{$test->{options}})."'" );
+ is_deeply( { $obj->extra }, $test->{extra}, "$t_name extra" );
+
# Fields
if ( $arg{fields} ) {
my @fldnames = map {$_->{name}} @{$arg{fields}};
is( $obj->database, $test->{database},
"$t_name database is '$test->{database}'" );
+
+ is_deeply( { $obj->extra }, $test->{extra}, "$t_name extra" );
is( $obj->is_valid, $test->{is_valid},
"$t_name is ".($test->{is_valid} ? '' : 'not ').'valid' );