masumsoft / express-cassandra

Cassandra ORM/ODM/OGM for NodeJS with support for Apache Cassandra, ScyllaDB, Datastax Enterprise, Elassandra & JanusGraph.
http://express-cassandra.readthedocs.io
GNU Lesser General Public License v3.0
227 stars 67 forks source link

Bug when using materialized views and multiple filters #205

Closed lorinvivus closed 4 years ago

lorinvivus commented 4 years ago

When using multiple filters on a materialized view, upon startup of Express cassandra it always believes it should alter the MV because the db schema and the model schemas don't match due to an erroneous space being added to the end of the where clause when replacing "IS NOT null".

Example:

"where intent_id IS NOT NULL and email IS NOT NULL "

It appears to come from this regex:

whereClause += util.format(' %s', filterClause).replace(/IS NOT null/g, 'IS NOT NULL');

We are on the latest release. If we can contribute a fix we'd be happy to do so.

For a "quick fix" I used the following:

 if (whereClause.endsWith(' ')){
    whereClause = whereClause.substr(0, whereClause.length - 1)
  }

After this: https://github.com/masumsoft/express-cassandra/blob/master/src/utils/parser.js#L614

Thanks!

masumsoft commented 4 years ago

A proper fix would be to trim() the generated where clause in the normalizer instead of changing the behaviour of the parser in this case imho.

https://github.com/masumsoft/express-cassandra/blob/master/src/utils/normalizer.js#L162

masumsoft commented 4 years ago

fixed in v2.3.2