diff --git a/include/matador/sql/basic_condition.hpp b/include/matador/sql/basic_condition.hpp index 0f9a135..daa250f 100644 --- a/include/matador/sql/basic_condition.hpp +++ b/include/matador/sql/basic_condition.hpp @@ -33,7 +33,7 @@ public: LIKE }; - virtual std::string evaluate(dialect &dialect, query_context &query) const = 0; + virtual std::string evaluate(const dialect &dialect, query_context &query) const = 0; static std::unordered_map operands; }; diff --git a/include/matador/sql/condition.hpp b/include/matador/sql/condition.hpp index a85f5d7..e390c3f 100644 --- a/include/matador/sql/condition.hpp +++ b/include/matador/sql/condition.hpp @@ -37,7 +37,7 @@ public: placeholder value; - std::string evaluate(dialect &d, query_context &query) const override; + std::string evaluate(const dialect &d, query_context &query) const override; }; template @@ -54,7 +54,7 @@ public: T value; - std::string evaluate(dialect &d, query_context &query) const override + std::string evaluate(const dialect &d, query_context &query) const override { query.bind_vars.emplace_back(field_.name); return d.prepare_identifier(field_) + " " + operand + " " + std::to_string(value); @@ -74,7 +74,7 @@ public: T value; - std::string evaluate(dialect &d, query_context &query) const override + std::string evaluate(const dialect &d, query_context &query) const override { query.bind_vars.emplace_back(field_.name); return d.prepare_identifier(field_) + " " + operand + " '" + value + "'"; @@ -95,7 +95,7 @@ public: T value; - std::string evaluate(dialect &d, query_context &query) const override + std::string evaluate(const dialect &d, query_context &query) const override { return std::to_string(value) + " " + operand + " " + d.prepare_identifier(field_); } @@ -114,7 +114,7 @@ public: T value; - std::string evaluate(dialect &d, query_context &query) const override + std::string evaluate(const dialect &d, query_context &query) const override { return "'" + std::to_string(value) + "' " + operand + " " + d.prepare_identifier(field_); } @@ -156,7 +156,7 @@ public: * @param d The d used to evaluate * @return A condition IN part of the query */ - std::string evaluate(dialect &d, query_context &query) const override { + std::string evaluate(const dialect &d, query_context &query) const override { auto count = size(); for (size_t i = 0; i < count; ++i) { query.bind_vars.emplace_back(field_.name); @@ -226,7 +226,7 @@ public: * @param d The d used to evaluate * @return A condition IN part of the query */ - std::string evaluate(dialect &d, query_context &query) const override; + std::string evaluate(const dialect &d, query_context &query) const override; private: query_context &query_; @@ -261,7 +261,7 @@ public: * @param d The d used to evaluate * @return A condition BETWEEN part of the query */ - std::string evaluate(dialect &d, query_context &query) const override { + std::string evaluate(const dialect &d, query_context &query) const override { query.bind_vars.emplace_back(field_.name); query.bind_vars.emplace_back(field_.name); return d.prepare_identifier(field_) + " BETWEEN " + std::to_string(range_.first) + " AND " + std::to_string(range_.second); @@ -303,7 +303,7 @@ public: * @param d The d used to evaluate * @return The evaluated string based on the compile type */ - std::string evaluate(dialect &d, query_context &query) const override + std::string evaluate(const dialect &d, query_context &query) const override { // ensure the numbering order for host vars auto cl = left.evaluate(d, query); @@ -346,7 +346,7 @@ public: * @param d The d used to evaluate * @return The evaluated string based on the compile type */ - std::string evaluate(dialect &d, query_context &query) const override + std::string evaluate(const dialect &d, query_context &query) const override { return operand + " (" + cond.evaluate(d) + ")"; } @@ -369,7 +369,7 @@ public: * @param d The d used to evaluate * @return The evaluated string based on the compile type */ - std::string evaluate(dialect &d, query_context &query) const override + std::string evaluate(const dialect &d, query_context &query) const override { return d.prepare_identifier(field_) + " " + operand + " " + d.prepare_identifier(other_column_); }