Skip to content

Commit

Permalink
Merge pull request #1214 from kuzudb/fix-add-property-tests
Browse files Browse the repository at this point in the history
fix tests for add property
  • Loading branch information
acquamarin committed Jan 30, 2023
2 parents 50c1da7 + 498a535 commit 730a39b
Show file tree
Hide file tree
Showing 7 changed files with 3,176 additions and 3,246 deletions.
2 changes: 0 additions & 2 deletions src/antlr4/Cypher.g4
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ RENAME: ( 'R' | 'r' ) ( 'E' | 'e' ) ( 'N' | 'n' ) ( 'A' | 'a' ) ( 'M' | 'm' ) (

ADD: ( 'A' | 'a' ) ( 'D' | 'd' ) ( 'D' | 'd' ) ;

COLUMN: ( 'C' | 'c' ) ( 'O' | 'o' ) ( 'L' | 'l' ) ( 'U' | 'u' ) ( 'M' | 'm' ) ( 'N' | 'n' ) ;

kU_RelConnections : kU_RelConnection ( SP? ',' SP? kU_RelConnection )* ;

kU_RelConnection: FROM SP kU_NodeLabels SP TO SP kU_NodeLabels ;
Expand Down
4 changes: 2 additions & 2 deletions test/binder/binder_error_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,14 +416,14 @@ TEST_F(BinderErrorTest, DropPrimaryKeyColumn) {

TEST_F(BinderErrorTest, AddPropertyDuplicateName) {
string expectedException = "Binder exception: Property: fName already exists.";
auto input = "alter table person add column fName STRING";
auto input = "alter table person add fName STRING";
ASSERT_STREQ(expectedException.c_str(), getBindingError(input).c_str());
}

TEST_F(BinderErrorTest, AddPropertyUnmatchedDefaultValueType) {
string expectedException = "Binder exception: Expression 3.2 has data type DOUBLE but expect "
"INT64. Implicit cast is not supported.";
auto input = "alter table person add column intCol INT64 DEFAULT 3.2";
auto input = "alter table person add intCol INT64 DEFAULT 3.2";
ASSERT_STREQ(expectedException.c_str(), getBindingError(input).c_str());
}

Expand Down
16 changes: 8 additions & 8 deletions test/runner/e2e_ddl_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ class TinySnbDDLTest : public DBTest {

void addPropertyToPersonTableWithoutDefaultValue(
string propertyType, TransactionTestType transactionTestType) {
executeQueryWithoutCommit(StringUtils::string_format(
"ALTER TABLE person ADD COLUMN random %s", propertyType.c_str()));
executeQueryWithoutCommit(
StringUtils::string_format("ALTER TABLE person ADD random %s", propertyType.c_str()));
auto tableSchema = catalog->getWriteVersion()->getTableSchema(personTableID);
auto propertyID = tableSchema->getPropertyID("random");
auto hasOverflow =
Expand Down Expand Up @@ -409,7 +409,7 @@ class TinySnbDDLTest : public DBTest {
void addPropertyToPersonTableWithDefaultValue(
string propertyType, string defaultVal, TransactionTestType transactionTestType) {
executeQueryWithoutCommit(
"ALTER TABLE person ADD COLUMN random " + propertyType + " DEFAULT " + defaultVal);
"ALTER TABLE person ADD random " + propertyType + " DEFAULT " + defaultVal);
auto tableSchema = catalog->getWriteVersion()->getTableSchema(personTableID);
auto propertyID = tableSchema->getPropertyID("random");
auto hasOverflow =
Expand Down Expand Up @@ -441,8 +441,8 @@ class TinySnbDDLTest : public DBTest {

void addPropertyToStudyAtTableWithoutDefaultValue(
string propertyType, TransactionTestType transactionTestType) {
executeQueryWithoutCommit(StringUtils::string_format(
"ALTER TABLE studyAt ADD COLUMN random %s", propertyType.c_str()));
executeQueryWithoutCommit(
StringUtils::string_format("ALTER TABLE studyAt ADD random %s", propertyType.c_str()));
auto tableSchema = catalog->getWriteVersion()->getTableSchema(studyAtTableID);
auto propertyID = tableSchema->getPropertyID("random");
auto hasOverflow =
Expand Down Expand Up @@ -488,7 +488,7 @@ class TinySnbDDLTest : public DBTest {
void addPropertyToStudyAtTableWithDefaultValue(
string propertyType, string defaultVal, TransactionTestType transactionTestType) {
executeQueryWithoutCommit(
"ALTER TABLE studyAt ADD COLUMN random " + propertyType + " DEFAULT " + defaultVal);
"ALTER TABLE studyAt ADD random " + propertyType + " DEFAULT " + defaultVal);
auto relTableSchema = catalog->getWriteVersion()->getTableSchema(studyAtTableID);
auto propertyID = relTableSchema->getPropertyID("random");
auto hasOverflow =
Expand Down Expand Up @@ -915,8 +915,8 @@ TEST_F(TinySnbDDLTest, AddListOfListOfStringPropertyToStudyAtTableWithDefaultVal
}

TEST_F(TinySnbDDLTest, AddPropertyWithComplexExpression) {
ASSERT_TRUE(conn->query("ALTER TABLE person ADD COLUMN random INT64 DEFAULT 2 * abs(-2)")
->isSuccess());
ASSERT_TRUE(
conn->query("ALTER TABLE person ADD random INT64 DEFAULT 2 * abs(-2)")->isSuccess());
vector<string> expectedResult(8, "4");
ASSERT_EQ(TestHelper::convertResultToString(*conn->query("MATCH (p:person) return p.random")),
expectedResult);
Expand Down
Loading

0 comments on commit 730a39b

Please sign in to comment.