benoitdm-oslandia / pg_featureserv

Apache License 2.0
1 stars 0 forks source link

Bug - POST requests result in error 500 #160

Closed azarz closed 1 year ago

azarz commented 1 year ago

When I do a POST request on a DB collection (as generated in the swagger webpage), I get a 500 error with a SQL syntax error

curl -X POST "http://localhost:9000/collections/public.test_arr/items" -H  "accept: */*" -H  "Content-Type: application/json" -d "{\"geometry\":{\"coordinates\":[-70.88461956597838,47.807897059236495],\"type\":\"Point\"},\"properties\":{},\"type\":\"Feature\"}"

Unable to create new feature in Collection - catalog error: public.test_arr Caused by: ERREUR: erreur de syntaxe sur ou près de « , » (SQLSTATE 42601)

Even if the request is bad, (in which case, I don't know where the problem is) I think this should be a 400 error instead of a 500

azarz commented 1 year ago

The SQL request generated after the POST request is

        INSERT INTO public.test_arr (, geom)
        VALUES (, ST_GeomFromGeoJSON($1))
        RETURNING id

As if geom was the only column. However, the test_arr table is defined with several columns

CREATE TABLE test_arr
(
    id integer primary key,
    geom geometry(point, 4326),
    val_bool boolean[],
    val_int integer[],
    val_dp double precision[],
    val_txt text[]
);
azarz commented 1 year ago

This happens when the posted feature has no property and no property is required in the schema.