__PACKAGE__->mk_group_accessors('component_class' => qw/resultset_class
result_class/);
-=head1 NAME
+=head1 NAME
DBIx::Class::ResultSource - Result source object
=over 4
-=item accessor
+=item accessor
Use this to set the name of the accessor for this column. If unset,
the name of the column will be used.
=item size
The length of your column, if it is a column type that can have a size
-restriction. This is currently not used by DBIx::Class.
+restriction. This is currently not used by DBIx::Class.
=item is_nullable
Set this to the default value which will be inserted into a column
by the database. Can contain either a value or a function. This is
-currently not used by DBIx::Class.
+currently not used by DBIx::Class.
=item sequence
sub add_columns {
my ($self, @cols) = @_;
$self->_ordered_columns(\@cols) unless $self->_ordered_columns;
-
+
my @added;
my $columns = $self->_columns;
while (my $col = shift @cols) {
sub column_info {
my ($self, $column) = @_;
- $self->throw_exception("No such column $column")
+ $self->throw_exception("No such column $column")
unless exists $self->_columns->{$column};
#warn $self->{_columns_info_loaded}, "\n";
- if ( ! $self->_columns->{$column}{data_type}
- and ! $self->{_columns_info_loaded}
+ if ( ! $self->_columns->{$column}{data_type}
+ and ! $self->{_columns_info_loaded}
and $self->schema and $self->storage )
{
$self->{_columns_info_loaded}++;
my $info;
- # eval for the case of storage without table
+ # eval for the case of storage without table
eval { $info = $self->storage->columns_info_for($self->from) };
unless ($@) {
foreach my $col ( keys %{$self->_columns} ) {
return @{$self->{_ordered_columns}||[]};
}
+=head2 remove_columns
+
+ $table->remove_columns(qw/col1 col2 col3/);
+
+Removes columns from the result source.
+
+=head2 remove_column
+
+ $table->remove_column('col');
+
+Convenience alias to remove_columns.
+
+=cut
+
+sub remove_columns {
+ my ($self, @cols) = @_;
+
+ return unless $self->_ordered_columns;
+
+ my $columns = $self->_columns;
+ my @remaining;
+
+ foreach my $col (@{$self->_ordered_columns}) {
+ push @remaining, $col unless grep(/$col/, @cols);
+ }
+
+ foreach (@cols) {
+ undef $columns->{$_};
+ };
+
+ $self->_ordered_columns(\@remaining);
+}
+
+*remove_column = \&remove_columns;
+
=head2 set_primary_key
=over 4
Additionally, defines a unique constraint named C<primary>.
The primary key columns are used by L<DBIx::Class::PK::Auto> to
-retrieve automatically created values from the database.
+retrieve automatically created values from the database.
=cut
=head2 storage
-Returns the storage handle for the current schema.
+Returns the storage handle for the current schema.
See also: L<DBIx::Class::Storage>
An arrayref containing a list of accessors in the foreign class to proxy in
the main class. If, for example, you do the following:
-
+
CD->might_have(liner_notes => 'LinerNotes', undef, {
proxy => [ qw/notes/ ],
});
-
+
Then, assuming LinerNotes has an accessor named notes, you can do:
my $cd = CD->find(1);
=item accessor
Specifies the type of accessor that should be created for the
-relationship. Valid values are C<single> (for when there is only a single
-related object), C<multi> (when there can be many), and C<filter> (for
-when there is a single related object, but you also want the relationship
-accessor to double as a column accessor). For C<multi> accessors, an
-add_to_* method is also created, which calls C<create_related> for the
+relationship. Valid values are C<single> (for when there is only a single
+related object), C<multi> (when there can be many), and C<filter> (for
+when there is a single related object, but you also want the relationship
+accessor to double as a column accessor). For C<multi> accessors, an
+add_to_* method is also created, which calls C<create_related> for the
relationship.
=back
eval { $self->resolve_join($rel, 'me') };
if ($@) { # If the resolve failed, back out and re-throw the error
- delete $rels{$rel}; #
+ delete $rels{$rel}; #
$self->_relationships(\%rels);
$self->throw_exception("Error creating relationship $rel: $@");
}
sub relationship_info {
my ($self, $rel) = @_;
return $self->_relationships->{$rel};
-}
+}
=head2 has_relationship
while (my ($k, $v) = each %{$cond}) {
# XXX should probably check these are valid columns
$k =~ s/^foreign\.// ||
- $self->throw_exception("Invalid rel cond key ${k}");
+ $self->throw_exception("Invalid rel cond key ${k}");
$v =~ s/^self\.// ||
- $self->throw_exception("Invalid rel cond val ${v}");
+ $self->throw_exception("Invalid rel cond val ${v}");
if (ref $for) { # Object
#warn "$self $k $for $v";
$ret{$k} = $for->get_column($v);
# 'artist.name',
# 'producer.producerid',
# 'producer.name'
- #)
+ #)
=cut
sub throw_exception {
my $self = shift;
- if (defined $self->schema) {
+ if (defined $self->schema) {
$self->schema->throw_exception(@_);
} else {
croak(@_);