@@ -379,7 +379,7 @@ bool QgsPostgresProvider::declareCursor(const QString &cursorName,
379
379
380
380
if (fetchGeometry)
381
381
{
382
- declare += QString (" ,asbinary(%1,'%2') as qgs_feature_geometry " )
382
+ declare += QString (" ,asbinary(%1,'%2')" )
383
383
.arg ( quotedIdentifier (geometryColumn) )
384
384
.arg ( endianString () );
385
385
}
@@ -393,22 +393,21 @@ bool QgsPostgresProvider::declareCursor(const QString &cursorName,
393
393
continue ;
394
394
395
395
const QString &type = fld.typeName ();
396
- if ( type == " money" || type. startsWith ( " _ " ) )
396
+ if ( type == " money" )
397
397
{
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) );
401
403
}
402
404
else if ( type == " bool" )
403
405
{
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) );
408
407
}
409
408
else
410
409
{
411
- declare += " ," + quotedIdentifier ( fieldname ) + " ::text" ;
410
+ declare += " ," + quotedIdentifier (fieldname) + " ::text" ;
412
411
}
413
412
}
414
413
@@ -439,7 +438,7 @@ bool QgsPostgresProvider::getFeature(PGresult *queryResult, int row, bool fetchG
439
438
440
439
feature.setFeatureId (oid);
441
440
442
- int col; // first attribute column
441
+ int col; // first attribute column after geometry
443
442
444
443
if (fetchGeometry)
445
444
{
@@ -448,7 +447,7 @@ bool QgsPostgresProvider::getFeature(PGresult *queryResult, int row, bool fetchG
448
447
{
449
448
unsigned char *featureGeom = new unsigned char [returnedLength + 1 ];
450
449
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);
452
451
feature.setGeometryAndOwnership (featureGeom, returnedLength + 1 );
453
452
}
454
453
else
0 commit comments