Alzabo
view release on metacpan or search on metacpan
0.91 Mar 25, 2007
BUG FIXES:
- Alzabo checked whether a particular variable was an array reference
with a construct like this "eval { @$thing } ? @$thing :
$thing". Under most circumstances, this is ok, but Mason installs a
$SIG{__DIE__} handler that turns all string exceptions into
exception objects. This meant that under Mason, for any eval where
the reference in question was _not_ an array reference, a string
exception was caught and turned into a full-blown exception
object. This could cause a massive performance hit in some cases.
0.90 Mar 9, 2007
ENHANCEMENTS:
- Added handling of multi-column indexes which include one function
when reverse-engineering Pg schemas.
lib/Alzabo/Exceptions.pm view on Meta::CPAN
'Alzabo::Exception::Params' =>
{ description => 'An exception generated when there is an error in the parameters passed in a method of function call',
isa => 'Alzabo::Exception',
alias => 'params_exception',
},
'Alzabo::Exception::NotNullable' =>
{ description => 'An exception generated when there is an attempt is made to set a non-nullable column to NULL',
isa => 'Alzabo::Exception::Params',
fields => [ 'column_name', 'table_name', 'schema_name' ],
alias => 'not_nullable_exception',
},
'Alzabo::Exception::Panic' =>
{ description => 'An exception generated when something totally unexpected happens',
isa => 'Alzabo::Exception',
alias => 'panic_exception',
},
'Alzabo::Exception::RDBMSRules' =>
{ description => 'An RDBMS rule check failed',
lib/Alzabo/RDBMSRules/PostgreSQL.pm view on Meta::CPAN
{
push @sql,
( 'UPDATE "' . $col->table->name
. '" SET "' . $col->name . qq|" = $def WHERE "|
. $col->name . '" IS NULL'
);
push @sql,
( 'ALTER TABLE "' . $col->table->name
. '" ADD CONSTRAINT "'
. $col->table->name . '_' . $col->name . '_not_null" CHECK ( "'
. $col->name . '" IS NOT NULL )'
);
}
return @sql;
}
sub column_sql_diff
{
my $self = shift;
lib/Alzabo/Runtime/Table.pm view on Meta::CPAN
package Alzabo::Runtime::Table;
use strict;
use vars qw($VERSION);
use Alzabo::Exceptions ( abbr => [ qw( logic_exception not_nullable_exception
params_exception ) ] );
use Alzabo::Runtime;
use Alzabo::Utils;
use Params::Validate qw( :all );
Params::Validate::validation_options( on_fail => sub { params_exception join '', @_ } );
use Scalar::Util ();
use Tie::IxHash;
lib/Alzabo/Runtime/Table.pm view on Meta::CPAN
}
}
}
foreach my $c ($self->columns)
{
next if $c->is_primary_key;
unless ( defined $vals->{ $c->name } || $c->nullable || defined $c->default )
{
not_nullable_exception
( error => $c->name . " column in " . $self->name . " table cannot be null.",
column_name => $c->name,
table_name => $c->table->name,
schema_name => $c->table->schema->name,
);
}
delete $vals->{ $c->name }
if ! defined $vals->{ $c->name } && defined $c->default;
}
lib/Alzabo/Runtime/Table.pm view on Meta::CPAN
# value. The value may be a placeholder or SQL function.
$cols{$_} = 1 foreach keys %func_vals;
foreach my $c ( $self->columns )
{
next if $c->is_primary_key || $c->nullable || defined $c->default;
unless ( $cols{ $c->name } )
{
not_nullable_exception
( error => $c->name . " column in " . $self->name . " table cannot be null.",
column_name => $c->name,
table_name => $c->table->name,
schema_name => $c->table->schema->name,
);
}
}
my @columns = $self->columns( keys %vals );
t/02-create.t view on Meta::CPAN
is( $t1_c1->type, 'INTEGER',
"foo_pk type should be 'INTEGER'" );
is( scalar @{[$t1_c1->attributes]}, 1,
"foo_pk should have one attribute" );
is( ($t1_c1->attributes)[0], $att,
"foo_pk's attribute should be $att" );
ok( $t1_c1->has_attribute( attribute => uc $att ),
"foo_pk should have attribute '\U$att\E' (case-insensitive check)" );
ok( ! $t1_c1->has_attribute( attribute => uc $att, case_sensitive => 1 ),
"foo_pk should _not_ have attribute '\U$att\E' (case-sensitive check)" );
ok( ! $t1_c1->nullable,
"foo_pk should not be nullable" );
eval_ok( sub { $t1->add_primary_key($t1_c1) },
"Make 'foo_pk' a primary key for 'footab'" );
ok( $t1_c1->is_primary_key,
"'foo_pk' should be a primary key" );
eval_ok( sub { $s->make_table( name => 'bartab' ) },
t/02-create.t view on Meta::CPAN
) },
'Add a relationship between two columns where one has a VARCHAR pk',
);
ok( $t2->column('t1_pk'), 't2 now has a column called t1_pk' );
}
{
my $t = $s->make_table( name => 'no_pk_table' );
$t->make_column( name => 'not_a_pk',
type => 'integer',
);
eval_ok( sub { my $pk = $t->primary_key },
"Calling primary_key on a table without a primary key should not fail" );
my @pk = $t->primary_key;
is( scalar @pk, 0,
"Return val from primary_key on a table without a primary key should be an empty list" );
}
( run in 2.223 seconds using v1.01-cache-2.11-cpan-cc502c75498 )