Skip to content

Commit 6114f06

Browse files
author
wonder
committed
Fix for creation of SQL query in postgres provider.
Was doing problems when exporting to shapefile (see #706) git-svn-id: http://svn.osgeo.org/qgis/trunk@6890 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent cc862d4 commit 6114f06

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/providers/postgres/qgspostgresprovider.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ void QgsPostgresProvider::select(QgsAttributeList fetchAttributes,
488488

489489
QgsDebugMsg("Binary cursor: " + declare);
490490

491+
bool hasWhere = FALSE;
492+
491493
if(!rect.isEmpty())
492494
{
493495
if(useIntersect)
@@ -513,11 +515,17 @@ void QgsPostgresProvider::select(QgsAttributeList fetchAttributes,
513515
declare += srid;
514516
declare += ")";
515517
}
518+
hasWhere = TRUE;
516519
}
517520

518521
if(sqlWhereClause.length() > 0)
519522
{
520-
declare += " and (" + sqlWhereClause + ")";
523+
if (hasWhere)
524+
declare += " and ";
525+
else
526+
declare += " where ";
527+
declare += "(" + sqlWhereClause + ")";
528+
hasWhere = TRUE;
521529
}
522530

523531
QgsDebugMsg("Selecting features using: " + declare);

0 commit comments

Comments
 (0)