Browse Source

v.to.db: Require --overwrite flag to overwrite existing columns (#487)

This is a very straightforward fix. It updates the manual and implements the overwrite flag as discussed before. I took the liberty of merging it.
Huidae Cho 5 years ago
parent
commit
8cc43e30dd
2 changed files with 10 additions and 7 deletions
  1. 6 2
      vector/v.to.db/main.c
  2. 4 5
      vector/v.to.db/v.to.db.html

+ 6 - 2
vector/v.to.db/main.c

@@ -206,8 +206,12 @@ int main(int argc, char *argv[])
 			}
 		    }
 
-		    G_warning(_("Values in column <%s> will be overwritten"),
-			      options.col[col]);
+		    if (G_get_overwrite())
+			G_warning(_("Values in column <%s> will be overwritten"),
+				  options.col[col]);
+		    else
+			G_fatal_error(_("Column <%s> exists. To overwrite, use the --overwrite flag"),
+				      options.col[col]);
 
 		    break;
 		}

+ 4 - 5
vector/v.to.db/v.to.db.html

@@ -36,11 +36,10 @@ a given input vector <em>layer</em>. The <b>print only</b> (<b>-p</b>) mode
 doesn't require a table. Use <em><a href="db.execute.html">db.execute</a></em>
 or <em><a href="v.db.addtable.html">v.db.addtable</a></em> to create a table if
 needed.
-<p>Updating the table has to be done column-wise. The <em>column</em> must be
-present in the table, except when using the <b>print only</b> (<b>-p</b>)
-mode. Use <em><a href="db.execute.html">db.execute</a></em> or
-<em><a href="v.db.addcolumn.html">v.db.addcolumn</a></em> to add new columns if
-needed.
+<p>Updating the table has to be done column-wise. The <em>column</em> will be
+created in the table if it doesn't already exist, except when using the
+<b>print only</b> (<b>-p</b>) mode. If the <em>column</em> exists, the
+<b>--overwrite</b> flag is required to overwrite it.
 
 <h2>EXAMPLES</h2>