@FixFor( "MODE-2151" )
@Test
public void shouldBeAbleToCreateAndExecuteJcrSql2QueryWithChildCountCriteria() throws RepositoryException {

    String sql = "SELECT * FROM [car:Car] as car";
    Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    String[] columnNames = carColumnNames("car");
    // No cars have children
    validateQuery().rowCount(13).hasColumns(columnNames).validate(query, query.execute());
    sql = "SELECT * FROM [car:Car] as car WHERE CHILDCOUNT(car) = 0";
    query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    validateQuery().rowCount(13).hasColumns(columnNames).validate(query, query.execute());
    sql = "SELECT [jcr:path], [mode:childCount] FROM [nt:unstructured] WHERE CHILDCOUNT() = 4";
    query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
    validateQuery().rowCount(2).validate(query, query.execute());
}