#ifndef QUERY_QUERY_DATA_HPP #define QUERY_QUERY_DATA_HPP #include "matador/object/attribute.hpp" #include "matador/sql/resolver_service.hpp" #include "matador/utils/types.hpp" namespace matador::sql { enum class sql_command { Unknown, Create, CreateTable, CreateSchema, CreateSequence, CreateDatabase, Update, Insert, Delete, Select, Drop, DropTable, DropSchema, DropSequence, DropDatabase, Alter, AlterTable, AlterSchema }; enum class return_mode { None, GeneratedKeys, Rows }; struct query_context { std::string sql; sql_command command{}; std::string command_name{}; std::string schema_name{}; std::string table_name{}; std::vector prototype{}; std::vector bind_vars{}; std::vector bind_types{}; // Data for resolving query result std::shared_ptr resolver{}; std::type_index result_type = typeid(void); return_mode mode = return_mode::None; [[nodiscard]] bool is_ddl() const { return command == sql_command::Create || command == sql_command::Alter; } [[nodiscard]] bool is_dml() const { return command == sql_command::Insert || command == sql_command::Update || command == sql_command::Delete; } [[nodiscard]] bool is_query() const { return command == sql_command::Select; } [[nodiscard]] bool expects_rows() const { return mode == return_mode::Rows; } [[nodiscard]] bool expects_generated_keys() const { return mode == return_mode::GeneratedKeys; } }; } #endif //QUERY_QUERY_DATA_HPP