From 73a63cfdfdc7ea6db01572d5f76f1e0e7a16e37f Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 10 Nov 2009 23:35:07 -0500 Subject: [PATCH] Removed rows length checks in two places, and replaced them with first-column-not-None checks. Removed an unnecessary conditional from get_block_geometry_as_wkt(). --- src/Census.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Census.py b/src/Census.py index 63f69aa..0f8d234 100644 --- a/src/Census.py +++ b/src/Census.py @@ -46,11 +46,12 @@ class Database: cursor.execute(query, sql_params) rows = cursor.fetchall() cursor.close() - - if len(rows) > 0: + + # SQL queries that return no results get returned as [[None]]. + if rows[0][0] != None: return rows[0][0] else: - return None + return 0 def find_contained_population(self, well_known_text): @@ -112,10 +113,11 @@ class Database: rows = cursor.fetchall() cursor.close() - if (len(rows) > 0): + # SQL queries that return no results get returned as [[None]]. + if rows[0][0] != None: return rows[0][0] else: - return None + return 0 @@ -137,8 +139,7 @@ class Database: rows = cursor.fetchall() cursor.close() - if len(rows) > 0: - return rows[0][0] - else: - return None + # Just pass on the None if that's what we got from the + # database. + return rows[0][0] -- 2.44.2