Bug when using materialized views and multiple filters
lorinvivus opened this issue · 2 comments
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!
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
fixed in v2.3.2