mcadecio / universal-database-proxy-rest

Transform any database you have into a RESTful API.
MIT License
3 stars 0 forks source link

Postgres/CockroachDB JSON type not allowing a string to be stored #18

Open mcadecio opened 3 months ago

mcadecio commented 3 months ago

Trying to store a string/boolean/integer in column with JSON datatype results in 400.

schema: CREATE TABLE vehicles.cars ( manufacturer varchar(50) not null, car_id bigint primary key not null constraint cars_car_id_uindex unique, doors bigint default 5, last_updated timestamptz default now(), extra_details json default '{}' );

Request:

curl -X 'POST' \ 'http://localhost:8010/cars' \ -H 'accept: /' \ -H 'Content-Type: application/json' \ -d '{ "car_id": 100, "manufacturer": "Tesla", "doors": 5, "last_updated": null, "extra_details": "type=roadster" }'

Response:

{ "timestamp": "2024-07-21T09:59:53", "path": "/cars", "message": "property 'extra_details' with value \"type=roadster\" is not a valid OBJECT", "code": 400, "errors": []

JSON datatype accepts: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', 'OBJECT', 'ARRAY'