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

Graphql delete_<table_name> mutation is deleting all rows when key is null. #4128

Closed
subhrashisdas opened this issue Mar 17, 2020 · 2 comments

Comments

@subhrashisdas
Copy link

subhrashisdas commented Mar 17, 2020

Issue
Graphql delete_<table_name> mutation is deleting all rows when key is null.

Table

                    Table "public.testing"
   Column   | Type | Collation | Nullable |      Default
------------+------+-----------+----------+-------------------
 testing_id | uuid |           | not null | gen_random_uuid()
Indexes:
    "testing_pkey" PRIMARY KEY, btree (testing_id)

Mutation

mutation DeleteTesting {
  delete_testing(where: {testing_id: {_eq: null}}) {
    affected_rows
  }
}

Response

{
  "data": {
    "delete_testing": {
      "affected_rows": 5
    }
  }
}

Expected Behaviour
As per the mutation, it should delete all rows whose testing_id is null.

Current Behaviour
Mutation is deleting all rows from the table.

Postgres Version
v11.6

Hasura Version
v1.1.0

@subhrashisdas subhrashisdas changed the title Graphql delete_<table_name> mutation is deleting all rows when primary key is null. Graphql delete_<table_name> mutation is deleting all rows when key is null. Mar 17, 2020
@tirumaraiselvan
Copy link
Contributor

@subhrashisdas This is actually the expected behaviour currently. The reason for this and efforts to solve this are discussed here: #704

I am closing this in favour of #704. Please feel free to re-open if you have any other comments.

@tirumaraiselvan
Copy link
Contributor

Forgot to mention, you can use the is_null operator to delete rows which have null value: https://hasura.io/docs/1.0/graphql/manual/queries/query-filters.html#filter-or-check-for-null-values-is-null

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

No branches or pull requests

2 participants