github PostgREST/postgrest v11.2.0

latest releases: devel, v12.2.3, v12.2.2...
13 months ago

Overview

PostgREST serves a RESTful API from any existing PostgreSQL database.

v11.2.0 brings you the possibility of using PostgreSQL domains and casts to change how your data is presented to web users. We call this feature "domain representations" and it holds some advantages over views.

-- having a uuid domain and a table
create domain app_uuid as uuid;

create table profiles(
  id   app_uuid
, name text
);

-- we define a function to convert the uuid domain to base64
create or replace function json(app_uuid) returns json as $$
  select to_json(encode(uuid_send($1),'base64'));
$$ language sql immutable;

-- and use the function for an implicit cast from domain to json 
create cast (app_uuid as json) with function json(app_uuid) as implicit;

-- the format changes when requesting JSON at the API level
curl "http://localhost:3000/profiles" \
  -H "Accept: application/json"

[{"id":"hGxP/ZLOTeeNEY4pkp9OxA==","name":"John Doe"}]

-- while the data is kept as is at the database level
select * from profiles;

                  id                  |   name
--------------------------------------+----------
 846c4ffd-92ce-4de7-8d11-8e29929f4ec4 | John Doe

Domain representations also allow you to change the format of the request payload and the format of the filters values. Check the Domain Representations docs for more details.

What is new

API

Admin

Resource Embedding

Resource Representation

Tables and Views

What is fixed

Auth

API

  • Fix OPTIONS not accepting all available media types by @steve-chavez in #2821
  • Fix Prefer: missing=default with DOMAIN default values by @steve-chavez in #2840
  • Fix HEAD unnecessarily executing aggregates by @steve-chavez in #2849
  • Fix unused index on jsonb/jsonb arrow filter and order (/bets?data->>contractId=eq.1 and /bets?order=data->>contractId) by @steve-chavez in #2594
  • Fix character and bit columns with fixed length not inserting/updating properly by @laurenceisla in #2861
    • Fixes the error "value too long for type character(1)" when the char length of the column was bigger than one.
  • Fix null filtering on embedded resource when using a column name equal to the relation name by @steve-chavez in #2862
  • Fix function parameters of type character and bit not ignoring length by @laurenceisla in #1586
    • Fixes the error "value too long for type character(1)" when the char length of the parameter was bigger than one.
  • Fix error when a function returns RECORD or SET OF RECORD by @laurenceisla in #2881

Misc

Deprecated

Resource Embedding

  • Deprecate resource embedding target disambiguation by @steve-chavez in #2863
    • The /table?select=*,other!fk(*) must be used to disambiguate
    • The server aids in choosing the !fk by sending a hint on the error whenever an ambiguous request happens.

New Contributors

Full Changelog: v11.1.0...v11.2.0

Don't miss a new postgrest release

NewReleases is sending notifications on new releases.