Changeset 299
- Timestamp:
- 05/18/06 18:19:44 (6 years ago)
- Location:
- wiki-toolkit/trunk
- Files:
-
- 2 modified
-
lib/Wiki/Toolkit/Store/Database.pm (modified) (2 diffs)
-
t/025_list_node_all_versions.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wiki-toolkit/trunk/lib/Wiki/Toolkit/Store/Database.pm
r298 r299 1464 1464 $sth->execute( $node_id ); 1465 1465 1466 # Need to hold onto the last row by hash ref, so we don't trash 1467 # it every time 1468 my %first_data; 1469 my $dataref = \%first_data; 1470 1466 1471 # Haul out the data 1467 1472 my @versions; 1468 1473 while(my @results = $sth->fetchrow_array) { 1469 # TODO: Support metadata multi-rows 1470 my %data; 1474 my %data = %$dataref; 1475 1476 # Is it the same version as last time? 1477 if(%data && $data{'version'} != $results[2]) { 1478 # New version 1479 push @versions, $dataref; 1480 %data = (); 1481 } else { 1482 # Same version as last time, must be more metadata 1483 } 1484 1485 # Grab the core data (will be the same on multi-row for metadata) 1471 1486 @data{ qw( node_id name version last_modified ) } = @results; 1472 1487 … … 1477 1492 } 1478 1493 if($with_metadata) { 1479 warn("Not supported properly yet"); 1494 my ($m_type,$m_value) = @results[$i,($i+1)]; 1495 $data{'metadata'}->{$m_type} = $m_value; 1480 1496 } 1481 1497 1482 push @versions, \%data; 1498 # Save where we've got to 1499 $dataref = \%data; 1500 } 1501 1502 # Handle final row saving 1503 if($dataref) { 1504 push @versions, $dataref; 1483 1505 } 1484 1506 -
wiki-toolkit/trunk/t/025_list_node_all_versions.t
r298 r299 6 6 plan skip_all => "no backends configured"; 7 7 } else { 8 plan tests => ( 9* scalar @Wiki::Toolkit::TestLib::wiki_info );8 plan tests => ( 22 * scalar @Wiki::Toolkit::TestLib::wiki_info ); 9 9 } 10 10 … … 45 45 46 46 # Fetch with content too 47 @all_versions = $wiki->list_node_all_versions( 48 name => "Cheese", 49 with_content => 1 50 ); 51 52 is( scalar @all_versions, 4, "list_node_all_versions gives the right number back" ); 53 54 # Check them 55 is( $all_versions[0]->{'version'}, 4, "right ordering" ); 56 is( $all_versions[1]->{'version'}, 3, "right ordering" ); 57 is( $all_versions[2]->{'version'}, 2, "right ordering" ); 58 is( $all_versions[3]->{'version'}, 1, "right ordering" ); 59 is( $all_versions[0]->{'name'}, "Cheese", "right node" ); 60 is( $all_versions[1]->{'name'}, "Cheese", "right node" ); 61 is( $all_versions[2]->{'name'}, "Cheese", "right node" ); 62 is( $all_versions[3]->{'name'}, "Cheese", "right node" ); 63 is( $all_versions[0]->{'content'}, "Content v4", "right node" ); 64 is( $all_versions[1]->{'content'}, "Content v3", "right node" ); 65 is( $all_versions[2]->{'content'}, "Content v2", "right node" ); 66 is( $all_versions[3]->{'content'}, "content", "right node" ); 47 67 48 68 # With metadata
