use left join on optional values, otherwise we lose a lot of _ports entries.

This commit is contained in:
espie 2009-08-25 09:15:43 +00:00
parent 7e35a4570c
commit 768004e514
2 changed files with 12 additions and 6 deletions

View File

@ -1,7 +1,7 @@
# $OpenBSD: Makefile,v 1.17 2009/08/15 12:43:58 espie Exp $
# $OpenBSD: Makefile,v 1.18 2009/08/25 09:15:43 espie Exp $
CATEGORIES = databases
V = 1.5
V = 1.6
DISTNAME = sqlports-$V
DISTFILES =
COMMENT = sqlite database of ports

View File

@ -1,5 +1,5 @@
#! /usr/bin/perl
# $OpenBSD: mksqlitedb,v 1.16 2009/08/16 03:24:28 espie Exp $
# $OpenBSD: mksqlitedb,v 1.17 2009/08/25 09:15:43 espie Exp $
#
# Copyright (c) 2006 Marc Espie <espie@openbsd.org>
#
@ -142,7 +142,7 @@ sub render
sub render_join
{
my ($self, $table) = @_;
return " JOIN Paths ".$self->{table}." ON ".$self->table.".ID=$table.".$self->name;
return "JOIN Paths ".$self->{table}." ON ".$self->table.".ID=$table.".$self->name;
}
package ValueColumn;
@ -179,7 +179,7 @@ sub render_join
{
my ($self, $table) = @_;
if (defined $self->k) {
return " JOIN ".$self->k." ".$self->table." ON ".$self->table.".KEYREF=$table.".$self->name;
return "JOIN ".$self->k." ".$self->table." ON ".$self->table.".KEYREF=$table.".$self->name;
}
}
@ -192,6 +192,12 @@ sub render
return $inserter->optvalue($self->k, $self->name);
}
sub render_join
{
my ($self, $table) = @_;
return "LEFT ".$self->SUPER::render_join($table);
}
package AbstractInserter;
# this is the object to use to put stuff into the db...
sub new
@ -376,7 +382,7 @@ sub create_view
my $name = "_$table";
my @l = map {$_->render_view($table) } @columns;
my @j = map {$_->render_join($table)} @columns;
my $v = "CREATE VIEW $name AS SELECT ".join(", ", @l). " FROM ".$table.join('', @j);
my $v = "CREATE VIEW $name AS SELECT ".join(", ", @l). " FROM ".$table.join(' ', @j);
$self->db->do("DROP VIEW IF EXISTS $name");
print "$v\n" if $main::opt_v;
$self->db->do($v);