From a30a19c25b84277581924b6a905bcb86b6ce3072 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 28 Sep 2016 20:01:31 -0500 Subject: [PATCH] Always warn if duplicate keys detected when caching a data model --- rattail/db/cache.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rattail/db/cache.py b/rattail/db/cache.py index 96e8e3b3..aa447a60 100644 --- a/rattail/db/cache.py +++ b/rattail/db/cache.py @@ -89,11 +89,12 @@ class ModelCacher(object): if prog: prog.destroy() - if self.omit_duplicates and self.duplicate_keys: - log.info("will prune {} duplicated keys from cache".format(len(self.duplicate_keys))) - for key in self.duplicate_keys: - log.debug("removing duplicated key from cache: {}".format(repr(key))) - del self.instances[key] + if self.duplicate_keys: + log.warning("found {} duplicated keys in cache".format(len(self.duplicate_keys))) + if self.omit_duplicates: + for key in self.duplicate_keys: + log.debug("removing duplicated key from cache: {}".format(repr(key))) + del self.instances[key] return self.instances