Skip to main content
Common Reference

dropcomments.js Filter

The dropcomments filter removes comments from statements within the event data.

Pre-configured filter namedropcomments
JavaScript Filter Filetungsten-replicator/support/filters-javascript/dropcomments.js
Property prefixreplicator.filter.dropcomments
Stage compatibilitybinlog-to-q, q-to-dbms
tpm Option compatibilitysvc-extractor-filters, svc-applier-filters
Data compatibilityAny event

Row changes do not have comments, so the filter only has to change the statement information, which is achieved by using a regular expression:

sqlOriginal = d.getQuery();
sqlNew = sqlOriginal.replaceAll("/\\*(?:.|[\\n\\r])*?\\*/","");
d.setQuery(sqlNew);

To handle the case where the statement could only be a comment, the statement is removed:

if(sqlNew.trim().length()==0)
{
data.remove(i);
i--;
}