return native PostgreSQL ISO8601 format #2924
-
Environment
Description of issuePostgreSQL by default returns ISO 8601 format withouth
But PostgREST has Anyway, is it possible to add a config option to choose the format? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
@seven1240 I always get the create table article_stars (
article_id integer not null,
user_id integer not null,
created_at timestamp without time zone default now() not null,
primary key (article_id, user_id)
);
curl localhost:3000/article_stars
[{"article_id":1,"user_id":1,"created_at":"2015-12-08T04:22:57.472738"},
{"article_id":1,"user_id":2,"created_at":"2015-12-08T04:22:57.472738"},
{"article_id":2,"user_id":3,"created_at":"2015-12-08T04:22:57.472738"},
{"article_id":3,"user_id":2,"created_at":"2015-12-08T04:22:57.472738"},
{"article_id":1,"user_id":3,"created_at":"2015-12-08T04:22:57.472738"}] To remove it, you could use a computed field or domain representation. For domain representations, this example could help: postgrest/test/spec/fixtures/schema.sql Lines 3128 to 3144 in 531a183 |
Beta Was this translation helpful? Give feedback.
-
Additionally you could try changing the alter role authenticator set datestyle to postgres; |
Beta Was this translation helpful? Give feedback.
-
Hi @steve-chavez , thank you for the detailed explain. The domain way seems is little complicated.
I tried this and no effect to me even after I restarted PostgREST. Also,
According to https://www.postgresql.org/docs/current/datatype-datetime.html :
So back in the original question, Looks like PostgREST in a 2015 version has not I guess the actual format is still formatted by PostgREST, or the low level pg client lib? Thanks again. |
Beta Was this translation helpful? Give feedback.
This format is used when returning a timestamp as json:
Since we use the built-in transformation to json now, all columns exposed as type timestamp will have this format. However, if you cast your columns to text first, you will receive what you want:
Datestyle settings will only affect the cast to TEXT (2nd example), not the cast to json directly.
You can achieve the cast either via
VIEW
s, via computed columns (as menti…