Alzabo
view release on metacpan or search on metacpan
ensures that the table to which we're referring will be available.
- When recreating a table during a SQL diff, make this an exception so
we don't do other column diff/add/drop operations on the same table.
- Fixed a test failure in 07-methodmaker.t when testing with
Postgres. This failure may not have showed up often because it came
from a test that depended on the DBMS returning rows in a speific
order by without specifying an ORDER BY.
- When a Postgres table is renamed, its sequences are also renamed.
0.8801 Mar 13, 2006
BUG FIXES:
- Quoting of PostgreSQL column defaults in DDL SQL was completely
broken.
that were null to the string "NULL" before performing a query.
- If a table name was changed and an index, column, or foreign key
dropped from that table, then the generated "diff" SQL could refer
to the old table name in the various DROP statements that were
generated.
- Workaround a bug in MySQL that reports a "Sub_part" of 1 for
fulltext indexes.
- The changes introduced in 0.71 to track table and column renames
could cause bogus SQL to be generated if something was renamed, the
schema was instantiated, and then the schema was compared to an
existing live database which also had the same renaming done to it.
- If you tried to create a relationship between two tables where one
of the tables had a varchar or char column as part of its PK, and
you let Alzabo create the foreign key column in the other table,
then Alzabo would try to set the length of the varchar/char column
to undef, which would cause an exception to be thrown.
---------------------------------------------------------------------------
- Fixed the Alzabo::MethodMaker->docs_as_pod method, which simply died
when used with a recent version of Params::Validate. Reported by
Ken Williams.
---------------------------------------------------------------------------
0.71 April 6, 2003
ENHANCEMENTS:
- Alzabo now tracks table and column renames after a schema has been
instantiated. This means that when updating the schema in the
database after such a change, Alzabo can ensure that there is no
data lost because of the change. Previously, Alzabo treated name
changes as a drop followed by an add, which caused data loss.
- Alzabo::DriverStatement->next_hash has been renamed next_as_hash, in
order to be consistent with the Alzabo::Runtime::Cursor classes.
- Experimental support for restriction clauses as part of an outer
join, such as
SELECT ...
FROM Foo
LEFT OUTER JOIN Bar
ON Foo.foo_id = Bar.foo_id
AND Bar.something > 2
- Exceptions did not include a stack trace.
- Trying to create a Postgres schema with foreign keys defined caused
an exception. Reported by Josh Jore.
- Fetching rows from the cursor for a join with multiple outer joins
could fail if data was being prefetched.
DEPRECATIONS:
- Alzabo::DriverStatement->next_hash method has been renamed
next_as_hash.
---------------------------------------------------------------------------
0.70 November 21, 2002
ENHANCEMENTS:
- The exception thrown when you attempt to set a non-nullable column
to NULL is now an Alzabo::Exception::NotNullable exception, instead
- Alzabo::ObjectCache::Sync::RDBMS created a table that it would later
consider incorrect. This made this module unusable.
- Alzabo::ObjectCache::Sync::RDBMS caused weird random errors when
used with MySQL's InnoDB tables.
- In the schema creator, the link to the graph page, and the link _on_
the graph page to the image, were both broken.
- Alzabo was allowing you to rename a column to the name of an
existing column in a table. Similarly, a table could be renamed to
the same name as an existing table. Doing this could trash a
schema.
- Alzabo::Runtime::Table->one_row would return undef if no row was
found, which in a list context evaluated to a true value.
- Allow no_cache option when calling Alzabo::Runtime::Schema->join.
- When displaying SQL, the schema creator now makes sure to
HTML-escape it, because it's possible to have HTML in there (in a
- Alzabo::MethodMaker will die properly if given a non-existent schema
name. Suggested by Ilya Martynov.
- If you added a sequenced primary key to a table with MySQL, Alzabo
did not generate all of the SQL necessary to change the table.
Reported by Ilya Martynov.
DEPRECATIONS:
- The Alzabo::Schema start_transaction method has been renamed to
begin_work. The finish_transaction method is now commit. The old
names are deprecated.
---------------------------------------------------------------------------
0.65 May 16, 2002
INCOMPATIBILITIES:
- Alzabo now uses the natively created Postgres sequence for SERIAL
CREATE SEQUENCE foo_foo_id_seq START 501;
- The Alzabo::Table->primary_key method is now context-sensitive,
returning a single column object in scalar context.
- The data browser is no longer installed, until such time as I can
rewrite it to be more useful.
DEPRECATIONS:
- The Alzabo::Create::Schema->add_relation method has been renamed as
Alzabo::Create::Schema->add_relationship.
ENHANCEMENTS:
- Check out the mason/widgets directory for some handy widgets that
can help integrate Mason and Alzabo in useful ways. These aren't
really well-documented yet but may be useful for playing with. More
widgets will be included in future releases (I hope).
- When creating a relationship between tables in the schema creator,
- Removed the deprecated next_row methods from the various cursor
classes.
- Removed the deprecated Alzabo::Runtime::Table->func method.
- Major changes to how joins are done. It is now possible to mix
together various sorts of outer joins in a single query. In
addition, it is now possible to specify a foreign key that should be
used when joining two tables.
- The "tables" parameter has been renamed as "join".
- The Alzabo::Create::Schema->right_outer_join and
Alzabo::Create::Schema->left_outer_join methods have been removed.
Use the ->join method instead, which can now be used to do outer
joins as well, via:
$schema->join( join => [ left_outer_join => $foo, $bar ], ... )
- The functionality of Alzabo::Runtime::OuterJoinCursor has been
merged into Alzabo::Runtime::JoinCursor.
0.63 Feb 18, 2002
ENHANCEMENTS:
- Calling Alzabo::Runtime::Row->select or
Alzabo::Runtime::Row->select_hash with no arguments returns the
values for all of the columns in the table. Suggested by Jeremy
R. Semeiks.
- The Alzabo::Runtime::Row->id method has been renamed to id_as_string
for the benefit of those crazy people who like to use "id" as a
column name and want Alzabo::MethodMaker to be able to create such a
method. Suggested by Alexei Barantsev.
- Changed the Alzabo::Create::Schema->sync_backend method so that if
there was no corresponding schema in the RDBMS, then it will
instantiate a new schema instead of just blowing up. Similarly, the
sync_backend_sql method will just return the SQL necessary to create
the schema from scratch.
a) place your modifications in the Public Domain or otherwise
make them Freely Available, such as by posting said modifications
to Usenet or an equivalent medium, or placing the modifications on
a major archive site such as ftp.uu.net, or by allowing the
Copyright Holder to include your modifications in the Standard
Version of the Package.
b) use the modified Package only within your corporation or
organization.
c) rename any non-standard executables so the names do not
conflict with standard executables, which must also be provided,
and provide a separate manual page for each non-standard
executable that clearly documents how it differs from the Standard
Version.
d) make other distribution arrangements with the Copyright Holder.
4. You may distribute the programs of this Package in object code or executable
form, provided that you do at least ONE of the following:
lib/Alzabo/RDBMSRules.pm view on Meta::CPAN
if ( $self->can_alter_table_name )
{
push @sql, $self->alter_table_name_sql($new_t);
}
else
{
push @sql, $self->recreate_table_sql( new => $new_t,
old => $old_t,
);
push @sql, $self->rename_sequences( new => $new_t,
old => $old_t,
);
# no need to do more because table will be
# recreated from scratch
next;
}
}
push @sql,
lib/Alzabo/RDBMSRules/PostgreSQL.pm view on Meta::CPAN
my @sql;
foreach my $fk ( $table->all_foreign_keys )
{
push @sql, $self->foreign_key_sql($fk);
push @sql, $self->foreign_key_sql( $fk->reverse );
}
return @sql;
}
sub rename_sequences
{
my $self = shift;
my %p = @_;
return () if $self->{state}{rename_sequence_sql}{ $p{new}->name };
my @sql;
for my $old_col ( grep { $_->sequenced } $p{old}->columns )
{
my $new_col = $p{new}->column( $old_col->name )
or next;
my $old_seq = $self->_sequence_name($old_col);
my $new_seq = $self->_sequence_name($new_col);
push @sql,
qq|ALTER TABLE "$old_seq" RENAME TO "$new_seq";\n|;
}
$self->{state}{rename_sequence_sql}{ $p{new}->name } = 1;
return @sql;
}
sub drop_foreign_key_sql
{
my $self = shift;
my $fk = shift;
if ( grep { $_->is_primary_key } $fk->columns_from )
t/98-schema-diff.t view on Meta::CPAN
eval_ok( sub { $s->create(%connect) },
"Create schema (via diff) with a column name change" );
($val) =
$s->driver->handle->selectrow_array( 'SELECT cruftiness FROM new_cruft WHERE new_cruft_id = 2' );
is( $val, 4,
"Data should be preserved across column name change" );
{
# Test table rename followed by drop column
my $table = $s->table('employee');
$table->set_name('new_emp_table');
$table->delete_column( $table->column('smell') );
my $sql = join "\n", $s->make_sql;
if ( $rdbms eq 'mysql' )
{
like( $sql, qr/RENAME TABLE\s+employee\s+TO\s+new_emp_table/i,
'SQL should include rename to new table name' );
like( $sql, qr/ALTER TABLE\s+new_emp_table/i,
'ALTER TABLE should refer to new table name' );
}
elsif ( $rdbms eq 'pg' )
{
like( $sql, qr/DROP TABLE\s+"employee"/i,
'SQL should include dropping table with old name' );
like( $sql, qr/CREATE TABLE\s+"new_emp_table"/i,
'SQL should include creation of table with new name' );
}
}
{
# will instantiate with renamed table from above block
$s->create(%connect);
# a bug (which should be fixed) caused bogus SQL to be
# generated when comparing this schema to a live DB with the
# rename already done.
my $sql = join "\n", $s->sync_backend_sql(%connect);
$sql ||= '';
is( $sql, '',
'No SQL should be generated when syncing to a backend after instantiating'
. ' with a renamed table'
);
}
}
( run in 0.600 second using v1.01-cache-2.11-cpan-131fc08a04b )