Преглед изворни кода

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.



git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58022 15284696-431f-4ddb-bdfa-cd5b030d7da7

Huidae Cho пре 11 година
родитељ
комит
58dbe5e6fc
1 измењених фајлова са 5 додато и 3 уклоњено
  1. 5 3
      vector/v.reclass/main.c

+ 5 - 3
vector/v.reclass/main.c

@@ -254,9 +254,11 @@ int main(int argc, char *argv[])
 		column = db_get_table_column(table, 1);
 		column = db_get_table_column(table, 1);
 		value = db_get_column_value(column);
 		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++;
 		    newval++;
 		    db_set_string(&lastval, db_get_value_string(value));
 		    db_set_string(&lastval, db_get_value_string(value));
 		    G_debug(3, "  newval = %d string = %s", newval,
 		    G_debug(3, "  newval = %d string = %s", newval,