removed unused methods from session
This commit is contained in:
@@ -56,66 +56,6 @@ session::session(session_context&& ctx, const query::schema &scm)
|
||||
}
|
||||
}
|
||||
|
||||
utils::result<void, utils::error> session::drop_table(const std::string &table_name) const {
|
||||
auto result = query::drop()
|
||||
.table(table_name)
|
||||
.execute(*this);
|
||||
if (result.is_error()) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
|
||||
return utils::ok<void>();
|
||||
}
|
||||
|
||||
utils::result<sql::query_result<sql::record>, utils::error> session::fetch_all(const sql::query_context &q) const {
|
||||
auto c = cache_.pool().acquire();
|
||||
if (!c.valid()) {
|
||||
return utils::failure(make_error(error_code::NoConnectionAvailable, "Failed to acquire connection."));
|
||||
}
|
||||
auto it = prototypes_.find(q.table_name);
|
||||
if (it == prototypes_.end()) {
|
||||
auto result = c->describe(q.table_name);
|
||||
if (!result) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
it = prototypes_.emplace(q.table_name, *result).first;
|
||||
}
|
||||
// adjust columns from given query
|
||||
for (auto &col: q.prototype) {
|
||||
if (const auto rit = std::find_if(it->second.begin(), it->second.end(), [&col](const auto &value) {
|
||||
return value.name() == col.name();
|
||||
}); rit != it->second.end()) {
|
||||
const_cast<object::attribute &>(col).change_type(rit->type());
|
||||
}
|
||||
}
|
||||
auto res = fetch(q);
|
||||
if (!res) {
|
||||
return utils::failure(res.err());
|
||||
}
|
||||
const auto prototype = res.value()->prototype();
|
||||
return utils::ok(sql::query_result<sql::record>{std::move(*res), prototype});
|
||||
}
|
||||
|
||||
utils::result<sql::execute_result, utils::error> session::execute(const std::string &sql) const {
|
||||
return execute(sql::query_context{sql});
|
||||
}
|
||||
|
||||
std::vector<object::attribute> session::describe_table(const std::string &table_name) const {
|
||||
const auto c = cache_.pool().acquire();
|
||||
if (!c.valid()) {
|
||||
throw std::logic_error("no database connection available");
|
||||
}
|
||||
return c->describe(table_name).release();
|
||||
}
|
||||
|
||||
bool session::table_exists(const std::string &table_name) const {
|
||||
const auto c = cache_.pool().acquire();
|
||||
if (!c.valid()) {
|
||||
throw std::logic_error("no database connection available");
|
||||
}
|
||||
return c->exists(dialect_.default_schema_name(), table_name);
|
||||
}
|
||||
|
||||
const class sql::dialect &session::dialect() const {
|
||||
return dialect_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user