GEOLYTIX / xyz

An open source javascript framework for spatial data and application interfaces.
MIT License
86 stars 25 forks source link

Key is ID = Throw Error #1283

Closed simon-leech closed 1 month ago

simon-leech commented 1 month ago

In the location_update and location_new queries, it is possible to update the id field on the table on the db. However, doing so will actually overwrite the %{id} reserved parameter. Example using location_update

UPDATE ${_.table} SET ${fields.join()} WHERE ${_.layer.qID} = %{id};

You are on location unique_id = 777. You want to update id field to be 123. The query you would expect to look like

UPDATE schema.table SET id = 123 WHERE unique_id = 777`

It actually does this

UPDATE  schema.table SET id = 123 WHERE unique_id = 123`

Proposed Fix

Long-Term Fix

simon-leech commented 1 month ago

I just pushed a commit to make sure the Error message throws the Error using the layer.qID not 'id' so it is explicit what the issue is.

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud