From f03664d60a076ce26bcf513f7cb3539af54ff002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20K=C3=BChl?= Date: Fri, 10 Apr 2026 16:33:35 +0200 Subject: [PATCH] fix: comment out unused/invalid code --- include/matador/orm/session.hpp | 100 ++++++++++++++++---------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/include/matador/orm/session.hpp b/include/matador/orm/session.hpp index 010c1b4..c6012c6 100644 --- a/include/matador/orm/session.hpp +++ b/include/matador/orm/session.hpp @@ -110,56 +110,56 @@ utils::result, utils::error> session::insert(object::ob } // Execute all steps; for Identity steps read RETURNING and write pk back into the object - for (auto &step : *steps) { - if (step.pk_is_unset && step.set_pk) { - if (step.pk_generator == utils::generator_type::Manual) { - if (step.pk_is_unset()) { - return utils::failure(make_error(error_code::NoPrimaryKey, "Manual primary key is required but unset.")); - } - } else if (step.pk_generator == utils::generator_type::Sequence) { - if (step.pk_is_unset()) { - // hard-coded naming as you specified earlier - // _seq (table name known in schema meta; if you prefer, store it in step too) - // For now, we derive from the schema type used for the root insert: simplistic but works if table name == entity name. - const std::string seq_name = it->second.name() + "_seq"; - - auto id_res = query::select().nextval(seq_name).fetch_value(*this); - if (!id_res.is_ok() || !id_res.value().has_value()) { - return utils::failure(make_error(error_code::FailedToBuildQuery, "Failed to obtain next sequence value.")); - } - step.set_pk(*id_res.value()); - } - } else if (step.pk_generator == utils::generator_type::Table) { - if (step.pk_is_unset()) { - // TODO: implement table id generation; same idea as above: - // UPDATE _tbl_seq ... RETURNING ... - return utils::failure(make_error(error_code::Failed, "Table primary key generator not implemented yet.")); - } - } - } - - // --- Execute step --- - if (std::holds_alternative(step.query)) { - const auto &q = std::get(step.query); - const auto exec_res = q.execute(*this); - if (!exec_res.is_ok()) { - return utils::failure(exec_res.err()); - } - continue; - } - - const auto &q = std::get(step.query); - auto rec_res = q.fetch_one(*this); - if (!rec_res.is_ok()) { - return utils::failure(rec_res.err()); - } - if (!rec_res.value().has_value()) { - return utils::failure(make_error(error_code::FailedToFindObject, "INSERT ... RETURNING did not return a row.")); - } - if (step.apply_returning) { - step.apply_returning(*rec_res.value()); - } - } + // for (auto &step : *steps) { + // if (step.pk_is_unset && step.set_pk) { + // if (step.pk_generator == utils::generator_type::Manual) { + // if (step.pk_is_unset()) { + // return utils::failure(make_error(error_code::NoPrimaryKey, "Manual primary key is required but unset.")); + // } + // } else if (step.pk_generator == utils::generator_type::Sequence) { + // if (step.pk_is_unset()) { + // // hard-coded naming as you specified earlier + // // _seq (table name known in schema meta; if you prefer, store it in step too) + // // For now, we derive from the schema type used for the root insert: simplistic but works if table name == entity name. + // const std::string seq_name = it->second.name() + "_seq"; + // + // auto id_res = query::select().nextval(seq_name).fetch_value(*this); + // if (!id_res.is_ok() || !id_res.value().has_value()) { + // return utils::failure(make_error(error_code::FailedToBuildQuery, "Failed to obtain next sequence value.")); + // } + // step.set_pk(*id_res.value()); + // } + // } else if (step.pk_generator == utils::generator_type::Table) { + // if (step.pk_is_unset()) { + // // TODO: implement table id generation; same idea as above: + // // UPDATE
_tbl_seq ... RETURNING ... + // return utils::failure(make_error(error_code::Failed, "Table primary key generator not implemented yet.")); + // } + // } + // } + // + // // --- Execute step --- + // if (std::holds_alternative(step.query)) { + // const auto &q = std::get(step.query); + // const auto exec_res = q.execute(*this); + // if (!exec_res.is_ok()) { + // return utils::failure(exec_res.err()); + // } + // continue; + // } + // + // const auto &q = std::get(step.query); + // auto rec_res = q.fetch_one(*this); + // if (!rec_res.is_ok()) { + // return utils::failure(rec_res.err()); + // } + // if (!rec_res.value().has_value()) { + // return utils::failure(make_error(error_code::FailedToFindObject, "INSERT ... RETURNING did not return a row.")); + // } + // if (step.apply_returning) { + // step.apply_returning(*rec_res.value()); + // } + // } obj.change_state(object::object_state::Persistent); return utils::ok(obj);