.Sql: modified SqlSession::SetError logic to overwrite last error out of transactions

.TSql: adjusted SqlBlock to do a ClearError when starting a transaction
+Core: added ArrayMap::Insert(int i, const K& key, T *newt) in analogy to Array

git-svn-id: svn://ultimatepp.org/upp/trunk@3466 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
rylek 2011-05-27 07:01:41 +00:00
parent 69ad26e600
commit 1164d686e7
3 changed files with 6 additions and 5 deletions

View file

@ -157,8 +157,9 @@ class ArrayMap : public MoveableAndDeepCopyOption< ArrayMap<K, T, HashFn> >,
public:
T& Add(const K& k, const T& x) { return B::Add(k, x); }
T& Add(const K& k) { return B::Add(k); }
T& Add(const K& k, T *newt) { B::key.Add(k); B::value.Add(newt); return *newt; }
template <class TT> TT& Create(const K& k) { TT *q = new TT; B::key.Add(k); B::value.Add(q); return *q; }
T& Add(const K& k, T *newt) { B::key.Add(k); return B::value.Add(newt); }
T& Insert(int i, const K& k, T *newt) { B::key.Insert(i, k); return B::value.Insert(i, newt); }
template <class TT> TT& Create(const K& k) { TT *q = new TT; B::key.Add(k); return B::value.Add(q); }
T& Set(int i, T *ptr) { return B::value.Set(i, ptr); }
T *PopDetach() { B::key.Drop(); return B::value.PopDetach(); }

View file

@ -682,7 +682,7 @@ Vector<SqlColumnInfo> SqlSession::EnumColumns(String database, String table)
void SqlSession::SetError(String error, String stmt, int code, const char *scode, Sql::ERRORCLASS clss) {
if(error_handler && (*error_handler)(error, stmt, code, scode, clss))
return;
if(errorstatement.GetCount())
if(GetTransactionLevel() && errorstatement.GetCount())
return;
lasterror = error;
errorstatement = stmt;

View file

@ -14,10 +14,10 @@ class SqlBlock
public:
#ifndef NOAPPSQL
SqlBlock(SqlSession& session = SQL.GetSession())
: session(session), done(false) { session.Begin(); }
: session(session), done(false) { session.ClearError(); session.Begin(); }
#else
SqlBlock(SqlSession& session)
: session(session), done(false) { session.Begin(); }
: session(session), done(false) { session.ClearError(); session.Begin(); }
#endif
~SqlBlock() { if(!done) session.Rollback(); }