question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mutation where: _or does not filter at all

See original GitHub issue

Version Information

Server Version: 2.15.0-ce

Environment

OSS

What is the current behaviour?

With this mutation:

mutation SoftDeleteAll($account_id: String!, $deleted_at: timestamptz!) {
  update_notification(
    where: {
      _or: [{ sender_id: { _eq: $account_id }, recipient_id: { _eq: $account_id } }]
    }
    _set: { deleted_at: $deleted_at }
  ) {
    affected_rows
  }
}

I get back 0 affected rows.

What is the expected behaviour?

Don’t know if this is a correct mutation filter as on docs there’s no _or filter mutation, so according to the docs this should be translated to this:

  update_notification_many(
    updates: [
      { where: { sender_id: { _eq: $account_id } },  _set: { deleted_at: $deleted_at } }
      { where: { recipient_id: { _eq: $account_id }}, _set: { deleted_at: $deleted_at } }
    ]
  ) {
    affected_rows
  }

The latter is working but why the 1st one does not work. I really can’t remember if the 1st query was working in previous server versions (I’m still in development mode and I’ve never touched this mutation until recently).

Edit: tried 2.14.0,2.13.0 and the same happens, 1st mutation returns 0 affected_rows

Keywords

_or where mutation

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
SamirTalwarcommented, Nov 8, 2022

Thanks for confirming! I agree, it’s so easy to mix up brackets.

FWIW, when I modified it, Prettier autoformatted it to be over multiple lines. (I use a plugin for my editor(s) to run Prettier on everything it can.) You might find that an autoformatter helps you find bugs like this, especially if you’re liberal in sprinkling newlines everywhere.

1reaction
adas98012commented, Nov 8, 2022

This is reproducible in Hasura Cloud (v2.14.0) too.

Steps to reproduce:

  1. Create the table :
CREATE TABLE notification
(
  id int NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, 
  sender_id TEXT,
  recipient_id TEXT,
  deleted_at timestamptz NULL DEFAULT now()
);
  1. Insert some test data (through SQL in Data Tab):
INSERT INTO notification(sender_id, recipient_id, deleted_at)
VALUES('100', '200', now());

INSERT INTO notification(sender_id, recipient_id, deleted_at)
VALUES('200', '300', now());

INSERT INTO notification(sender_id, recipient_id, deleted_at)
VALUES('300', '400', now());
  1. Run the following mutation on the API tab of Console:
mutation MyMutation($account_id: String!, $deleted_at: timestamptz!) {
  update_notification(
    where: {
      _or: [{ sender_id: { _eq: $account_id }, recipient_id: { _eq: $account_id } }]
    }
    _set: { deleted_at: $deleted_at }
  ) {
    affected_rows
  }
}

Query Variables:

{
  "account_id": "200",
  "deleted_at": "2020-01-01T01:00:00.000000+00:00"
}
  1. Record the result:
{
  "data": {
    "update_notification": {
      "affected_rows": 0
    }
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

FilterMutectCalls does not actually filter mutations. Only flag ...
Only flag them. Hi I was wonder why this tool only annotate the mutations, and does not actually filter (out) mutations that are...
Read more >
Array.prototype - .filter - Does it mutate?
Description. The filter() method creates a new array with all elements that pass the test implemented by the provided function.
Read more >
How to filter observable data not mutation source?
You can achieve that just using pipe and filter . Filter by text field: public textChanged(text: string) { this.
Read more >
Mutation Filters - omicsoft doc
Mutation Filters. For views that contain data from DNA-seq and RNA-seq, these views can be filtered to variants of interest. The Mutation tab...
Read more >
MTHFR Mutation: What It Is & What to Do About It
If you have no mutations at MTHFR, you will excrete all ten parts of mercury at 100%, assuming your detox pathways are optimal....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found