[QGIS Commit] r8292 - trunk/qgis/src/providers/postgres
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Mar 28 07:02:05 EDT 2008
Author: jef
Date: 2008-03-28 07:02:05 -0400 (Fri, 28 Mar 2008)
New Revision: 8292
Modified:
trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
Log:
yet another postgres provider update
- apply patch #1009 from Steven Mizuno. Thanks.
- remove column name and use of PQfnumber for cursors
Modified: trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
===================================================================
--- trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp 2008-03-28 10:55:27 UTC (rev 8291)
+++ trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp 2008-03-28 11:02:05 UTC (rev 8292)
@@ -379,7 +379,7 @@
if(fetchGeometry)
{
- declare += QString(",asbinary(%1,'%2') as qgs_feature_geometry")
+ declare += QString(",asbinary(%1,'%2')")
.arg( quotedIdentifier(geometryColumn) )
.arg( endianString() );
}
@@ -393,22 +393,21 @@
continue;
const QString &type = fld.typeName();
- if( type == "money" || type.startsWith("_") )
+ if( type == "money" )
{
- // money and arrays don't support cast to text, but return text
- // TODO: check other types
- declare += "," + quotedIdentifier( fieldname );
+ declare += QString(",cash_out(%1)").arg( quotedIdentifier(fieldname) );
}
+ else if( type.startsWith("_") )
+ {
+ declare += QString(",array_out(%1)").arg( quotedIdentifier(fieldname) );
+ }
else if( type == "bool" )
{
- // bool doesn't support cast to text either and even doesn't return text.
- // (even text() doesn't work with binary cursors)
- declare += QString(",CASE WHEN %1 THEN 't' WHEN NOT %1 THEN 'f' ELSE NULL END AS %1")
- .arg( quotedIdentifier(fieldname) );
+ declare += QString(",boolout(%1)").arg( quotedIdentifier(fieldname) );
}
else
{
- declare += "," + quotedIdentifier( fieldname ) + "::text";
+ declare += "," + quotedIdentifier(fieldname) + "::text";
}
}
@@ -439,7 +438,7 @@
feature.setFeatureId(oid);
- int col; // first attribute column
+ int col; // first attribute column after geometry
if (fetchGeometry)
{
@@ -448,7 +447,7 @@
{
unsigned char *featureGeom = new unsigned char[returnedLength + 1];
memset(featureGeom, '\0', returnedLength + 1);
- memcpy(featureGeom, PQgetvalue(queryResult, row, PQfnumber(queryResult,QString("qgs_feature_geometry").toUtf8())), returnedLength);
+ memcpy(featureGeom, PQgetvalue(queryResult, row, 1), returnedLength);
feature.setGeometryAndOwnership(featureGeom, returnedLength + 1);
}
else
More information about the QGIS-commit
mailing list