[GRASS-SVN] r60596 - grass/trunk/vector/v.in.ogr

svn_grass at osgeo.org svn_grass at osgeo.org
Thu May 29 21:46:55 PDT 2014


Author: hcho
Date: 2014-05-29 21:46:55 -0700 (Thu, 29 May 2014)
New Revision: 60596

Modified:
   grass/trunk/vector/v.in.ogr/main.c
Log:
v.in.ogr: fallback datetime type for pg and dbf drivers

Modified: grass/trunk/vector/v.in.ogr/main.c
===================================================================
--- grass/trunk/vector/v.in.ogr/main.c	2014-05-30 04:01:53 UTC (rev 60595)
+++ grass/trunk/vector/v.in.ogr/main.c	2014-05-30 04:46:55 UTC (rev 60596)
@@ -103,6 +103,8 @@
     int OFTIntegerListlength;
 
     char *dsn;
+    const char *driver_name;
+    char *datetime_type;
     char *output;
     char **layer_names;		/* names of layers to be imported */
     int *layers;		/* layer indexes */
@@ -336,9 +338,18 @@
 	G_fatal_error(_("Required parameter <%s> not set"), param.dsn->key);
     }
 
+    driver_name = db_get_default_driver_name();
+
+    if (strcmp(driver_name, "pg") == 0)
+	datetime_type = G_store("timestamp with time zone");
+    else if (strcmp(driver_name, "dbf") == 0)
+	datetime_type = G_store("varchar(22)");
+    else
+	datetime_type = G_store("datetime");
+
     /* dsn is 'PG:', check default connection settings */
     dsn = NULL;
-    if (strcmp(db_get_default_driver_name(), "pg") == 0 &&
+    if (strcmp(driver_name, "pg") == 0 &&
         G_strcasecmp(param.dsn->answer, "PG:") == 0) {
         const char *dbname;
         dbConnection conn;
@@ -1010,7 +1021,7 @@
 		    sprintf(buf, ", %s time", Ogr_fieldname);
 		}
 		else if (Ogr_ftype == OFTDateTime) {
-		    sprintf(buf, ", %s datetime", Ogr_fieldname);
+		    sprintf(buf, ", %s %s", Ogr_fieldname, datetime_type);
 #endif
 		}
 		else if (Ogr_ftype == OFTString) {



More information about the grass-commit mailing list