From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id AC69E138010 for ; Tue, 18 Sep 2012 19:02:47 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EB85C21C098; Tue, 18 Sep 2012 19:02:19 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id BE9ED21C098 for ; Tue, 18 Sep 2012 19:02:19 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2AAB333D3E0 for ; Tue, 18 Sep 2012 19:02:19 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id F04C1E5444 for ; Tue, 18 Sep 2012 19:02:16 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1347994919.8279b1e6626e634b4e8f5175180cf17cf09d5b8a.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/cache/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/cache/sqlite.py X-VCS-Directories: pym/portage/cache/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 8279b1e6626e634b4e8f5175180cf17cf09d5b8a X-VCS-Branch: master Date: Tue, 18 Sep 2012 19:02:16 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: af83a23f-d323-4818-8a0c-7ee218634114 X-Archives-Hash: 6189a4fefd9fdf1d4f666623424d7502 commit: 8279b1e6626e634b4e8f5175180cf17cf09d5b8a Author: Zac Medico gentoo org> AuthorDate: Tue Sep 18 19:01:59 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue Sep 18 19:01:59 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8279b1e6 cache/sqlite.py: fix getitem order assumption The order assumption was incorrect when new columns were added, since they could be added in any order. --- pym/portage/cache/sqlite.py | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-) diff --git a/pym/portage/cache/sqlite.py b/pym/portage/cache/sqlite.py index a6a3e06..1038bb2 100644 --- a/pym/portage/cache/sqlite.py +++ b/pym/portage/cache/sqlite.py @@ -29,6 +29,7 @@ class database(fs_template.FsBased): self._allowed_keys = ["_mtime_", "_eclasses_"] self._allowed_keys.extend(self._known_keys) self._allowed_keys.sort() + self._allowed_keys_set = frozenset(self._allowed_keys) self.location = os.path.join(self.location, self.label.lstrip(os.path.sep).rstrip(os.path.sep)) @@ -93,9 +94,6 @@ class database(fs_template.FsBased): self._db_table["packages"]["table_name"] = mytable self._db_table["packages"]["package_id"] = "internal_db_package_id" self._db_table["packages"]["package_key"] = "portage_package_key" - self._db_table["packages"]["internal_columns"] = \ - [self._db_table["packages"]["package_id"], - self._db_table["packages"]["package_key"]] create_statement = [] create_statement.append("CREATE TABLE") create_statement.append(mytable) @@ -110,9 +108,6 @@ class database(fs_template.FsBased): create_statement.append(")") self._db_table["packages"]["create"] = " ".join(create_statement) - self._db_table["packages"]["columns"] = \ - self._db_table["packages"]["internal_columns"] + \ - self._allowed_keys cursor = self._db_cursor for k, v in self._db_table.items(): @@ -212,11 +207,10 @@ class database(fs_template.FsBased): else: raise cache_errors.CacheCorruption(cpv, "key is not unique") d = {} - internal_columns = self._db_table["packages"]["internal_columns"] - column_index = -1 - for k in self._db_table["packages"]["columns"]: - column_index +=1 - if k not in internal_columns: + allowed_keys_set = self._allowed_keys_set + for column_index, column_info in enumerate(cursor.description): + k = column_info[0] + if k in allowed_keys_set: d[k] = result[0][column_index] return d