use SQL::Translator::Utils 'parse_list_arg';
use base 'SQL::Translator::Schema::Object';
-use vars qw[ $VERSION $TABLE_ORDER $VIEW_ORDER $TRIGGER_ORDER $PROC_ORDER ];
+use vars qw[ $VERSION ];
$VERSION = '1.59';
__PACKAGE__->_attributes(qw/name database translator/);
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new (@_)
+ or return;
+
+ $self->{_order} = { map { $_ => 0 } qw/
+ table
+ view
+ trigger
+ proc
+ /};
+
+ return $self;
+}
+
# ----------------------------------------------------------------------
sub as_graph {
or return $self->error( $table_class->error );
}
- $table->order( ++$TABLE_ORDER );
+ $table->order( ++$self->{_order}{table} );
# We know we have a name as the Table->new above errors if none given.
my $table_name = $table->name;
or return $self->error( $procedure_class->error );
}
- $procedure->order( ++$PROC_ORDER );
+ $procedure->order( ++$self->{_order}{proc} );
my $procedure_name = $procedure->name
or return $self->error('No procedure name');
or return $self->error( $trigger_class->error );
}
- $trigger->order( ++$TRIGGER_ORDER );
+ $trigger->order( ++$self->{_order}{trigger} );
my $trigger_name = $trigger->name or return $self->error('No trigger name');
if ( defined $self->{'triggers'}{$trigger_name} ) {
$view = $view_class->new( \%args ) or return $view_class->error;
}
- $view->order( ++$VIEW_ORDER );
+ $view->order( ++$self->{_order}{view} );
my $view_name = $view->name or return $self->error('No view name');
if ( defined $self->{'views'}{$view_name} ) {
use base 'SQL::Translator::Schema::Object';
-use vars qw( $VERSION $FIELD_ORDER );
+use vars qw( $VERSION );
$VERSION = '1.59';
=cut
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new (@_)
+ or return;
+
+ $self->{_order} = { map { $_ => 0 } qw/
+ field
+ /};
+
+ return $self;
+}
+
+
+
# ----------------------------------------------------------------------
sub add_constraint {
$self->error( $field_class->error );
}
- $field->order( ++$FIELD_ORDER );
+ $field->order( ++$self->{_order}{field} );
# We know we have a name as the Field->new above errors if none given.
my $field_name = $field->name;
<schema name="" database="" xmlns="http://sqlfairy.sourceforge.net/sqlfairy.xml">
<extra />
<tables>
- <table name="Basic" order="2">
+ <table name="Basic" order="1">
<extra />
<fields></fields>
<indices></indices>
<schema name="" database="" xmlns="http://sqlfairy.sourceforge.net/sqlfairy.xml">
<extra />
<tables>
- <table name="Basic" order="3">
+ <table name="Basic" order="1">
<extra />
<fields>
- <field name="foo" data_type="integer" size="10" is_nullable="1" is_auto_increment="0" is_primary_key="0" is_foreign_key="0" order="5">
+ <field name="foo" data_type="integer" size="10" is_nullable="1" is_auto_increment="0" is_primary_key="0" is_foreign_key="0" order="1">
<extra ZEROFILL="1" />
<comments></comments>
</field>