File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
core/src/main/java/com/scalar/db/storage/cassandra Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -218,7 +218,9 @@ private TableMetadata createTableMetadata(com.datastax.driver.core.TableMetadata
218218 ClusteringOrder clusteringOrder = metadata .getClusteringOrder ().get (i );
219219 builder .addClusteringKey (clusteringColumnName , convertOrder (clusteringOrder ));
220220 }
221- metadata .getIndexes ().forEach (i -> builder .addSecondaryIndex (i .getTarget ()));
221+ metadata
222+ .getIndexes ()
223+ .forEach (i -> builder .addSecondaryIndex (unquoteIfNecessary (i .getTarget ())));
222224 return builder .build ();
223225 }
224226
@@ -318,8 +320,8 @@ public void addNewColumnToTable(
318320 }
319321 try {
320322 String alterTableQuery =
321- SchemaBuilder .alterTable (namespace , table )
322- .addColumn (columnName )
323+ SchemaBuilder .alterTable (quoteIfNecessary ( namespace ), quoteIfNecessary ( table ) )
324+ .addColumn (quoteIfNecessary ( columnName ) )
323325 .type (toCassandraDataType (columnType ))
324326 .getQueryString ();
325327
@@ -524,4 +526,14 @@ public String toString() {
524526 return strategyName ;
525527 }
526528 }
529+
530+ private String unquoteIfNecessary (String identifier ) {
531+ if (identifier == null ) {
532+ return null ;
533+ }
534+ if (identifier .length () >= 2 && identifier .startsWith ("\" " ) && identifier .endsWith ("\" " )) {
535+ return identifier .substring (1 , identifier .length () - 1 ).replace ("\" \" " , "\" " );
536+ }
537+ return identifier ;
538+ }
527539}
You can’t perform that action at this time.
0 commit comments