Skip to content

Commit a0c1772

Browse files
author
jef
committedMar 28, 2008
yet another postgres provider update
- apply patch #1009 from Steven Mizuno. Thanks. - remove column name and use of PQfnumber for cursors git-svn-id: http://svn.osgeo.org/qgis/trunk@8292 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 317ec56 commit a0c1772

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed
 

‎src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ bool QgsPostgresProvider::declareCursor(const QString &cursorName,
379379

380380
if(fetchGeometry)
381381
{
382-
declare += QString(",asbinary(%1,'%2') as qgs_feature_geometry")
382+
declare += QString(",asbinary(%1,'%2')")
383383
.arg( quotedIdentifier(geometryColumn) )
384384
.arg( endianString() );
385385
}
@@ -393,22 +393,21 @@ bool QgsPostgresProvider::declareCursor(const QString &cursorName,
393393
continue;
394394

395395
const QString &type = fld.typeName();
396-
if( type == "money" || type.startsWith("_") )
396+
if( type == "money" )
397397
{
398-
// money and arrays don't support cast to text, but return text
399-
// TODO: check other types
400-
declare += "," + quotedIdentifier( fieldname );
398+
declare += QString(",cash_out(%1)").arg( quotedIdentifier(fieldname) );
399+
}
400+
else if( type.startsWith("_") )
401+
{
402+
declare += QString(",array_out(%1)").arg( quotedIdentifier(fieldname) );
401403
}
402404
else if( type == "bool" )
403405
{
404-
// bool doesn't support cast to text either and even doesn't return text.
405-
// (even text() doesn't work with binary cursors)
406-
declare += QString(",CASE WHEN %1 THEN 't' WHEN NOT %1 THEN 'f' ELSE NULL END AS %1")
407-
.arg( quotedIdentifier(fieldname) );
406+
declare += QString(",boolout(%1)").arg( quotedIdentifier(fieldname) );
408407
}
409408
else
410409
{
411-
declare += "," + quotedIdentifier( fieldname ) + "::text";
410+
declare += "," + quotedIdentifier(fieldname) + "::text";
412411
}
413412
}
414413

@@ -439,7 +438,7 @@ bool QgsPostgresProvider::getFeature(PGresult *queryResult, int row, bool fetchG
439438

440439
feature.setFeatureId(oid);
441440

442-
int col; // first attribute column
441+
int col; // first attribute column after geometry
443442

444443
if (fetchGeometry)
445444
{
@@ -448,7 +447,7 @@ bool QgsPostgresProvider::getFeature(PGresult *queryResult, int row, bool fetchG
448447
{
449448
unsigned char *featureGeom = new unsigned char[returnedLength + 1];
450449
memset(featureGeom, '\0', returnedLength + 1);
451-
memcpy(featureGeom, PQgetvalue(queryResult, row, PQfnumber(queryResult,QString("qgs_feature_geometry").toUtf8())), returnedLength);
450+
memcpy(featureGeom, PQgetvalue(queryResult, row, 1), returnedLength);
452451
feature.setGeometryAndOwnership(featureGeom, returnedLength + 1);
453452
}
454453
else

0 commit comments

Comments
 (0)
Please sign in to comment.