Alzabo

 view release on metacpan or  search on metacpan

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

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
                 \&add_comment_fields,
               ],
               [ 0.71, 0.73,
                 \&convert_pk_to_array,
               ],
               [ 0.79, $Alzabo::VERSION,
                 \&add_table_attributes,
               ],
             );
 
sub update_schema
{
    my %p = validate( @_, { name    => { type => SCALAR },
                            version => { type => SCALAR },
                          } );
 
    my @cb;
    foreach my $c (@compat)
    {
        return
            if ( ( $p{version} >= $c->[0] &&

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

193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
  $movie->delete;
 
=head2 Validating data
 
Let's assume that we've been passed a hash of values representing an
update to the location table. Here's a way of making sure that that
this update won't lead to a loop in terms of the parent/child
relationships.
 
  sub update_location
  {
      my $self = shift; # this is the row object
 
      my %data = @_;
 
      if ( $data{parent_location_id} )
      {
          my $parent_location_id = $data{parent_location_id};
          my $location_t = $schema->table('Location');

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

218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
                  if $location->select('parent_location_id') == $data{location_id};
 
              $parent_location_id = $location->select('parent_location_id');
          }
      }
  }
 
Once again, let's rewrite the code to use
L<C<Alzabo::MethodMaker>|Alzabo::MethodMaker>:
 
  sub update_location
  {
      my $self = shift; # this is the row object
 
      my %data = @_;
 
      if ( $data{parent_location_id} )
      {
          my $location = $self;
          while ( my $location = $location->parent )
          {

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

711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
    $code .= "        \$s->schema->run_in_transaction( sub {\n";
    $code .= "            \$s->pre_update(\\\%p);\n" if $self->{row_class}->can('pre_update');
    $code .= "            \$s->SUPER::update(\%p);\n";
    $code .= "            \$s->post_update(\\\%p);\n" if $self->{row_class}->can('post_update');
    $code .= "        } );\n";
 
    eval <<"EOF";
{
    package $self->{row_class};
 
    sub update
    {
        my \$s = shift;
        my \%p = \@_;
 
$code
 
    }
}
EOF

lib/Alzabo/Runtime/RowState/InCache.pm  view on Meta::CPAN

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
        *{__PACKAGE__ . "::$meth"} =
            sub { my $s = shift;
 
                  $s->refresh(@_) unless $s->_in_cache(@_);
 
                  $s->$super(@_);
              };
    }
}
 
sub update
{
    my $class = shift;
    my $row = shift;
 
    my $old_id = $row->id_as_string;
 
    $class->refresh($row) unless $class->_in_cache($row);
 
    my $changed = $class->SUPER::update( $row, @_ );

lib/Alzabo/Runtime/RowState/Live.pm  view on Meta::CPAN

152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
sub select_hash
{
    my $class = shift;
    my $row = shift;
 
    my @cols = @_ ? @_ : map { $_->name } $row->table->columns;
 
    return $class->_get_data( $row, @cols );
}
 
sub update
{
    my $class = shift;
    my $row = shift;
    my %data = @_;
 
    my $schema = $row->schema;
 
    my @fk; # this never gets populated unless referential integrity
            # checking is on
    my @set;

lib/Alzabo/Runtime/RowState/Potential.pm  view on Meta::CPAN

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{
    my $class = shift;
    my $row = shift;
 
    my %data;
    @data{@_} = @{ $row->{data} }{@_};
 
    return %data;
}
 
sub update
{
    my $class = shift;
    my $row = shift;
    my %data = @_;
 
    foreach my $k (keys %data)
    {
        # This will throw an exception if the column doesn't exist.
        my $c = $row->table->column($k);

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

928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
            ( error => "Cannot mix actual bound values and placeholders in call to values()" );
    }
 
    $self->{last_op} = 'values';
 
    return $self;
}
 
use constant UPDATE_SPEC => { can => 'alias_name' };
 
sub update
{
    my $self = shift;
 
    validate_pos( @_, UPDATE_SPEC );
 
    my $table = shift;
 
    $self->{sql} = 'UPDATE ';
 
    $self->{sql} .= ( $self->{quote_identifiers} ?



( run in 0.516 second using v1.01-cache-2.11-cpan-49f99fa48dc )