Merge pull request #157 from ankushrayabhari/date_cast
Added support for casting to DATE
This commit is contained in:
commit
159c786cdb
File diff suppressed because it is too large
Load Diff
|
@ -562,6 +562,7 @@ column_type:
|
|||
| CHAR '(' INTVAL ')' { $$ = ColumnType{DataType::CHAR, $3}; }
|
||||
| TEXT { $$ = ColumnType{DataType::TEXT}; }
|
||||
| DATETIME { $$ = ColumnType{DataType::DATETIME}; }
|
||||
| DATE { $$ = ColumnType{DataType::DATE}; }
|
||||
;
|
||||
|
||||
opt_column_nullable:
|
||||
|
|
|
@ -13,7 +13,8 @@ namespace hsql {
|
|||
CHAR,
|
||||
VARCHAR,
|
||||
TEXT,
|
||||
DATETIME
|
||||
DATETIME,
|
||||
DATE
|
||||
};
|
||||
|
||||
// Represents the type of a column, e.g., FLOAT or VARCHAR(10)
|
||||
|
|
|
@ -57,6 +57,9 @@ namespace hsql {
|
|||
case DataType::DATETIME:
|
||||
stream << "DATETIME";
|
||||
break;
|
||||
case DataType::DATE:
|
||||
stream << "DATE";
|
||||
break;
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
|
|
@ -737,4 +737,18 @@ TEST(WithClauseDouble) {
|
|||
ASSERT_EQ(stmt->selectList->size(), 1);
|
||||
ASSERT_STREQ(stmt->selectList->at(0)->name, "nameA");
|
||||
ASSERT_STREQ(stmt->fromTable->name, "a");
|
||||
}
|
||||
}
|
||||
|
||||
TEST(CastAsDate) {
|
||||
TEST_PARSE_SINGLE_SQL(
|
||||
"SELECT CAST(ID AS DATE) FROM TEST",
|
||||
kStmtSelect,
|
||||
SelectStatement,
|
||||
result,
|
||||
stmt);
|
||||
|
||||
ASSERT_TRUE(result.isValid());
|
||||
ASSERT_EQ(1, stmt->selectList->size());
|
||||
ASSERT_STREQ("CAST", stmt->selectList->front()->name);
|
||||
ASSERT_EQ(DataType::DATE, stmt->selectList->front()->columnType.data_type);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue