Subscription doesn't respect notEqualTo in pointer field

Hello!
For some reason the following two queries (query and subscription) gives me different results.

QUERY:

let query = new parse.Query('ChatMessage');
const user = parse.User.current();
query.notEqualTo('author', user);
query.containedIn('chat', chats);

return query.find();

SUBSCRIPTION

let query = new parse.Query('ChatMessage');
const user = parse.User.current();
query.notEqualTo('author', user);
query.containedIn('chat', chats);

return query.subscribe();

The query gives the expected result where I get an array of ChatMessages where messages written by current user (author pointer) is excluded.
The subscription triggers create events when ChatMessages written by the logged in user is created.

Why? Is it a bug by me? Is it a bug in parse? Is it an (undocumented?) limitation in parse?

The subscription should work as you expect with this query. What I saw happening with other apps and maybe is happening for you: maybe you are first creating the ChatMessage object (without assigning the author) and later assigning the author. In this case you will have the create event triggered for the first action and the leave event triggered for the second action. This behavior uses to happen a lot when using the Parse Dashboard to test the subscriptions. Could you please double check if that’s not your case?

Thx for the answer!

I’ll look into if this could be the case :+1:

I have now verified that the author field indeed is set on creation (before calling .save() that is) but still triggers the subscription even though the author is the currently logged in user.

So, unfortunately, no, that is not my case.
Any ideas what could be wrong would be much appreciated?

Would you mind to share the code that you are using to create and save the ChatMessage object?

Sure! Here goes:

export async function addMessageToChat(chat, msg, img, task = undefined, type = 'userMessage') {
  let message = new parse.Object('ChatMessage');
  message.set('chat', chat);

  if(msg){
    message.set('message', msg);
  }

  message.set('type', type);
  message.set('author', parse.User.current());

  if (img) {
    let image = new parse.Object('ChatImage');
    image.set('imageData', img);
    let parseImage = await image.save();
    message.set('image', parseImage);
  }

  if(task){
    message.set('task', task);
  }
  console.log('gonna create message: ' , message);

  return message.save();

}

I appreciate you taking the time!

Could you please also share how you are importing parse and how you are initializing the SDK?