Skip to content
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

server: avoid raising mutation check constraint violation in pg procedure #6123

Merged
merged 11 commits into from
Nov 6, 2020

Conversation

rakeshkky
Copy link
Member

@rakeshkky rakeshkky commented Nov 3, 2020

Description

This is incremental PR towards #5797. It removes dependency on hdb_catalog.check_violation pg procedure to raise mutation (insert & update) check constraint violation exception. Instead, the check constraint violation error is thrown in Haskell code itself.

Changelog

  • CHANGELOG.md is updated with user-facing content relevant to this PR. If no changelog is required, then add the no-changelog-required label.

Affected components

  • Server

Related Issues

Refer the PR #5797

Solution and Design

SQL is generated such a way that it returns a nullable error message column check__constraint which is result of a check constraint evaluation.

....
....
RETURNING *,
<check-constraint> AS "check__constraint"

In Haskell code, the error is raised when check__error column is not null.

Steps to test and verify

Limitations, known bugs & workarounds

Server checklist

Catalog upgrade

Does this PR change Hasura Catalog version?

  • No
  • Yes
    • Updated docs with SQL for downgrading the catalog

Metadata

Does this PR add a new Metadata feature?

  • No
  • Yes

GraphQL

  • No new GraphQL schema is generated
  • New GraphQL schema is being generated

Breaking changes

  • No Breaking changes

-> Raise check constraint error in Haskell code itself.
-> Avoid usage of hdb_catalog.check_constraint procedure
Copy link
Contributor

@abooij abooij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I understand RQL well enough to be able to judge if this has any odd side-effects. But the Haskell code itself looks okay to me. @0x777, what do you think?

@abooij abooij changed the title avoid raising mutation check constraint violation in pg procedure server: avoid raising mutation check constraint violation in pg procedure Nov 3, 2020
@rakeshkky rakeshkky requested a review from abooij November 4, 2020 08:39
@rakeshkky rakeshkky requested a review from a team as a code owner November 5, 2020 08:53
@kodiakhq
Copy link
Contributor

kodiakhq bot commented Nov 5, 2020

This PR currently has a merge conflict. Please resolve this and then re-add the auto-update-auto-merge label.

Copy link
Contributor

@marionschleifer marionschleifer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs

@netlify
Copy link

netlify bot commented Nov 5, 2020

Deploy preview for hasura-docs ready!

Built with commit 86dd527

https://deploy-preview-6123--hasura-docs.netlify.app

Resolve Conflicts:
	server/src-lib/Hasura/Backends/Postgres/Execute/RemoteJoin.hs
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
@rakeshkky rakeshkky requested a review from 0x777 November 6, 2020 06:22
@rakeshkky
Copy link
Member Author

@0x777 Please have a final look at the PR.

@kodiakhq kodiakhq bot merged commit ca47c92 into hasura:master Nov 6, 2020
@nicuveo
Copy link
Contributor

nicuveo commented Nov 7, 2020

Ah, this introduced some Postgres-specific code in RQL.IR. :(
I'll open a new PR to fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants