Filter by UUID (binary subtype 0x04) for mongodb not working.

Steps to Reproduce

In mongo shell I can find documents by UUID using BinData:

> use users
switched to db users

> db.users.insert({ "_id" : ObjectId("60dc2c3a7911f0e60f6dceb2"), "userId" : UUID("1dee688c-9974-4939-ade3-bac9735efffd") })
WriteResult({ "nInserted" : 1 })

> UUID('1dee688c-9974-4939-ade3-bac9735efffd').base64()
He5ojJl0STmt47rJc17//Q==

> db.users.findOne({ "userId": BinData(4, "He5ojJl0STmt47rJc17//Q==" ) } )
{ "_id" : ObjectId("60dc2c3a7911f0e60f6dceb2"), "userId" : UUID("1dee688c-9974-4939-ade3-bac9735efffd") }

> JSON.stringify(db.users.findOne({ "userId": BinData(4, "He5ojJl0STmt47rJc17//Q==" ) } ))
{"_id":{"$oid":"60dc2c3a7911f0e60f6dceb2"},"userId":{"$binary":"He5ojJl0STmt47rJc17//Q==","$type":"04"}}

But in redash, same query return empty results:

{
    "collection": "users",
    "query": {
        "userId": {
            "$eq": {
                "$binary": {
                    "base64": "He5ojJl0STmt47rJc17//Q==",
                    "subType": "04"
                }
            }
        }
    },
    "fields": {
        "_id": 1,
        "userId": 2
    }
}
1 Like

redash create incorrect query:

> db.system.profile.find({"ns" : "test.users"}, {"op":1, "command": 1}).pretty()
{
        "op" : "query",
        "command" : {
                "find" : "users",
                "filter" : {
                        "userId" : {
                                "$eq" : BinData(3,"He5ojJl0STmt47rJc17//Q==")
                        }
                },
                "projection" : {
                        "_id" : 1,
                        "userId" : 2
                },
                "lsid" : {
                        "id" : UUID("6d70603f-de19-4f4a-ba5a-9951e2e99a9a")
                },
                "$readPreference" : {
                        "mode" : "secondaryPreferred"
                },
                "$db" : "users"
        }
}
1 Like

I’m moving this into the feature requests portion of the forum. It’s not a bug as such. We just don’t support that column type. Would love to see this implemented, however!

Original title of this post was Filter by UUID not working