cassandra-lucene-index icon indicating copy to clipboard operation
cassandra-lucene-index copied to clipboard

Add support for ifNotExists clause in Builder.

Open rickstroo opened this issue 6 years ago • 0 comments

This is a request to add a feature to allow support for inserting an "IF NOT EXISTS" in the CQL statement that is generated by the Builder. This feature would eliminate the need to write exception handling code in software that initializes the database schema.

The change is simply and requires the following changes to be applied to the Index class.

  • private boolean ifNotExists = false;

  • public Index ifNotExists() {

  •    this.ifNotExists = true;
    
  •    return this;
    
  • }

    @Override public String build() { StringBuilder sb = new StringBuilder(); sb.append("CREATE CUSTOM INDEX ");

  •    if (ifNotExists) {
    
  •        sb.append("IF NOT EXISTS ");
    
  •    }
       if (name != null) {
           sb.append(name).append(" ");
       }
    

rickstroo avatar Apr 05 '18 13:04 rickstroo