[Jifty-commit] jifty-dbi branch, master, updated. 0.64-9-ga908e1d
Jifty commits
jifty-commit at lists.jifty.org
Thu Feb 10 10:29:03 EST 2011
The branch, master has been updated
via a908e1d35b508f48018d22ed3a9341bb2d3aaf44 (commit)
from 57079cda5d620a7592e423ac369fc507ed8da495 (commit)
Summary of changes:
lib/Jifty/DBI/Record.pm | 22 ++++++----------------
t/10schema.t | 8 +++++++-
2 files changed, 13 insertions(+), 17 deletions(-)
- Log -----------------------------------------------------------------
commit a908e1d35b508f48018d22ed3a9341bb2d3aaf44
Author: Thomas Sibley <trs at bestpractical.com>
Date: Thu Feb 10 10:23:27 2011 -0500
Refactor columns to use all_columns and update all_columns
Avoid code divergence between the two since columns is always a subset
of all_columns.
Add some basic tests to make sure that columns respects since and till
and that all_columns doesn't.
diff --git a/lib/Jifty/DBI/Record.pm b/lib/Jifty/DBI/Record.pm
index 91bbf2a..22e8404 100755
--- a/lib/Jifty/DBI/Record.pm
+++ b/lib/Jifty/DBI/Record.pm
@@ -573,18 +573,9 @@ sub columns {
my $self = shift;
return @{
$self->_COLUMNS_CACHE() || $self->_COLUMNS_CACHE(
- [ sort {
- ( ( ( $b->type || '' ) eq 'serial' )
- <=> ( ( $a->type || '' ) eq 'serial' ) )
- or (
- ( $a->sort_order || 0 ) <=> ( $b->sort_order || 0 ) )
- or ( $a->name cmp $b->name )
- } grep {
- $_->active
- } values %{ $self->_columns_hashref }
- ]
+ [ grep { $_->active } $self->all_columns ]
)
- };
+ };
}
=head2 all_columns
@@ -600,11 +591,10 @@ sub all_columns {
# Not cached because it's not expected to be used often
return sort {
- ( ( ( $b->type || '' ) eq 'serial' )
- <=> ( ( $a->type || '' ) eq 'serial' ) )
- or ( ( $a->sort_order || 0 ) <=> ( $b->sort_order || 0 ) )
- or ( $a->name cmp $b->name )
- } values %{ $self->_columns_hashref || {} };
+ ((($b->type || '') eq 'serial') <=> (($a->type || '') eq 'serial'))
+ or (($a->sort_order || 0) <=> ($b->sort_order || 0))
+ or ( $a->name cmp $b->name )
+ } values %{ $self->_columns_hashref }
}
sub _columns_hashref {
diff --git a/t/10schema.t b/t/10schema.t
index 0a01e9e..eb5efaf 100644
--- a/t/10schema.t
+++ b/t/10schema.t
@@ -5,7 +5,7 @@ use warnings;
use Test::More;
use version;
-use constant TESTS_PER_DRIVER => 77;
+use constant TESTS_PER_DRIVER => 87;
our @available_drivers;
BEGIN {
@@ -111,6 +111,7 @@ foreach my $d ( @available_drivers ) {
for my $version (qw/ 0.2.0 0.2.4 0.2.6 0.2.8 0.2.9 /) {
+ Sample::Address->_COLUMNS_CACHE(undef);
Sample::Address->schema_version($version);
my $SG = Jifty::DBI::SchemaGenerator->new($handle, $version);
@@ -132,6 +133,11 @@ foreach my $d ( @available_drivers ) {
ok(!Sample::Address->COLUMNS->{street}->active, 'street not active');
}
+ # employee_id shows up twice when we map over name because employee
+ # is automagically injected as an aliased column
+ is_deeply([map { $_->name } Sample::Address->all_columns], [qw(id employee_id employee_id name phone street)], "got all columns");
+ is_deeply([map { $_->name } Sample::Address->columns], [qw(id employee_id employee_id name phone), ($street_added ? qw(street) : ())], "got all active columns");
+
my $address_version_schema = $street_added ? "${address_schema}_024"
: $address_schema;
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list