[Rt-commit] r3577 - in DBIx-SearchBuilder/trunk: . SearchBuilder
alexmv at bestpractical.com
alexmv at bestpractical.com
Tue Aug 2 01:46:15 EDT 2005
Author: alexmv
Date: Tue Aug 2 01:46:15 2005
New Revision: 3577
Modified:
DBIx-SearchBuilder/trunk/ (props changed)
DBIx-SearchBuilder/trunk/SearchBuilder.pm
DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm
Log:
r5571 at zoq-fot-pik: chmrr | 2005-08-02 01:45:37 -0400
* ->foo_id now returns just a number if it is a reference; ->foo
returns the object.
* POD fixes
Modified: DBIx-SearchBuilder/trunk/SearchBuilder.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder.pm (original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder.pm Tue Aug 2 01:46:15 2005
@@ -58,7 +58,7 @@
are doing.
=head1 METHOD NAMING
-
+
Each method has a lower case alias; '_' is used to separate words.
For example, the method C<RedoSearch> has the alias C<redo_search>.
@@ -168,8 +168,6 @@
return ( $self->{'DBIxHandle'} );
}
-
-
=head2 _DoSearch
This internal private method actually executes the search on the database;
@@ -281,7 +279,6 @@
This routine takes a reference to a scalar containing an SQL statement.
It massages the statement to ensure a distinct result set is returned.
-
=cut
sub _DistinctQuery {
@@ -298,8 +295,6 @@
}
}
-
-
=head2 _BuildJoins
Build up all of the joins we need to perform this query.
@@ -1501,7 +1496,7 @@
=head2 Fields TABLE
-
+
Return a list of fields in TABLE, lowercased.
TODO: Why are they lowercased?
Modified: DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm (original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm Tue Aug 2 01:46:15 2005
@@ -336,7 +336,7 @@
ever else I think of.
=head1 METHOD NAMING
-
+
Each method has a lower case alias; '_' is used to separate words.
For example, the method C<_PrimaryKeys> has the alias C<_primary_keys>.
@@ -593,7 +593,12 @@
$accessible->{$field} = { 'read' => 1, 'write' => 1 };
} elsif (my $refclass = $schema->{$field}{'REFERENCES'}) {
if (UNIVERSAL::isa($refclass, 'DBIx::SearchBuilder::Record')) {
- $accessible->{$field} = { 'record-read' => 1, 'record-write' => 1 };
+ if ($field =~ /(.*)_id$/) {
+ $accessible->{$field} = { 'read' => 1, 'write' => 1 };
+ $accessible->{$1} = { 'record-read' => 1, 'column' => $field };
+ } else {
+ $accessible->{$field} = { 'record-read' => 1, 'record-write' => 1 };
+ }
} elsif (UNIVERSAL::isa($refclass, 'DBIx::SearchBuilder')) {
$accessible->{$field} = { 'foreign-collection' => 1 };
} else {
@@ -614,8 +619,10 @@
return unless defined $value;
my $schema = $self->Schema;
- my $description = $schema->{$field};
+ my $description = $schema->{$field} || $schema->{$field . "_id"};
+ die "Can't get schema for $field on $self" unless $description;
+
return unless $description;
return $value unless $description->{'REFERENCES'};
@@ -696,6 +703,8 @@
my $self = shift;
my $field = lc shift;
+ $field = $self->_Accessible($field, "column") while defined $self->_Accessible($field, "column");
+
if (!$self->{'fetched'}{$field} and my $id = $self->id() ) {
my $pkey = $self->_PrimaryKey();
my $QueryString = "SELECT $field FROM " . $self->Table . " WHERE $pkey = ?";
More information about the Rt-commit
mailing list