realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.77k stars 573 forks source link

Watchsteam filters cannot use UUID #5160

Open tcollins590 opened 1 year ago

tcollins590 commented 1 year ago

How frequently does the bug occur?

Seen once

Description

When setting up a watch stream with a filter using the realm-web package, UUID's appear to not be valid as a filter. I can successfully filter for BSON.ObjectID but not BSON.UUID.

Eg filter: {"fullDocument.field": new BSON.UUID("38547a33-7686-4bfb-bda6-ce8bb0479d52")}

It's verified that it's not taking the filter by looking at the App Services logs under a watch stream function. When using BSON.ObjectID, the filter shows up in the function output, and when using the BSON.UUID, there is no filter object in the function output in the log.

Stacktrace & log output

No response

Can you reproduce the bug?

Yes, always

Reproduction Steps

Pass a filter to .watch() on a collection using a BSON.UUID. Reference app services logs to see that the filter is not being applied

Version

1.7.1

What SDK flavour are you using?

Atlas App Services (auth, functions, etc.)

Are you using encryption?

No, not using encryption

Platform OS and version(s)

Typescript, react 18, next.js

Build environment

Which debugger for React Native: ..

Cocoapods version

No response

tcollins590 commented 1 year ago

I've realized that converting the UUID to Binary using .toBinary() the filter then works. Is this the intended behavior?

kneth commented 1 year ago

According to the BSON specification, UUID is binary data with a special subtype. In that light, it is not surprising.

The conversion could be done by Realm Web by scanning the filter argument for UUID.