Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/oatpp-postgresql/QueryResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ v_int64 QueryResult::getKnownCount() const {
return 0;
}

v_uint64 QueryResult::getRowsAffected() const {
return m_resultData.affectedRowCount;
}

bool QueryResult::hasMoreToFetch() const {
return getKnownCount() > 0;
}
Expand Down
2 changes: 2 additions & 0 deletions src/oatpp-postgresql/QueryResult.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class QueryResult : public orm::QueryResult {

bool hasMoreToFetch() const override;

v_uint64 getRowsAffected() const override;

oatpp::Void fetch(const oatpp::Type* const resultType, v_int64 count) override;

};
Expand Down
4 changes: 4 additions & 0 deletions src/oatpp-postgresql/mapping/ResultMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "ResultMapper.hpp"
#include "oatpp/base/Log.hpp"
#include "oatpp/utils/parser/Caret.hpp"

namespace oatpp { namespace postgresql { namespace mapping {

Expand All @@ -44,6 +45,9 @@ ResultMapper::ResultData::ResultData(PGresult* pDbResult, const std::shared_ptr<
}
}

char* rowsAffectedStr = PQcmdTuples(dbResult); // will be freed when the result is freed
affectedRowCount = oatpp::utils::parser::Caret(rowsAffectedStr).parseUnsignedInt();

}

ResultMapper::ResultMapper() {
Expand Down
5 changes: 5 additions & 0 deletions src/oatpp-postgresql/mapping/ResultMapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ class ResultMapper {
*/
v_int64 rowCount;

/**
* rows affected by the operation might be 0
*/
v_uint64 affectedRowCount;

};

private:
Expand Down