Alzabo

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

- Fix bugs in Alzabo::MethodMaker.  The insert, update, lookup_table,
  and self_relation (parent portion only) were broken.

- A bug in the SQL making code was causing some queries to appear as
  if they failed when they didn't.

---------------------------------------------------------------------------

0.30 Feb 4, 2001

- The convert.pl script in eg/ has been updated to handle the new
  release.  IMPORTANT: I forgot to include a mention of this in the
  last release but you need to run the script _before_ installing a
  new version of Alzabo.

- Many improvements and updates to Alzabo::MethodMaker.  Highlights
  include fixing a bug that prevented the insert and update methods
  from being created, a new callback system that allows you to specify
  all the method names to be generated, and a new 'self_relations'
  option for tables that have parent/child relationships with
  themself.

Changes  view on Meta::CPAN

  mixed and matched.  Right now there is only one storage class (which
  stores the objects in memory).  There are 3 syncing classes.  One,
  NullSync, doesn't actually sync objects.  It does track deletions,
  but not expirations.  The others, IPCSync and DBMSync, use IPC or
  DBM files to track expiration and deletion of objects.

- Doing this work highlighted some bugs in the caching/syncing code.
  One oversight was that if you deleted an object and then inserted
  another row with the exact same primary key, the cache continued to
  think the object was deleted.  Other bugs also surfaced.  These have
  been fixed and the test suite has been updated so caching should be
  stable (if not, I'll have to cry).

- When viewing an existing column in the schema creator, defaults,
  lengths, and precision of 0 were not being shown.

- Alzabo::Runtime::Table->row_count can now take a where clause.

- Fix bugs in Alzabo::Create::Table.  This was causing problems with
  indexes when the table name was changed.

lib/Alzabo/BackCompat.pm  view on Meta::CPAN

        my $msg = <<"EOF";

The '$p{name}' schema was created by an older version of Alzabo
($v) than the one currently installed ($Alzabo::VERSION).

Alzabo can update your schema objects but your schema file:

  $c_file

is not writeable by this process.  Loading this schema in a process
which can write to this file will cause the schema to be updated.

EOF

        die $msg;
    }

    my $dir = dirname($c_file);
    unless ( -w $dir )
    {
        my $msg = <<"EOF";

The '$p{name}' schema was created by an older version of Alzabo
($v) than the one currently installed ($Alzabo::VERSION).

Alzabo can update your schema objects but its director:

  $dir

is not writeable by this process.  Loading this schema in a process
which can write to this file will cause the schema to be updated.

EOF

        die $msg;
    }

    foreach my $file ( glob("$dir/*.alz"),
                       glob("$dir/*.rdbms"),
                       glob("$dir/*.version") )
    {

lib/Alzabo/BackCompat.pm  view on Meta::CPAN

        or Alzabo::Exception::System->throw( error => "Can't write to $version_file: $!" );
    close $fh
        or Alzabo::Exception::System->throw( error => "Unable to close $version_file: $!" );

    Alzabo::Create::Schema->load_from_file( name => $p{name} )->save_to_file;

    if ($create_loaded)
    {
        warn <<"EOF"

Your schema, $p{name}, has been updated to be compatible with the
installed version of Alzabo.  This required that the Alzabo::Create::*
classes be loaded.  If you were loading an Alzabo::Runtime::Schema
object, your running process is now somewhat larger than it has to be.

If this is a long running process you may want to reload it.

EOF
    }
}

lib/Alzabo/Design.pod  view on Meta::CPAN

And finally, they also handle the reverse engineering of an existing
database.

=item * C<Alzabo::Runtime::Row> and C<Alzabo::Runtime::RowState::*>

The C<Alzabo::Runtime::Row> class represents a single row.  These
objects are created by
L<C<Alzabo::Runtime::Table>|Alzabo::Runtime::Table>,
L<C<Alzabo::Runtime::RowCursor>|Alzabo::Runtime::RowCursor>, and
L<C<Alzabo::Runtime::JoinCursor>|Alzabo::Runtime::JoinCursor> objects.
It is the sole interface by which actual data is retrieved, updated,
or deleted in a table.

The various C<RowState> classes are used in order to change a row's
behavior depending on whether it is live, live and cached, potential,
or deleted.

=item * C<Alzabo::Runtime::JoinCursor> and C<Alzabo::Runtime::RowCursor>

These objects are cursor that returns row objects.  Using a cursor
saves a lot of memory for big selects.

lib/Alzabo/MethodMaker.pm  view on Meta::CPAN

=back

=head2 Row object methods

=over 4

=item * row_columns => $bool

This tells MethodMaker to create get/set methods for each column a row
has.  These methods take a single optional argument, which if given
will cause that column to be updated for the row.

=item * update_hooks => $bool

Look for hooks to wrap around the C<update> method in
L<C<Alzabo::Runtime::Row>|Alzabo::Runtime::Row>.  See L<Loading
Classes> for more details.  You have to define a C<pre_update()>
and/or C<post_update()> method for the generated row class or this
parameter will not do anything.  See the L<HOOKS|/"HOOKS"> section for
more details.

lib/Alzabo/QuickRef.pod  view on Meta::CPAN

L<C<Alzabo::Runtime::RowCursor>|Alzabo::Runtime::RowCursor> objects.

All methods that return a single row return an
L<C<Alzabo::Runtime::Row>|Alzabo::Runtime::Row> object.

All methods that return multiple rows return an
L<C<Alzabo::Runtime::RowCursor>|Alzabo::Runtime::RowCursor> object.

