Skip to content

Commit b16b23d

Browse files
committed
Updated MS SQLServer driver to work off the NATIVE_FILTER processing key (#5001).
1 parent b2940db commit b16b23d

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

mapmssql2008.c

+10-11
Original file line numberDiff line numberDiff line change
@@ -904,21 +904,20 @@ static int prepare_database(layerObj *layer, rectObj rect, char **query_string)
904904
}
905905

906906
/* test whether we should omit spatial filtering */
907+
/* TODO: once this driver supports expression translation then filter->native_string will need to be considered here */
907908
msMSSQL2008LayerGetExtent(layer, &extent);
908-
if (rect.minx <= extent.minx && rect.miny <= extent.miny &&
909-
rect.maxx >= extent.maxx && rect.maxy >= extent.maxy) {
909+
if (rect.minx <= extent.minx && rect.miny <= extent.miny && rect.maxx >= extent.maxx && rect.maxy >= extent.maxy) {
910910
/* no spatial filter used */
911-
if(!layer->filter.native_string) {
912-
snprintf(query_string_temp, sizeof(query_string_temp), "SELECT %s from %s", columns_wanted, data_source );
911+
if(msLayerGetProcessingKey(layer, "NATIVE_FILTER") == NULL) {
912+
snprintf(query_string_temp, sizeof(query_string_temp), "SELECT %s from %s", columns_wanted, data_source );
913913
} else {
914-
snprintf(query_string_temp, sizeof(query_string_temp), "SELECT %s from %s WHERE (%s)", columns_wanted, data_source, layer->filter.native_string );
914+
snprintf(query_string_temp, sizeof(query_string_temp), "SELECT %s from %s WHERE (%s)", columns_wanted, data_source, msLayerGetProcessingKey(layer, "NATIVE_FILTER"));
915915
}
916-
}
917-
else {
918-
if(!layer->filter.native_string) {
919-
snprintf(query_string_temp, sizeof(query_string_temp), "SELECT %s from %s WHERE %s.STIntersects(%s) = 1 ", columns_wanted, data_source, layerinfo->geom_column, box3d );
916+
} else {
917+
if(msLayerGetProcessingKey(layer, "NATIVE_FILTER") == NULL) {
918+
snprintf(query_string_temp, sizeof(query_string_temp), "SELECT %s from %s WHERE %s.STIntersects(%s) = 1 ", columns_wanted, data_source, layerinfo->geom_column, box3d );
920919
} else {
921-
snprintf(query_string_temp, sizeof(query_string_temp), "SELECT %s from %s WHERE (%s) and %s.STIntersects(%s) = 1 ", columns_wanted, data_source, layer->filter.native_string, layerinfo->geom_column, box3d );
920+
snprintf(query_string_temp, sizeof(query_string_temp), "SELECT %s from %s WHERE (%s) and %s.STIntersects(%s) = 1 ", columns_wanted, data_source, msLayerGetProcessingKey(layer, "NATIVE_FILTER"), layerinfo->geom_column, box3d );
922921
}
923922
}
924923

@@ -2221,7 +2220,7 @@ MS_DLL_EXPORT int PluginInitializeVirtualTable(layerVTableObj* vtable, layerObj
22212220
assert(layer != NULL);
22222221
assert(vtable != NULL);
22232222

2224-
/* vtable->LayerTranslateFilter, use default */
2223+
/* vtable->LayerTranslateFilter, use default - need to add this... */
22252224

22262225
vtable->LayerInitItemInfo = msMSSQL2008LayerInitItemInfo;
22272226
vtable->LayerFreeItemInfo = msMSSQL2008LayerFreeItemInfo;

0 commit comments

Comments
 (0)