made dialect parameter const in condition::evaluate

This commit is contained in:
Sascha Kuehl 2024-04-07 14:44:42 +02:00
parent 85f87367c0
commit 30e2e0c221
2 changed files with 12 additions and 12 deletions

View File

@ -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<operand_t, std::string> operands;
};

View File

@ -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<class T>
@ -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_);
}