All methods that return rows can be given the C<no_cache> parameter,
which ensures that the row(s) returned will not be cached.  Rows
obtained in this manner should not be updated or deleted, as this will
play havoc with the caching system.  See the
L<C<Alzabo::Runtime::Row>|Alzabo::Runtime::Row> documentation for more
details.

All methods that return multiple rows in the form of a cursor object
can take an C<order_by> parameter.  See the
L<C<Alzabo::Runtime::Table>|Alzabo::Runtime::Table> documentation for
more details.

=over 4

lib/Alzabo/Runtime/Schema.pm  view on Meta::CPAN

Set the port to use when connecting to the database.

=head2 port

Returns the port used by the schema when connecting to the database.

=head2 set_referential_integrity ($boolean)

Turns referential integrity checking on or off.  If it is on, then
when L<C<Alzabo::Runtime::Row>|Alzabo::Runtime::Row> objects are
deleted, updated, or inserted, they will report this activity to any
relevant L<C<Alzabo::Runtime::ForeignKey>|Alzabo::Runtime::ForeignKey>
objects for the row, so that the foreign key objects can take
appropriate action.

This defaults to false.  If your RDBMS supports foreign key
constraints, these should be used instead of Alzabo's built-in
referential integrity checking, as they will be much faster.

=head2 referential_integrity

mason/widgets/insert_or_update  view on Meta::CPAN

of %ARGS.  An insert is done if the primary key columns for the table
are not defined in C<%ARGS>.  Otherwise an update is done.

=head1 PARAMETERS

=over 4

=item * table

An <Alzabo::Table> object into which a new row is inserted or an
existing row is updated.

=back

The rest of the arguments should simply be the C<%ARGS> hash as passed
to the calling component.  This component will extract the relevant
column values from that hash.

=head1 RETURNS

The row that was inserted or updated.

=cut
</%doc>
<%args>
$table
</%args>
<%init>
my $insert = 1;
foreach my $c ( $table->primary_key )
{

mason/widgets/update  view on Meta::CPAN

=head1 DESCRIPTION

A simple widget to perform an update based on the values of %ARGS.

=head1 PARAMETERS

=over 4

=item * table

An <Alzabo::Table> object which contains the row to be updated

=back

The rest of the arguments should simply be the C<%ARGS> hash as passed
to the calling component.  This component will extract the relevant
column values from that hash.

=head1 RETURNS

The row just updated is returned from this component.

=cut
</%doc>
<%args>
$table
</%args>
<%init>
my %data;
my %pk;
foreach my $c ( $table->primary_key )

t/03-runtime.t  view on Meta::CPAN

    $e = $@;
    isa_ok( $e, 'Alzabo::Exception::Params',
	    "Exception thrown from attempt to insert a NULL into dep_id for an employee" );

    eval { $emp{bill}->update( dep_id => undef ) };
    $e = $@;
    isa_ok( $e, 'Alzabo::Exception::Params',
	    "Exception thrown from attempt to update dep_id to NULL for an employee" );

    {
        my $updated = $emp{bill}->update( cash => undef, smell => 'hello!' );

        ok( $updated, 'update() did change values' );
        ok( ! defined $emp{bill}->select('cash'),
            "Bill has no cash" );
    }

    {
        my $updated = $emp{bill}->update( cash => undef, smell => 'hello!' );

        ok( ! $updated, 'update() did not change values' );
    }

    ok( $emp{bill}->select('smell') eq 'hello!',
	"smell for bill should be 'hello!'" );

    eval { $emp{bill}->update( name => undef ) };
    $e = $@;
    isa_ok( $e, 'Alzabo::Exception::NotNullable',
	    "Exception thrown from attempt to update a non-nullable column to NULL" );

t/03-runtime.t  view on Meta::CPAN

    eval_ok( sub { $p_emp = $emp_t->potential_row },
	     "Create potential row object");

    is( $p_emp->is_live, 0,
        "potential_row should ! ->is_live" );

    is( $p_emp->select('smell'), 'grotesque',
	"Potential Employee should have default smell, 'grotesque'" );

    {
        my $updated = $p_emp->update( cash => undef, smell => 'hello!' );

        ok( $updated, 'update() did change values' );
        ok( ! defined $p_emp->select('cash'),
            "Potential Employee cash column is not defined" );
    }

    {
        my $updated = $p_emp->update( cash => undef, smell => 'hello!' );

        ok( ! $updated, 'update() did not change values' );
    }

    is( $p_emp->select('smell'), 'hello!',
	"smell for employee should be 'hello!' after update" );

    $p_emp->update( name => 'Ilya' );
    is( $p_emp->select('name'), 'Ilya',
        "New employee got a name" );

    $p_emp->update( dep_id => $dep_id );

t/14-unique-row-cache.t  view on Meta::CPAN

                    bind => [ 'bar', $dep2->select('department_id') ],
                  );

    $dep2->refresh;

    is( $dep2->select('name'), 'bar', 'refresh works for cached rows' );
    is( $dep2_copy->select('name'), 'bar', 'refresh works for cached rows' );

    my $old_id = $dep2->id_as_string;
    {
        my $updated = $dep2->update( department_id => 1000 );
        ok( $updated, 'update() did change values' );
    }

    {
        my $updated = $dep2->update( department_id => 1000 );
        ok( ! $updated, 'update() did not change values' );
    }

    ok( Alzabo::Runtime::UniqueRowCache->row_in_cache
            ( $dep2->table->name, $dep2->id_as_string ),
        'row is still in cache after updating primary key' );

    ok( ! Alzabo::Runtime::UniqueRowCache->row_in_cache( $dep2->table->name, $old_id ),
        'old id is not in cache' );

    my $dep2_copy_2 =



( run in 0.389 second using v1.01-cache-2.11-cpan-05444aca049 )