Skip to content

Azure Cosmos DB $regexMatch issue #306

Closed as not planned
Closed as not planned
@StarkLiew

Description

@StarkLiew

I ran into issue with Azure Cosmos DB with latest ver 8 during deployment.

My solution a quick fix via monkey patch of query_utils.py

def regex_match(field, regex_vals, insensitive=False):
    """
    Safe override for MongoDB $regexMatch to ensure input is a string.
    """
    regex = {"$concat": regex_vals} if isinstance(regex_vals, tuple) else regex_vals
    options = "i" if insensitive else ""

    return {
        "$regexMatch": {
            "input": {
                "$cond": [
                    {"$eq": [{"$type": field}, "string"]},
                    field,
                    {"$toString": field}
                ]
            },
            "regex": regex,
            "options": options
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions