Sql: Fixed issue with lowercase SqlId in operator[]

git-svn-id: svn://ultimatepp.org/upp/trunk@5113 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2012-07-04 13:23:48 +00:00
parent 5091ad3a9f
commit 3cfe5186a4
3 changed files with 22 additions and 10 deletions

View file

@ -17,6 +17,7 @@ SqlSession::SqlSession()
errorclass = Sql::ERROR_UNSPECIFIED;
error_handler = NULL;
throwonerror = false;
error_log = NULL;
}
SqlSession::~SqlSession()
@ -71,7 +72,9 @@ void SqlSession::SetError(String error, String stmt, int code, const char *sco
errorclass = clss;
String err;
err << "ERROR " << error << "(" << code << "): " << stmt << '\n';
if(GetTrace())
if(error_log)
*error_log << err;
if(trace && trace != error_log)
*GetTrace() << err;
}

View file

@ -310,11 +310,14 @@ void Sql::GetColumn(int i, Ref r) const {
void Sql::GetColumn(SqlId colid, Ref r) const
{
String s = ~colid;
for(int i = 0; i < cn->info.GetCount(); i++)
if(cn->info[i].name == s) {
GetColumn(i, r);
return;
}
for(int j = 0; j < 2; j++) {
for(int i = 0; i < cn->info.GetCount(); i++)
if(cn->info[i].name == s) {
GetColumn(i, r);
return;
}
s = ToUpper(s);
}
r.SetNull();
}
@ -326,9 +329,12 @@ Value Sql::operator[](int i) const {
Value Sql::operator[](SqlId id) const {
String s = ~id;
for(int i = 0; i < cn->info.GetCount(); i++)
if(cn->info[i].name == s)
return operator[](i);
for(int j = 0; j < 2; j++) {
for(int i = 0; i < cn->info.GetCount(); i++)
if(cn->info[i].name == s)
return operator[](i);
s = ToUpper(s);
}
NEVER();
return Value();
}

View file

@ -300,7 +300,7 @@ protected:
friend class Sql;
Stream *trace;
Stream *trace, *error_log;
bool tracetime;
int traceslow;
int dialect;
@ -355,6 +355,9 @@ public:
Stream *GetTrace() const { return trace; }
void KillTrace() { trace = NULL; }
void LogErrors(Stream& s = VppLog()) { error_log = &s; }
void LogErrors(bool b) { error_log = b ? &VppLog() : NULL; }
void TraceTime(bool b = true) { tracetime = b; }
bool IsTraceTime() const { return tracetime; }