Add support for ifNotExists clause in Builder.
rickstroo opened this issue · 0 comments
rickstroo commented
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(" "); }