Skip to content

Query statement dumps nw as nwr #799

Description

@b1tw153

Query_Statement::to_string() in src/overpass_api/statements/query.h:100-101 returns "nwr" for the nw type mask:

else if (type == (QUERY_NODE | QUERY_WAY | QUERY_RELATION))
    return "nwr";
else if (type == (QUERY_NODE | QUERY_WAY))
    return "nwr";        // should be "nw"

wr and nr are handled correctly; only nw is incorrect.

to_string() backs dump_compact_ql() and dump_pretty_ql() via dump_subquery_map_ql(), so the QL dump forms misreport the type. XML dumps are not affected.

Impact: Only query dumps are incorrect. Execution is unaffected — type holds the correct bitmask and only the echoed-back text is wrong. The dumped query with nwr in place of nw is still valid, but it is a different query that also returns relations.

Reproduce (verified against v0.7.62.11):

echo 'nw[amenity=cafe];' | osm3s_query --dump-compact-ql

Expected nw["amenity"="cafe"]; but output is nwr["amenity"="cafe"];. Same under --dump-pretty-ql and --dump-bbox-ql. The output with --dump-xml is correct.

Reproduces from XML input as well, so it is the dump side, not the parser:

osm3s_query --dump-compact-ql 2>/dev/null <<'EOF'
<osm-script>
<query type="nw"><has-kv k="amenity" v="cafe"/></query>
</osm-script>
EOF

Expected nw["amenity"="cafe"]; but output is nwr["amenity"="cafe"];

Fix: return "nw" on the type == (QUERY_NODE | QUERY_WAY) branch.

Version: present since the shortcuts were introduced in v0.7.56.1 (2020-03-03) and unchanged through v0.7.62.11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions