Alzabo
view release on metacpan or search on metacpan
lib/Alzabo/BackCompat.pm view on Meta::CPAN
313233343536373839404142434445464748495051
\
&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
193194195196197198199200201202203204205206207208209210211212
$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
218219220221222223224225226227228229230231232233234235236237238
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
711712713714715716717718719720721722723724725726727728729730
$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
1314151617181920212223242526272829303132
*{__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
152153154155156157158159160161162163164165166167168169170171172sub
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
4142434445464748495051525354555657585960{
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
928929930931932933934935936937938939940941942943944945946947948
(
error
=>
"Cannot mix actual bound values and placeholders in call to values()"
);
}
$self
->{last_op} =
'values'
;
return
$self
;
}
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 )