crate / sqlalchemy-cratedb

SQLAlchemy dialect for CrateDB.
https://cratedb.com/docs/sqlalchemy-cratedb/
Apache License 2.0
3 stars 2 forks source link

sqlalchemy MATCH support is not properly escaped #133

Closed jeffnappi closed 9 years ago

jeffnappi commented 9 years ago

Adding a single quote to a query utilizing MATCH will break the query. I modified the test case to induce the behavior:

    def test_simple_match(self):
        query = self.session.query(self.Character.name) \
                    .filter(match(self.Character.name, 'Trill\'ian'))
        self.assertSQL(
            "SELECT characters.name AS characters_name FROM characters WHERE match(characters.name, 'Trill\\'ian')",
            query
        )

Result:

Failure
Expected :"SELECT characters.name AS characters_name FROM characters WHERE match(characters.name, 'Trill\\'ian')"
Actual   :"SELECT characters.name AS characters_name FROM characters WHERE match(characters.name, 'Trill'ian')"

The output of the test error is a little misleading - the comparison is of course taking place without the escapes.