Skip to content

Commit

Permalink
squash w/ first commit. optional -> variant
Browse files Browse the repository at this point in the history
  • Loading branch information
korydraughn committed Jun 6, 2024
1 parent a86853c commit 411b1c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

#include <boost/variant.hpp>

#include <optional>
#include <string>
#include <utility>
#include <variant>
#include <vector>

namespace irods::experimental::genquery2
Expand Down Expand Up @@ -193,19 +193,18 @@ namespace irods::experimental::genquery2
condition() = default;

condition(column column, condition_expression expression)
: column{std::move(column)}
: lhs{std::move(column)}
, expression{std::move(expression)}
{
}

condition(function func, condition_expression expression)
: function{std::move(func)}
: lhs{std::move(func)}
, expression{std::move(expression)}
{
}

column column;
std::optional<function> function;
std::variant<column, function> lhs;
condition_expression expression;
}; // struct condition

Expand Down
13 changes: 3 additions & 10 deletions server/genquery2/src/genquery2_sql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,13 +875,6 @@ namespace irods::experimental::genquery2
// order to generate the proper SQL.
_state.ast_column_ptrs.push_back(&_function.column);

#if 0
// Aggregate functions are not allowed in the WHERE clause of an SQL statement!
if (!_state.in_select_clause) {
throw std::invalid_argument{"aggregate functions not allowed in where clause"};
}
#endif

auto [is_special_column, table_alias] =
setup_column_for_post_processing(_state, _function.column, iter->second);
const std::string_view alias =
Expand Down Expand Up @@ -1012,14 +1005,14 @@ namespace irods::experimental::genquery2

auto to_sql(gq_state& _state, const condition& _condition) -> std::string
{
if (_condition.function) {
if (const auto* fn = std::get_if<function>(&_condition.lhs); fn) {
return fmt::format("{}{}",
to_sql(_state, *_condition.function),
to_sql(_state, *fn),
boost::apply_visitor(sql_visitor{_state}, _condition.expression));
}

return fmt::format("{}{}",
to_sql(_state, _condition.column),
to_sql(_state, std::get<column>(_condition.lhs)),
boost::apply_visitor(sql_visitor{_state}, _condition.expression));
} // to_sql

Expand Down

0 comments on commit 411b1c8

Please sign in to comment.