[GRASS-SVN] r58022 - grass/trunk/vector/v.reclass

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Oct 17 00:16:07 PDT 2013


Author: hcho
Date: 2013-10-17 00:16:07 -0700 (Thu, 17 Oct 2013)
New Revision: 58022

Modified:
   grass/trunk/vector/v.reclass/main.c
Log:
Consistent NULL handling across different db drivers.  For example, Postgres
sorts and returns NULLs at the bottom and v.reclass skipped those values in the
new attribute table.  SQLite returns NULLs at the top and v.reclass created an
empty string for the new category column.  As a result, the pg driver created
one less row in the table than the sqlite driver did.  With this fix, the pg
driver handles NULLs as an empty string and creates the same table as sqlite.



Modified: grass/trunk/vector/v.reclass/main.c
===================================================================
--- grass/trunk/vector/v.reclass/main.c	2013-10-16 23:31:40 UTC (rev 58021)
+++ grass/trunk/vector/v.reclass/main.c	2013-10-17 07:16:07 UTC (rev 58022)
@@ -254,9 +254,11 @@
 		column = db_get_table_column(table, 1);
 		value = db_get_column_value(column);
 
-		if (i == 0 || (!db_test_value_isnull(value) &&
-		    strcmp(db_get_value_string(value),
-			   db_get_string(&lastval)) != 0)) {
+		if (db_test_value_isnull(value))
+		    db_set_value_string(value, "");
+
+		if (i == 0 || strcmp(db_get_value_string(value),
+					db_get_string(&lastval)) != 0) {
 		    newval++;
 		    db_set_string(&lastval, db_get_value_string(value));
 		    G_debug(3, "  newval = %d string = %s", newval,



More information about the grass-commit mailing list