[QGIS Commit] r13359 - trunk/qgis/src/plugins/spit
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Apr 24 04:28:08 EDT 2010
Author: jef
Date: 2010-04-24 04:28:07 -0400 (Sat, 24 Apr 2010)
New Revision: 13359
Modified:
trunk/qgis/src/plugins/spit/qgsshapefile.cpp
Log:
implement #2676
Modified: trunk/qgis/src/plugins/spit/qgsshapefile.cpp
===================================================================
--- trunk/qgis/src/plugins/spit/qgsshapefile.cpp 2010-04-24 03:44:26 UTC (rev 13358)
+++ trunk/qgis/src/plugins/spit/qgsshapefile.cpp 2010-04-24 08:28:07 UTC (rev 13359)
@@ -291,7 +291,7 @@
import_canceled = false;
bool result = true;
- QString query = QString( "CREATE TABLE %1.%2(%3 int4 PRIMARY KEY" )
+ QString query = QString( "CREATE TABLE %1.%2(%3 SERIAL PRIMARY KEY" )
.arg( QgsPgUtil::quotedIdentifier( schema ) )
.arg( QgsPgUtil::quotedIdentifier( table_name ) )
.arg( QgsPgUtil::quotedIdentifier( primary_key ) );
@@ -397,10 +397,10 @@
OGRGeometryH geom = OGR_F_GetGeometryRef( feat );
if ( geom )
{
- query = QString( "INSERT INTO %1.%2 VALUES(%3" )
+ query = QString( "INSERT INTO %1.%2(" )
.arg( QgsPgUtil::quotedIdentifier( schema ) )
- .arg( QgsPgUtil::quotedIdentifier( table_name ) )
- .arg( m );
+ .arg( QgsPgUtil::quotedIdentifier( table_name ) );
+ QString values = " VALUES (";
char *geo_temp;
// 'GeometryFromText' supports only 2D coordinates
@@ -426,12 +426,21 @@
else
val = QgsPgUtil::quotedValue( val );
- query += "," + val;
+ if ( n > 0 )
+ {
+ query += ",";
+ values += ",";
+ }
+ query += QgsPgUtil::quotedIdentifier( column_names[n] );
+ values += val;
}
- query += QString( ",GeometryFromText(%1,%2))" )
- .arg( QgsPgUtil::quotedValue( geometry ) )
- .arg( srid );
+ query += "," + QgsPgUtil::quotedIdentifier( geom_col );
+ values += QString( ",GeometryFromText(%1,%2)" )
+ .arg( QgsPgUtil::quotedValue( geometry ) )
+ .arg( srid );
+ query += ")" + values + ")";
+
if ( result )
res = PQexec( conn, query.toUtf8() );
More information about the QGIS-commit
mailing list