PostgREST / postgrest

REST API for any Postgres database
https://postgrest.org
MIT License
23.51k stars 1.03k forks source link

Extra json properties are not ignored #1261

Closed rrdlpl closed 5 years ago

rrdlpl commented 5 years ago

Environment

Description of issue

According to this merge request this feature should be already supported.

https://github.com/PostgREST/postgrest/issues/1234 https://github.com/PostgREST/postgrest/pull/1241

I have the following table:

CREATE TABLE api.controllers
(
    id uuid NOT NULL,
    "siteId" uuid NOT NULL,
    host text  NOT NULL,
    port integer NOT NULL,
    username text   NOT NULL,
    password text   NOT NULL
)

My Post requests

http://localhost:3000/controllers?columns=id,"siteId",host,port,username,password

Payload:

{
  "_id": "5c99e1870b709d0082b71fd4",
  "id": "0b81b399-a062-4488-b9ab-db29c2d2482c",
  "assetId": "",
  "port": 4335,
  "name": "plcsim",
  "serialNumber": "",
  "warranty": "",
  "siteId": "226168be-866c-11e8-adc0-fa7ae01bbebc",
  "host": "plc-simulator",
  "username": "a",
  "password": "a",
  "line": "",
  "type": "",
  "lastSeen": "",
  "createdAt": "2019-03-26T08:23:20.942Z",
  "updatedAt": "2019-03-26T08:23:20.942Z",
  "__v": 0
}

As I understand it, only the properties that were added after columns=, should be considered in the Insert query. However, I'm getting this response back:

{
    "hint": null,
    "details": null,
    "code": "42703",
    "message": "column \"__v\" of relation \"controllers\" does not exist"
}

Expected result:

The row should be inserted only with the columns that I specified

vichugunov commented 5 years ago

+1 that issue also relevant for me

ruslantalpa commented 5 years ago

this is in master but it's not released yet, you need to compile from source if you want this feature now

steve-chavez commented 5 years ago

To build from source, see http://postgrest.org/en/v5.2/install.html#build-from-source.