#ifndef QUERY_SESSION_HPP #define QUERY_SESSION_HPP #include "matador/sql/column_generator.hpp" #include "matador/sql/connection.hpp" #include "matador/sql/connection_pool.hpp" #include "matador/sql/query_builder.hpp" #include "matador/sql/query_intermediates.hpp" #include "matador/sql/table_repository.hpp" #include namespace matador::sql { class dialect; class session { public: explicit session(connection_pool &pool); query_create_intermediate create(); query_drop_intermediate drop(); template < class Type > query_select_intermediate select() { return query_select_intermediate{*this, column_generator::generate(table_repository_)}; } query_select_intermediate select(std::initializer_list columns); query_insert_intermediate insert(); query_update_intermediate update(const std::string &table); query_delete_intermediate remove(); [[nodiscard]] query_result fetch(const query &q) const; // [[nodiscard]] query_result fetch(const std::string &sql) const; [[nodiscard]] std::pair execute(const std::string &sql) const; template void attach(const std::string &table_name) { table_repository_.attach(table_name); } [[nodiscard]] const table_repository& tables() const; const class dialect& dialect() const; private: friend class query_select_finish; [[nodiscard]] std::unique_ptr fetch(const std::string &sql) const; private: connection_pool &pool_; const class dialect &dialect_; table_repository table_repository_; mutable std::unordered_map prototypes_; }; } #endif //QUERY_SESSION_HPP