Skip to content

Commit

Permalink
Add duplicate column check for add column to encrypt table
Browse files Browse the repository at this point in the history
  • Loading branch information
Pace2Car committed Oct 12, 2023
1 parent 864b2cd commit 5d2658b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ private Optional<SQLToken> getAddColumnPositionToken(final EncryptTable encryptT
if (columnPositionSegment.isPresent()) {
String columnName = columnPositionSegment.get().getColumnName().getIdentifier().getValue();
if (encryptTable.isEncryptColumn(columnName)) {
return Optional.of(getPositionColumnToken(encryptTable.getEncryptColumn(columnName), segment.getColumnPosition().get()));
EncryptColumn encryptColumn = encryptTable.getEncryptColumn(columnName);
ShardingSpherePreconditions.checkState(encryptColumn.getName().equals(encryptColumn.getCipher().getName()),
() -> new UnsupportedOperationException(String.format("Column %s is already exists", columnName)));
return Optional.of(getPositionColumnToken(encryptColumn, segment.getColumnPosition().get()));
}
}
return Optional.empty();
Expand Down

0 comments on commit 5d2658b

Please sign in to comment.