koopjs / winnow

Deprecated
Apache License 2.0
90 stars 18 forks source link

Handle where queries on OBJECTID when OBJECTID is generated on the fly #116

Closed rgwozdz closed 5 years ago

rgwozdz commented 5 years ago

The PR addresses a deficiency in current code base that prevents ability to query on OBJECTID in the where parameter when OBJECTIDs are generated on-the-fly in Winnow.

Context: If data arrives in winnow without an OBJECTID field and no alternative assignment using the metadata.idField property, then winnow generates an OBJECTID on-the-fly in a user-defined SELECT function that is passed into alasql. However, problems occur if the where parameter queries OBJECTID, e.g., where=OBJECTID=1234, because the OBJECTID does not yet exist on the data when the alasql WHERE does its filtering. Thus, no features are ever returned.

Solution: If the WHERE includes predicates with OBJECTID, but no OBJECTID is defined on the data, and no idField has been assigned, we have to use a user-defined function in the WHERE part of alasql to generate an on-the-fly OBJECTID for comparison to the submitted value.