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 @@ -211,7 +211,9 @@ private TableMetadata createTableMetadata(com.datastax.driver.core.TableMetadata
211211 ClusteringOrder clusteringOrder = metadata .getClusteringOrder ().get (i );
212212 builder .addClusteringKey (clusteringColumnName , convertOrder (clusteringOrder ));
213213 }
214- metadata .getIndexes ().forEach (i -> builder .addSecondaryIndex (i .getTarget ()));
214+ metadata
215+ .getIndexes ()
216+ .forEach (i -> builder .addSecondaryIndex (unquoteIfNecessary (i .getTarget ())));
215217 return builder .build ();
216218 }
217219
@@ -302,8 +304,8 @@ public void addNewColumnToTable(
302304 throws ExecutionException {
303305 try {
304306 String alterTableQuery =
305- SchemaBuilder .alterTable (namespace , table )
306- .addColumn (columnName )
307+ SchemaBuilder .alterTable (quoteIfNecessary ( namespace ), quoteIfNecessary ( table ) )
308+ .addColumn (quoteIfNecessary ( columnName ) )
307309 .type (toCassandraDataType (columnType ))
308310 .getQueryString ();
309311
@@ -496,4 +498,14 @@ public String toString() {
496498 return strategyName ;
497499 }
498500 }
501+
502+ private String unquoteIfNecessary (String identifier ) {
503+ if (identifier == null ) {
504+ return null ;
505+ }
506+ if (identifier .length () >= 2 && identifier .startsWith ("\" " ) && identifier .endsWith ("\" " )) {
507+ return identifier .substring (1 , identifier .length () - 1 ).replace ("\" \" " , "\" " );
508+ }
509+ return identifier ;
510+ }
499511}
You can’t perform that action at this time.
0 commit comments