[Jifty-commit] r7437 - Jifty-DBI/trunk/lib/Jifty/DBI
Jifty commits
jifty-commit at lists.jifty.org
Tue Aug 25 02:32:15 EDT 2009
Author: sartak
Date: Tue Aug 25 02:32:14 2009
New Revision: 7437
Modified:
Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
Log:
Primary keys come before nonprimary keys in readable_attributes
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm Tue Aug 25 02:32:14 2009
@@ -604,17 +604,26 @@
=head2 readable_attributes
-Returns a list this table's readable columns
+Returns the list of this table's readable columns. They are first sorted so
+that primary keys come first, and then they are sorted in alphabetical order.
=cut
sub readable_attributes {
my $self = shift;
- return @{
- $self->_READABLE_COLS_CACHE() || $self->_READABLE_COLS_CACHE(
- [ sort map { $_->name } grep { $_->readable } $self->columns ]
- )
- };
+
+ my %is_primary = map { $_ => 1 } @{ $self->_primary_keys };
+
+ return @{ $self->_READABLE_COLS_CACHE() || $self->_READABLE_COLS_CACHE([
+ map { $_->name }
+ sort {
+ ($is_primary{$b->name} <=> $is_primary{$a->name})
+ ||
+ ($a->name cmp $b->name)
+ }
+ grep { $_->readable }
+ $self->columns
+ ])};
}
=head2 serialize_metadata
More information about the Jifty-commit
mailing list