Skip to content
Permalink
Browse files
Allow sorting in MSSQL with WFS (#5833)
  • Loading branch information
geographika committed Jul 3, 2019
1 parent 65b1ba9 commit f42d7d16157fc1b00909640ec09b51a9f8223e7c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
@@ -1680,7 +1680,7 @@ int msLayerApplyPlainFilterToLayer(FilterEncodingNode *psNode, mapObj *map, int
int msLayerSupportsSorting(layerObj *layer)
{
if (layer && (
(layer->connectiontype == MS_OGR) || (layer->connectiontype == MS_POSTGIS) || (layer->connectiontype == MS_ORACLESPATIAL) || ((layer->connectiontype == MS_PLUGIN) && (strstr(layer->plugin_library,"msplugin_oracle") != NULL))
(layer->connectiontype == MS_OGR) || (layer->connectiontype == MS_POSTGIS) || (layer->connectiontype == MS_ORACLESPATIAL) || ((layer->connectiontype == MS_PLUGIN) && (strstr(layer->plugin_library,"msplugin_oracle") != NULL)) || ((layer->connectiontype == MS_PLUGIN) && (strstr(layer->plugin_library,"msplugin_mssql2008") != NULL))
)
)
return MS_TRUE;
@@ -1506,8 +1506,21 @@ static int prepare_database(layerObj *layer, rectObj rect, char **query_string)
query = msStringConcatenate(query, box3d);
query = msStringConcatenate(query, ") = 1 ");

if (layerinfo->sort_spec)
if (layerinfo->sort_spec) {
query = msStringConcatenate(query, layerinfo->sort_spec);
}

/* Add extra sort by */
if( layer->sortBy.nProperties > 0 ) {
char* pszTmp = msLayerBuildSQLOrderBy(layer);
if (layerinfo->sort_spec)
query = msStringConcatenate(query, ", ");
else
query = msStringConcatenate(query, " ORDER BY ");
query = msStringConcatenate(query, pszTmp);
msFree(pszTmp);
}


if (layer->debug) {
msDebug("query:%s\n", query);

0 comments on commit f42d7d1

Please sign in to comment.