@@ -1342,10 +1342,15 @@ inline size_t Mapper<T>::update(const T &obj) noexcept(false)
13421342 clear ();
13431343 static_assert (!std::is_same_v<typename T::PrimaryKeyType, void >,
13441344 " No primary key in the table!" );
1345+ std::vector<std::string> colNames = obj.updateColumns ();
1346+ if (colNames.empty ())
1347+ {
1348+ return 0 ;
1349+ }
13451350 std::string sql = " update " ;
13461351 sql += T::tableName;
13471352 sql += " set " ;
1348- for (auto const &colName : obj. updateColumns () )
1353+ for (auto const &colName : colNames )
13491354 {
13501355 sql += colName;
13511356 sql += " = $?," ;
@@ -1415,10 +1420,17 @@ inline void Mapper<T>::update(const T &obj,
14151420 clear ();
14161421 static_assert (!std::is_same_v<typename T::PrimaryKeyType, void >,
14171422 " No primary key in the table!" );
1423+
1424+ std::vector<std::string> colNames = obj.updateColumns ();
1425+ if (colNames.empty ())
1426+ {
1427+ rcb (0 );
1428+ return ;
1429+ }
14181430 std::string sql = " update " ;
14191431 sql += T::tableName;
14201432 sql += " set " ;
1421- for (auto const &colName : obj. updateColumns () )
1433+ for (auto const &colName : colNames )
14221434 {
14231435 sql += colName;
14241436 sql += " = $?," ;
@@ -1478,10 +1490,18 @@ inline std::future<size_t> Mapper<T>::updateFuture(const T &obj) noexcept
14781490 clear ();
14791491 static_assert (!std::is_same_v<typename T::PrimaryKeyType, void >,
14801492 " No primary key in the table!" );
1493+ std::vector<std::string> colNames = obj.updateColumns ();
1494+ if (colNames.empty ())
1495+ {
1496+ std::shared_ptr<std::promise<size_t >> prom =
1497+ std::make_shared<std::promise<size_t >>();
1498+ prom->set_value (0 );
1499+ return prom->get_future ();
1500+ }
14811501 std::string sql = " update " ;
14821502 sql += T::tableName;
14831503 sql += " set " ;
1484- for (auto const &colName : obj. updateColumns () )
1504+ for (auto const &colName : colNames )
14851505 {
14861506 sql += colName;
14871507 sql += " = $?," ;
0 commit comments