Skip to content

Commit

Permalink
Fix TableMetadata (#2075)
Browse files Browse the repository at this point in the history
  • Loading branch information
brfrn169 authored Jul 26, 2024
1 parent 9d44bd7 commit a247823
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions core/src/main/java/com/scalar/db/api/TableMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ private Builder(TableMetadata prototype) {
clusteringKeyNames.addAll(prototype.clusteringKeyNames);
clusteringOrders.putAll(prototype.clusteringOrders);
secondaryIndexNames.addAll(prototype.secondaryIndexNames);
encryptedColumnNames.addAll(prototype.encryptedColumnNames);
}

/**
Expand Down Expand Up @@ -246,6 +247,7 @@ public Builder addColumn(String name, DataType type, boolean encrypted) {
*/
public Builder removeColumn(String name) {
columns.remove(name);
encryptedColumnNames.remove(name);
return this;
}

Expand Down
12 changes: 8 additions & 4 deletions core/src/test/java/com/scalar/db/api/TableMetadataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public void builder_ProperParametersGiven_ShouldReturnProperTableMetadata() {
.addColumn(COL_NAME7, DataType.BIGINT)
.addColumn(COL_NAME8, DataType.FLOAT)
.addColumn(COL_NAME9, DataType.DOUBLE)
.addColumn(COL_NAME10, DataType.BOOLEAN)
.addColumn(COL_NAME11, DataType.BLOB)
.addColumn(COL_NAME10, DataType.BOOLEAN, true)
.addColumn(COL_NAME11, DataType.BLOB, true)
.addPartitionKey(COL_NAME2)
.addPartitionKey(COL_NAME1)
.addClusteringKey(COL_NAME4, Order.ASC)
Expand Down Expand Up @@ -99,6 +99,8 @@ public void builder_ProperParametersGiven_ShouldReturnProperTableMetadata() {
assertThat(tableMetadata.getSecondaryIndexNames().size()).isEqualTo(2);
assertThat(tableMetadata.getSecondaryIndexNames().contains(COL_NAME5)).isTrue();
assertThat(tableMetadata.getSecondaryIndexNames().contains(COL_NAME6)).isTrue();

assertThat(tableMetadata.getEncryptedColumnNames()).containsOnly(COL_NAME10, COL_NAME11);
}

@Test
Expand Down Expand Up @@ -191,8 +193,8 @@ public void builder_basedOnAnotherTableMetadata_ShouldReturnProperTableMetadata(
.addColumn(COL_NAME7, DataType.BIGINT)
.addColumn(COL_NAME8, DataType.FLOAT)
.addColumn(COL_NAME9, DataType.DOUBLE)
.addColumn(COL_NAME10, DataType.BOOLEAN)
.addColumn(COL_NAME11, DataType.BLOB)
.addColumn(COL_NAME10, DataType.BOOLEAN, true)
.addColumn(COL_NAME11, DataType.BLOB, true)
.addPartitionKey(COL_NAME2)
.addPartitionKey(COL_NAME1)
.addClusteringKey(COL_NAME4, Order.ASC)
Expand Down Expand Up @@ -258,5 +260,7 @@ public void builder_basedOnAnotherTableMetadata_ShouldReturnProperTableMetadata(

assertThat(tableMetadata.getSecondaryIndexNames().size()).isEqualTo(1);
assertThat(tableMetadata.getSecondaryIndexNames().contains(COL_NAME5)).isTrue();

assertThat(tableMetadata.getEncryptedColumnNames()).containsOnly(COL_NAME10);
}
}

0 comments on commit a247823

Please sign in to comment.