strongduanmu commented on code in PR #37896:
URL: https://github.com/apache/shardingsphere/pull/37896#discussion_r2744740196
##########
features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowCreateTableMergedResult.java:
##########
@@ -75,12 +79,25 @@ public Object getValue(final int columnIndex, final
Class<?> type) throws SQLExc
}
CreateTableStatement createTableStatement = (CreateTableStatement)
sqlParserEngine.parse(createTableSQL, false);
List<ColumnDefinitionSegment> columnDefinitions = new
ArrayList<>(createTableStatement.getColumnDefinitions());
+ List<ConstraintDefinitionSegment> constraintDefinitions = new
ArrayList<>(createTableStatement.getConstraintDefinitions());
+ constraintDefinitions.sort((a, b) ->
Integer.compare(a.getStartIndex(), b.getStartIndex()));
Review Comment:
Why sort constraintDefinitions?
##########
features/encrypt/core/src/main/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowCreateTableMergedResult.java:
##########
@@ -75,12 +79,25 @@ public Object getValue(final int columnIndex, final
Class<?> type) throws SQLExc
}
CreateTableStatement createTableStatement = (CreateTableStatement)
sqlParserEngine.parse(createTableSQL, false);
List<ColumnDefinitionSegment> columnDefinitions = new
ArrayList<>(createTableStatement.getColumnDefinitions());
+ List<ConstraintDefinitionSegment> constraintDefinitions = new
ArrayList<>(createTableStatement.getConstraintDefinitions());
+ constraintDefinitions.sort((a, b) ->
Integer.compare(a.getStartIndex(), b.getStartIndex()));
StringBuilder result = new StringBuilder(createTableSQL.substring(0,
columnDefinitions.get(0).getStartIndex()));
+ Collection<String> existedVisibleColumnsLowerCase =
collectExistedVisibleColumnsLowerCase(columnDefinitions, encryptTable.get());
+ List<String> definitions = new ArrayList<>();
for (ColumnDefinitionSegment each : columnDefinitions) {
- findLogicColumnDefinition(each, encryptTable.get(),
createTableSQL).ifPresent(optional -> result.append(optional).append(COMMA));
+ processColumnDefinition(each, encryptTable.get(), createTableSQL,
definitions, existedVisibleColumnsLowerCase);
}
- // TODO decorate encrypt column index when we support index rewrite
- result.delete(result.length() - COMMA.length(),
result.length()).append(createTableSQL.substring(columnDefinitions.get(columnDefinitions.size()
- 1).getStopIndex() + 1));
+ for (ConstraintDefinitionSegment each : constraintDefinitions) {
+ findLogicConstraintDefinition(each, encryptTable.get(),
createTableSQL).ifPresent(definitions::add);
Review Comment:
Can you remove existedVisibleColumnsLowerCase? And use encrypt column config
to replace actual index to logic index.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]