From 46b3ce56314d014645fb79ee8ba3d176e29fcb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gammels=C3=A6ter?= Date: Mon, 20 Jun 2016 18:49:52 +0200 Subject: [PATCH] Name custom types and domains on OPTIONS requests (#640) --- CHANGELOG.md | 2 ++ src/PostgREST/DbStructure.hs | 4 ++-- test/Feature/StructureSpec.hs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b566bd72..114a9b1b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added +- Output names of used-defined types (instead of 'USER-DEFINED') - @martingms + ### Fixed - Do not apply limit to parent items - @ruslantalpa diff --git a/src/PostgREST/DbStructure.hs b/src/PostgREST/DbStructure.hs index a9365ce75..c6e6a77f1 100644 --- a/src/PostgREST/DbStructure.hs +++ b/src/PostgREST/DbStructure.hs @@ -289,13 +289,13 @@ allColumns tabs = CASE WHEN bt.typelem <> 0::oid AND bt.typlen = (-1) THEN 'ARRAY'::text WHEN nbt.nspname = 'pg_catalog'::name THEN format_type(t.typbasetype, NULL::integer) - ELSE 'USER-DEFINED'::text + ELSE format_type(a.atttypid, a.atttypmod) END ELSE CASE WHEN t.typelem <> 0::oid AND t.typlen = (-1) THEN 'ARRAY'::text WHEN nt.nspname = 'pg_catalog'::name THEN format_type(a.atttypid, NULL::integer) - ELSE 'USER-DEFINED'::text + ELSE format_type(a.atttypid, a.atttypmod) END END::information_schema.character_data AS data_type, information_schema._pg_char_max_length(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*))::information_schema.cardinal_number AS character_maximum_length, diff --git a/test/Feature/StructureSpec.hs b/test/Feature/StructureSpec.hs index 3d58947ac..f5313b69c 100644 --- a/test/Feature/StructureSpec.hs +++ b/test/Feature/StructureSpec.hs @@ -204,7 +204,7 @@ spec = do "updatable": true, "schema": "test", "name": "enum", - "type": "USER-DEFINED", + "type": "test.enum_menagerie_type", "maxLen": null, "enum": [ "foo",