Closed mathew-rizing closed 2 weeks ago
Currently the ST_GEOMETRY
and ST_POINT
functionalities are not fully supported on @cap-js/postgres
and @cap-js/sqlite
. There has been an initial attempt to make ST_POINT
work in an uniform manor across databases, but this takes an javascript
centric perspective on the API. Where a point is represented by an JSON
of structure {x:1,y:1}
. This implementation is capable of making all the databases behave the same, but clearly doesn't actually match to any user currently using ST
types on HANA
.
For postgres
there is a widely supported extension that implements proper geo spatial types (aws,azure,gcp)
For sqlite
there is also spatialite
, but extensions for sqlite
are always difficult to actually adopt.
The current ST_POINT
implementation will be removed and will rely on the native functionalities of the database to parse WKT
and convert any native storage formats back into WKT
when reading these fields.
Which will mean that for both ST_POINT
and ST_GEOMETRY
the input converters will have to be applied to UPDATE
placeholders as they will bridge the gap between the natively stored value and the read values.
The ST
types are not the only type which requires the input converters for UPDATE
placeholders. There is also the cds.vector
type which uses input and output converters to make them work, but the input converter is currently also not applied to these UPDATE
queries.
thanks for the investigation, that would also explain why I was experiencing issues with saving drafts on entities with cds.Vector only if they already have an active entity
confirmed to be fixed with latest version, thanks!
Description of erroneous behaviour
Updating entity properties of type ST_GEOMETRY like so:
Results in the following error:
However, INSERT works correctly like so:
Output (notice that it correctly uses TO_GEOMETRY function):
This is causing error during SAVE of draft-enabled entities when the CAP framework tries to update the active entity with geometries from the draft entity (without custom UPDATE call). It seems like HANAService.js's onUPDATE does not correctly set the UPDATE statement with TO_GEOMETRY(). Converting the geometry to buffer to pass to UPDATE like so works without errors:
Additional Information:
Detailed steps to reproduce
Details about your project