Compare commits

...

2 Commits

Author SHA1 Message Date
vaclavt
525694fbae double is alias for float 2022-05-31 19:26:07 +02:00
vaclavt
a063e14f3e crash fix in distinct (strict weak ordering) 2022-05-31 19:25:47 +02:00
4 changed files with 2 additions and 8 deletions

View File

@@ -1,10 +1,8 @@
### WIP
compare in row.cpp shoud take into account m_visible
### TODO
- create local_install.sh
- change float type keyword to double and in code functions too
- add functions:

View File

@@ -162,7 +162,7 @@ TokenType Lexer::type(const std::string &token) {
if (token == "not") return TokenType::keyword_not;
if (token == "null") return TokenType::keyword_null;
if (token == "integer") return TokenType::keyword_integer;
if (token == "float") return TokenType::keyword_float;
if (token == "float" || token == "double") return TokenType::keyword_float;
if (token == "varchar") return TokenType::keyword_varchar;
if (token == "date") return TokenType::keyword_date;
if (token == "boolean") return TokenType::keyword_bool;

View File

@@ -157,9 +157,6 @@ void Row::setColumnValue(ColDefNode *col_def, ValueNode *col_value) {
int Row::compare(const Row &other) const {
for (size_t ci = 0; ci < m_columns.size(); ci++) {
// CRASHES HERE
// auto a = this->operator[](ci).getStringValue();
// auto b = other[ci].getStringValue();
int cmp = this->operator[](ci).compare(other[ci]);
if (cmp != 0) return cmp;
}

View File

@@ -155,8 +155,7 @@ void USql::setup_order_columns(std::vector<ColOrderNode> &node, Table *table) {
void USql::execute_distinct(SelectFromTableNode &node, Table *result) {
if (!node.distinct) return;
auto compare_rows = [](const Row &a, const Row &b) { return a.compare(b) >= 0; };
std::sort(result->m_rows.begin(), result->m_rows.end(), compare_rows);
std::sort(result->m_rows.begin(), result->m_rows.end(), [](const Row &a, const Row &b) { return a.compare(b) > 0; });
result->m_rows.erase(std::unique(result->m_rows.begin(), result->m_rows.end()), result->m_rows.end());
}