lwtdev commented on issue #7880:
URL: https://github.com/apache/shardingsphere/issues/7880#issuecomment-733033027
@jingshanglu Hi, I'm trying to add TableAssert (for UpdateStatementAssert)
OwnerAssit and WhereAssert in next pull request.
- **Questions About** `ExpectedWhereClause`
1. What's the different between `ExpectedAndPredicate` and
`ExpectedPredicate` in `ExpectedWhereClause`?
2. Why does define a `List` of `ExpectedAndPredicate` in
`ExpectedPredicate` , In which situation do we need more then one
`ExpectedAndPredicate` in `ExpectedWhereClause`?
- **Other TODO Tags**
I also found some `TODO` tags that need not only add `*Assert` but should
need to add parse logic. These changes have a lot of impact, so if we should
fix them, I hope to fix it in other pull requests.
1. `AssignmentAssert`
```java
public static void assertIs(final SQLCaseAssertContext assertContext,
final AssignmentSegment actual, final ExpectedAssignment expected) {
ColumnAssert.assertIs(assertContext, actual.getColumn(),
expected.getColumn());
// TODO assert assign operator
AssignmentValueAssert.assertIs(assertContext, actual.getValue(),
expected.getAssignmentValue());
}
```
Here need to add `operator` in `AssignmentSegment`, add change all test case
that not contains `operator` before.
```g4
assignment
: columnName EQ_ assignmentValue
;
```
```java
public final class AssignmentSegment implements SQLSegment {
private final int startIndex;
private final int stopIndex;
private final ColumnSegment column;
private final ExpressionSegment value;
}
```
2 . `MySQLUseStatementAssert`
```java
public static void assertIs(final SQLCaseAssertContext assertContext,
final MySQLUseStatement actual, final UseStatementTestCase expected) {
assertThat(assertContext.getText("Schema name assertion error: "),
actual.getSchema(), is(expected.getSchema().getName()));
// TODO create a new assert class named `SchemaAssert`
// TODO extract and assert start index, stop index, start
delimiter and end delimiter
}
```
Here need to change `String schema` to `SchemaSegment schema`. and add
`visitSchemaSegmentContext` logic in visitor.
All code that references it also needs to be changed and tested.
```java
public final class MySQLUseStatement extends AbstractSQLStatement
implements DALStatement, MySQLStatement {
private String schema;
}
```
3. `DropIndexStatementAssert` `AlterIndexStatementAssert` and
`CreateIndexStatementAssert`
```java
private static void assertIndex(final SQLCaseAssertContext
assertContext, final DropIndexStatement actual, final
DropIndexStatementTestCase expected) {
// TODO should assert index for all databases(mysql and
sqlserver do not parse index right now)
}
```
Here we also need add logic in parser.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]