Ticket #325 (closed defect: fixed)

Opened 6 years ago

Last modified 6 years ago

Limit or maxfeatures parameters are not sent to SQL request

Reported by: yjacolin Owned by: fredj
Priority: blocker Milestone: 1.1 Release
Component: General.server Version: SVN
Keywords: SQL,limit,maxfeatures Cc: yjacolin@…
State: Commit

Description

if this code is used:

  var styleMap = new OpenLayers.StyleMap(OpenLayers.Util.applyDefaults(
        {fillColor: "green", fillOpacity: 1, strokeColor: "green", strokeWidth: 2},
        OpenLayers.Feature.Vector.style["default"]));

  var osm = new OpenLayers.Layer.Vector("OpenStreetMap", {
     strategies: [new OpenLayers.Strategy.Fixed()],
     protocol: new OpenLayers.Protocol.HTTP({
        url: "http://localhost:5000/roads/?",
        format: new OpenLayers.Format.GeoJSON(),
        params: {maxfeatures: 1000, type: "motorway", box: '169537.3287161743,6237873.003429162,332501.072990979,6278843.250582677', limit: 1000}
    }),
    styleMap: styleMap
  });

The SQL request sent is:

SELECT roads.gid AS roads_gid, roads.osm_id AS roads_osm_id, roads.name AS roads_name, roads.type AS roads_type, roads.oneway AS roads_oneway, roads.the_geom AS roads_the_geom, roads.mercator AS roads_mercator                        
FROM roads                                                                                                                                         
WHERE roads.mercator && geomfromtext(%(geomfromtext_1)s, %(geomfromtext_2)s)

maxfeatures or limit parameter are not used in the SQL request made by SQLAchemy.

Note: if limit or maxfeatures are used directly in the url, this is not working as well.

Y.

Attachments

patch-MapFish-325-r1374-A0.diff (1.1 kB) - added by elemoine 6 years ago.

Change History

  Changed 6 years ago by elemoine

does it work better if you do:

?limit=10&offset=0

?

  Changed 6 years ago by elemoine

  • milestone changed from 1.0 Release to 1.1 Release

follow-up: ↓ 4   Changed 6 years ago by yjacolin

Yes it is working now. thanks very much!

Y.

in reply to: ↑ 3   Changed 6 years ago by elemoine

Replying to yjacolin:

Yes it is working now. thanks very much! Y.

Yet, there is a bug and a fix is required.

Changed 6 years ago by elemoine

  Changed 6 years ago by elemoine

  • state set to Review

  Changed 6 years ago by pvalsecc

  • state changed from Review to Commit

You can maybe avoid reusing the limit variable and introduce a "endOffset", because the semantic is wrong. Appart from that, you can commit.

  Changed 6 years ago by elemoine

  • status changed from new to closed
  • resolution set to fixed

(In [1378]) when used without offset, the limit param doesn't result in an SQL query with a LIMIT clause; likewise, when used without limit, the offset param doesn't result in an SQL query with an OFFSET clause. This patch removes the use of a Python slice for LIMIT and OFFSET and makes use of the limit() and offset() Query methods instead, in this way the code is more readable and more importantly less error-prone. Thanks yjacolin for the bug report. r=pvalsecc (closes #325)

Note: See TracTickets for help on using tickets.