From a2478230c26fb7c6d7245da60a348339fe24200a Mon Sep 17 00:00:00 2001 From: Toshihiro Suzuki Date: Fri, 26 Jul 2024 19:41:37 +0900 Subject: [PATCH] Fix TableMetadata (#2075) --- .../main/java/com/scalar/db/api/TableMetadata.java | 2 ++ .../java/com/scalar/db/api/TableMetadataTest.java | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/scalar/db/api/TableMetadata.java b/core/src/main/java/com/scalar/db/api/TableMetadata.java index bed51f74cf..9adb868a23 100644 --- a/core/src/main/java/com/scalar/db/api/TableMetadata.java +++ b/core/src/main/java/com/scalar/db/api/TableMetadata.java @@ -209,6 +209,7 @@ private Builder(TableMetadata prototype) { clusteringKeyNames.addAll(prototype.clusteringKeyNames); clusteringOrders.putAll(prototype.clusteringOrders); secondaryIndexNames.addAll(prototype.secondaryIndexNames); + encryptedColumnNames.addAll(prototype.encryptedColumnNames); } /** @@ -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; } diff --git a/core/src/test/java/com/scalar/db/api/TableMetadataTest.java b/core/src/test/java/com/scalar/db/api/TableMetadataTest.java index e693421672..c931b309db 100644 --- a/core/src/test/java/com/scalar/db/api/TableMetadataTest.java +++ b/core/src/test/java/com/scalar/db/api/TableMetadataTest.java @@ -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) @@ -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 @@ -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) @@ -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); } }