From 1477a267ff1174dfc2ee7ae6eb2e9cef9655dd39 Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Sat, 30 Aug 2008 21:24:52 +0200 Subject: [PATCH] Handle deleted items correctly in export Need to do it in perl, SQL seems to be too weak to do this efectively --- scripts/export.pl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/export.pl b/scripts/export.pl index f8261b3..84e2aab 100755 --- a/scripts/export.pl +++ b/scripts/export.pl @@ -9,11 +9,18 @@ use PciIds::Db; use PciIds::DBQAny; my $db = PciIds::DBQAny::new( connectDb(), { - 'list' => 'SELECT id, name, note FROM locations WHERE name IS NOT NULL ORDER BY id' + 'list' => 'SELECT id, name, note FROM locations WHERE id like "PC/%" OR id like "PD/%" ORDER BY id' } ); +my $lastInvalid = undef; + foreach( @{$db->query( 'list', [] )} ) { my( $id, $name, $description ) = @{$_}; + next if defined $lastInvalid and substr( $id, 0, length $lastInvalid ) eq $lastInvalid; + if( !defined $name || $name eq '' ) { + $lastInvalid = $id; + next; + } $_ = $id; my $prefix = ( /^PD\/..$/ ) ? 'C ' : ''; s/^P.\///; -- 2.39.5