You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I have a Postgres generated column and attempt to make a Graphql insert mutation, it works perfectly when running as admin role with a Hasura admin secret set in the header.
It fails though for any other role, ie. whenever the admin secret is not set. When I make the insert mutation query without being admin, Hasura adds all fields into the INSERT statement and puts their values as DEFAULT. Postgres then complains that you can't insert into generated columns.
When my table name is work_entry and one of the generated columns is startTime (which casts the start timestamp to time of day) this is the query Hasura makes and Postgres fails on:
acdcwelding_postgres | 2020-01-10 22:33:59.835 UTC [129] ERROR: cannot insert into column "startTime"
acdcwelding_postgres | 2020-01-10 22:33:59.835 UTC [129] DETAIL: Column "startTime" is a generated column.
There is no default set for all these columns. Why does Hasura stick them into the INSERT query? And why does this work perfectly when querying with a Hasura admin secret header but not without?
I do not have any role presets and the permissions work perfectly for all other fields.
nolandg
changed the title
Generated columns broken by Hasura adding DEFAULT values into INSERT mutations
All INSERT mutations fail, Hasura adds DEFAULT values into generated columns
Jan 12, 2020
When I have a Postgres generated column and attempt to make a Graphql insert mutation, it works perfectly when running as
admin
role with a Hasura admin secret set in the header.It fails though for any other role, ie. whenever the admin secret is not set. When I make the insert mutation query without being admin, Hasura adds all fields into the
INSERT
statement and puts their values asDEFAULT
. Postgres then complains that you can't insert into generated columns.When my table name is
work_entry
and one of the generated columns isstartTime
(which casts thestart
timestamp to time of day) this is the query Hasura makes and Postgres fails on:There is no default set for all these columns. Why does Hasura stick them into the
INSERT
query? And why does this work perfectly when querying with a Hasura admin secret header but not without?I do not have any role presets and the permissions work perfectly for all other fields.
On discord it was pointed out that there is a separate code path for admin inserts vs. non-admin inserts:
https://github.com/hasura/graphql-engine/blob/master/server/src-lib/Hasura/RQL/DML/Insert.hs#L254
The text was updated successfully, but these errors were encountered: