Skip to content

We need to do a better job of converting SQL LIKE expression into Regex #719

@hackel

Description

@hackel

In \Jenssegers\Mongodb\Query\Builder::compileWhereBasic, the conversion from an SQL LIKE expression to a MongoRegex is incomplete. A quick search revealed a more complete implementation here: http://stackoverflow.com/a/11436643/4186945 Specifically, it should at least be calling preg_quote on the input parts that aren't operators (% and _). You could leave quoting % and _ up to the developer, since that's what one would have to do with a SQL DB.

This bit me when trying to do a like query on an email address that contained a + character, that ends up going unescaped. For now I'm just running preg_quote myself, but unfortunately that will break once this is fixed. :-/

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