L<DBIx::Class::Validation> - Validate all data before submitting to your database.
+L<DBIx::Class::Positional> - Modify the position of objects in an ordered list.
+
+L<DBIx::Class::Tree::AdjacencyList> - Manage a tree of data using the common adjacency list model.
+
+L<DBIx::Class::Tree::NestedSet> - Manage a positional tree of data using the nested set model.
+
=head2 Core
These are the components that all, or nearly all, people will use
# vim: ts=8:sw=4:sts=4:et
-package DBIx::Class::Positioned;
+package DBIx::Class::Positional;
use strict;
use warnings;
use base qw( DBIx::Class );
=head1 NAME
-DBIx::Class::Positioned - Modify the position of objects in an ordered list.
+DBIx::Class::Positional - Modify the position of objects in an ordered list.
=head1 SYNOPSIS
);
# Optional: group_id INTEGER NOT NULL
-In your Schema or DB class add Positioned to the top
+In your Schema or DB class add Positional to the top
of the component list.
- __PACKAGE__->load_components(qw( Positioned ... ));
+ __PACKAGE__->load_components(qw( Positional ... ));
Specify the column that stores the position number for
each row.
This method specified a column to limit all queries in
this module by. This effectively allows you to have multiple
-positioned lists within the same table.
+positional lists within the same table.
=cut
__PACKAGE__->load_components(qw( Tree::AdjacencyList ... ));
# If you want positionable data make sure this
# module comes first, as in:
- __PACKAGE__->load_components(qw( Tree::AdjacencyList Positioned ... ));
+ __PACKAGE__->load_components(qw( Tree::AdjacencyList Positional ... ));
Specify the column that contains the parent ID each row.
Declares the name of the column that contains the self-referential
ID which defines the parent row. Defaults to "parent_id".
-If you are useing the Positioned component then this parent_column
-will automatically be used as the collection_column.
+If you are useing the L<DBIx::Class::Positional> component then this
+parent_column will automatically be used as the collection_column.
=cut
if the object already has the specified parent, and 1 on
success.
-If you are using the Positioned component this
+If you are using the L<DBIx::Class::Positional> component this
module will first move the object to the last position of
the list, change the parent ID, then move the object to the
last position of the new list. This ensures the intergrity
$new_parent = $new_parent->id() || 0;
}
return 0 if ($new_parent == ($self->get_column($parent_column)||0));
- my $is_positioned = $self->isa('DBIx::Class::Positioned');
- $self->move_last() if ($is_positioned);
+ my $is_positional = $self->isa('DBIx::Class::Positional');
+ $self->move_last() if ($is_positional);
$self->set_column( $parent_column => $new_parent );
- if ($is_positioned) {
+ if ($is_positional) {
$self->set_column(
$self->position_column() => $self->search( {$self->_collection_clause()} )->count() + 1
);
Returns a list or record set, depending on context, of all
the objects one level below the current one.
-If you are using the Positioned component then this method
+If you are using the L<DBIx::Class::Positional> component then this method
will return the children sorted by the position column.
=cut
=head2 _collection_clause
This method is provided as an override of the method in
-DBIx::Class::Positioned. This way Positioned and Tree::AdjacencyList
+L<DBIx::Class::Positional>. This way Positional and Tree::AdjacencyList
may be used together without conflict. Make sure that in
your component list that you load Tree::AdjacencyList before you
-load Positioned.
+load Positional.
=cut
use DBICTest;
use DBICTest::HelperRels;
-require "t/run/26positioned.tl";
+require "t/run/26positional.tl";
run_tests(DBICTest->schema);
__PACKAGE__->load_classes(qw/
Artist
- Employee::Positioned
+ Employee::Positional
Employee::AdjacencyList
CD
#dummy
__PACKAGE__->load_components(qw(
Tree::AdjacencyList
- Positioned
+ Positional
PK::Auto
Core
));
package # hide from PAUSE
- DBICTest::Schema::Employee::Positioned;
+ DBICTest::Schema::Employee::Positional;
use base 'DBIx::Class';
-__PACKAGE__->load_components(qw( Positioned PK::Auto Core ));
+__PACKAGE__->load_components(qw( Positional PK::Auto Core ));
-__PACKAGE__->table('employees_positioned');
+__PACKAGE__->table('employees_positional');
__PACKAGE__->add_columns(
employee_id => {
--
-- Created by SQL::Translator::Producer::SQLite
--- Created on Thu Mar 23 19:41:26 2006
+-- Created on Fri Mar 24 07:13:26 2006
--
BEGIN TRANSACTION;
);
--
--- Table: employees_positioned
---
-CREATE TABLE employees_positioned (
- employee_id INTEGER PRIMARY KEY NOT NULL,
- position integer NOT NULL,
- group_id integer,
- name varchar(100)
-);
-
---
-- Table: employees_adjacencylist
--
CREATE TABLE employees_adjacencylist (
);
--
+-- Table: employees_positional
+--
+CREATE TABLE employees_positional (
+ employee_id INTEGER PRIMARY KEY NOT NULL,
+ position integer NOT NULL,
+ group_id integer,
+ name varchar(100)
+);
+
+--
-- Table: fourkeys
--
CREATE TABLE fourkeys (
plan tests => 321;
my $schema = shift;
- my $employees = $schema->resultset('Employee::Positioned');
+ my $employees = $schema->resultset('Employee::Positional');
$employees->delete();
foreach (1..5) {
hammer_rs( $employees );
- DBICTest::Employee::Positioned->collection_column('group_id');
+ DBICTest::Employee::Positional->collection_column('group_id');
$employees->delete();
foreach my $group_id (1..3) {
foreach (1..6) {