-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PG v10 GENERATED BY DEFAULT AS IDENTITY result in Not-NULL violation #2508
Comments
Interesting bug—I wasn’t aware of Postgres 10’s identity columns. Brief investigation reveals this is more subtle than it might seem. For inserting into tables as non-admin roles, Hasura uses a view. So a view like CREATE VIEW hdb_views.anonymous__insert__public__color AS SELECT * FROM color; will be created. For inserts into that view, Hasura uses a trigger, created like CREATE FUNCTION hdb_views.anonymous__insert__public__color() RETURNS trigger
LANGUAGE plpgsql AS $$ /* ... */ $$;
CREATE TRIGGER anonymous__insert__public__color
INSTEAD OF INSERT ON hdb_views.anonymous__insert__public__color
FOR EACH ROW EXECUTE PROCEDURE hdb_views.anonymous__insert__public__color(); which redirections insertions into the actual ALTER VIEW hdb_views.anonymous__insert__public__color
ALTER COLUMN color_id SET DEFAULT nextval('color_color_id_seq'::regclass); That works out okay, since views are allowed to have default values. But columns created with So I think this is a bug, but I’m not immediately sure what the right fix is. Can you get away with using |
did this bug fixed? |
@susen4517x Sorry for the delayed response. This bug has not been fixed, but it is not forgotten—we’re going to try and fix it sometime in the next few weeks. |
@paf31 I did a little bit of extra looking into this that didn’t make it into the issue, and I have a work-in-progress commit from way back in July here: lexi-lambda@fcb3e9f. Here’s what I found:
So I think you ought to be able to combine the queries in my definitions of |
This should be fixed by the |
Fixed by #3598. |
To reproduce:
0. Important: make sure to run this mutation as anonymous (ie not as hasura admin etc). Set "anonymous" permisions on insert and select actions for example (as shown in the link below)
https://media.discordapp.net/attachments/428469959530643466/598763216192929792/unknown.png?width=1321&height=720
You should the see the following result:
Further info:
x-hasura-admin-secret
header is passed in console headersThe text was updated successfully, but these errors were encountered: