Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Oct 13, 2021
1 parent c021ec6 commit 2d960ce
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/graph/validator/MaintainValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ Status AlterValidator::alterSchema(const std::vector<AlterSchemaOptItem *> &sche
if (opType == meta::cpp2::AlterSchemaOp::DROP) {
const auto &colNames = schemaOpt->columnNames();
for (auto &colName : colNames) {
if (uniqueColName.find(colName) != uniqueColName.end()) {
return Status::SemanticError("Duplicate column name `%s'", colName.c_str());
if (uniqueColName.find(*colName) != uniqueColName.end()) {
return Status::SemanticError("Duplicate column name `%s'", colName->c_str());
}
uniqueColName.emplace(colName);
uniqueColName.emplace(*colName);
meta::cpp2::ColumnDef column;
column.name = *colName;
schema.columns_ref().value().emplace_back(std::move(column));
Expand Down
44 changes: 44 additions & 0 deletions tests/tck/features/ttl/TTL.feature
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,50 @@ Feature: TTLTest
Then the result should be, in any order:
| Edge | Create Edge |
| "work2" | 'CREATE EDGE `work2` (\n `email` string NULL,\n `age` string NULL,\n `gender` string NULL\n) ttl_duration = 0, ttl_col = ""' |
When executing query:
"""
CREATE EDGE player(id int, name string, age int, address string, score float);
"""
Then the execution should be successful
When executing query:
"""
SHOW CREATE EDGE player;
"""
Then the result should be, in any order:
| Edge | Create Edge |
| "player" | 'CREATE EDGE `player` (\n `id` int64 NULL,\n `name` string NULL,\n `age` int64 NULL,\n `address` string NULL,\n `score` float NULL\n) ttl_duration = 0, ttl_col = ""' |
When executing query:
"""
ALTER EDGE player change(name int), drop(name);
"""
Then a SemanticError should be raised at runtime: Duplicate column name `name'
When executing query:
"""
ALTER EDGE player drop(name), change(name int);
"""
Then a SemanticError should be raised at runtime: Duplicate column name `name'
When executing query:
"""
ALTER EDGE player drop(name, name), change(address int);
"""
Then a SemanticError should be raised at runtime: Duplicate column name `name'
When executing query:
"""
ALTER EDGE player change(address int, address string);
"""
Then a SemanticError should be raised at runtime: Duplicate column name `address'
When executing query:
"""
ALTER EDGE player change(address int), drop(name);
"""
Then the execution should be successful
When executing query:
"""
SHOW CREATE EDGE player;
"""
Then the result should be, in any order:
| Edge | Create Edge |
| "player" | 'CREATE EDGE `player` (\n `id` int64 NULL,\n `age` int64 NULL,\n `address` int64 NULL,\n `score` float NULL\n) ttl_duration = 0, ttl_col = ""' |
And drop the used space

Scenario: TTLTest Datatest
Expand Down

0 comments on commit 2d960ce

Please sign in to comment.