Skip to content

Azure Cosmos DB $regexMatch issue #306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
StarkLiew opened this issue May 20, 2025 · 2 comments
Closed

Azure Cosmos DB $regexMatch issue #306

StarkLiew opened this issue May 20, 2025 · 2 comments

Comments

@StarkLiew
Copy link

StarkLiew commented May 20, 2025

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
        }
    }
@timgraham
Copy link
Collaborator

Please provide steps (model and queryset) to reproduce the issue. It could be a valid issue if the steps don't work on MongoDB, otherwise the report should be directed to Cosmos DB (if they claim interoperability with MongoDB).

@timgraham timgraham changed the title Azure Cosmos DB Azure Cosmos DB $regexMatch issue May 22, 2025
@timgraham
Copy link
Collaborator

Closing as "needs info".

@timgraham timgraham closed this as not planned Won't fix, can't repro, duplicate, stale Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants