/** * @file mix_cc/sql/where.h * @brief 查询条件 * @author Cat (null.null.null@qq.com) * @version 0.1 * @date 2021-09-17 * * Copyright: Baosight Co. Ltd. * DO NOT COPY/USE WITHOUT PERMISSION * */ #pragma once #include #include #include #include #include namespace mix_cc { namespace sql { template struct where_t : public prev_statement_t, public statement_t { static constexpr auto s_text = op::cmd_t::where; constexpr explicit where_t(PrevStatement prev_st, Conditions... conditions) : prev_statement_t(prev_st), conditions_(conditions...) {} constexpr auto get_command() { auto sel_str_c = " "_s + s_text + " "_s; auto conditions_str = hana::transform(conditions_, [](auto col) { return col.get_str(); }); auto r_str = hana::fold_left(conditions_str, [](auto cond1, auto cond2) { return cond1 + " AND " + cond2; }); return std::string(sel_str_c.c_str()) + r_str; } hana::tuple conditions_; }; } // namespace sql } // namespace mix_cc