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}; }
|
| CHAR '(' INTVAL ')' { $$ = ColumnType{DataType::CHAR, $3}; }
|
||||||
| TEXT { $$ = ColumnType{DataType::TEXT}; }
|
| TEXT { $$ = ColumnType{DataType::TEXT}; }
|
||||||
| DATETIME { $$ = ColumnType{DataType::DATETIME}; }
|
| DATETIME { $$ = ColumnType{DataType::DATETIME}; }
|
||||||
|
| DATE { $$ = ColumnType{DataType::DATE}; }
|
||||||
;
|
;
|
||||||
|
|
||||||
opt_column_nullable:
|
opt_column_nullable:
|
||||||
|
|
|
@ -13,7 +13,8 @@ namespace hsql {
|
||||||
CHAR,
|
CHAR,
|
||||||
VARCHAR,
|
VARCHAR,
|
||||||
TEXT,
|
TEXT,
|
||||||
DATETIME
|
DATETIME,
|
||||||
|
DATE
|
||||||
};
|
};
|
||||||
|
|
||||||
// Represents the type of a column, e.g., FLOAT or VARCHAR(10)
|
// Represents the type of a column, e.g., FLOAT or VARCHAR(10)
|
||||||
|
|
|
@ -57,6 +57,9 @@ namespace hsql {
|
||||||
case DataType::DATETIME:
|
case DataType::DATETIME:
|
||||||
stream << "DATETIME";
|
stream << "DATETIME";
|
||||||
break;
|
break;
|
||||||
|
case DataType::DATE:
|
||||||
|
stream << "DATE";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
|
@ -738,3 +738,17 @@ TEST(WithClauseDouble) {
|
||||||
ASSERT_STREQ(stmt->selectList->at(0)->name, "nameA");
|
ASSERT_STREQ(stmt->selectList->at(0)->name, "nameA");
|
||||||
ASSERT_STREQ(stmt->fromTable->name, "a");
|
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