]> gitweb.michael.orlitzky.com - dead/census-tools.git/commitdiff
Removed rows length checks in two places, and replaced them with first-column-not...
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 11 Nov 2009 04:35:07 +0000 (23:35 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 11 Nov 2009 04:35:07 +0000 (23:35 -0500)
Removed an unnecessary conditional from get_block_geometry_as_wkt().

src/Census.py

index 63f69aaccaadf355b7d1b82414841e1d2839111b..0f8d23473144d38602e3094797de3f44cd9b05fb 100644 (file)
@@ -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]