date printed with time now

This commit is contained in:
VaclavT 2021-08-31 18:58:46 +02:00
parent 412e2fd455
commit a1b3b0140f
3 changed files with 20 additions and 6 deletions

View File

@ -1,5 +1,6 @@
### TODO
- escape " in save csv
- is null | is not null
- coalesce, date functions now, add_date; string functions rtrim, ltrim, rpad, lpad; math function round
- add pipe | concatenation
@ -9,6 +10,8 @@
- support for joining
- add count min and max functions, eg aggregate functions
- use string_to_double and string_to_long (from Table) everywhere
- add const wherever should be
- use static methods where posible
- PERF in Row::Row(const Row &other), could be more efficient (memory and cpu)
- use references where pointer cannot be nullptr

18
row.cpp
View File

@ -133,7 +133,7 @@ void Row::setColumnValue(ColDefNode *col_def, ValueNode *col_value) {
else if (col_def->type == ColumnType::varchar_type)
setStringColumnValue(col_def->order, col_value->getStringValue());
else if (col_def->type == ColumnType::date_type)
setIntColumnValue(col_def->order, col_value->getDateValue());
setDateColumnValue(col_def->order, col_value->getDateValue());
else if (col_def->type == ColumnType::bool_type)
setBoolColumnValue(col_def->order, col_value->getBooleanValue());
else
@ -169,9 +169,19 @@ void Row::print(const std::vector<ColDefNode> &col_defs) {
int Row::print_get_column_size(const ColDefNode &col_def) {
int col_size = col_def.type == ColumnType::varchar_type ? col_def.length :
col_def.type == ColumnType::float_type ? 16 : 10;
return col_size;
switch (col_def.type) {
case ColumnType::varchar_type:
return col_def.length;
break;
case ColumnType::date_type:
return 19;
break;
case ColumnType::float_type:
return 16;
break;
default:
return 10;
}
}
} // namespace

View File

@ -6,7 +6,7 @@
namespace usql {
std::vector<std::pair<std::string, std::string>> Settings::m_settings =
{ std::make_pair("DATE_FORMAT", "%Y-%m-%d"),
{ std::make_pair("DATE_FORMAT", "%Y-%m-%d %H:%M:%S"),
std::make_pair("BOOL_TRUE_LITERAL", "Y"),
std::make_pair("BOOL_FALSE_LITERAL", "N"),
std::make_pair("DOUBLE_FORMAT", "%.2f") };
@ -21,6 +21,7 @@ std::string Settings::date_to_string(long date) {
return ::date_to_string(date, get_setting("DATE_FORMAT"));
}
std::string Settings::double_to_string(double d) {
char buffer[32];
int r, buf_size = 32;