@@ -306,6 +306,9 @@ namespace BOT_ORM
306306			size_t  index = 0 ;
307307			const  auto  &fieldNames = ORMapper::_FieldNames<C> ();
308308
309+ 			os << " set "  ;
310+ 			osKey << " where "  ;
311+ 
309312			entity.__Accept  (BOT_ORM_Impl::FnVisitor  (),
310313							 [&os, &osKey, &index, &fieldNames] (auto  &val)
311314			{
@@ -325,10 +328,7 @@ namespace BOT_ORM
325328				return  true ;
326329			});
327330
328- 			_connector.Execute  (" update "   +
329- 								std::string  (C::__ClassName) +
330- 								"  set "   + os.str  () +
331- 								"  where "   + osKey.str  () + " ;"  );
331+ 			_Update  (entity, os.str  (), osKey.str  ());
332332		}
333333
334334		template  <typename  In>
@@ -376,6 +376,7 @@ namespace BOT_ORM
376376		void  Delete  (const  C &entity)
377377		{
378378			std::stringstream os;
379+ 			os << " where "  ;
379380
380381			entity.__Accept  (BOT_ORM_Impl::FnVisitor  (),
381382							 [&os] (auto  &val)
@@ -385,9 +386,7 @@ namespace BOT_ORM
385386				return  false ;
386387			});
387388
388- 			_connector.Execute  (" delete from "   +
389- 								std::string  (C::__ClassName) +
390- 								"  where "   + os.str  () + " ;"  );
389+ 			_Delete  (entity, os.str  ());
391390		}
392391
393392		struct  Expr 
@@ -625,7 +624,7 @@ namespace BOT_ORM
625624		protected: 
626625			const  C &_queryHelper;
627626			ORMapper *_pMapper;
628- 			 
627+ 
629628			std::string _sqlWhere;
630629			std::string _sqlOrderBy;
631630			std::string _sqlLimit, _sqlOffset;
@@ -736,9 +735,9 @@ namespace BOT_ORM
736735								"  ("   + field + " ) as agg from "   +
737736								std::string  (C::__ClassName) +
738737								"  "   + sqlCond + " ;"  ,
739- 								[&] (int , char  **argv, char  **)
738+ 								[&] (int  argc , char  **argv, char  **)
740739			{
741- 				ret = argv[0 ];
740+ 				if  (argv[ 0 ])  ret = argv[0 ];
742741			});
743742
744743			if  (ret.empty  ())
0 commit comments